Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3plus-hierarchy

Package Overview
Dependencies
Maintainers
1
Versions
49
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.6.2 to 0.6.3

30

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

@@ -85,2 +85,3 @@ Copyright (c) 2018 D3plus - https://d3plus.org

this._shapeConfig = d3plusCommon.assign(this._shapeConfig, {
ariaLabel: function (d, i) { return this$1._pieData ? ((++this$1._pieData[i].index) + ". " + (this$1._drawLabel(d, i)) + ", " + (this$1._value(d, i)) + ".") : ""; },
Path: {

@@ -97,3 +98,2 @@ labelConfig: {

this._value = d3plusCommon.accessor("value");
}

@@ -120,3 +120,3 @@

var pieData = this._pie
var pieData = this._pieData = this._pie
.padAngle(this._padAngle || this._padPixel / outerRadius)

@@ -154,3 +154,2 @@ .sort(this._sort)

return this;
};

@@ -286,3 +285,5 @@

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

@@ -295,2 +296,3 @@

this._shapeConfig = d3plusCommon.assign(this._shapeConfig, {
ariaLabel: function (d, i) { return this$1._treeData ? ((this$1._treeData[i].depth) + ". " + (this$1._drawLabel(d, i)) + ".") : ""; },
labelConfig: {

@@ -337,3 +339,3 @@ fontColor: "#444"

var treeData = this._tree
var treeData = this._treeData = this._tree
.separation(this._separation)

@@ -505,3 +507,5 @@ .size([width, height])

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

@@ -511,2 +515,6 @@

this._shapeConfig = d3plusCommon.assign({}, this._shapeConfig, {
ariaLabel: function (d, i) {
var rank = this$1._rankData ? ((this$1._rankData.indexOf(d) + 1) + ". ") : "";
return ("" + rank + (this$1._drawLabel(d, i)) + ", " + (this$1._sum(d, i)) + ".");
},
labelConfig: {

@@ -530,3 +538,4 @@ fontMax: 20,

/**
Extends the draw behavior of the abstract Viz class.
@memberof Treemap
@desc Extends the draw behavior of the abstract Viz class.
@private

@@ -539,3 +548,3 @@ */

Viz.prototype._draw.call(this, callback);
var nestedData = d3Collection.nest();

@@ -557,3 +566,4 @@ for (var i = 0; i <= this._drawDepth; i++) { nestedData.key(this$1._groupBy[i]); }

/**
Flattens and merges treemap data.
@memberof Treemap
@desc Flattens and merges treemap data.
@private

@@ -568,4 +578,4 @@ */

node.id = node.data.key;
node.i = node.data.values.length === 1 && that._filteredData.includes(node.data.values[0]) ? that._filteredData.indexOf(node.data.values[0]) : undefined;
node.data = d3plusCommon.merge(node.data.values);
node.i = i;
node.x = node.x0 + (node.x1 - node.x0) / 2;

@@ -578,2 +588,4 @@ node.y = node.y0 + (node.y1 - node.y0) / 2;

if (tmapData.children) { extractLayout(tmapData.children); }
this._rankData = shapeData.sort(this._sort).map(function (d) { return d.data; });
var total = tmapData.value;

@@ -580,0 +592,0 @@

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

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

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

@@ -21,2 +21,3 @@ import {min} from "d3-array";

this._shapeConfig = assign(this._shapeConfig, {
ariaLabel: function (d, i) { return this$1._pieData ? ((++this$1._pieData[i].index) + ". " + (this$1._drawLabel(d, i)) + ", " + (this$1._value(d, i)) + ".") : ""; },
Path: {

@@ -33,3 +34,2 @@ labelConfig: {

this._value = accessor("value");
}

@@ -56,3 +56,3 @@

var pieData = this._pie
var pieData = this._pieData = this._pie
.padAngle(this._padAngle || this._padPixel / outerRadius)

@@ -90,3 +90,2 @@ .sort(this._sort)

return this;
};

@@ -93,0 +92,0 @@

@@ -18,3 +18,5 @@ import {extent, min, max} from "d3-array";

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

@@ -27,2 +29,3 @@

this._shapeConfig = assign(this._shapeConfig, {
ariaLabel: function (d, i) { return this$1._treeData ? ((this$1._treeData[i].depth) + ". " + (this$1._drawLabel(d, i)) + ".") : ""; },
labelConfig: {

@@ -69,3 +72,3 @@ fontColor: "#444"

var treeData = this._tree
var treeData = this._treeData = this._tree
.separation(this._separation)

@@ -72,0 +75,0 @@ .size([width, height])

@@ -15,3 +15,5 @@ import {nest} from "d3-collection";

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

@@ -21,2 +23,6 @@

this._shapeConfig = assign({}, this._shapeConfig, {
ariaLabel: function (d, i) {
var rank = this$1._rankData ? ((this$1._rankData.indexOf(d) + 1) + ". ") : "";
return ("" + rank + (this$1._drawLabel(d, i)) + ", " + (this$1._sum(d, i)) + ".");
},
labelConfig: {

@@ -40,3 +46,4 @@ fontMax: 20,

/**
Extends the draw behavior of the abstract Viz class.
@memberof Treemap
@desc Extends the draw behavior of the abstract Viz class.
@private

@@ -49,3 +56,3 @@ */

Viz.prototype._draw.call(this, callback);
var nestedData = nest();

@@ -67,3 +74,4 @@ for (var i = 0; i <= this._drawDepth; i++) { nestedData.key(this$1._groupBy[i]); }

/**
Flattens and merges treemap data.
@memberof Treemap
@desc Flattens and merges treemap data.
@private

@@ -78,4 +86,4 @@ */

node.id = node.data.key;
node.i = node.data.values.length === 1 && that._filteredData.includes(node.data.values[0]) ? that._filteredData.indexOf(node.data.values[0]) : undefined;
node.data = merge(node.data.values);
node.i = i;
node.x = node.x0 + (node.x1 - node.x0) / 2;

@@ -88,2 +96,4 @@ node.y = node.y0 + (node.y1 - node.y0) / 2;

if (tmapData.children) { extractLayout(tmapData.children); }
this._rankData = shapeData.sort(this._sort).map(function (d) { return d.data; });
var total = tmapData.value;

@@ -90,0 +100,0 @@

{
"name": "d3plus-hierarchy",
"version": "0.6.2",
"version": "0.6.3",
"description": "Nested, hierarchical, and cluster charts built on D3",

@@ -32,4 +32,4 @@ "main": "build/d3plus-hierarchy.js",

"d3plus-common": "^0.6.39",
"d3plus-shape": "^0.14.7",
"d3plus-viz": "^0.11.12"
"d3plus-shape": "^0.14.11",
"d3plus-viz": "^0.11.14"
},

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

# d3plus-hierarchy
[![NPM Release](http://img.shields.io/npm/v/d3plus-hierarchy.svg?style=flat)](https://www.npmjs.org/package/d3plus-hierarchy) [![Build Status](https://travis-ci.org/d3plus/d3plus-hierarchy.svg?branch=master)](https://travis-ci.org/d3plus/d3plus-hierarchy) [![Dependency Status](http://img.shields.io/david/d3plus/d3plus-hierarchy.svg?style=flat)](https://david-dm.org/d3plus/d3plus-hierarchy) [![Gitter](https://img.shields.io/badge/-chat_on_gitter-brightgreen.svg?style=flat&logo=gitter-white)](https://gitter.im/d3plus/) [![1.0 progress](https://img.shields.io/badge/1.0_progress-0%25-red.svg?style=flat)](https://github.com/d3plus/d3plus-hierarchy/projects/1)
[![NPM Release](http://img.shields.io/npm/v/d3plus-hierarchy.svg?style=flat)](https://www.npmjs.org/package/d3plus-hierarchy) [![Build Status](https://travis-ci.org/d3plus/d3plus-hierarchy.svg?branch=master)](https://travis-ci.org/d3plus/d3plus-hierarchy) [![Dependency Status](http://img.shields.io/david/d3plus/d3plus-hierarchy.svg?style=flat)](https://david-dm.org/d3plus/d3plus-hierarchy) [![Gitter](https://img.shields.io/badge/-chat_on_gitter-brightgreen.svg?style=flat&logo=gitter-white)](https://gitter.im/d3plus/) [![1.0 progress](https://img.shields.io/badge/1.0_progress-33%25-orange.svg?style=flat)](https://github.com/d3plus/d3plus-hierarchy/projects/1)

@@ -111,3 +111,3 @@ Nested, hierarchical, and cluster charts built on D3

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

@@ -120,3 +120,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#L102)
<a name="Pie.padAngle" href="#Pie.padAngle">#</a> Pie.**padAngle**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L101)

@@ -129,3 +129,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#L111)
<a name="Pie.padPixel" href="#Pie.padPixel">#</a> Pie.**padPixel**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L110)

@@ -138,3 +138,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#L124)
<a name="Pie.sort" href="#Pie.sort">#</a> Pie.**sort**([*comparator*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L123)

@@ -154,3 +154,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#L137)
<a name="Pie.value" href="#Pie.value">#</a> Pie.**value**(*value*) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Pie.js#L136)

@@ -192,3 +192,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="Tree.orient" href="#Tree.orient">#</a> Tree.**orient**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Tree.js#L207)
<a name="Tree.orient" href="#Tree.orient">#</a> Tree.**orient**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Tree.js#L208)

@@ -201,3 +201,3 @@ If *value* is specified, sets the orientation to the specified value. If *value* is not specified, returns the current orientation.

<a name="Tree.separation" href="#Tree.separation">#</a> Tree.**separation**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Tree.js#L223)
<a name="Tree.separation" href="#Tree.separation">#</a> Tree.**separation**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Tree.js#L224)

@@ -244,3 +244,3 @@ If *value* is specified, sets the separation accessor to the specified function. If *value* is not specified, returns the current separation accessor.

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

@@ -253,3 +253,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#L137)
<a name="Treemap.sort" href="#Treemap.sort">#</a> Treemap.**sort**([*comparator*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L145)

@@ -269,3 +269,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#L158)

@@ -285,3 +285,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#L159)
<a name="Treemap.tile" href="#Treemap.tile">#</a> Treemap.**tile**([*value*]) [<>](https://github.com/d3plus/d3plus-hierarchy/blob/master/src/Treemap.js#L167)

@@ -311,2 +311,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, 05 Jun 2018 17:51:10 GMT</sub>
###### <sub>Documentation generated on Wed, 27 Jun 2018 17:45:25 GMT</sub>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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