@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3plus/core",
3
- "version": "3.0.9",
3
+ "version": "3.0.11",
4
4
  "description": "Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -34,13 +34,13 @@
34
34
  "test": "eslint index.js src/**/*.js && eslint --global=it test && mocha 'test/**/*-test.js'"
35
35
  },
36
36
  "dependencies": {
37
- "@d3plus/color": "3.0.9",
38
- "@d3plus/data": "3.0.9",
39
- "@d3plus/dom": "3.0.9",
40
- "@d3plus/format": "3.0.9",
41
- "@d3plus/locales": "3.0.9",
42
- "@d3plus/math": "3.0.9",
43
- "@d3plus/text": "3.0.9",
37
+ "@d3plus/color": "3.0.11",
38
+ "@d3plus/data": "3.0.11",
39
+ "@d3plus/dom": "3.0.11",
40
+ "@d3plus/format": "3.0.11",
41
+ "@d3plus/locales": "3.0.11",
42
+ "@d3plus/math": "3.0.11",
43
+ "@d3plus/text": "3.0.11",
44
44
  "@popperjs/core": "^2.11.8",
45
45
  "d3-array": "^3.2.4",
46
46
  "d3-brush": "^3.0.0",
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/core v3.0.9
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
@@ -254,6 +254,8 @@
254
254
  date4.setFullYear(d);
255
255
  return date4;
256
256
  }
257
+ var iso8601 = new RegExp(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?$/g).exec(s);
258
+ if (iso8601) return new Date(s);
257
259
  // falls back to Date object, replacing hyphens with slashes
258
260
  return new Date(s.replace(/-/g, "/"));
259
261
  }
@@ -31921,7 +31923,7 @@
31921
31923
  }, []);
31922
31924
  }
31923
31925
 
