@d3plus/core 3.0.15 → 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,5 +1,5 @@
1
1
  /*
2
- @d3plus/core v3.0.15
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
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
@@ -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());