@d3plus/core 3.0.14 → 3.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*
2
- @d3plus/core v3.0.14
2
+ @d3plus/core v3.0.15
3
3
  Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
4
- Copyright (c) 2025 D3plus - https://d3plus.org
4
+ Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
6
6
  */
7
7
  (t=>{"function"==typeof define&&define.amd?define(t):t()})(function(){if("undefined"!=typeof window){try{if("undefined"==typeof SVGElement||Boolean(SVGElement.prototype.innerHTML))return}catch(t){return}function i(t){switch(t.nodeType){case 1:var n=t,e="";return e+="<"+n.tagName,n.hasAttributes()&&[].forEach.call(n.attributes,function(t){e+=" "+t.name+'="'+t.value+'"'}),e+=">",n.hasChildNodes()&&[].forEach.call(n.childNodes,function(t){e+=i(t)}),e+="</"+n.tagName+">";case 3:return t.textContent.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");case 8:return"\x3c!--"+t.nodeValue+"--\x3e"}}Object.defineProperty(SVGElement.prototype,"innerHTML",{get:function(){var n="";return[].forEach.call(this.childNodes,function(t){n+=i(t)}),n},set:function(t){for(;this.firstChild;)this.removeChild(this.firstChild);try{var n=new DOMParser,e=(n.async=!1,"<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>"+t+"</svg>"),i=n.parseFromString(e,"text/xml").documentElement;[].forEach.call(i.childNodes,function(t){this.appendChild(this.ownerDocument.importNode(t,!0))}.bind(this))}catch(t){throw new Error("Error parsing markup string")}}}),Object.defineProperty(SVGElement.prototype,"innerSVG",{get:function(){return this.innerHTML},set:function(t){this.innerHTML=t}})}}),((t,n)=>{"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define("@d3plus/core",["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3plus={})})(this,function(t){
@@ -7148,13 +7148,19 @@ r=r<0?r%I9+I9:r)?this._+="A"+e+","+e+",0,1,"+u+","+(t-o)+","+(n-s)+"A"+e+","+e+"
7148
7148
  /**
7149
7149
  Extends the draw behavior of the abstract Viz class.
7150
7150
  @private
7151
- */_draw(t){super._draw(t);var t=this._height-this._margin.top-this._margin.bottom,n=this._width-this._margin.left-this._margin.right,e=(Array.isArray(this._nodes)?this._nodes:this._links.reduce((t,n)=>(t.includes(n[this._linksSource])||t.push(n[this._linksSource]),t.includes(n[this._linksTarget])||t.push(n[this._linksTarget]),t),[]).map(t=>({id:t}))).map((t,n)=>({__d3plus__:!0,data:t,i:n,id:this._nodeId(t,n),node:t,shape:"Rect"}));let i=this._nodeLookup=e.reduce((t,n,e)=>(t[n.id]=e,t),{});var a=this._links.map((e,t)=>{var n=[this._linksSource,this._linksTarget].reduce((t,n)=>(t[n]=i[e[n]],t),{});return{source:n[this._linksSource],target:n[this._linksTarget],value:this._value(e,t)}});this._linkLookup=a.reduce((t,n)=>(t[n.source]||(t[n.source]=[]),t[n.source].push(n.target),t[n.target]||(t[n.target]=[]),t[n.target].push(n.source),t),{});let r=`translate(${this._margin.left}, ${this._margin.top})`;return this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(e).links(a).size([n,t])(),this._shapes.push((new Sc).config(this._shapeConfig.Path).data(a).d(this._path).select(Pt("g.d3plus-Links",{parent:this._select,enter:{transform:r},update:{transform:r}}).node()).render()),ca().key(t=>t.shape).entries(e).forEach(t=>{this._shapes.push((new kc[t.key]).data(t.values).height(t=>t.y1-t.y0).width(t=>t.x1-t.x0).x(t=>(t.x1+t.x0)/2).y(t=>(t.y1+t.y0)/2).select(Pt("g.d3plus-sankey-nodes",{parent:this._select,enter:{transform:r},update:{transform:r}}).node()).config(Bt.bind(this)(this._shapeConfig,"shape",t.key)).render())}),this}
7151
+ */_draw(t){super._draw(t);var t=this._height-this._margin.top-this._margin.bottom,n=this._width-this._margin.left-this._margin.right,e=(Array.isArray(this._nodes)?this._nodes:this._links.reduce((t,n)=>(t.includes(n[this._linksSource])||t.push(n[this._linksSource]),t.includes(n[this._linksTarget])||t.push(n[this._linksTarget]),t),[]).map(t=>({id:t}))).map((t,n)=>({__d3plus__:!0,data:t,i:n,id:this._nodeId(t,n),node:t,shape:"Rect"}));let i=this._nodeLookup=e.reduce((t,n,e)=>(t[n.id]=e,t),{});var a=this._links.map((e,t)=>{var n=[this._linksSource,this._linksTarget].reduce((t,n)=>(t[n]=i[e[n]],t),{});return{source:n[this._linksSource],target:n[this._linksTarget],value:this._value(e,t)}});this._linkLookup=a.reduce((t,n)=>(t[n.source]||(t[n.source]=[]),t[n.source].push(n.target),t[n.target]||(t[n.target]=[]),t[n.target].push(n.source),t),{});let r=`translate(${this._margin.left}, ${this._margin.top})`;return this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(e).nodeSort(this._nodeSort).links(a).linkSort(this._linkSort).iterations(this._iterations).size([n,t])(),this._shapes.push((new Sc).config(this._shapeConfig.Path).data(a).d(this._path).select(Pt("g.d3plus-Links",{parent:this._select,enter:{transform:r},update:{transform:r}}).node()).render()),ca().key(t=>t.shape).entries(e).forEach(t=>{this._shapes.push((new kc[t.key]).data(t.values).height(t=>t.y1-t.y0).width(t=>t.x1-t.x0).x(t=>(t.x1+t.x0)/2).y(t=>(t.y1+t.y0)/2).select(Pt("g.d3plus-sankey-nodes",{parent:this._select,enter:{transform:r},update:{transform:r}}).node()).config(Bt.bind(this)(this._shapeConfig,"shape",t.key)).render())}),this}
7152
7152
  /**
7153
7153
  @memberof Sankey
7154
7154
  @desc If *value* is specified, sets the hover method to the specified function and returns the current class instance.
7155
7155
  @param {Function} [*value*]
7156
7156
  @chainable
7157
7157
  */hover(n){return this._hover=n,this._shapes.forEach(t=>t.hover(n)),this._legend&&this._legendClass.hover(n),this}
7158
+ /**
7159
+ @memberof Sankey
7160
+ @desc A pass-through for the d3-sankey [iterations](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_iterations) function.
7161
+ @param {Number} [*value* = 6]
7162
+ @chainable
7163
+ */iterations(t){return arguments.length?(this._iterations=t,this):this._iterations}
7158
7164
  /**
7159
7165
  @memberof Sankey
7160
7166
  @desc A predefined *Array* of edges that connect each object passed to the [node](#Sankey.node) method. The `source` and `target` keys in each link need to map to the nodes in one of one way:
@@ -7164,6 +7170,12 @@ r=r<0?r%I9+I9:r)?this._+="A"+e+","+e+",0,1,"+u+","+(t-o)+","+(n-s)+"A"+e+","+e+"
7164
7170
  @param {Array} *links* = []
7165
7171
  @chainable
7166
7172
  */links(t,n){return arguments.length?(lu.bind(this)(t,n,"links"),this):this._links}
7173
+ /**
7174
+ @memberof Sankey
7175
+ @desc A pass-through for the d3-sankey [linkSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_linkSort) function.
7176
+ @param {Function|undefined} [*value* = undefined]
7177
+ @chainable
7178
+ */linkSort(t){return arguments.length?(this._linkSort=t,this):this._linkSort}
7167
7179
  /**
7168
7180
  @memberof Sankey
7169
7181
  @desc The key inside of each link Object that references the source node.
@@ -7202,6 +7214,12 @@ r=r<0?r%I9+I9:r)?this._+="A"+e+","+e+",0,1,"+u+","+(t-o)+","+(n-s)+"A"+e+","+e+"
7202
7214
  @param {Number} [*value* = 8]
7203
7215
  @chainable
7204
7216
  */nodePadding(t){return arguments.length?(this._nodePadding=t,this):this._nodePadding}
7217
+ /**
7218
+ @memberof Sankey
7219
+ @desc A pass-through for the d3-sankey [nodeSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_nodeSort) function.
7220
+ @param {Function|undefined} [*value* = undefined]
7221
+ @chainable
7222
+ */nodeSort(t){return arguments.length?(this._nodeSort=t,this):this._nodeSort}
7205
7223
  /**
7206
7224
  @memberof Sankey
7207
7225
  @desc If *value* is specified, sets the width of the node and returns the current class instance. If *value* is not specified, returns the current nodeWidth. By default, the nodeWidth size is 30.
@@ -7221,7 +7239,7 @@ r=r<0?r%I9+I9:r)?this._+="A"+e+","+e+",0,1,"+u+","+(t-o)+","+(n-s)+"A"+e+","+e+"
7221
7239
  @memberof Sankey
7222
7240
  @desc Invoked when creating a new class instance, and sets any default parameters.
7223
7241
  @private
7224
- */constructor(){super(),this._nodeId=p("id"),this._links=p("links"),this._linksSource="source",this._linksTarget="target",this._noDataMessage=!1,this._nodes=p("nodes"),this._nodeAlign=tx.justify,this._nodePadding=8,this._nodeWidth=30,this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let n=this._on["mousemove.shape"];this._on["mousemove.shape"]=(a,r,o,t)=>{if(n(a,r,o,t),this._focus&&this._focus===a.id)this.hover(!1),this._on.mouseenter.bind(this)(a,r,o,t),this._focus=void 0;else{let e=this._nodeId(a,r),t=this._nodeLookup[e],n=Object.keys(this._nodeLookup).reduce((t,n)=>(t[this._nodeLookup[n]]=isNaN(n)?n:parseInt(n,10),t),{});o=this._linkLookup[t];let i=[e];o.forEach(t=>{i.push(n[t])}),this.hover((t,n)=>t.source&&t.target?t.source.id===e||t.target.id===e:i.includes(this._nodeId(t,n)))}},this._path=X9().source(J9).target(Q9),this._sankey=j9(),this._shape=Lt("Rect"),this._shapeConfig=Et(this._shapeConfig,{Path:{fill:"none",hoverStyle:{"stroke-width":t=>Math.max(1,Math.abs(t.source.y1-t.source.y0)*(t.value/t.source.value)-2)},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:t=>Math.max(1,Math.abs(t.source.y1-t.source.y0)*(t.value/t.source.value)-2)},Rect:{}}),this._value=Lt(1)}}class ex extends If{
7242
+ */constructor(){super(),this._iterations=6,this._nodeId=p("id"),this._nodeSort=void 0,this._links=p("links"),this._linkSort=void 0,this._linksSource="source",this._linksTarget="target",this._noDataMessage=!1,this._nodes=p("nodes"),this._nodeAlign=tx.justify,this._nodePadding=8,this._nodeWidth=30,this._on.mouseenter=()=>{},this._on["mouseleave.shape"]=()=>{this.hover(!1)};let n=this._on["mousemove.shape"];this._on["mousemove.shape"]=(a,r,o,t)=>{if(n(a,r,o,t),this._focus&&this._focus===a.id)this.hover(!1),this._on.mouseenter.bind(this)(a,r,o,t),this._focus=void 0;else{let e=this._nodeId(a,r),t=this._nodeLookup[e],n=Object.keys(this._nodeLookup).reduce((t,n)=>(t[this._nodeLookup[n]]=isNaN(n)?n:parseInt(n,10),t),{});o=this._linkLookup[t];let i=[e];o.forEach(t=>{i.push(n[t])}),this.hover((t,n)=>t.source&&t.target?t.source.id===e||t.target.id===e:i.includes(this._nodeId(t,n)))}},this._path=X9().source(J9).target(Q9),this._sankey=j9(),this._shape=Lt("Rect"),this._shapeConfig=Et(this._shapeConfig,{Path:{fill:"none",hoverStyle:{"stroke-width":t=>Math.max(1,Math.abs(t.source.y1-t.source.y0)*(t.value/t.source.value)-2)},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:t=>Math.max(1,Math.abs(t.source.y1-t.source.y0)*(t.value/t.source.value)-2)},Rect:{}}),this._value=Lt(1)}}class ex extends If{
7225
7243
  /**
7226
7244
  @memberof StackedArea
7227
7245
  @desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
@@ -1,7 +1,7 @@
1
1
  /*
2
- @d3plus/core v3.0.14
2
+ @d3plus/core v3.0.15
3
3
  Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
4
- Copyright (c) 2025 D3plus - https://d3plus.org
4
+ Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
6
6
  */
7
7
 
@@ -13772,7 +13772,7 @@
13772
13772
  return obj;
13773
13773
  }, {});
13774
13774
  const transform = `translate(${this._margin.left}, ${this._margin.top})`;
13775
- this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(nodes).links(links).size([
13775
+ this._sankey.nodeAlign(this._nodeAlign).nodePadding(this._nodePadding).nodeWidth(this._nodeWidth).nodes(nodes).nodeSort(this._nodeSort).links(links).linkSort(this._linkSort).iterations(this._iterations).size([
13776
13776
  width,
13777
13777
  height
13778
13778
  ])();
@@ -13809,6 +13809,14 @@
13809
13809
  if (this._legend) this._legendClass.hover(_);
13810
13810
  return this;
13811
13811
  }
13812
+ /**
13813
+ @memberof Sankey
13814
+ @desc A pass-through for the d3-sankey [iterations](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_iterations) function.
13815
+ @param {Number} [*value* = 6]
13816
+ @chainable
13817
+ */ iterations(_) {
13818
+ return arguments.length ? (this._iterations = _, this) : this._iterations;
13819
+ }
13812
13820
  /**
13813
13821
  @memberof Sankey
13814
13822
  @desc A predefined *Array* of edges that connect each object passed to the [node](#Sankey.node) method. The `source` and `target` keys in each link need to map to the nodes in one of one way:
@@ -13824,6 +13832,14 @@
13824
13832
  }
13825
13833
  return this._links;
13826
13834
  }
13835
+ /**
13836
+ @memberof Sankey
13837
+ @desc A pass-through for the d3-sankey [linkSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_linkSort) function.
13838
+ @param {Function|undefined} [*value* = undefined]
13839
+ @chainable
13840
+ */ linkSort(_) {
13841
+ return arguments.length ? (this._linkSort = _, this) : this._linkSort;
13842
+ }
13827
13843
  /**
13828
13844
  @memberof Sankey
13829
13845
  @desc The key inside of each link Object that references the source node.
@@ -13878,6 +13894,14 @@
13878
13894
  */ nodePadding(_) {
13879
13895
  return arguments.length ? (this._nodePadding = _, this) : this._nodePadding;
13880
13896
  }
13897
+ /**
13898
+ @memberof Sankey
13899
+ @desc A pass-through for the d3-sankey [nodeSort](https://github.com/d3/d3-sankey?tab=readme-ov-file#sankey_nodeSort) function.
13900
+ @param {Function|undefined} [*value* = undefined]
13901
+ @chainable
13902
+ */ nodeSort(_) {
13903
+ return arguments.length ? (this._nodeSort = _, this) : this._nodeSort;
13904
+ }
13881
13905
  /**
13882
13906
  @memberof Sankey
13883
13907
  @desc If *value* is specified, sets the width of the node and returns the current class instance. If *value* is not specified, returns the current nodeWidth. By default, the nodeWidth size is 30.
@@ -13903,8 +13927,11 @@
13903
13927
  @private
13904
13928
  */ constructor(){
13905
13929
  super();
13930
+ this._iterations = 6;
13906
13931
  this._nodeId = accessor("id");
13932
+ this._nodeSort = undefined;
13907
13933
  this._links = accessor("links");
13934
+ this._linkSort = undefined;
13908
13935
  this._linksSource = "source";
13909
13936
  this._linksTarget = "target";
13910
13937
  this._noDataMessage = false;