d3plus-hierarchy
Advanced tools
Comparing version 0.3.13 to 0.3.14
/* | ||
d3plus-hierarchy v0.3.13 | ||
d3plus-hierarchy v0.3.14 | ||
Nested, hierarchical, and cluster charts built on D3 | ||
Copyright (c) 2017 D3plus - https://d3plus.org | ||
Copyright (c) 2018 D3plus - https://d3plus.org | ||
@license MIT | ||
@@ -67,6 +67,6 @@ */ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(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'], factory) : | ||
(factory((global.d3plus = {}),global.d3Array,global.d3Shape,global.d3plusCommon,global.d3plusShape,global.d3plusViz,global.d3Hierarchy,global.d3Scale,global.d3Collection)); | ||
}(this, (function (exports,d3Array,d3Shape,d3plusCommon,d3plusShape,d3plusViz,d3Hierarchy,d3Scale,d3Collection) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(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'], factory) : | ||
(factory((global.d3plus = {}),global.d3Array,global.d3Shape,global.d3plusCommon,global.d3plusShape,global.d3plusViz,global.d3Collection,global.d3Hierarchy,global.d3Scale)); | ||
}(this, (function (exports,d3Array,d3Shape,d3plusCommon,d3plusShape,d3plusViz,d3Collection,d3Hierarchy,d3Scale) { 'use strict'; | ||
@@ -78,6 +78,6 @@ /** | ||
*/ | ||
var Pie = (function (Viz$$1) { | ||
var Pie = (function (Viz) { | ||
function Pie() { | ||
Viz$$1.call(this); | ||
Viz.call(this); | ||
@@ -99,4 +99,4 @@ this._shapeConfig = d3plusCommon.assign(this._shapeConfig, { | ||
if ( Viz$$1 ) Pie.__proto__ = Viz$$1; | ||
Pie.prototype = Object.create( Viz$$1 && Viz$$1.prototype ); | ||
if ( Viz ) Pie.__proto__ = Viz; | ||
Pie.prototype = Object.create( Viz && Viz.prototype ); | ||
Pie.prototype.constructor = Pie; | ||
@@ -112,3 +112,3 @@ | ||
Viz$$1.prototype._draw.call(this, callback); | ||
Viz.prototype._draw.call(this, callback); | ||
@@ -245,3 +245,3 @@ var height = this._height - this._margin.top - this._margin.bottom, | ||
*/ | ||
function nest$1(data, keys) { | ||
function nest(data, keys) { | ||
@@ -283,6 +283,6 @@ if (!(keys instanceof Array)) { keys = [keys]; } | ||
*/ | ||
var Tree = (function (Viz$$1) { | ||
var Tree = (function (Viz) { | ||
function Tree() { | ||
Viz$$1.call(this); | ||
Viz.call(this); | ||
@@ -311,4 +311,4 @@ this._orient = "vertical"; | ||
if ( Viz$$1 ) Tree.__proto__ = Viz$$1; | ||
Tree.prototype = Object.create( Viz$$1 && Viz$$1.prototype ); | ||
if ( Viz ) Tree.__proto__ = Viz; | ||
Tree.prototype = Object.create( Viz && Viz.prototype ); | ||
Tree.prototype.constructor = Tree; | ||
@@ -322,6 +322,5 @@ | ||
var this$1 = this; | ||
var obj; | ||
Viz$$1.prototype._draw.call(this, callback); | ||
Viz.prototype._draw.call(this, callback); | ||
@@ -343,3 +342,3 @@ var height = this._orient === "vertical" | ||
key: "root", | ||
values: nest$1(this._filteredData, this._groupBy.slice(0, this._drawDepth + 1)) | ||
values: nest(this._filteredData, this._groupBy.slice(0, this._drawDepth + 1)) | ||
}, function (d) { return d.key && d.values ? d.values : null; }).sort(this._sort)) | ||
@@ -374,3 +373,3 @@ .descendants() | ||
this._labelWidths = nest$1(treeData, function (d) { return d.depth; }) | ||
this._labelWidths = nest(treeData, function (d) { return d.depth; }) | ||
.map(function (d) { return d.values.reduce(function (num, v, i) { | ||
@@ -435,3 +434,3 @@ var next = i < d.values.length - 1 ? d.values[i + 1].x : width + this$1._margin[left], | ||
textAnchor: function (d) { return this$1._orient === "vertical" ? "middle" | ||
: d.data.children && d.data.depth !== this$1._groupBy.length ? "end" : "start"; }, | ||
: 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"; } | ||
@@ -453,3 +452,5 @@ }, | ||
labelBounds: function (d, i, s) { | ||
var obj; | ||
var h = this$1._labelHeight, | ||
@@ -505,6 +506,6 @@ height = this$1._orient === "vertical" ? "height" : "width", | ||
*/ | ||
var Treemap = (function (Viz$$1) { | ||
var Treemap = (function (Viz) { | ||
function Treemap() { | ||
Viz$$1.call(this); | ||
Viz.call(this); | ||
@@ -524,4 +525,4 @@ this._padding = 1; | ||
if ( Viz$$1 ) Treemap.__proto__ = Viz$$1; | ||
Treemap.prototype = Object.create( Viz$$1 && Viz$$1.prototype ); | ||
if ( Viz ) Treemap.__proto__ = Viz; | ||
Treemap.prototype = Object.create( Viz && Viz.prototype ); | ||
Treemap.prototype.constructor = Treemap; | ||
@@ -537,3 +538,3 @@ | ||
Viz$$1.prototype._draw.call(this, callback); | ||
Viz.prototype._draw.call(this, callback); | ||
@@ -540,0 +541,0 @@ var nestedData = d3Collection.nest(); |
/* | ||
d3plus-hierarchy v0.3.13 | ||
d3plus-hierarchy v0.3.14 | ||
Nested, hierarchical, and cluster charts built on D3 | ||
Copyright (c) 2017 D3plus - https://d3plus.org | ||
Copyright (c) 2018 D3plus - https://d3plus.org | ||
@license MIT | ||
*/ | ||
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-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.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 c=i.arc().innerRadius(this._innerRadius).outerRadius(l);var d="translate("+u/2+", "+h/2+")";this._shapes.push((new n.Path).data(p).d(c).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);function p(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 c(n)}function c(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=c(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;var u;t.prototype._draw.call(this,a);var l=this._orient==="vertical"?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right,c=this._orient==="vertical"?"left":"top",d=this,_="translate("+this._margin.left+", "+this._margin.top+")",f=this._orient==="horizontal"?this._height-this._margin.top-this._margin.bottom:this._width-this._margin.left-this._margin.right;var g=this._tree.separation(this._separation).size([f,l])(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 v(t){return r.merge(t.values.map(function(t){return t.key&&t.values?v(t):t}),d._aggs)}g.forEach(function(t,e){if(t.data.key&&t.data.values){t.data=v(t.data)}t.__d3plus__=true;t.i=e});var y=this._shapeConfig.r;if(typeof y!=="function"){y=r.constant(y)}var m=e.max(g,function(t){return t.depth===1?y(t.data,t.i):0});var b=e.max(g,function(t){return t.children?0:y(t.data,t.i)});var w=e.extent(g,function(t){return t.y});this._labelHeight=e.min([this._orient==="vertical"?50:100,(w[1]-m-b)/(this._groupBy.length+1)]);this._labelWidths=p(g,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:f+h._margin[c],o=n?t.values[n-1].x:h._margin[c];return e.min([i,a-r.x,r.x-o])},f)});var x=s.scaleLinear().domain(w).range([m+this._labelHeight,l-b-this._labelHeight]);g.forEach(function(t){var e=x(t.y);if(h._orient==="horizontal"){t.y=t.x;t.x=e}else{t.y=e}});var C={parent:this._select,enter:{transform:_},update:{transform:_}};this._shapes.push((new n.Path).data(g.filter(function(t){return t.depth>1})).select(r.elem("g.d3plus-Tree-Links",C).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(g).select(r.elem("g.d3plus-Tree-Shapes",C).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",l=h._orient==="vertical"?"y":"x";return u={},u[o]=a,u[n]=r,u[s]=-a/2,u[l]=t.children&&t.depth!==h._groupBy.length?-(i.r+r):i.r,u}}).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 _=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=[],c=this;function d(t){for(var e=0;e<t.length;e++){var i=t[e];if(i.depth<=c._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 _=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)/_*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=_;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,c,b,w){"use strict";var i=function(u){function t(){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 e.value-t.value};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+", "+r/2+")";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.constant(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=5}if(e)t.__proto__=e;t.prototype=Object.create(e&&e.prototype);t.prototype.constructor=t;return t}(i);function x(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:x(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 d=v.extent(a,function(t){return t.y});this._labelHeight=v.min([this._orient==="vertical"?50:100,(d[1]-p-c)/(this._groupBy.length+1)]);this._labelWidths=x(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 _=w.scaleLinear().domain(d).range([p+this._labelHeight,i-c-this._labelHeight]);a.forEach(function(t){var e=_(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._padding=1;this._shapeConfig=y.assign({},this._shapeConfig,{labelConfig:{fontResize:true}});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._padding).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.padding=function t(e){return arguments.length?(this._padding=typeof e==="function"?e:y.constant(e),this):this._padding};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.constant(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})}); |
@@ -53,3 +53,2 @@ import {extent, min, max} from "d3-array"; | ||
var this$1 = this; | ||
var obj; | ||
@@ -164,3 +163,3 @@ | ||
textAnchor: function (d) { return this$1._orient === "vertical" ? "middle" | ||
: d.data.children && d.data.depth !== this$1._groupBy.length ? "end" : "start"; }, | ||
: 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"; } | ||
@@ -182,3 +181,5 @@ }, | ||
labelBounds: function (d, i, s) { | ||
var obj; | ||
var h = this$1._labelHeight, | ||
@@ -185,0 +186,0 @@ height = this$1._orient === "vertical" ? "height" : "width", |
{ | ||
"name": "d3plus-hierarchy", | ||
"version": "0.3.13", | ||
"version": "0.3.14", | ||
"description": "Nested, hierarchical, and cluster charts built on D3", | ||
@@ -29,7 +29,7 @@ "main": "build/d3plus-hierarchy.js", | ||
"d3-hierarchy": "^1.0.0", | ||
"d3-scale": "^1.0.7", | ||
"d3-scale": "^2.0.0", | ||
"d3-shape": "^1.0.3", | ||
"d3plus-common": "^0.6.29", | ||
"d3plus-shape": "^0.13.11", | ||
"d3plus-viz": "^0.10.14" | ||
"d3plus-common": "^0.6.33", | ||
"d3plus-shape": "^0.14.2", | ||
"d3plus-viz": "^0.10.18" | ||
}, | ||
@@ -46,3 +46,3 @@ "scripts": { | ||
"devDependencies": { | ||
"d3plus-dev": "^0.5.4" | ||
"d3plus-dev": "^0.6.5" | ||
}, | ||
@@ -57,2 +57,2 @@ "module": "es/index", | ||
] | ||
} | ||
} |
# 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/gitter/room/nwjs/nw.js.svg?style=flat)](https://gitter.im/d3plus/) | ||
[![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/) | ||
@@ -49,3 +49,4 @@ Nested, hierarchical, and cluster charts built on D3 | ||
* [Custom Tooltip Contents](http://d3plus.org/examples/d3plus-hierarchy/tooltip-contents/)<sup> ***New***</sup> | ||
* [Changing Font Styles](http://d3plus.org/examples/d3plus-hierarchy/custom-font/) | ||
* [Custom Tooltip Contents](http://d3plus.org/examples/d3plus-hierarchy/tooltip-contents/) | ||
* [Custom Mouse Events](http://d3plus.org/examples/d3plus-hierarchy/mouse-events/) | ||
@@ -297,2 +298,2 @@ * [Rendering into a Specific DOM Container](http://d3plus.org/examples/d3plus-hierarchy/selecting-container/) | ||
###### <sub>Documentation generated on Thu, 21 Dec 2017 22:19:37 GMT</sub> | ||
###### <sub>Documentation generated on Thu, 29 Mar 2018 15:25:30 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
141615
298
0
+ Addedd3plus-shape@0.14.11(transitive)
- Removedd3-scale@1.0.7(transitive)
- Removedd3plus-shape@0.13.16(transitive)
Updatedd3-scale@^2.0.0
Updatedd3plus-common@^0.6.33
Updatedd3plus-shape@^0.14.2
Updatedd3plus-viz@^0.10.18