New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

d3plus-hierarchy

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3plus-hierarchy - npm Package Compare versions

Comparing version 0.3.9 to 0.3.10

169

build/d3plus-hierarchy.js
/*
d3plus-hierarchy v0.3.9
d3plus-hierarchy v0.3.10
Nested, hierarchical, and cluster charts built on D3

@@ -20,5 +20,3 @@ Copyright (c) 2017 D3plus - https://d3plus.org

function Pie() {
var this$1 = this;
Viz$$1.call(this);

@@ -28,9 +26,5 @@

Path: {
id: function (d) { return this$1._ids(d).join("-"); },
label: function (d) { return this$1._drawLabel(d.data, d.i); },
labelConfig: {
fontResize: true
},
x: 0,
y: 0
}
}

@@ -55,3 +49,5 @@ });

Pie.prototype._draw = function _draw (callback) {
var this$1 = this;
Viz$$1.prototype._draw.call(this, callback);

@@ -88,2 +84,7 @@

}).node())
.config({
id: function (d) { return this$1._ids(d).join("-"); },
x: 0,
y: 0
})
.config(d3plusCommon.configPrep.bind(this)(this._shapeConfig, "shape", "Path"))

@@ -234,5 +235,3 @@ .render());

function Tree() {
var this$1 = this;
Viz$$1.call(this);

@@ -243,45 +242,4 @@

var nodeConfig = {
id: function (d, i) { return this$1._ids(d, i).join("-"); },
label: function (d, i) {
if (this$1._label) { return this$1._label(d.data, i); }
var ids = this$1._ids(d, i).slice(0, d.depth);
return ids[ids.length - 1];
},
labelConfig: {
textAnchor: function (d) { return this$1._orient === "vertical" ? "middle"
: d.data.children && d.data.depth !== this$1._groupBy.length ? "end" : "start"; },
verticalAlign: function (d) { return this$1._orient === "vertical" ? d.data.depth === 1 ? "bottom" : "top" : "middle"; }
},
hitArea: function (d, i, s) {
var h = this$1._labelHeight,
w = this$1._labelWidths[d.depth - 1];
return {
width: this$1._orient === "vertical" ? w : s.r * 2 + w,
height: this$1._orient === "horizontal" ? h : s.r * 2 + h,
x: this$1._orient === "vertical" ? -w / 2 : d.children && d.depth !== this$1._groupBy.length ? -(s.r + w) : -s.r,
y: this$1._orient === "horizontal" ? -h / 2 : d.children && d.depth !== this$1._groupBy.length ? -(s.r + this$1._labelHeight) : -s.r
};
},
labelBounds: function (d, i, s) {
var h = this$1._labelHeight,
height = this$1._orient === "vertical" ? "height" : "width",
w = this$1._labelWidths[d.depth - 1],
width = this$1._orient === "vertical" ? "width" : "height",
x = this$1._orient === "vertical" ? "x" : "y",
y = this$1._orient === "vertical" ? "y" : "x";
return ( obj = {}, obj[width] = w, obj[height] = h, obj[x] = -w / 2, obj[y] = d.children && d.depth !== this$1._groupBy.length ? -(s.r + h) : s.r, obj );
var obj;
}
};
this._shape = d3plusCommon.constant("Circle");
this._shapeConfig = d3plusCommon.assign(this._shapeConfig, {
Circle: nodeConfig,
labelConfig: {

@@ -291,20 +249,3 @@ fontColor: "#444"

Path: {
d: function (d) {
var r = this$1._shapeConfig.Circle.r || this$1._shapeConfig.r;
if (typeof r === "function") { r = r(d.data, d.i); }
var px = d.parent.x - d.x + (this$1._orient === "vertical" ? 0 : r),
py = d.parent.y - d.y + (this$1._orient === "vertical" ? r : 0),
x = this$1._orient === "vertical" ? 0 : -r,
y = this$1._orient === "vertical" ? -r : 0;
return this$1._orient === "vertical"
? ("M" + x + "," + y + "C" + x + "," + ((y + py) / 2) + " " + px + "," + ((y + py) / 2) + " " + px + "," + py)
: ("M" + x + "," + y + "C" + ((x + px) / 2) + "," + y + " " + ((x + px) / 2) + "," + py + " " + px + "," + py);
},
fill: "none",
id: function (d, i) { return this$1._ids(d, i).join("-"); },
stroke: "#ccc",

@@ -370,3 +311,3 @@ strokeWidth: 1

var r = this._shapeConfig.Circle.r || this._shapeConfig.r;
var r = this._shapeConfig.r;
if (typeof r !== "function") { r = d3plusCommon.constant(r); }

@@ -409,2 +350,21 @@ var rBufferRoot = d3Array.max(treeData, function (d) { return d.depth === 1 ? r(d.data, d.i) : 0; });

.config(d3plusCommon.configPrep.bind(this)(this._shapeConfig, "shape", "Path"))
.config({
d: function (d) {
var r = this$1._shapeConfig.r;
if (typeof r === "function") { r = r(d.data, d.i); }
var px = d.parent.x - d.x + (this$1._orient === "vertical" ? 0 : r),
py = d.parent.y - d.y + (this$1._orient === "vertical" ? r : 0),
x = this$1._orient === "vertical" ? 0 : -r,
y = this$1._orient === "vertical" ? -r : 0;
return this$1._orient === "vertical"
? ("M" + x + "," + y + "C" + x + "," + ((y + py) / 2) + " " + px + "," + ((y + py) / 2) + " " + px + "," + py)
: ("M" + x + "," + y + "C" + ((x + px) / 2) + "," + y + " " + ((x + px) / 2) + "," + py + " " + px + "," + py);
},
id: function (d, i) { return this$1._ids(d, i).join("-"); }
})
.render());

@@ -416,2 +376,41 @@

.config(d3plusCommon.configPrep.bind(this)(this._shapeConfig, "shape", "Circle"))
.config({
id: function (d, i) { return this$1._ids(d, i).join("-"); },
label: function (d, i) {
if (this$1._label) { return this$1._label(d.data, i); }
var ids = this$1._ids(d, i).slice(0, d.depth);
return ids[ids.length - 1];
},
labelConfig: {
textAnchor: function (d) { return this$1._orient === "vertical" ? "middle"
: d.data.children && d.data.depth !== this$1._groupBy.length ? "end" : "start"; },
verticalAlign: function (d) { return this$1._orient === "vertical" ? d.data.depth === 1 ? "bottom" : "top" : "middle"; }
},
hitArea: function (d, i, s) {
var h = this$1._labelHeight,
w = this$1._labelWidths[d.depth - 1];
return {
width: this$1._orient === "vertical" ? w : s.r * 2 + w,
height: this$1._orient === "horizontal" ? h : s.r * 2 + h,
x: this$1._orient === "vertical" ? -w / 2 : d.children && d.depth !== this$1._groupBy.length ? -(s.r + w) : -s.r,
y: this$1._orient === "horizontal" ? -h / 2 : d.children && d.depth !== this$1._groupBy.length ? -(s.r + this$1._labelHeight) : -s.r
};
},
labelBounds: function (d, i, s) {
var h = this$1._labelHeight,
height = this$1._orient === "vertical" ? "height" : "width",
w = this$1._labelWidths[d.depth - 1],
width = this$1._orient === "vertical" ? "width" : "height",
x = this$1._orient === "vertical" ? "x" : "y",
y = this$1._orient === "vertical" ? "y" : "x";
return ( obj = {}, obj[width] = w, obj[height] = h, obj[x] = -w / 2, obj[y] = d.children && d.depth !== this$1._groupBy.length ? -(s.r + h) : s.r, obj );
var obj;
}
})
.render());

@@ -468,17 +467,3 @@

labelConfig: {
fontResize: true,
textAnchor: function (d) { return d.l ? "middle" : "start"; },
verticalAlign: function (d) { return d.l ? "bottom" : "top"; }
},
Rect: {
height: function (d) { return d.y1 - d.y0; },
labelBounds: function (d, i, s) {
var h = s.height;
var sh = Math.min(50, h * 0.25);
return [
{width: s.width, height: h - sh, x: -s.width / 2, y: -h / 2},
{width: s.width, height: sh, x: -s.width / 2, y: h / 2 - sh}
];
},
width: function (d) { return d.x1 - d.x0; }
fontResize: true
}

@@ -556,2 +541,18 @@ });

}).node())
.config({
height: function (d) { return d.y1 - d.y0; },
labelBounds: function (d, i, s) {
var h = s.height;
var sh = Math.min(50, h * 0.25);
return [
{width: s.width, height: h - sh, x: -s.width / 2, y: -h / 2},
{width: s.width, height: sh, x: -s.width / 2, y: h / 2 - sh}
];
},
labelConfig: {
textAnchor: function (d) { return d.l ? "middle" : "start"; },
verticalAlign: function (d) { return d.l ? "bottom" : "top"; }
},
width: function (d) { return d.x1 - d.x0; }
})
.config(d3plusCommon.configPrep.bind(this)(this._shapeConfig, "shape", "Rect"))

@@ -558,0 +559,0 @@ .render());

/*
d3plus-hierarchy v0.3.9
d3plus-hierarchy v0.3.10
Nested, hierarchical, and cluster charts built on D3

@@ -7,2 +7,2 @@ Copyright (c) 2017 D3plus - https://d3plus.org

*/
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-array"),require("d3-shape"),require("d3plus-common"),require("d3plus-shape"),require("d3plus-viz"),require("d3-hierarchy"),require("d3-scale"),require("d3-collection")):typeof define==="function"&&define.amd?define("d3plus-hierarchy",["exports","d3-array","d3-shape","d3plus-common","d3plus-shape","d3plus-viz","d3-hierarchy","d3-scale","d3-collection"],e):e(t.d3plus=t.d3plus||{},t.d3Array,t.d3Shape,t.d3plusCommon,t.d3plusShape,t.d3plusViz,t.d3Hierarchy,t.d3Scale,t.d3Collection)})(this,function(t,e,i,r,n,a,s,o,h){"use strict";var u=function(t){function a(){var e=this;t.call(this);this._shapeConfig=r.assign(this._shapeConfig,{Path:{id:function(t){return e._ids(t).join("-")},label:function(t){return e._drawLabel(t.data,t.i)},labelConfig:{fontResize:true},x:0,y:0}});this._innerRadius=0;this._padPixel=0;this._pie=i.pie();this._sort=function(t,e){return e.value-t.value};this._value=r.accessor("value")}if(t)a.__proto__=t;a.prototype=Object.create(t&&t.prototype);a.prototype.constructor=a;a.prototype._draw=function a(s){t.prototype._draw.call(this,s);var o=this._height-this._margin.top-this._margin.bottom,h=this._width-this._margin.left-this._margin.right;var u=e.min([h,o])/2;var l=this._pie.padAngle(this._padAngle||this._padPixel/u).sort(this._sort).value(this._value)(this._filteredData);l.forEach(function(t,e){t.__d3plus__=true;t.i=e});var p=i.arc().innerRadius(this._innerRadius).outerRadius(u);var _="translate("+h/2+", "+o/2+")";this._shapes.push((new n.Path).data(l).d(p).select(r.elem("g.d3plus-Pie",{parent:this._select,enter:{transform:_},update:{transform:_}}).node()).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Path")).render());return this};a.prototype.innerRadius=function t(e){return arguments.length?(this._innerRadius=e,this):this._innerRadius};a.prototype.padAngle=function t(e){return arguments.length?(this._padAngle=e,this):this._padAngle};a.prototype.padPixel=function t(e){return arguments.length?(this._padPixel=e,this):this._padPixel};a.prototype.sort=function t(e){return arguments.length?(this._sort=e,this):this._sort};a.prototype.value=function t(e){return arguments.length?(this._value=typeof e==="function"?e:r.constant(e),this):this._value};return a}(a.Viz);var l=function(t){function i(){var i=this;t.call(this);this._innerRadius=function(){return e.min([i._width-i._margin.left-i._margin.right,i._height-i._margin.top-i._margin.bottom])/4};this._padPixel=5}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;return i}(u);var p=function(t,e){if(!(e instanceof Array)){e=[e]}var i=h.nest();for(var r=0;r<e.length;r++){i.key(e[r])}var n=i.entries(t);return _(n)};function _(t){return t.map(function(t){if(t.key&&t.values){if(t.values[0].key==="undefined"){return t.values[0].values[0]}else{t.values=_(t.values)}}return t})}var d=function(t){function i(){var e=this;t.call(this);this._orient="vertical";this._separation=function(t,e){return t.parent===e.parent?1:2};var i={id:function(t,i){return e._ids(t,i).join("-")},label:function(t,i){if(e._label){return e._label(t.data,i)}var r=e._ids(t,i).slice(0,t.depth);return r[r.length-1]},labelConfig:{textAnchor:function(t){return e._orient==="vertical"?"middle":t.data.children&&t.data.depth!==e._groupBy.length?"end":"start"},verticalAlign:function(t){return e._orient==="vertical"?t.data.depth===1?"bottom":"top":"middle"}},hitArea:function(t,i,r){var n=e._labelHeight,a=e._labelWidths[t.depth-1];return{width:e._orient==="vertical"?a:r.r*2+a,height:e._orient==="horizontal"?n:r.r*2+n,x:e._orient==="vertical"?-a/2:t.children&&t.depth!==e._groupBy.length?-(r.r+a):-r.r,y:e._orient==="horizontal"?-n/2:t.children&&t.depth!==e._groupBy.length?-(r.r+e._labelHeight):-r.r}},labelBounds:function(t,i,r){var n=e._labelHeight,a=e._orient==="vertical"?"height":"width",s=e._labelWidths[t.depth-1],o=e._orient==="vertical"?"width":"height",h=e._orient==="vertical"?"x":"y",u=e._orient==="vertical"?"y":"x";return l={},l[o]=s,l[a]=n,l[h]=-s/2,l[u]=t.children&&t.depth!==e._groupBy.length?-(r.r+n):r.r,l;var l}};this._shape=r.constant("Circle");this._shapeConfig=r.assign(this._shapeConfig,{Circle:i,labelConfig:{fontColor:"#444"},Path:{d:function(t){var i=e._shapeConfig.Circle.r||e._shapeConfig.r;if(typeof i==="function"){i=i(t.data,t.i)}var r=t.parent.x-t.x+(e._orient==="vertical"?0:i),n=t.parent.y-t.y+(e._orient==="vertical"?i:0),a=e._orient==="vertical"?0:-i,s=e._orient==="vertical"?-i:0;return e._orient==="vertical"?"M"+a+","+s+"C"+a+","+(s+n)/2+" "+r+","+(s+n)/2+" "+r+","+n:"M"+a+","+s+"C"+(a+r)/2+","+s+" "+(a+r)/2+","+n+" "+r+","+n},fill:"none",id:function(t,i){return e._ids(t,i).join("-")},stroke:"#ccc",strokeWidth:1},r:r.constant(5),width:r.constant(10),height:r.constant(10)});this._tree=s.tree()}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;i.prototype._draw=function i(a){var h=this;t.prototype._draw.call(this,a);var u=this._orient==="vertical"?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right,l=this._orient==="vertical"?"left":"top",_=this,d="translate("+this._margin.left+", "+this._margin.top+")",c=this._orient==="horizontal"?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right;var f=this._tree.separation(this._separation).size([c,u])(s.hierarchy({key:"root",values:p(this._filteredData,this._groupBy.slice(0,this._drawDepth+1))},function(t){return t.key&&t.values?t.values:null}).sort(this._sort)).descendants().filter(function(t){return t.depth<=h._groupBy.length&&t.parent});function g(t){return r.merge(t.values.map(function(t){return t.key&&t.values?g(t):t}),_._aggs)}f.forEach(function(t,e){if(t.data.key&&t.data.values){t.data=g(t.data)}t.__d3plus__=true;t.i=e});var v=this._shapeConfig.Circle.r||this._shapeConfig.r;if(typeof v!=="function"){v=r.constant(v)}var y=e.max(f,function(t){return t.depth===1?v(t.data,t.i):0});var m=e.max(f,function(t){return t.children?0:v(t.data,t.i)});var b=e.extent(f,function(t){return t.y});this._labelHeight=e.min([this._orient==="vertical"?50:100,(b[1]-y-m)/(this._groupBy.length+1)]);this._labelWidths=p(f,function(t){return t.depth}).map(function(t){return t.values.reduce(function(i,r,n){var a=n<t.values.length-1?t.values[n+1].x:c+h._margin[l],s=n?t.values[n-1].x:h._margin[l];return e.min([i,a-r.x,r.x-s])},c)});var x=o.scaleLinear().domain(b).range([y+this._labelHeight,u-m-this._labelHeight]);f.forEach(function(t){var e=x(t.y);if(h._orient==="horizontal"){t.y=t.x;t.x=e}else{t.y=e}});var w={parent:this._select,enter:{transform:d},update:{transform:d}};this._shapes.push((new n.Path).data(f.filter(function(t){return t.depth>1})).select(r.elem("g.d3plus-Tree-Links",w).node()).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Path")).render());this._shapes.push((new n.Circle).data(f).select(r.elem("g.d3plus-Tree-Shapes",w).node()).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Circle")).render());return this};i.prototype.orient=function t(e){return arguments.length?(this._orient=e,this):this._orient};i.prototype.separation=function t(e){return arguments.length?(this._separation=e,this):this._separation};return i}(a.Viz);var c=function(t){function e(){t.call(this);this._padding=1;this._shapeConfig=r.assign({},this._shapeConfig,{labelConfig:{fontResize:true,textAnchor:function(t){return t.l?"middle":"start"},verticalAlign:function(t){return t.l?"bottom":"top"}},Rect:{height:function(t){return t.y1-t.y0},labelBounds:function(t,e,i){var r=i.height;var n=Math.min(50,r*.25);return[{width:i.width,height:r-n,x:-i.width/2,y:-r/2},{width:i.width,height:n,x:-i.width/2,y:r/2-n}]},width:function(t){return t.x1-t.x0}}});this._sort=function(t,e){return e.value-t.value};this._sum=r.accessor("value");this._tile=s.treemapSquarify;this._treemap=s.treemap().round(true)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype._draw=function e(i){var a=this;t.prototype._draw.call(this,i);var o=h.nest();for(var u=0;u<=this._drawDepth;u++){o.key(a._groupBy[u])}o=o.entries(this._filteredData);var l=this._treemap.padding(this._padding).size([this._width-this._margin.left-this._margin.right,this._height-this._margin.top-this._margin.bottom]).tile(this._tile)(s.hierarchy({values:o},function(t){return t.values}).sum(this._sum).sort(this._sort));var p=[],_=this;function d(t){for(var e=0;e<t.length;e++){var i=t[e];if(i.depth<=_._drawDepth){d(i.children)}else{i.__d3plus__=true;i.id=i.data.key;i.data=r.merge(i.data.values);i.i=e;i.x=i.x0+(i.x1-i.x0)/2;i.y=i.y0+(i.y1-i.y0)/2;p.push(i)}}}if(l.children){d(l.children)}var c=l.value;var f="translate("+this._margin.left+", "+this._margin.top+")";this._shapes.push((new n.Rect).data(p).label(function(t){return[a._drawLabel(t.data,t.i),Math.round(a._sum(t.data,t.i)/c*100)+"%"]}).select(r.elem("g.d3plus-Treemap",{parent:this._select,enter:{transform:f},update:{transform:f}}).node()).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Rect")).render());return this};e.prototype.padding=function t(e){return arguments.length?(this._padding=typeof e==="function"?e:r.constant(e),this):this._padding};e.prototype.sort=function t(e){return arguments.length?(this._sort=e,this):this._sort};e.prototype.sum=function t(e){return arguments.length?(this._sum=typeof e==="function"?e:r.constant(e),this):this._sum};e.prototype.tile=function t(e){return arguments.length?(this._tile=e,this):this._tile};return e}(a.Viz);t.Donut=l;t.Pie=u;t.Tree=d;t.Treemap=c;Object.defineProperty(t,"__esModule",{value:true})});
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("d3-array"),require("d3-shape"),require("d3plus-common"),require("d3plus-shape"),require("d3plus-viz"),require("d3-hierarchy"),require("d3-scale"),require("d3-collection")):typeof define==="function"&&define.amd?define("d3plus-hierarchy",["exports","d3-array","d3-shape","d3plus-common","d3plus-shape","d3plus-viz","d3-hierarchy","d3-scale","d3-collection"],e):e(t.d3plus=t.d3plus||{},t.d3Array,t.d3Shape,t.d3plusCommon,t.d3plusShape,t.d3plusViz,t.d3Hierarchy,t.d3Scale,t.d3Collection)})(this,function(t,e,i,r,n,a,o,s,h){"use strict";var u=function(t){function a(){t.call(this);this._shapeConfig=r.assign(this._shapeConfig,{Path:{labelConfig:{fontResize:true}}});this._innerRadius=0;this._padPixel=0;this._pie=i.pie();this._sort=function(t,e){return e.value-t.value};this._value=r.accessor("value")}if(t)a.__proto__=t;a.prototype=Object.create(t&&t.prototype);a.prototype.constructor=a;a.prototype._draw=function a(o){var s=this;t.prototype._draw.call(this,o);var h=this._height-this._margin.top-this._margin.bottom,u=this._width-this._margin.left-this._margin.right;var l=e.min([u,h])/2;var p=this._pie.padAngle(this._padAngle||this._padPixel/l).sort(this._sort).value(this._value)(this._filteredData);p.forEach(function(t,e){t.__d3plus__=true;t.i=e});var _=i.arc().innerRadius(this._innerRadius).outerRadius(l);var d="translate("+u/2+", "+h/2+")";this._shapes.push((new n.Path).data(p).d(_).select(r.elem("g.d3plus-Pie",{parent:this._select,enter:{transform:d},update:{transform:d}}).node()).config({id:function(t){return s._ids(t).join("-")},x:0,y:0}).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Path")).render());return this};a.prototype.innerRadius=function t(e){return arguments.length?(this._innerRadius=e,this):this._innerRadius};a.prototype.padAngle=function t(e){return arguments.length?(this._padAngle=e,this):this._padAngle};a.prototype.padPixel=function t(e){return arguments.length?(this._padPixel=e,this):this._padPixel};a.prototype.sort=function t(e){return arguments.length?(this._sort=e,this):this._sort};a.prototype.value=function t(e){return arguments.length?(this._value=typeof e==="function"?e:r.constant(e),this):this._value};return a}(a.Viz);var l=function(t){function i(){var i=this;t.call(this);this._innerRadius=function(){return e.min([i._width-i._margin.left-i._margin.right,i._height-i._margin.top-i._margin.bottom])/4};this._padPixel=5}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;return i}(u);var p=function(t,e){if(!(e instanceof Array)){e=[e]}var i=h.nest();for(var r=0;r<e.length;r++){i.key(e[r])}var n=i.entries(t);return _(n)};function _(t){return t.map(function(t){if(t.key&&t.values){if(t.values[0].key==="undefined"){return t.values[0].values[0]}else{t.values=_(t.values)}}return t})}var d=function(t){function i(){t.call(this);this._orient="vertical";this._separation=function(t,e){return t.parent===e.parent?1:2};this._shape=r.constant("Circle");this._shapeConfig=r.assign(this._shapeConfig,{labelConfig:{fontColor:"#444"},Path:{fill:"none",stroke:"#ccc",strokeWidth:1},r:r.constant(5),width:r.constant(10),height:r.constant(10)});this._tree=o.tree()}if(t)i.__proto__=t;i.prototype=Object.create(t&&t.prototype);i.prototype.constructor=i;i.prototype._draw=function i(a){var h=this;t.prototype._draw.call(this,a);var u=this._orient==="vertical"?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right,l=this._orient==="vertical"?"left":"top",_=this,d="translate("+this._margin.left+", "+this._margin.top+")",c=this._orient==="horizontal"?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right;var f=this._tree.separation(this._separation).size([c,u])(o.hierarchy({key:"root",values:p(this._filteredData,this._groupBy.slice(0,this._drawDepth+1))},function(t){return t.key&&t.values?t.values:null}).sort(this._sort)).descendants().filter(function(t){return t.depth<=h._groupBy.length&&t.parent});function g(t){return r.merge(t.values.map(function(t){return t.key&&t.values?g(t):t}),_._aggs)}f.forEach(function(t,e){if(t.data.key&&t.data.values){t.data=g(t.data)}t.__d3plus__=true;t.i=e});var v=this._shapeConfig.r;if(typeof v!=="function"){v=r.constant(v)}var y=e.max(f,function(t){return t.depth===1?v(t.data,t.i):0});var m=e.max(f,function(t){return t.children?0:v(t.data,t.i)});var b=e.extent(f,function(t){return t.y});this._labelHeight=e.min([this._orient==="vertical"?50:100,(b[1]-y-m)/(this._groupBy.length+1)]);this._labelWidths=p(f,function(t){return t.depth}).map(function(t){return t.values.reduce(function(i,r,n){var a=n<t.values.length-1?t.values[n+1].x:c+h._margin[l],o=n?t.values[n-1].x:h._margin[l];return e.min([i,a-r.x,r.x-o])},c)});var x=s.scaleLinear().domain(b).range([y+this._labelHeight,u-m-this._labelHeight]);f.forEach(function(t){var e=x(t.y);if(h._orient==="horizontal"){t.y=t.x;t.x=e}else{t.y=e}});var w={parent:this._select,enter:{transform:d},update:{transform:d}};this._shapes.push((new n.Path).data(f.filter(function(t){return t.depth>1})).select(r.elem("g.d3plus-Tree-Links",w).node()).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Path")).config({d:function(t){var e=h._shapeConfig.r;if(typeof e==="function"){e=e(t.data,t.i)}var i=t.parent.x-t.x+(h._orient==="vertical"?0:e),r=t.parent.y-t.y+(h._orient==="vertical"?e:0),n=h._orient==="vertical"?0:-e,a=h._orient==="vertical"?-e:0;return h._orient==="vertical"?"M"+n+","+a+"C"+n+","+(a+r)/2+" "+i+","+(a+r)/2+" "+i+","+r:"M"+n+","+a+"C"+(n+i)/2+","+a+" "+(n+i)/2+","+r+" "+i+","+r},id:function(t,e){return h._ids(t,e).join("-")}}).render());this._shapes.push((new n.Circle).data(f).select(r.elem("g.d3plus-Tree-Shapes",w).node()).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Circle")).config({id:function(t,e){return h._ids(t,e).join("-")},label:function(t,e){if(h._label){return h._label(t.data,e)}var i=h._ids(t,e).slice(0,t.depth);return i[i.length-1]},labelConfig:{textAnchor:function(t){return h._orient==="vertical"?"middle":t.data.children&&t.data.depth!==h._groupBy.length?"end":"start"},verticalAlign:function(t){return h._orient==="vertical"?t.data.depth===1?"bottom":"top":"middle"}},hitArea:function(t,e,i){var r=h._labelHeight,n=h._labelWidths[t.depth-1];return{width:h._orient==="vertical"?n:i.r*2+n,height:h._orient==="horizontal"?r:i.r*2+r,x:h._orient==="vertical"?-n/2:t.children&&t.depth!==h._groupBy.length?-(i.r+n):-i.r,y:h._orient==="horizontal"?-r/2:t.children&&t.depth!==h._groupBy.length?-(i.r+h._labelHeight):-i.r}},labelBounds:function(t,e,i){var r=h._labelHeight,n=h._orient==="vertical"?"height":"width",a=h._labelWidths[t.depth-1],o=h._orient==="vertical"?"width":"height",s=h._orient==="vertical"?"x":"y",u=h._orient==="vertical"?"y":"x";return l={},l[o]=a,l[n]=r,l[s]=-a/2,l[u]=t.children&&t.depth!==h._groupBy.length?-(i.r+r):i.r,l;var l}}).render());return this};i.prototype.orient=function t(e){return arguments.length?(this._orient=e,this):this._orient};i.prototype.separation=function t(e){return arguments.length?(this._separation=e,this):this._separation};return i}(a.Viz);var c=function(t){function e(){t.call(this);this._padding=1;this._shapeConfig=r.assign({},this._shapeConfig,{labelConfig:{fontResize:true}});this._sort=function(t,e){return e.value-t.value};this._sum=r.accessor("value");this._tile=o.treemapSquarify;this._treemap=o.treemap().round(true)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype._draw=function e(i){var a=this;t.prototype._draw.call(this,i);var s=h.nest();for(var u=0;u<=this._drawDepth;u++){s.key(a._groupBy[u])}s=s.entries(this._filteredData);var l=this._treemap.padding(this._padding).size([this._width-this._margin.left-this._margin.right,this._height-this._margin.top-this._margin.bottom]).tile(this._tile)(o.hierarchy({values:s},function(t){return t.values}).sum(this._sum).sort(this._sort));var p=[],_=this;function d(t){for(var e=0;e<t.length;e++){var i=t[e];if(i.depth<=_._drawDepth){d(i.children)}else{i.__d3plus__=true;i.id=i.data.key;i.data=r.merge(i.data.values);i.i=e;i.x=i.x0+(i.x1-i.x0)/2;i.y=i.y0+(i.y1-i.y0)/2;p.push(i)}}}if(l.children){d(l.children)}var c=l.value;var f="translate("+this._margin.left+", "+this._margin.top+")";this._shapes.push((new n.Rect).data(p).label(function(t){return[a._drawLabel(t.data,t.i),Math.round(a._sum(t.data,t.i)/c*100)+"%"]}).select(r.elem("g.d3plus-Treemap",{parent:this._select,enter:{transform:f},update:{transform:f}}).node()).config({height:function(t){return t.y1-t.y0},labelBounds:function(t,e,i){var r=i.height;var n=Math.min(50,r*.25);return[{width:i.width,height:r-n,x:-i.width/2,y:-r/2},{width:i.width,height:n,x:-i.width/2,y:r/2-n}]},labelConfig:{textAnchor:function(t){return t.l?"middle":"start"},verticalAlign:function(t){return t.l?"bottom":"top"}},width:function(t){return t.x1-t.x0}}).config(r.configPrep.bind(this)(this._shapeConfig,"shape","Rect")).render());return this};e.prototype.padding=function t(e){return arguments.length?(this._padding=typeof e==="function"?e:r.constant(e),this):this._padding};e.prototype.sort=function t(e){return arguments.length?(this._sort=e,this):this._sort};e.prototype.sum=function t(e){return arguments.length?(this._sum=typeof e==="function"?e:r.constant(e),this):this._sum};e.prototype.tile=function t(e){return arguments.length?(this._tile=e,this):this._tile};return e}(a.Viz);t.Donut=l;t.Pie=u;t.Tree=d;t.Treemap=c;Object.defineProperty(t,"__esModule",{value:true})});
{
"name": "d3plus-hierarchy",
"version": "0.3.9",
"version": "0.3.10",
"description": "Nested, hierarchical, and cluster charts built on D3",

@@ -31,5 +31,5 @@ "main": "build/d3plus-hierarchy.js",

"d3-shape": "^1.0.3",
"d3plus-common": "^0.6.18",
"d3plus-common": "^0.6.21",
"d3plus-shape": "^0.13.2",
"d3plus-viz": "^0.9.2"
"d3plus-viz": "^0.9.4"
},

@@ -36,0 +36,0 @@ "scripts": {

@@ -104,3 +104,3 @@ # d3plus-hierarchy

<a name="Pie.innerRadius" href="Pie.innerRadius">#</a> Pie.**innerRadius**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L92)
<a name="Pie.innerRadius" href="Pie.innerRadius">#</a> Pie.**innerRadius**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L93)

@@ -112,3 +112,3 @@ If *value* is specified, sets the inner radius accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current inner radius accessor.

<a name="Pie.padAngle" href="Pie.padAngle">#</a> Pie.**padAngle**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L103)
<a name="Pie.padAngle" href="Pie.padAngle">#</a> Pie.**padAngle**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L104)

@@ -120,3 +120,3 @@ If *value* is specified, sets the arc padding to the specified radian value and returns the current class instance. If *value* is not specified, returns the current radian padding.

<a name="Pie.padPixel" href="Pie.padPixel">#</a> Pie.**padPixel**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L114)
<a name="Pie.padPixel" href="Pie.padPixel">#</a> Pie.**padPixel**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L115)

@@ -128,3 +128,3 @@ If *value* is specified, sets the arc padding to the specified pixel value and returns the current class instance. If *value* is not specified, returns the current pixel padding.

<a name="Pie.sort" href="Pie.sort">#</a> Pie.**sort**([*comparator*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L129)
<a name="Pie.sort" href="Pie.sort">#</a> Pie.**sort**([*comparator*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L130)

@@ -142,3 +142,3 @@ If *comparator* is specified, sets the sort order for the pie slices using the specified comparator function. If *comparator* is not specified, returns the current sort order, which defaults to descending order by the associated input data's numeric value attribute.

```
<a name="Pie.value" href="Pie.value">#</a> Pie.**value**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L144)
<a name="Pie.value" href="Pie.value">#</a> Pie.**value**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L145)

@@ -223,3 +223,3 @@ If *value* is specified, sets the value accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current value accessor.

<a name="Treemap.padding" href="Treemap.padding">#</a> Treemap.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L120)
<a name="Treemap.padding" href="Treemap.padding">#</a> Treemap.**padding**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L122)

@@ -231,3 +231,3 @@ If *value* is specified, sets the inner and outer padding accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current padding accessor.

<a name="Treemap.sort" href="Treemap.sort">#</a> Treemap.**sort**([*comparator*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L135)
<a name="Treemap.sort" href="Treemap.sort">#</a> Treemap.**sort**([*comparator*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L137)

@@ -245,3 +245,3 @@ If *comparator* is specified, sets the sort order for the treemap using the specified comparator function. If *comparator* is not specified, returns the current group sort order, which defaults to descending order by the associated input data's numeric value attribute.

```
<a name="Treemap.sum" href="Treemap.sum">#</a> Treemap.**sum**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L150)
<a name="Treemap.sum" href="Treemap.sum">#</a> Treemap.**sum**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L152)

@@ -259,3 +259,3 @@ If *value* is specified, sets the sum accessor to the specified function or number and returns the current class instance. If *value* is not specified, returns the current sum accessor.

```
<a name="Treemap.tile" href="Treemap.tile">#</a> Treemap.**tile**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L161)
<a name="Treemap.tile" href="Treemap.tile">#</a> Treemap.**tile**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L163)

@@ -285,2 +285,2 @@ If *value* is specified, sets the [tiling method](https://github.com/d3/d3-hierarchy#treemap-tiling) to the specified function and returns the current class instance. If *value* is not specified, returns the current [tiling method](https://github.com/d3/d3-hierarchy#treemap-tiling).

###### <sub>Documentation generated on Tue, 30 May 2017 19:05:05 GMT</sub>
###### <sub>Documentation generated on Thu, 22 Jun 2017 17:23:38 GMT</sub>

@@ -26,9 +26,5 @@ import {min} from "d3-array";

Path: {
id: d => this._ids(d).join("-"),
label: d => this._drawLabel(d.data, d.i),
labelConfig: {
fontResize: true
},
x: 0,
y: 0
}
}

@@ -81,2 +77,7 @@ });

}).node())
.config({
id: d => this._ids(d).join("-"),
x: 0,
y: 0
})
.config(configPrep.bind(this)(this._shapeConfig, "shape", "Path"))

@@ -83,0 +84,0 @@ .render());

@@ -30,49 +30,4 @@ import {extent, min, max} from "d3-array";

const nodeConfig = {
id: (d, i) => this._ids(d, i).join("-"),
label: (d, i) => {
if (this._label) return this._label(d.data, i);
const ids = this._ids(d, i).slice(0, d.depth);
return ids[ids.length - 1];
},
labelConfig: {
textAnchor: d => this._orient === "vertical" ? "middle"
: d.data.children && d.data.depth !== this._groupBy.length ? "end" : "start",
verticalAlign: d => this._orient === "vertical" ? d.data.depth === 1 ? "bottom" : "top" : "middle"
},
hitArea: (d, i, s) => {
const h = this._labelHeight,
w = this._labelWidths[d.depth - 1];
return {
width: this._orient === "vertical" ? w : s.r * 2 + w,
height: this._orient === "horizontal" ? h : s.r * 2 + h,
x: this._orient === "vertical" ? -w / 2 : d.children && d.depth !== this._groupBy.length ? -(s.r + w) : -s.r,
y: this._orient === "horizontal" ? -h / 2 : d.children && d.depth !== this._groupBy.length ? -(s.r + this._labelHeight) : -s.r
};
},
labelBounds: (d, i, s) => {
const h = this._labelHeight,
height = this._orient === "vertical" ? "height" : "width",
w = this._labelWidths[d.depth - 1],
width = this._orient === "vertical" ? "width" : "height",
x = this._orient === "vertical" ? "x" : "y",
y = this._orient === "vertical" ? "y" : "x";
return {
[width]: w,
[height]: h,
[x]: -w / 2,
[y]: d.children && d.depth !== this._groupBy.length ? -(s.r + h) : s.r
};
}
};
this._shape = constant("Circle");
this._shapeConfig = assign(this._shapeConfig, {
Circle: nodeConfig,
labelConfig: {

@@ -82,20 +37,3 @@ fontColor: "#444"

Path: {
d: d => {
let r = this._shapeConfig.Circle.r || this._shapeConfig.r;
if (typeof r === "function") r = r(d.data, d.i);
const px = d.parent.x - d.x + (this._orient === "vertical" ? 0 : r),
py = d.parent.y - d.y + (this._orient === "vertical" ? r : 0),
x = this._orient === "vertical" ? 0 : -r,
y = this._orient === "vertical" ? -r : 0;
return this._orient === "vertical"
? `M${x},${y}C${x},${(y + py) / 2} ${px},${(y + py) / 2} ${px},${py}`
: `M${x},${y}C${(x + px) / 2},${y} ${(x + px) / 2},${py} ${px},${py}`;
},
fill: "none",
id: (d, i) => this._ids(d, i).join("-"),
stroke: "#ccc",

@@ -155,3 +93,3 @@ strokeWidth: 1

let r = this._shapeConfig.Circle.r || this._shapeConfig.r;
let r = this._shapeConfig.r;
if (typeof r !== "function") r = constant(r);

@@ -194,2 +132,21 @@ const rBufferRoot = max(treeData, d => d.depth === 1 ? r(d.data, d.i) : 0);

.config(configPrep.bind(this)(this._shapeConfig, "shape", "Path"))
.config({
d: d => {
let r = this._shapeConfig.r;
if (typeof r === "function") r = r(d.data, d.i);
const px = d.parent.x - d.x + (this._orient === "vertical" ? 0 : r),
py = d.parent.y - d.y + (this._orient === "vertical" ? r : 0),
x = this._orient === "vertical" ? 0 : -r,
y = this._orient === "vertical" ? -r : 0;
return this._orient === "vertical"
? `M${x},${y}C${x},${(y + py) / 2} ${px},${(y + py) / 2} ${px},${py}`
: `M${x},${y}C${(x + px) / 2},${y} ${(x + px) / 2},${py} ${px},${py}`;
},
id: (d, i) => this._ids(d, i).join("-")
})
.render());

@@ -201,2 +158,45 @@

.config(configPrep.bind(this)(this._shapeConfig, "shape", "Circle"))
.config({
id: (d, i) => this._ids(d, i).join("-"),
label: (d, i) => {
if (this._label) return this._label(d.data, i);
const ids = this._ids(d, i).slice(0, d.depth);
return ids[ids.length - 1];
},
labelConfig: {
textAnchor: d => this._orient === "vertical" ? "middle"
: d.data.children && d.data.depth !== this._groupBy.length ? "end" : "start",
verticalAlign: d => this._orient === "vertical" ? d.data.depth === 1 ? "bottom" : "top" : "middle"
},
hitArea: (d, i, s) => {
const h = this._labelHeight,
w = this._labelWidths[d.depth - 1];
return {
width: this._orient === "vertical" ? w : s.r * 2 + w,
height: this._orient === "horizontal" ? h : s.r * 2 + h,
x: this._orient === "vertical" ? -w / 2 : d.children && d.depth !== this._groupBy.length ? -(s.r + w) : -s.r,
y: this._orient === "horizontal" ? -h / 2 : d.children && d.depth !== this._groupBy.length ? -(s.r + this._labelHeight) : -s.r
};
},
labelBounds: (d, i, s) => {
const h = this._labelHeight,
height = this._orient === "vertical" ? "height" : "width",
w = this._labelWidths[d.depth - 1],
width = this._orient === "vertical" ? "width" : "height",
x = this._orient === "vertical" ? "x" : "y",
y = this._orient === "vertical" ? "y" : "x";
return {
[width]: w,
[height]: h,
[x]: -w / 2,
[y]: d.children && d.depth !== this._groupBy.length ? -(s.r + h) : s.r
};
}
})
.render());

@@ -203,0 +203,0 @@

@@ -27,17 +27,3 @@ import {nest} from "d3-collection";

labelConfig: {
fontResize: true,
textAnchor: d => d.l ? "middle" : "start",
verticalAlign: d => d.l ? "bottom" : "top"
},
Rect: {
height: d => d.y1 - d.y0,
labelBounds: (d, i, s) => {
const h = s.height;
const sh = Math.min(50, h * 0.25);
return [
{width: s.width, height: h - sh, x: -s.width / 2, y: -h / 2},
{width: s.width, height: sh, x: -s.width / 2, y: h / 2 - sh}
];
},
width: d => d.x1 - d.x0
fontResize: true
}

@@ -109,2 +95,18 @@ });

}).node())
.config({
height: d => d.y1 - d.y0,
labelBounds: (d, i, s) => {
const h = s.height;
const sh = Math.min(50, h * 0.25);
return [
{width: s.width, height: h - sh, x: -s.width / 2, y: -h / 2},
{width: s.width, height: sh, x: -s.width / 2, y: h / 2 - sh}
];
},
labelConfig: {
textAnchor: d => d.l ? "middle" : "start",
verticalAlign: d => d.l ? "bottom" : "top"
},
width: d => d.x1 - d.x0
})
.config(configPrep.bind(this)(this._shapeConfig, "shape", "Rect"))

@@ -111,0 +113,0 @@ .render());

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc