@d3plus/core 3.0.9 → 3.0.11
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.
- package/README.md +48 -57
- package/es/src/charts/Viz.js +46 -40
- package/package.json +8 -8
- package/umd/d3plus-core.full.js +43 -40
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +174 -177
- package/umd/d3plus-core.js +39 -38
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +10 -13
package/umd/d3plus-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v3.0.
|
|
2
|
+
@d3plus/core v3.0.11
|
|
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) 2025 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
@@ -7452,6 +7452,14 @@
|
|
|
7452
7452
|
this._tooltipClass.data([]).render();
|
|
7453
7453
|
}
|
|
7454
7454
|
|
|
7455
|
+
function debounce(func, delay) {
|
|
7456
|
+
let timeout;
|
|
7457
|
+
return function(...args) {
|
|
7458
|
+
const context = this;
|
|
7459
|
+
clearTimeout(timeout);
|
|
7460
|
+
timeout = setTimeout(()=>func.apply(context, args), delay);
|
|
7461
|
+
};
|
|
7462
|
+
}
|
|
7455
7463
|
/**
|
|
7456
7464
|
* Default padding logic that will return false if the screen is less than 600 pixels wide.
|
|
7457
7465
|
* @private
|
|
@@ -7662,12 +7670,34 @@
|
|
|
7662
7670
|
*/ _thresholdFunction(data) {
|
|
7663
7671
|
return data;
|
|
7664
7672
|
}
|
|
7673
|
+
/**
|
|
7674
|
+
* Detects width and height and sets SVG properties
|
|
7675
|
+
* @private
|
|
7676
|
+
*/ _setSVGSize() {
|
|
7677
|
+
const display = this._select.style("display");
|
|
7678
|
+
this._select.style("display", "none");
|
|
7679
|
+
let [w, h] = dom.getSize(this._select.node().parentNode);
|
|
7680
|
+
w -= parseFloat(this._select.style("border-left-width"), 10);
|
|
7681
|
+
w -= parseFloat(this._select.style("border-right-width"), 10);
|
|
7682
|
+
h -= parseFloat(this._select.style("border-top-width"), 10);
|
|
7683
|
+
h -= parseFloat(this._select.style("border-bottom-width"), 10);
|
|
7684
|
+
this._select.style("display", display);
|
|
7685
|
+
if (this._autoWidth) {
|
|
7686
|
+
this.width(w);
|
|
7687
|
+
this._select.style("width", `${this._width}px`).attr("width", `${this._width}px`);
|
|
7688
|
+
}
|
|
7689
|
+
if (this._autoHeight) {
|
|
7690
|
+
this.height(h);
|
|
7691
|
+
this._select.style("height", `${this._height}px`).attr("height", `${this._height}px`);
|
|
7692
|
+
}
|
|
7693
|
+
}
|
|
7665
7694
|
/**
|
|
7666
7695
|
@memberof Viz
|
|
7667
7696
|
@desc Draws the visualization given the specified configuration.
|
|
7668
7697
|
@param {Function} [*callback*] An optional callback function that, if passed, will be called after animation is complete.
|
|
7669
7698
|
@chainable
|
|
7670
7699
|
*/ render(callback) {
|
|
7700
|
+
this._callback = callback;
|
|
7671
7701
|
// Resets margins and padding
|
|
7672
7702
|
this._margin = {
|
|
7673
7703
|
bottom: 0,
|
|
@@ -7687,29 +7717,11 @@
|
|
|
7687
7717
|
const svg = parent.select(".d3plus-viz").size() ? parent.select(".d3plus-viz") : parent.append("svg");
|
|
7688
7718
|
this.select(svg.node());
|
|
7689
7719
|
}
|
|
7690
|
-
/** detects width and height and sets SVG properties */ function setSVGSize() {
|
|
7691
|
-
const display = this._select.style("display");
|
|
7692
|
-
this._select.style("display", "none");
|
|
7693
|
-
let [w, h] = dom.getSize(this._select.node().parentNode);
|
|
7694
|
-
w -= parseFloat(this._select.style("border-left-width"), 10);
|
|
7695
|
-
w -= parseFloat(this._select.style("border-right-width"), 10);
|
|
7696
|
-
h -= parseFloat(this._select.style("border-top-width"), 10);
|
|
7697
|
-
h -= parseFloat(this._select.style("border-bottom-width"), 10);
|
|
7698
|
-
this._select.style("display", display);
|
|
7699
|
-
if (this._autoWidth) {
|
|
7700
|
-
this.width(w);
|
|
7701
|
-
this._select.style("width", `${this._width}px`).attr("width", `${this._width}px`);
|
|
7702
|
-
}
|
|
7703
|
-
if (this._autoHeight) {
|
|
7704
|
-
this.height(h);
|
|
7705
|
-
this._select.style("height", `${this._height}px`).attr("height", `${this._height}px`);
|
|
7706
|
-
}
|
|
7707
|
-
}
|
|
7708
7720
|
// Calculates the width and/or height of the Viz based on the this._select, if either has not been defined.
|
|
7709
7721
|
if ((!this._width || !this._height) && (!this._detectVisible || dom.inViewport(this._select.node()))) {
|
|
7710
7722
|
this._autoWidth = this._width === undefined;
|
|
7711
7723
|
this._autoHeight = this._height === undefined;
|
|
7712
|
-
|
|
7724
|
+
this._setSVGSize();
|
|
7713
7725
|
}
|
|
7714
7726
|
this._select.attr("class", "d3plus-viz").attr("aria-hidden", this._ariaHidden).attr("aria-labelledby", `${this._uuid}-title ${this._uuid}-desc`).attr("role", "img").attr("xmlns", "http://www.w3.org/2000/svg").attr("xmlns:xlink", "http://www.w3.org/1999/xlink").transition().duration(this._duration).style("width", this._width !== undefined ? `${this._width}px` : undefined).style("height", this._height !== undefined ? `${this._height}px` : undefined).attr("width", this._width !== undefined ? `${this._width}px` : undefined).attr("height", this._height !== undefined ? `${this._height}px` : undefined);
|
|
7715
7727
|
// sets "position: relative" on the SVG parent if currently undefined
|
|
@@ -7735,7 +7747,6 @@
|
|
|
7735
7747
|
this._resizePoll = clearTimeout(this._resizePoll);
|
|
7736
7748
|
this._scrollPoll = clearTimeout(this._scrollPoll);
|
|
7737
7749
|
d3Selection.select(this._scrollContainer).on(`scroll.${this._uuid}`, null);
|
|
7738
|
-
d3Selection.select(this._resizeContainer).on(`resize.${this._uuid}`, null);
|
|
7739
7750
|
if (this._detectVisible && this._select.style("visibility") === "hidden") {
|
|
7740
7751
|
this._visiblePoll = setInterval(()=>{
|
|
7741
7752
|
if (this._select.style("visibility") !== "hidden") {
|
|
@@ -7805,14 +7816,9 @@
|
|
|
7805
7816
|
if (this._select.attr("opacity") === "0") this._select.transition().duration(this._duration).attr("opacity", 1);
|
|
7806
7817
|
}
|
|
7807
7818
|
if (this._detectResize && (this._autoWidth || this._autoHeight)) {
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
this._resizePoll = clearTimeout(this._resizePoll);
|
|
7812
|
-
setSVGSize.bind(this)();
|
|
7813
|
-
this.render(callback);
|
|
7814
|
-
}, this._detectResizeDelay);
|
|
7815
|
-
});
|
|
7819
|
+
this._resizeObserver.observe(this._select.node().parentNode);
|
|
7820
|
+
} else {
|
|
7821
|
+
this._resizeObserver.unobserve(this._select.node().parentNode);
|
|
7816
7822
|
}
|
|
7817
7823
|
if (callback) setTimeout(callback, this._duration + 100);
|
|
7818
7824
|
});
|
|
@@ -8294,14 +8300,6 @@
|
|
|
8294
8300
|
*/ noDataMessage(_) {
|
|
8295
8301
|
return arguments.length ? (this._noDataMessage = _, this) : this._noDataMessage;
|
|
8296
8302
|
}
|
|
8297
|
-
/**
|
|
8298
|
-
@memberof Viz
|
|
8299
|
-
@desc If using resize detection, this method allow a custom override of the element to which the resize detection function gets attached.
|
|
8300
|
-
@param {String|HTMLElement} *selector*
|
|
8301
|
-
@chainable
|
|
8302
|
-
*/ resizeContainer(_) {
|
|
8303
|
-
return arguments.length ? (this._resizeContainer = _, this) : this._resizeContainer;
|
|
8304
|
-
}
|
|
8305
8303
|
/**
|
|
8306
8304
|
@memberof Viz
|
|
8307
8305
|
@desc If using scroll or visibility detection, this method allow a custom override of the element to which the scroll detection function gets attached.
|
|
@@ -8790,7 +8788,10 @@
|
|
|
8790
8788
|
"mousemove.legend": mousemoveLegend.bind(this)
|
|
8791
8789
|
};
|
|
8792
8790
|
this._queue = [];
|
|
8793
|
-
this.
|
|
8791
|
+
this._resizeObserver = new ResizeObserver(debounce(()=>{
|
|
8792
|
+
this._setSVGSize();
|
|
8793
|
+
this.render(this._callback);
|
|
8794
|
+
}, this._detectResizeDelay));
|
|
8794
8795
|
this._scrollContainer = typeof window === "undefined" ? "" : window;
|
|
8795
8796
|
this._shape = constant("Rect");
|
|
8796
8797
|
this._shapes = [];
|