@d3plus/core 3.1.4 → 3.1.6

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 +1 @@
1
- {"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n gridConfig?: Record<string, string | number>;\n label?: string;\n labels?: unknown[];\n labelOffset?: false | number;\n maxSize?: number;\n scale?: AxisScale;\n tickFormat?: (d: number | string) => string | number;\n ticks?: unknown[];\n tickSize?: number;\n title?: string;\n}\n\nexport interface TooltipConfig {\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Position of the color scale, or false to hide it. */\n colorScalePosition?: false | Position;\n /** Column key for matrix-style layouts. */\n column?: string;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Label accessor for shapes. */\n label?: string | ((...args: unknown[]) => string);\n /** Whether to show the legend. */\n legend?: boolean;\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Position of the legend. */\n legendPosition?: Position;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator. */\n loadingHTML?: string;\n /** Metric key for the visualization. */\n metric?: string;\n /** Ocean color for geomaps (any CSS value including 'transparent'). */\n ocean?: string;\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /** Custom order for stacked series. */\n stackOrder?: string[];\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group. */\n thresholdName?: string;\n /** URL to XYZ map tiles. */\n tileUrl?: string;\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether to show tooltips. */\n tooltip?: boolean;\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((...args: unknown[]) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((...args: unknown[]) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Set to false to disable zooming on geomaps. */\n zoom?: false;\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAwEA,WA8IC"}
1
+ {"version":3,"sources":["../../../src/utils/D3plusConfig.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\n\ntype Position = \"top\" | \"right\" | \"bottom\" | \"left\";\n\ntype DataPointAccessor<T> = string | ((d: DataPoint) => T);\n\ntype AxisScale =\n | \"auto\"\n | \"band\"\n | \"diverging\"\n | \"divergingLog\"\n | \"divergingPow\"\n | \"divergingSqrt\"\n | \"divergingSymlog\"\n | \"identity\"\n | \"implicit\"\n | \"jenks\"\n | \"linear\"\n | \"log\"\n | \"ordinal\"\n | \"point\"\n | \"pow\"\n | \"quantile\"\n | \"quantize\"\n | \"radial\"\n | \"sequential\"\n | \"sequentialLog\"\n | \"sequentialPow\"\n | \"sequentialQuantile\"\n | \"sequentialSqrt\"\n | \"sequentialSymlog\"\n | \"sqrt\"\n | \"symlog\"\n | \"threshold\"\n | \"time\"\n | \"utc\";\n\nexport interface AxisConfig {\n barConfig?: Record<string, string | number>;\n gridConfig?: Record<string, string | number>;\n label?: string;\n labels?: unknown[];\n labelOffset?: false | number;\n maxSize?: number;\n scale?: AxisScale;\n tickFormat?: (d: number | string) => string | number;\n ticks?: unknown[];\n tickSize?: number;\n title?: string;\n}\n\nexport interface TooltipConfig {\n title?: ((d: DataPoint) => string) | string;\n body?: ((d: DataPoint) => string) | string;\n thead?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n tbody?:\n | ((d: DataPoint) => [string, string][])\n | Array<\n Array<\n | ((d: DataPoint, i?: number, x?: {share: number}) => string)\n | string\n >\n >;\n}\n\nexport interface D3plusConfig {\n /** Data array or URL string to load data from. */\n data?: DataPoint[] | string;\n /** Locale code used for text and number formatting. */\n locale?: string;\n\n /** Custom aggregation functions keyed by data property. */\n aggs?: {[k: string]: (d: DataPoint[]) => unknown};\n /** Padding between bars in pixels. */\n barPadding?: number;\n /** Color scale key or custom color function. */\n colorScale?: string | ((d: number) => string);\n /** Configuration for the color scale component. */\n colorScaleConfig?: {\n axisConfig?: AxisConfig;\n centered?: boolean;\n colors?: string[];\n colorMin?: string;\n colorMid?: string;\n colorMax?: string;\n scale?: AxisScale;\n };\n /** Position of the color scale, or false to hide it. */\n colorScalePosition?: false | Position;\n /** Column key for matrix-style layouts. */\n column?: string;\n /** Active depth level for nested groupings. */\n depth?: number;\n /** Sets orientation of main category axis. */\n discrete?: \"x\" | \"y\";\n /** Default duration of transitions, in milliseconds. */\n duration?: number;\n /** Allows removing specific geographies from topojson file to improve zoom. */\n fitFilter?:\n | number\n | string\n | ((d: Record<string, unknown>) => boolean);\n /** Grouping key(s) or accessor function(s). */\n groupBy?:\n | string\n | string[]\n | ((d: DataPoint) => string | number)\n | ((d: DataPoint) => string | number)[];\n /** Padding between groups of bars in pixels. */\n groupPadding?: number;\n /** Label accessor for shapes. */\n label?: string | ((...args: unknown[]) => string);\n /** Whether to show the legend. */\n legend?: boolean;\n /** Configuration for the legend component. */\n legendConfig?: {\n label?: DataPointAccessor<string>;\n shapeConfig?: Record<string, string | number>;\n };\n /** Position of the legend. */\n legendPosition?: Position;\n /** Tooltip configuration for legend items. */\n legendTooltip?: TooltipConfig;\n /** Whether to show labels on line charts. */\n lineLabels?: boolean;\n /** Whether to show the loading message. */\n loadingMessage?: boolean;\n /** Custom HTML content for the loading indicator. */\n loadingHTML?: string;\n /** Metric key for the visualization. */\n metric?: string;\n /** Ocean color for geomaps (any CSS value including 'transparent'). */\n ocean?: string;\n /** Event listeners keyed by event name. */\n on?: Record<string, (event: Event) => void>;\n /** Coordinate accessor for point-based geomaps. */\n point?: (d: DataPoint) => number[];\n /** Point size accessor for geomaps. */\n pointSize?: string | ((d: DataPoint) => number);\n /** Minimum point size for geomaps. */\n pointSizeMin?: number;\n /** Maximum point size for geomaps. */\n pointSizeMax?: number;\n /** Map projection name or function. */\n projection?: string | ((x: number, y: number) => [number, number]);\n /** Outer padding between the visualization edge and map shapes. */\n projectionPadding?: number | string;\n /** Rotation offset for the map projection center. */\n projectionRotate?: [number, number];\n /** Row key for matrix-style layouts. */\n row?: string;\n /** Scrollable container selector for tooltip positioning. */\n scrollContainer?: string | Window;\n /** Configuration for shape rendering. */\n shapeConfig?: {\n duration?: number;\n [key: string]: unknown;\n };\n /** Size accessor key. */\n size?: string;\n /** Whether to stack series. */\n stacked?: boolean;\n /** Custom order for stacked series. */\n stackOrder?: string[];\n /** Value accessor for treemaps and aggregation. */\n sum?: DataPointAccessor<number>;\n /** Threshold value for grouping small slices. */\n threshold?: number;\n /** Label for the threshold group. */\n thresholdName?: string;\n /** URL to XYZ map tiles. */\n tileUrl?: string;\n /** Whether to show map tiles. */\n tiles?: boolean;\n /** Time key for temporal data. */\n time?: string;\n /** Chart title or title accessor function. */\n title?: string | ((data: DataPoint[]) => string);\n /** CSS style configuration for the title. */\n titleConfig?: Record<string, string | number>;\n /** Whether to show tooltips. */\n tooltip?: boolean;\n /** Configuration for the tooltip component. */\n tooltipConfig?: TooltipConfig;\n /** Path or object for the topojson data. */\n topojson?: string | object;\n /** CSS color to fill the map shapes. */\n topojsonFill?: string;\n /** Accessor function for topojson feature IDs. */\n topojsonId?: (obj: Record<string, unknown>) => string;\n /** Value accessor for the visualization. */\n value?: DataPointAccessor<number>;\n /** Key, index, or accessor function for x-axis values. */\n x?: string | number | ((...args: unknown[]) => unknown);\n /** Configuration for the x-axis. */\n xConfig?: AxisConfig;\n /** Custom sort function for x-axis values. */\n xSort?: (a: DataPoint, b: DataPoint) => number;\n /** Key, index, or accessor function for y-axis values. */\n y?: string | number | ((...args: unknown[]) => unknown);\n /** Configuration for the y-axis. */\n yConfig?: AxisConfig;\n /** Custom sort function for y-axis values. */\n ySort?: (a: DataPoint, b: DataPoint) => number;\n /** Set to false to disable zooming on Geomap and Network. */\n zoom?: boolean;\n\n /** Allows additional custom properties. */\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAwEA,WAgJC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3plus/core",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
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",
@@ -58,13 +58,16 @@
58
58
  "open-color": "^1.9.1",
59
59
  "textures": "^1.2.3",
60
60
  "topojson-client": "^3.1.0",
61
- "@d3plus/data": "3.1.4",
62
- "@d3plus/dom": "3.1.4",
63
- "@d3plus/format": "3.1.4",
64
- "@d3plus/locales": "3.1.4",
65
- "@d3plus/math": "3.1.4",
66
- "@d3plus/color": "3.1.4",
67
- "@d3plus/text": "3.1.4"
61
+ "@d3plus/locales": "3.1.6",
62
+ "@d3plus/text": "3.1.6",
63
+ "@d3plus/math": "3.1.6",
64
+ "@d3plus/format": "3.1.6",
65
+ "@d3plus/data": "3.1.6",
66
+ "@d3plus/dom": "3.1.6",
67
+ "@d3plus/color": "3.1.6"
68
+ },
69
+ "devDependencies": {
70
+ "playwright": "1.59.1"
68
71
  },
69
72
  "scripts": {
70
73
  "build:esm": "node ../../scripts/build-esm.js",
@@ -56,6 +56,8 @@ export interface D3plusConfig {
56
56
  depth?: number;
57
57
  /** Sets orientation of main category axis. */
58
58
  discrete?: "x" | "y";
59
+ /** Default duration of transitions, in milliseconds. */
60
+ duration?: number;
59
61
  /** Allows removing specific geographies from topojson file to improve zoom. */
60
62
  fitFilter?: number | string | ((d: Record<string, unknown>) => boolean);
61
63
  /** Grouping key(s) or accessor function(s). */
@@ -156,8 +158,8 @@ export interface D3plusConfig {
156
158
  yConfig?: AxisConfig;
157
159
  /** Custom sort function for y-axis values. */
158
160
  ySort?: (a: DataPoint, b: DataPoint) => number;
159
- /** Set to false to disable zooming on geomaps. */
160
- zoom?: false;
161
+ /** Set to false to disable zooming on Geomap and Network. */
162
+ zoom?: boolean;
161
163
  /** Allows additional custom properties. */
162
164
  [key: string]: unknown;
163
165
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/core v3.1.3
2
+ @d3plus/core v3.1.5
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
@@ -31906,7 +31906,11 @@
31906
31906
  "line-height": lineHeight
31907
31907
  };
31908
31908
  var line = 1, textProg = "", truncated = false, widthProg = 0;
31909
- var lineData = [], sizes = textWidth(words, style);
31909
+ var lineData = [], // of the per-word widths the break logic actually compared against
31910
+ // `width`, which can differ from re-measuring the finished line as a
31911
+ // single string (e.g. a soft hyphen counts toward the break decision but
31912
+ // is stripped from the rendered line, and trailing spaces measure as 0).
31913
+ lineWidths = [], sizes = textWidth(words, style);
31910
31914
  for(var i = 0; i < words.length; i++){
31911
31915
  var word = words[i];
31912
31916
  var wordWidth = sizes[words.indexOf(word)];
@@ -31939,16 +31943,23 @@
31939
31943
  }
31940
31944
  textProg += word;
31941
31945
  widthProg += wordWidth;
31946
+ lineWidths[line - 1] = widthProg;
31942
31947
  }
31943
31948
  // Clean remaining soft hyphens from all lines
31944
31949
  var lines = lineData.map(function(l) {
31945
31950
  return l.replaceAll(softHyphen, "");
31946
31951
  });
31952
+ // Report each line's width as at least the width the break logic consumed,
31953
+ // so that re-wrapping the same text at the reported width is stable (a
31954
+ // consumer that sizes a box to `max(widths)` won't trigger another break).
31955
+ var lineWidthsVisible = textWidth(lines, style);
31947
31956
  return {
31948
31957
  lines: lines,
31949
31958
  sentence: sentence,
31950
31959
  truncated: truncated,
31951
- widths: textWidth(lines, style),
31960
+ widths: lineWidthsVisible.map(function(w, i) {
31961
+ return Math.max(w, lineWidths[i] || 0);
31962
+ }),
31952
31963
  words: words
31953
31964
  };
31954
31965
  }
@@ -35075,6 +35086,9 @@
35075
35086
  zeroLength(initialDomain[0]),
35076
35087
  zeroLength(initialDomain[1])
35077
35088
  ].filter(Boolean).sort();