31924
- function debounce(fn) {
31926
+ function debounce$1(fn) {
31925
31927
  var pending;
31926
31928
  return function() {
31927
31929
  if (!pending) {
@@ -32053,7 +32055,7 @@
32053
32055
  },
32054
32056
  // Async and optimistically optimized update – it will not be executed if
32055
32057
  // not necessary (debounced to run at most once-per-tick)
32056
- update: debounce(function() {
32058
+ update: debounce$1(function() {
32057
32059
  return new Promise(function(resolve) {
32058
32060
  instance.forceUpdate();
32059
32061
  resolve(state);
@@ -34144,6 +34146,14 @@
34144
34146
  this._tooltipClass.data([]).render();
34145
34147
  }
34146
34148
 
34149
+ function debounce(func, delay) {
34150
+ let timeout;
34151
+ return function(...args) {
34152
+ const context = this;
34153
+ clearTimeout(timeout);
34154
+ timeout = setTimeout(()=>func.apply(context, args), delay);
34155
+ };
34156
+ }
34147
34157
  /**
34148
34158
  * Default padding logic that will return false if the screen is less than 600 pixels wide.
34149
34159
  * @private
@@ -34354,12 +34364,34 @@
34354
34364
  */ _thresholdFunction(data) {
34355
34365
  return data;
34356
34366
  }
34367
+ /**
34368
+ * Detects width and height and sets SVG properties
34369
+ * @private
34370
+ */ _setSVGSize() {
34371
+ const display = this._select.style("display");
34372
+ this._select.style("display", "none");
34373
+ let [w, h] = getSize(this._select.node().parentNode);
34374
+ w -= parseFloat(this._select.style("border-left-width"), 10);
34375
+ w -= parseFloat(this._select.style("border-right-width"), 10);
34376
+ h -= parseFloat(this._select.style("border-top-width"), 10);
34377
+ h -= parseFloat(this._select.style("border-bottom-width"), 10);
34378
+ this._select.style("display", display);
34379
+ if (this._autoWidth) {
34380
+ this.width(w);
34381
+ this._select.style("width", `${this._width}px`).attr("width", `${this._width}px`);
34382
+ }
34383
+ if (this._autoHeight) {
34384
+ this.height(h);
34385
+ this._select.style("height", `${this._height}px`).attr("height", `${this._height}px`);
34386
+ }
34387
+ }
34357
34388
  /**
34358
34389
  @memberof Viz
34359
34390
  @desc Draws the visualization given the specified configuration.
34360
34391
  @param {Function} [*callback*] An optional callback function that, if passed, will be called after animation is complete.
34361
34392
  @chainable
34362
34393
  */ render(callback) {
34394
+ this._callback = callback;
34363
34395
  // Resets margins and padding
34364
34396
  this._margin = {
34365
34397
  bottom: 0,
@@ -34379,29 +34411,11 @@
34379
34411
  const svg = parent.select(".d3plus-viz").size() ? parent.select(".d3plus-viz") : parent.append("svg");
34380
34412
  this.select(svg.node());
34381
34413
  }
34382
- /** detects width and height and sets SVG properties */ function setSVGSize() {
34383
- const display = this._select.style("display");
34384
- this._select.style("display", "none");
34385
- let [w, h] = getSize(this._select.node().parentNode);
34386
- w -= parseFloat(this._select.style("border-left-width"), 10);
34387
- w -= parseFloat(this._select.style("border-right-width"), 10);
34388
- h -= parseFloat(this._select.style("border-top-width"), 10);
34389
- h -= parseFloat(this._select.style("border-bottom-width"), 10);
34390
- this._select.style("display", display);
34391
- if (this._autoWidth) {
34392
- this.width(w);
34393
- this._select.style("width", `${this._width}px`).attr("width", `${this._width}px`);
34394
- }
34395
- if (this._autoHeight) {
34396
- this.height(h);
34397
- this._select.style("height", `${this._height}px`).attr("height", `${this._height}px`);
34398
- }
34399
- }
34400
34414
  // Calculates the width and/or height of the Viz based on the this._select, if either has not been defined.
34401
34415
  if ((!this._width || !this._height) && (!this._detectVisible || inViewport(this._select.node()))) {
34402
34416
  this._autoWidth = this._width === undefined;
34403
34417
  this._autoHeight = this._height === undefined;
34404
- setSVGSize.bind(this)();
34418
+ this._setSVGSize();
34405
34419
  }
34406
34420
  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);
34407
34421
  // sets "position: relative" on the SVG parent if currently undefined
@@ -34427,7 +34441,6 @@
34427
34441
  this._resizePoll = clearTimeout(this._resizePoll);
34428
34442
  this._scrollPoll = clearTimeout(this._scrollPoll);
34429
34443
  select(this._scrollContainer).on(`scroll.${this._uuid}`, null);
34430
- select(this._resizeContainer).on(`resize.${this._uuid}`, null);
34431
34444
  if (this._detectVisible && this._select.style("visibility") === "hidden") {
34432
34445
  this._visiblePoll = setInterval(()=>{
34433
34446
  if (this._select.style("visibility") !== "hidden") {
@@ -34497,14 +34510,9 @@
34497
34510
  if (this._select.attr("opacity") === "0") this._select.transition().duration(this._duration).attr("opacity", 1);
34498
34511
  }
34499
34512
  if (this._detectResize && (this._autoWidth || this._autoHeight)) {
34500
- select(this._resizeContainer).on(`resize.${this._uuid}`, ()=>{
34501
- this._resizePoll = clearTimeout(this._resizePoll);
34502
- this._resizePoll = setTimeout(()=>{
34503
- this._resizePoll = clearTimeout(this._resizePoll);
34504
- setSVGSize.bind(this)();
34505
- this.render(callback);
34506
- }, this._detectResizeDelay);
34507
- });
34513
+ this._resizeObserver.observe(this._select.node().parentNode);
34514
+ } else {
34515
+ this._resizeObserver.unobserve(this._select.node().parentNode);
34508
34516
  }
34509
34517
  if (callback) setTimeout(callback, this._duration + 100);
34510
34518
  });
@@ -34986,14 +34994,6 @@
34986
34994
  */ noDataMessage(_) {
34987
34995
  return arguments.length ? (this._noDataMessage = _, this) : this._noDataMessage;
34988
34996
  }
34989
- /**
34990
- @memberof Viz
34991
- @desc If using resize detection, this method allow a custom override of the element to which the resize detection function gets attached.
34992
- @param {String|HTMLElement} *selector*
34993
- @chainable
34994
- */ resizeContainer(_) {
34995
- return arguments.length ? (this._resizeContainer = _, this) : this._resizeContainer;
34996
- }
34997
34997
  /**
34998
34998
  @memberof Viz
34999
34999
  @desc If using scroll or visibility detection, this method allow a custom override of the element to which the scroll detection function gets attached.
@@ -35482,7 +35482,10 @@
35482
35482
  "mousemove.legend": mousemoveLegend.bind(this)
35483
35483
  };
35484
35484
  this._queue = [];
35485
- this._resizeContainer = typeof window === "undefined" ? "" : window;
35485
+ this._resizeObserver = new ResizeObserver(debounce(()=>{
35486
+ this._setSVGSize();
35487
+ this.render(this._callback);
35488
+ }, this._detectResizeDelay));
35486
35489
  this._scrollContainer = typeof window === "undefined" ? "" : window;
35487
35490
  this._shape = constant$9("Rect");
35488
35491
  this._shapes = [];