@d3plus/core 3.0.14 → 3.0.16

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.16
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
 
@@ -587,7 +587,7 @@
587
587
  }
588
588
  }
589
589
  }
590
- return 0; // Return -1 if no element is found with the class
590
+ return -1; // Return -1 if no element is found with the class
591
591
  }
592
592
  class Shape extends BaseClass {
593
593
  /**
@@ -784,8 +784,6 @@
784
784
  this._group.selectAll(`g.d3plus-${this._name}-shape, g.d3plus-${this._name}-image, g.d3plus-${this._name}-text, g.d3plus-${this._name}-hover`).selectAll(".d3plus-Shape, .d3plus-Image, .d3plus-textBox").each(function(d, i) {
785
785
  if (!d) d = {};
786
786
  if (!d.parentNode) d.parentNode = this.parentNode;
787
- if (!d.dataIndex) d.dataIndex = i;
788
- const dataIndex = d.dataIndex;
789
787
  const parent = d.parentNode;
790
788
  const d3plusType = d3Selection.select(this).classed("d3plus-textBox") ? "textBox" : d3Selection.select(this).classed("d3plus-Image") ? "Image" : "Shape";
791
789
  if (d3plusType === "textBox") d = d.data;
@@ -798,13 +796,15 @@
798
796
  const notHovering = !that._hover || typeof that._hover !== "function" || !that._hover(d, i);
799
797
  const group = notHovering ? parent : that._hoverGroup.node();
800
798
  if (group !== this.parentNode) {
801
- const offset = d3plusType === "textBox" ? findLastIndexWithClass(group.childNodes, [
799
+ const afterIndex = d3plusType === "textBox" ? findLastIndexWithClass(group.childNodes, [
802
800
  "d3plus-Image",
803
801
  "d3plus-Shape"
804
802
  ]) : d3plusType === "Image" ? findLastIndexWithClass(group.childNodes, [
805
803
  "d3plus-Shape"
806
- ]) : 0;
807
- group.insertBefore(this, group.childNodes[offset + dataIndex]);
804
+ ]) : -1;
805
+ if (notHovering) group.appendChild(this);
806
+ else if (afterIndex === -1) group.prepend(this);
807
+ else group.childNodes[afterIndex].after(this);
808
808
  }
809
809
  if (this.className.baseVal.includes("d3plus-Shape")) {
810
810
  if (parent === group) d3Selection.select(this).call(that._applyStyle.bind(that));
@@ -8179,7 +8179,7 @@
8179
8179
  @chainable
8180
8180
  */ hover(_) {
8181
8181
  let hoverFunction = this._hover = _;
8182
- if (this._shapeConfig.hoverOpacity !== 1) {
8182
+ if (this._shapeConfig.hoverOpacity !== 1 && _ !== undefined) {
8183
8183
  if (typeof _ === "function") {
8184
8184
  let shapeData = d3Array.merge(this._shapes.map((s)=>s.data()));
8185
8185
  shapeData = shapeData.concat(this._legendClass.data());
@@ -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;