35089
+ // Nothing meaningful to round to (e.g. a zero-extent domain like
35090
+ // [0, 0]); leave the scale's domain as-is to avoid a NaN factor.
35091
+ if (!zeroArray.length) return;
35078
35092
  const diverging = initialDomain.some((d)=>isNegative(d)) && initialDomain.some((d)=>d > 0);
35079
35093
  const zeros = zeroArray.length === 1 ? zeroArray[0] : zeroArray[0] > 1 && zeroArray[0] === zeroArray[1] ? zeroArray[0] - 1 : this._rounding === "outside" || !diverging ? zeroArray[0] + (zeroArray[1] - zeroArray[0]) / 2 : max$5(zeroArray);
35080
35094
  let factor = zeros < 1 ? fixFloat(zeros) : +`1${Array(Math.floor(fixFloat(zeros)) - 1).fill(0).join("")}`;
@@ -35335,7 +35349,7 @@
35335
35349
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35336
35350
  textData.forEach((datum)=>{
35337
35351
  const { fP, i, position } = datum;
35338
- const sizeName = horizontal ? "width" : "height";
35352
+ const sizeName = datum.rotate && horizontal || !datum.rotate && !horizontal ? "height" : "width";
35339
35353
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35340
35354
  let prev = i ? reverseTextData.find((t)=>t.i < i && !t.truncated) : false;
35341
35355
  if (i === textData.length - 1) {
@@ -35443,7 +35457,7 @@
35443
35457
  id: d,
35444
35458
  labelBounds: rotated && data ? {
35445
35459
  x: -data.width / 2 + data.fS / 4,
35446
- y: this._orient === "bottom" ? size + (data.width - lineHeight * lines) / 2 + fP : size * 2 - (data.width + lineHeight * lines) / 2 + fP,
35460
+ y: this._orient === "bottom" ? size + (data.width - lineHeight * lines) / 2 + fP : size - (data.width + lineHeight * lines) / 2 - 2 * fP,
35447
35461
  width: data.width,
35448
35462
  height: data.height
35449
35463
  } : {
@@ -35711,7 +35725,7 @@
35711
35725
  const rtl$1 = rtl();
35712
35726
  return this._orient === "left" ? rtl$1 ? "start" : "end" : this._orient === "right" ? rtl$1 ? "end" : "start" : this._labelRotation ? this._orient === "bottom" ? "end" : "start" : "middle";
35713
35727
  },
35714
- verticalAlign: ()=>this._orient === "bottom" ? "top" : this._orient === "top" ? "bottom" : "middle"
35728
+ verticalAlign: ()=>this._orient === "bottom" ? "top" : this._orient === "top" ? this._labelRotation ? "top" : "bottom" : "middle"
35715
35729
  },
35716
35730
  r: (d)=>d.tick ? 4 : 0,
35717
35731
  stroke: ()=>{
@@ -57601,7 +57615,7 @@
57601
57615
  defaultMouseMoveShape(d, i, x, event);
57602
57616
  const row = getProp.bind(this)("row", d, i);
57603
57617
  const column = getProp.bind(this)("column", d, i);
57604
- this.hover((h, ii)=>getProp.bind(this)("row", h, ii) === row || getProp.bind(this)("column", h, ii) === column);
57618
+ this.hover((h, ii)=>(getProp.bind(this)("row", h, ii) === row || getProp.bind(this)("column", h, ii) === column) && typeof this._colorScale(h, ii) === "number");
57605
57619
  };
57606
57620
  this._row = accessor("row");
57607
57621
  this._rowAxis = new Axis();