@d3plus/core 4.2.0 → 4.5.0
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 +2137 -953
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/internal.js +7 -1
- package/es/internal.js.map +1 -1
- package/es/src/charts/AreaPlot/index.js +1 -2
- package/es/src/charts/AreaPlot/index.js.map +1 -1
- package/es/src/charts/BarChart/index.js +1 -2
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +1 -2
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/BumpChart/index.js +1 -2
- package/es/src/charts/BumpChart/index.js.map +1 -1
- package/es/src/charts/Chord/applyLayout.js +205 -0
- package/es/src/charts/Chord/applyLayout.js.map +1 -0
- package/es/src/charts/Chord/emit.js +168 -0
- package/es/src/charts/Chord/emit.js.map +1 -0
- package/es/src/charts/Chord/index.js +234 -0
- package/es/src/charts/Chord/index.js.map +1 -0
- package/es/src/charts/Geomap/basemapTheme.js +78 -0
- package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
- package/es/src/charts/Geomap/emit.js +58 -9
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +93 -99
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/LinePlot/index.js +1 -2
- package/es/src/charts/LinePlot/index.js.map +1 -1
- package/es/src/charts/Matrix/emit.js +6 -0
- package/es/src/charts/Matrix/emit.js.map +1 -1
- package/es/src/charts/Matrix/index.js +1 -2
- package/es/src/charts/Matrix/index.js.map +1 -1
- package/es/src/charts/Network/emit.js +58 -24
- package/es/src/charts/Network/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +34 -54
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +3 -0
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +1 -2
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/emit.js +6 -2
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +1 -2
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +99 -4
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +25 -5
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/plotZoom.js +278 -0
- package/es/src/charts/Plot/plotZoom.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +4 -0
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/Priestley/index.js +1 -2
- package/es/src/charts/Priestley/index.js.map +1 -1
- package/es/src/charts/Radar/emit.js +4 -1
- package/es/src/charts/Radar/emit.js.map +1 -1
- package/es/src/charts/Radar/index.js +1 -2
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/emit.js +6 -0
- package/es/src/charts/RadialMatrix/emit.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +1 -2
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/emit.js +74 -8
- package/es/src/charts/Rings/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +11 -3
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/emit.js +55 -11
- package/es/src/charts/Sankey/emit.js.map +1 -1
- package/es/src/charts/Sankey/index.js +8 -2
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/StackedArea/index.js +1 -2
- package/es/src/charts/StackedArea/index.js.map +1 -1
- package/es/src/charts/Tree/emit.js +8 -2
- package/es/src/charts/Tree/emit.js.map +1 -1
- package/es/src/charts/Tree/index.js +1 -2
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/index.js +1 -2
- package/es/src/charts/Treemap/index.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/drawSteps/backControl.js +70 -0
- package/es/src/charts/drawSteps/backControl.js.map +1 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
- package/es/src/charts/drawSteps/minimap.js +370 -0
- package/es/src/charts/drawSteps/minimap.js.map +1 -0
- package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
- package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/searchControls.js +358 -0
- package/es/src/charts/drawSteps/searchControls.js.map +1 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/tableView.js +173 -0
- package/es/src/charts/drawSteps/tableView.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewControl.js +39 -0
- package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControls.js +73 -0
- package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/zoomControls.js +314 -175
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
- package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
- package/es/src/charts/features/attributionFeature.js +137 -0
- package/es/src/charts/features/attributionFeature.js.map +1 -0
- package/es/src/charts/features/axes.js +20 -8
- package/es/src/charts/features/axes.js.map +1 -1
- package/es/src/charts/features/chartGeometry.js +16 -2
- package/es/src/charts/features/chartGeometry.js.map +1 -1
- package/es/src/charts/features/edgeArrows.js +155 -0
- package/es/src/charts/features/edgeArrows.js.map +1 -0
- package/es/src/charts/features/emitHelpers.js +8 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/ensureZoomDom.js +63 -12
- package/es/src/charts/features/ensureZoomDom.js.map +1 -1
- package/es/src/charts/features/features.js +83 -110
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +45 -17
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/plotPaint.js +32 -7
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +3 -1
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/features/zoomExtent.js +185 -0
- package/es/src/charts/features/zoomExtent.js.map +1 -0
- package/es/src/charts/helpers/tileAttributions.js +26 -0
- package/es/src/charts/helpers/tileAttributions.js.map +1 -1
- package/es/src/charts/index.js +1 -0
- package/es/src/charts/index.js.map +1 -1
- package/es/src/charts/pipeline/runVizPipeline.js +33 -14
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/pipeline/vizDrawPure.js +32 -6
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
- package/es/src/charts/viz/Viz.js +102 -61
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBase.js +157 -4
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +32 -2
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +4 -1
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +247 -51
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +7 -3
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/components/Axis/Axis.js +10 -1
- package/es/src/components/Axis/Axis.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +2 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
- package/es/src/components/Axis/axisRender.js +5 -1
- package/es/src/components/Axis/axisRender.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +86 -20
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/shapes/Shape.js +12 -10
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/hitAreaNode.js +31 -5
- package/es/src/shapes/hitAreaNode.js.map +1 -1
- package/es/src/shapes/interactionPoints.js +30 -0
- package/es/src/shapes/interactionPoints.js.map +1 -0
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +11 -10
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +8 -1
- package/types/src/charts/Chord/applyLayout.d.ts +43 -0
- package/types/src/charts/Chord/emit.d.ts +10 -0
- package/types/src/charts/Chord/index.d.ts +19 -0
- package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
- package/types/src/charts/Plot/index.d.ts +32 -2
- package/types/src/charts/Plot/pipeline.d.ts +2 -1
- package/types/src/charts/Plot/plotZoom.d.ts +65 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
- package/types/src/charts/drawSteps/backControl.d.ts +29 -0
- package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
- package/types/src/charts/drawSteps/minimap.d.ts +19 -0
- package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
- package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
- package/types/src/charts/drawSteps/tableView.d.ts +23 -0
- package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
- package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
- package/types/src/charts/features/attributionFeature.d.ts +21 -0
- package/types/src/charts/features/axes.d.ts +1 -1
- package/types/src/charts/features/chartGeometry.d.ts +9 -3
- package/types/src/charts/features/edgeArrows.d.ts +92 -0
- package/types/src/charts/features/emitHelpers.d.ts +11 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
- package/types/src/charts/features/features.d.ts +32 -17
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/plotPaint.d.ts +15 -2
- package/types/src/charts/features/zoomExtent.d.ts +25 -0
- package/types/src/charts/index.d.ts +1 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
- package/types/src/charts/viz/Viz.d.ts +31 -1
- package/types/src/charts/viz/VizBase.d.ts +86 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
- package/types/src/charts/viz/vizDefaults.d.ts +155 -0
- package/types/src/charts/viz/vizTypes.d.ts +75 -1
- package/types/src/components/Axis/Axis.d.ts +2 -0
- package/types/src/shapes/Shape.d.ts +2 -2
- package/types/src/shapes/hitAreaNode.d.ts +5 -4
- package/types/src/shapes/interactionPoints.d.ts +15 -0
- package/types/src/utils/D3plusConfig.d.ts +102 -8
- package/umd/d3plus-core.full.js +39793 -34875
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +5836 -4264
- package/umd/d3plus-core.js +13998 -9927
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +3716 -2264
|
@@ -3,6 +3,90 @@ import { colorContrast } from "@d3plus/color";
|
|
|
3
3
|
import { backgroundColor } from "@d3plus/dom";
|
|
4
4
|
import { accessor, constant } from "../../utils/index.js";
|
|
5
5
|
var padding = 5;
|
|
6
|
+
var positionCache = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
Every swatch's x/y position, computed in one pass and cached until the
|
|
9
|
+
legend's layout changes. Scene repaints (hover, zoom) re-walk the swatch
|
|
10
|
+
accessors, and resolving each item against its whole row made that
|
|
11
|
+
quadratic in the number of legend items.
|
|
12
|
+
*/ function legendPositions(legend) {
|
|
13
|
+
var lineData = legend._lineData;
|
|
14
|
+
var _legend_schema = legend.schema, align = _legend_schema.align, direction = _legend_schema.direction, pad = _legend_schema.padding;
|
|
15
|
+
var bounds = legend._outerBounds;
|
|
16
|
+
var deps = [
|
|
17
|
+
lineData,
|
|
18
|
+
legend._data,
|
|
19
|
+
bounds.x,
|
|
20
|
+
bounds.y,
|
|
21
|
+
bounds.width,
|
|
22
|
+
legend._titleHeight,
|
|
23
|
+
legend._rtl,
|
|
24
|
+
align,
|
|
25
|
+
direction,
|
|
26
|
+
pad
|
|
27
|
+
];
|
|
28
|
+
var cached = positionCache.get(legend);
|
|
29
|
+
if (cached && cached.deps.every(function(v, i) {
|
|
30
|
+
return v === deps[i];
|
|
31
|
+
})) return cached;
|
|
32
|
+
// Each row's items (in legend order), total width, and tallest label.
|
|
33
|
+
var rows = new Map();
|
|
34
|
+
lineData.forEach(function(l) {
|
|
35
|
+
var row = rows.get(l.y);
|
|
36
|
+
if (row) row.push(l);
|
|
37
|
+
else rows.set(l.y, [
|
|
38
|
+
l
|
|
39
|
+
]);
|
|
40
|
+
});
|
|
41
|
+
var rowWidths = new Map();
|
|
42
|
+
var rowHeights = new Map();
|
|
43
|
+
rows.forEach(function(row, y) {
|
|
44
|
+
rowWidths.set(y, legend._rowWidth(row));
|
|
45
|
+
rowHeights.set(y, max(row.map(function(l) {
|
|
46
|
+
return l.height;
|
|
47
|
+
})));
|
|
48
|
+
});
|
|
49
|
+
var dataHeight = max(legend._data.map(function(l, x) {
|
|
50
|
+
return legend._fetchConfig("height", l, x);
|
|
51
|
+
}));
|
|
52
|
+
// Running `_rowWidth` of the items before each one in its row: the sum of
|
|
53
|
+
// their shape + label widths, plus the padding after every one but the last.
|
|
54
|
+
var running = new Map();
|
|
55
|
+
var x = [];
|
|
56
|
+
var y = [];
|
|
57
|
+
lineData.forEach(function(datum) {
|
|
58
|
+
var rowY = datum.y;
|
|
59
|
+
var rowWidth = rowWidths.get(rowY);
|
|
60
|
+
var offset = align === "left" || align === "right" && direction === "column" ? 0 : align === "center" ? (bounds.width - rowWidth) / 2 : bounds.width - rowWidth;
|
|
61
|
+
var r = running.get(rowY) || {
|
|
62
|
+
widths: 0,
|
|
63
|
+
pads: 0,
|
|
64
|
+
last: 0,
|
|
65
|
+
count: 0
|
|
66
|
+
};
|
|
67
|
+
var prevWidth = r.count ? r.widths + pad * (r.pads - r.last) : 0;
|
|
68
|
+
var rtlMod = legend._rtl ? datum.width + pad : 0;
|
|
69
|
+
x.push(prevWidth + pad * (r.count ? datum.sentence ? 2 : 1 : 0) + bounds.x + datum.shapeWidth / 2 + offset + rtlMod);
|
|
70
|
+
y.push(rowY + legend._titleHeight + bounds.y + max([
|
|
71
|
+
rowHeights.get(rowY),
|
|
72
|
+
dataHeight
|
|
73
|
+
]) / 2);
|
|
74
|
+
var factor = datum.width ? 2 : 1;
|
|
75
|
+
running.set(rowY, {
|
|
76
|
+
widths: r.widths + datum.shapeWidth + datum.width,
|
|
77
|
+
pads: r.pads + factor,
|
|
78
|
+
last: factor,
|
|
79
|
+
count: r.count + 1
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
var positions = {
|
|
83
|
+
deps: deps,
|
|
84
|
+
x: x,
|
|
85
|
+
y: y
|
|
86
|
+
};
|
|
87
|
+
positionCache.set(legend, positions);
|
|
88
|
+
return positions;
|
|
89
|
+
}
|
|
6
90
|
/**
|
|
7
91
|
Builds the Legend's default `shapeConfig` object. The accessors close over
|
|
8
92
|
the `legend` instance so they read live `_lineData` / `_outerBounds` /
|
|
@@ -58,28 +142,10 @@ var padding = 5;
|
|
|
58
142
|
r: constant(6),
|
|
59
143
|
width: constant(12),
|
|
60
144
|
x: function x(d, i) {
|
|
61
|
-
|
|
62
|
-
var y = datum.y;
|
|
63
|
-
var pad = legend.schema.align === "left" || legend.schema.align === "right" && legend.schema.direction === "column" ? 0 : legend.schema.align === "center" ? (legend._outerBounds.width - legend._rowWidth(legend._lineData.filter(function(l) {
|
|
64
|
-
return y === l.y;
|
|
65
|
-
}))) / 2 : legend._outerBounds.width - legend._rowWidth(legend._lineData.filter(function(l) {
|
|
66
|
-
return y === l.y;
|
|
67
|
-
}));
|
|
68
|
-
var prevWords = legend._lineData.slice(0, i).filter(function(l) {
|
|
69
|
-
return y === l.y;
|
|
70
|
-
});
|
|
71
|
-
var rtlMod = legend._rtl ? datum.width + legend.schema.padding : 0;
|
|
72
|
-
return legend._rowWidth(prevWords) + legend.schema.padding * (prevWords.length ? datum.sentence ? 2 : 1 : 0) + legend._outerBounds.x + datum.shapeWidth / 2 + pad + rtlMod;
|
|
145
|
+
return legendPositions(legend).x[i];
|
|
73
146
|
},
|
|
74
147
|
y: function y(d, i) {
|
|
75
|
-
|
|
76
|
-
return ld.y + legend._titleHeight + legend._outerBounds.y + max(legend._lineData.filter(function(l) {
|
|
77
|
-
return ld.y === l.y;
|
|
78
|
-
}).map(function(l) {
|
|
79
|
-
return l.height;
|
|
80
|
-
}).concat(legend._data.map(function(l, x) {
|
|
81
|
-
return legend._fetchConfig("height", l, x);
|
|
82
|
-
}))) / 2;
|
|
148
|
+
return legendPositions(legend).y[i];
|
|
83
149
|
}
|
|
84
150
|
};
|
|
85
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Legend/legendConfig.ts"],"sourcesContent":["import {max} from \"d3-array\";\n\nimport {colorContrast} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport {accessor, constant} from \"../../utils/index.js\";\n\nimport type Legend from \"./Legend.js\";\n\nconst padding = 5;\n\n/**\n Builds the Legend's default `shapeConfig` object. The accessors close over\n the `legend` instance so they read live `_lineData` / `_outerBounds` /\n `_rtl` / `_titleHeight` state during render.\n*/\nexport function buildLegendShapeConfig(legend: Legend): Record<string, unknown> {\n return {\n fill: accessor(\"color\"),\n height: constant(12),\n hitArea: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i],\n h = max([d.height as number, d.shapeHeight as number]);\n return {\n width: (d.width as number) + (d.shapeWidth as number),\n height: h,\n x: -(d.shapeWidth as number) / 2,\n y: -h! / 2,\n };\n },\n labelBounds: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i];\n let x = (d.shapeWidth as number) / 2;\n if (d.shape === \"Circle\") x -= (d.shapeR as number) / 2;\n const height = max([d.shapeHeight as number, d.height as number]);\n const rtlMod = legend._rtl\n ? (d.shapeWidth as number) + (d.width as number) + legend.schema.padding * 2\n : 0;\n return {\n width: d.width as number,\n height,\n x: x + padding - rtlMod,\n y: -height! / 2,\n };\n },\n labelConfig: {\n fontColor: () => {\n const bg = legend._select ? backgroundColor(legend._select.node()) : \"rgb(255, 255, 255)\";\n return colorContrast(bg);\n },\n fontFamily: legend._titleClass.fontFamily(),\n fontResize: false,\n fontSize: constant(10),\n // The swatch's `hitArea` already spans the label, so let it own pointer\n // events for the whole item. A bare label would carry a different scene\n // key than its swatch, so hovering across the swatch→label padding would\n // otherwise read as leaving one item and entering another.\n pointerEvents: constant(\"none\"),\n verticalAlign: \"middle\",\n },\n opacity: 1,\n r: constant(6),\n width: constant(12),\n x: (d: DataPoint, i: number) => {\n const datum = legend._lineData[i];\n const y = datum.y;\n const pad =\n legend.schema.align === \"left\" ||\n (legend.schema.align === \"right\" && legend.schema.direction === \"column\")\n ? 0\n : legend.schema.align === \"center\"\n ? (legend._outerBounds.width -\n legend._rowWidth(\n legend._lineData.filter(\n (l: Record<string, unknown>) => y === l.y,\n ),\n )) /\n 2\n : legend._outerBounds.width -\n legend._rowWidth(\n legend._lineData.filter((l: Record<string, unknown>) => y === l.y),\n );\n const prevWords = legend._lineData\n .slice(0, i)\n .filter((l: Record<string, unknown>) => y === l.y);\n const rtlMod = legend._rtl ? (datum.width as number) + legend.schema.padding : 0;\n return (\n legend._rowWidth(prevWords) +\n legend.schema.padding * (prevWords.length ? (datum.sentence ? 2 : 1) : 0) +\n legend._outerBounds.x +\n (datum.shapeWidth as number) / 2 +\n pad +\n rtlMod\n );\n },\n y: (d: DataPoint, i: number) => {\n const ld = legend._lineData[i];\n return (\n (ld.y as number) +\n legend._titleHeight +\n legend._outerBounds.y +\n max(\n legend._lineData\n .filter((l: Record<string, unknown>) => ld.y === l.y)\n .map((l: Record<string, unknown>) => l.height as number)\n .concat(\n legend._data.map((l: DataPoint, x: number) =>\n legend._fetchConfig(\"height\", l, x) as number,\n ),\n ),\n )! /\n 2\n );\n },\n };\n}\n"],"names":["max","colorContrast","backgroundColor","accessor","constant","padding","buildLegendShapeConfig","legend","fill","height","hitArea","dd","i","d","_lineData","h","shapeHeight","width","shapeWidth","x","y","labelBounds","shape","shapeR","rtlMod","_rtl","schema","labelConfig","fontColor","bg","_select","node","fontFamily","_titleClass","fontResize","fontSize","pointerEvents","verticalAlign","opacity","r","datum","pad","align","direction","_outerBounds","_rowWidth","filter","l","prevWords","slice","length","sentence","ld","_titleHeight","map","concat","_data","_fetchConfig"],"mappings":"AAAA,SAAQA,GAAG,QAAO,WAAW;AAE7B,SAAQC,aAAa,QAAO,gBAAgB;AAE5C,SAAQC,eAAe,QAAO,cAAc;AAE5C,SAAQC,QAAQ,EAAEC,QAAQ,QAAO,uBAAuB;AAIxD,IAAMC,UAAU;AAEhB;;;;AAIA,GACA,OAAO,SAASC,uBAAuBC,MAAc;IACnD,OAAO;QACLC,MAAML,SAAS;QACfM,QAAQL,SAAS;QACjBM,SAAS,SAATA,QAAUC,IAAeC;YACvB,IAAMC,IAAIN,OAAOO,SAAS,CAACF,EAAE,EAC3BG,IAAIf,IAAI;gBAACa,EAAEJ,MAAM;gBAAYI,EAAEG,WAAW;aAAW;YACvD,OAAO;gBACLC,OAAO,AAACJ,EAAEI,KAAK,GAAeJ,EAAEK,UAAU;gBAC1CT,QAAQM;gBACRI,GAAG,CAAEN,EAAEK,UAAU,GAAc;gBAC/BE,GAAG,CAACL,IAAK;YACX;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"sources":["../../../../src/components/Legend/legendConfig.ts"],"sourcesContent":["import {max} from \"d3-array\";\n\nimport {colorContrast} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {backgroundColor} from \"@d3plus/dom\";\n\nimport {accessor, constant} from \"../../utils/index.js\";\n\nimport type Legend from \"./Legend.js\";\n\nconst padding = 5;\n\ntype Row = Record<string, unknown>;\n\ninterface LegendPositions {\n deps: unknown[];\n x: number[];\n y: number[];\n}\n\nconst positionCache = new WeakMap<Legend, LegendPositions>();\n\n/**\n Every swatch's x/y position, computed in one pass and cached until the\n legend's layout changes. Scene repaints (hover, zoom) re-walk the swatch\n accessors, and resolving each item against its whole row made that\n quadratic in the number of legend items.\n*/\nfunction legendPositions(legend: Legend): LegendPositions {\n const lineData = legend._lineData as Row[];\n const {align, direction, padding: pad} = legend.schema;\n const bounds = legend._outerBounds;\n const deps = [\n lineData, legend._data, bounds.x, bounds.y, bounds.width,\n legend._titleHeight, legend._rtl, align, direction, pad,\n ];\n const cached = positionCache.get(legend);\n if (cached && cached.deps.every((v, i) => v === deps[i])) return cached;\n\n // Each row's items (in legend order), total width, and tallest label.\n const rows = new Map<unknown, Row[]>();\n lineData.forEach(l => {\n const row = rows.get(l.y);\n if (row) row.push(l);\n else rows.set(l.y, [l]);\n });\n const rowWidths = new Map<unknown, number>();\n const rowHeights = new Map<unknown, number>();\n rows.forEach((row, y) => {\n rowWidths.set(y, legend._rowWidth(row));\n rowHeights.set(y, max(row.map(l => l.height as number))!);\n });\n const dataHeight = max(\n legend._data.map((l: DataPoint, x: number) => legend._fetchConfig(\"height\", l, x) as number),\n );\n\n // Running `_rowWidth` of the items before each one in its row: the sum of\n // their shape + label widths, plus the padding after every one but the last.\n const running = new Map<unknown, {widths: number; pads: number; last: number; count: number}>();\n const x: number[] = [];\n const y: number[] = [];\n lineData.forEach(datum => {\n const rowY = datum.y;\n const rowWidth = rowWidths.get(rowY)!;\n const offset =\n align === \"left\" || (align === \"right\" && direction === \"column\")\n ? 0\n : align === \"center\"\n ? (bounds.width - rowWidth) / 2\n : bounds.width - rowWidth;\n const r = running.get(rowY) || {widths: 0, pads: 0, last: 0, count: 0};\n const prevWidth = r.count ? r.widths + pad * (r.pads - r.last) : 0;\n const rtlMod = legend._rtl ? (datum.width as number) + pad : 0;\n x.push(\n prevWidth +\n pad * (r.count ? (datum.sentence ? 2 : 1) : 0) +\n bounds.x +\n (datum.shapeWidth as number) / 2 +\n offset +\n rtlMod,\n );\n y.push(\n (rowY as number) +\n legend._titleHeight +\n bounds.y +\n max([rowHeights.get(rowY)!, dataHeight!])! / 2,\n );\n const factor = datum.width ? 2 : 1;\n running.set(rowY, {\n widths: r.widths + (datum.shapeWidth as number) + (datum.width as number),\n pads: r.pads + factor,\n last: factor,\n count: r.count + 1,\n });\n });\n\n const positions = {deps, x, y};\n positionCache.set(legend, positions);\n return positions;\n}\n\n/**\n Builds the Legend's default `shapeConfig` object. The accessors close over\n the `legend` instance so they read live `_lineData` / `_outerBounds` /\n `_rtl` / `_titleHeight` state during render.\n*/\nexport function buildLegendShapeConfig(legend: Legend): Record<string, unknown> {\n return {\n fill: accessor(\"color\"),\n height: constant(12),\n hitArea: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i],\n h = max([d.height as number, d.shapeHeight as number]);\n return {\n width: (d.width as number) + (d.shapeWidth as number),\n height: h,\n x: -(d.shapeWidth as number) / 2,\n y: -h! / 2,\n };\n },\n labelBounds: (dd: DataPoint, i: number) => {\n const d = legend._lineData[i];\n let x = (d.shapeWidth as number) / 2;\n if (d.shape === \"Circle\") x -= (d.shapeR as number) / 2;\n const height = max([d.shapeHeight as number, d.height as number]);\n const rtlMod = legend._rtl\n ? (d.shapeWidth as number) + (d.width as number) + legend.schema.padding * 2\n : 0;\n return {\n width: d.width as number,\n height,\n x: x + padding - rtlMod,\n y: -height! / 2,\n };\n },\n labelConfig: {\n fontColor: () => {\n const bg = legend._select ? backgroundColor(legend._select.node()) : \"rgb(255, 255, 255)\";\n return colorContrast(bg);\n },\n fontFamily: legend._titleClass.fontFamily(),\n fontResize: false,\n fontSize: constant(10),\n // The swatch's `hitArea` already spans the label, so let it own pointer\n // events for the whole item. A bare label would carry a different scene\n // key than its swatch, so hovering across the swatch→label padding would\n // otherwise read as leaving one item and entering another.\n pointerEvents: constant(\"none\"),\n verticalAlign: \"middle\",\n },\n opacity: 1,\n r: constant(6),\n width: constant(12),\n x: (d: DataPoint, i: number) => legendPositions(legend).x[i],\n y: (d: DataPoint, i: number) => legendPositions(legend).y[i],\n };\n}\n"],"names":["max","colorContrast","backgroundColor","accessor","constant","padding","positionCache","WeakMap","legendPositions","legend","lineData","_lineData","schema","align","direction","pad","bounds","_outerBounds","deps","_data","x","y","width","_titleHeight","_rtl","cached","get","every","v","i","rows","Map","forEach","l","row","push","set","rowWidths","rowHeights","_rowWidth","map","height","dataHeight","_fetchConfig","running","datum","rowY","rowWidth","offset","r","widths","pads","last","count","prevWidth","rtlMod","sentence","shapeWidth","factor","positions","buildLegendShapeConfig","fill","hitArea","dd","d","h","shapeHeight","labelBounds","shape","shapeR","labelConfig","fontColor","bg","_select","node","fontFamily","_titleClass","fontResize","fontSize","pointerEvents","verticalAlign","opacity"],"mappings":"AAAA,SAAQA,GAAG,QAAO,WAAW;AAE7B,SAAQC,aAAa,QAAO,gBAAgB;AAE5C,SAAQC,eAAe,QAAO,cAAc;AAE5C,SAAQC,QAAQ,EAAEC,QAAQ,QAAO,uBAAuB;AAIxD,IAAMC,UAAU;AAUhB,IAAMC,gBAAgB,IAAIC;AAE1B;;;;;AAKA,GACA,SAASC,gBAAgBC,MAAc;IACrC,IAAMC,WAAWD,OAAOE,SAAS;IACjC,IAAyCF,iBAAAA,OAAOG,MAAM,EAA/CC,QAAkCJ,eAAlCI,OAAOC,YAA2BL,eAA3BK,WAAWT,AAASU,MAAON,eAAhBJ;IACzB,IAAMW,SAASP,OAAOQ,YAAY;IAClC,IAAMC,OAAO;QACXR;QAAUD,OAAOU,KAAK;QA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AAE;;QAC5DR,GAAG,SAAHA,EAAI2C,GAAcnC;mBAAcrB,gBAAgBC,QAAQY,CAAC,CAACQ,EAAE;;IAC9D;AACF"}
|
package/es/src/shapes/Shape.js
CHANGED
|
@@ -214,6 +214,7 @@ import { accessor, BaseClass, constant } from "../utils/index.js";
|
|
|
214
214
|
import { installFluent } from "../fluent.js";
|
|
215
215
|
import { buildLabelData } from "./buildLabelData.js";
|
|
216
216
|
import { hitAreaNode } from "./hitAreaNode.js";
|
|
217
|
+
import { interactionPoints } from "./interactionPoints.js";
|
|
217
218
|
/** Coerces a value to a finite number, or undefined. @private */ export function numOrUndef(v) {
|
|
218
219
|
var n = Number(v);
|
|
219
220
|
return Number.isFinite(n) ? n : undefined;
|
|
@@ -584,16 +585,13 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
584
585
|
Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
|
|
585
586
|
@param callback Optional callback invoked after rendering completes.
|
|
586
587
|
*/ /**
|
|
587
|
-
Resolves a style accessor
|
|
588
|
-
|
|
588
|
+
Resolves a style accessor. For a nested shape (Line/Area) the accessor gets
|
|
589
|
+
the merged aggregate `d.data`/`d.i` — matching `_nestWrapper` + scene datum.
|
|
589
590
|
@private
|
|
590
591
|
*/ key: "_styleVal",
|
|
591
592
|
value: function _styleVal(fn, d, i) {
|
|
592
593
|
if (typeof fn !== "function") return fn;
|
|
593
|
-
if (d.nested && d.key && d.values)
|
|
594
|
-
var first = d.values[0];
|
|
595
|
-
return fn(first, this._data.indexOf(first));
|
|
596
|
-
}
|
|
594
|
+
if (d.nested && d.key && d.values) return fn(d.data, d.i);
|
|
597
595
|
return fn(d, i);
|
|
598
596
|
}
|
|
599
597
|
},
|
|
@@ -692,14 +690,18 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
692
690
|
var key = _this._nestWrapper(_this.schema.id)(d, i);
|
|
693
691
|
var datum = d.__d3plusShape__ ? d.data : d;
|
|
694
692
|
var transform = _this._sceneTransform(d, i);
|
|
693
|
+
// Per-point positions (Line/Area) shared by the geometry and its hit area
|
|
694
|
+
// so a hover anywhere on either resolves to the nearest point.
|
|
695
|
+
var iPoints = interactionPoints(d, _this.schema.x, _this.schema.y, _this.schema.defined);
|
|
695
696
|
// Push the hit area (if any) before the geometry so it sits behind it.
|
|
697
|
+
// Line's is a fat path built from the geometry `d`; Bar/legend etc. a rect.
|
|
696
698
|
if (_this.schema.hitArea) {
|
|
697
|
-
var ha = hitAreaNode(_this.schema.hitArea, d, i, _this._aes(d, i), key, datum, _this._name, transform);
|
|
699
|
+
var ha = hitAreaNode(_this.schema.hitArea, d, i, _this._aes(d, i), key, datum, _this._name, transform, geom.d);
|
|
698
700
|
// Share the datum's rank so the hit area stays paired just behind its
|
|
699
701
|
// own geometry (equal `z`, kept in push order by the stable sort).
|
|
700
|
-
if (ha) children.push(rank ? _object_spread_props(_object_spread({}, ha), {
|
|
702
|
+
if (ha) children.push(rank ? _object_spread_props(_object_spread({}, ha, iPoints), {
|
|
701
703
|
z: rank[i]
|
|
702
|
-
}) : ha);
|
|
704
|
+
}) : _object_spread({}, ha, iPoints));
|
|
703
705
|
}
|
|
704
706
|
children.push(_object_spread(_object_spread_props(_object_spread({}, geom), {
|
|
705
707
|
key: key,
|
|
@@ -712,7 +714,7 @@ var Shape = /*#__PURE__*/ function(BaseClass) {
|
|
|
712
714
|
role: strOrUndef(_this._nestWrapper(_this.schema.role)(d, i)),
|
|
713
715
|
label: strOrUndef(_this._nestWrapper(_this.schema.ariaLabel)(d, i))
|
|
714
716
|
}
|
|
715
|
-
}), rank ? {
|
|
717
|
+
}), iPoints, rank ? {
|
|
716
718
|
z: rank[i]
|
|
717
719
|
} : {}));
|
|
718
720
|
// backgroundImage: collect a per-datum image (see backgroundImageLayout for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shapes/Shape.ts"],"sourcesContent":["import {color} from \"d3-color\";\nimport {select} from \"d3-selection\";\nimport {transition} from \"d3-transition\";\n\nimport {colorContrast} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {assign, getSize, isObject} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\n\nimport {SvgRenderer} from \"@d3plus/render\";\nimport type {GroupNode, Paint, SceneNode, Transform} from \"@d3plus/render\";\n\nimport {TextBox} from \"../components/index.js\";\nimport {accessor, BaseClass, constant} from \"../utils/index.js\";\nimport type {AccessorFn, D3plusConfig} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\nimport {buildLabelData} from \"./buildLabelData.js\";\nimport {hitAreaNode} from \"./hitAreaNode.js\";\nimport type {BaseShapeConfig} from \"./shapeConfig.js\";\n\n/** Coerces a value to a finite number, or undefined. @private */\nexport function numOrUndef(v: unknown): number | undefined {\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n}\n\n/** Returns a non-empty string, or undefined. @private */\nexport function strOrUndef(v: unknown): string | undefined {\n return v == null || v === \"\" ? undefined : String(v);\n}\n\n/** Parses an SVG stroke-dasharray value into an array of numbers. @private */\nexport function parseDash(v: unknown): number[] | undefined {\n if (v == null || v === \"none\" || v === \"\") return undefined;\n if (typeof v === \"number\") return [v];\n const parts = String(v)\n .split(/[\\s,]+/)\n .map(Number)\n .filter(n => Number.isFinite(n));\n return parts.length ? parts : undefined;\n}\n\nexport interface ShapeAes {\n width?: number;\n height?: number;\n points?: [number, number][];\n r?: number;\n x?: number;\n y?: number;\n}\n\n\nimport {\n backgroundImageLayout,\n emitBackgroundImages,\n sortRanks,\n type BackgroundImageSpec,\n} from \"./sceneSort.js\";\n\n/** Shape's fluent accessor schema. Config storage lives on `this.schema.<key>`. */\nconst shapeSchema: ConfigField[] = [\n {key: \"activeOpacity\", coerce: \"identity\", default: 0.25},\n {key: \"ariaLabel\", coerce: \"const\", default: constant(\"\")},\n {key: \"backgroundImage\", coerce: \"const\", default: constant(false)},\n {key: \"backgroundImageFit\", coerce: \"const\", default: constant(\"cover\")},\n {key: \"discrete\", coerce: \"identity\"},\n {key: \"duration\", coerce: \"identity\", default: 600},\n {key: \"fill\", coerce: \"const\", default: constant(\"black\")},\n {key: \"fillOpacity\", coerce: \"const\", default: constant(1)},\n {key: \"hitArea\", coerce: \"const\"},\n {key: \"hoverOpacity\", coerce: \"identity\", default: 0.5},\n {\n key: \"id\",\n coerce: \"accessor\",\n default: (d: DataPoint, i?: number) => (d.id !== void 0 ? d.id : i!),\n },\n {key: \"label\", coerce: \"const\", default: constant(false)},\n {key: \"labelBounds\", coerce: \"const\"},\n {key: \"opacity\", coerce: \"const\", default: constant(1)},\n {key: \"pointerEvents\", coerce: \"const\", default: constant(\"visiblePainted\")},\n {key: \"renderMode\", coerce: \"identity\", default: \"full\"},\n {key: \"role\", coerce: \"const\", default: constant(\"presentation\")},\n {key: \"rotate\", coerce: \"const\", default: constant(0)},\n {key: \"rx\", coerce: \"const\", default: constant(0)},\n {key: \"ry\", coerce: \"const\", default: constant(0)},\n {key: \"scale\", coerce: \"const\", default: constant(1)},\n {key: \"shapeRendering\", coerce: \"const\", default: constant(\"geometricPrecision\")},\n {key: \"stroke\", coerce: \"const\"},\n {key: \"strokeDasharray\", coerce: \"const\", default: constant(\"0\")},\n {key: \"strokeLinecap\", coerce: \"const\", default: constant(\"butt\")},\n {key: \"strokeOpacity\", coerce: \"const\", default: constant(1)},\n {key: \"strokeWidth\", coerce: \"const\", default: constant(0)},\n {key: \"textAnchor\", coerce: \"const\", default: constant(\"start\")},\n {key: \"texture\", coerce: \"const\", default: constant(false)},\n {key: \"vectorEffect\", coerce: \"const\", default: constant(\"non-scaling-stroke\")},\n {key: \"verticalAlign\", coerce: \"const\", default: constant(\"top\")},\n // \"accessor\" (not \"const\"): a string names a data key (`.x(\"year\")`), a\n // number is a constant (`.x(50)`), and a function passes through — so a\n // standalone shape given string accessors (as the pipeline never does, but\n // direct users do) reads the field instead of treating \"x\" as the literal.\n {key: \"x\", coerce: \"accessor\", default: accessor(\"x\", 0)},\n {key: \"y\", coerce: \"accessor\", default: accessor(\"y\", 0)},\n];\n\n/**\n An abstracted class for generating shapes.\n*/\nexport default class Shape extends BaseClass {\n // installFluent generates the config accessors (fill, x, id, …) at runtime;\n // the index signature lets callers reach them through the type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n\n _data: DataPoint[];\n _labelClass: TextBox;\n _name: string;\n _tagName: string;\n _textureDefs: Record<string, Record<string, unknown>>;\n _select!: D3Selection;\n _transition!: ReturnType<typeof transition>;\n /** @param data The raw data array to filter. */\n _dataFilter?(data: DataPoint[]): DataPoint[];\n _group!: D3Selection;\n _update!: D3Selection;\n _enter!: D3Selection;\n _exit!: D3Selection;\n _hoverGroup!: D3Selection;\n _activeGroup!: D3Selection;\n _path!: Record<string, unknown>;\n /** SvgRenderer mounted by the standalone `render()` path; reused across redraws. */\n _sceneRenderer?: SvgRenderer;\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor(tagName: string = \"g\") {\n super();\n\n installFluent(this, shapeSchema);\n\n this._data = [];\n this._labelClass = new TextBox();\n this._name = \"Shape\";\n this._tagName = tagName;\n this._textureDefs = {};\n\n // stroke defaults to a darker shade of fill — closes over `this.schema`\n // so it tracks the current fill accessor. A fill that doesn't parse as a\n // color (e.g. \"none\"/\"transparent\", a gradient token) has no darker shade,\n // so fall back to the fill value itself.\n this.schema.stroke = (d: DataPoint, i?: number) => {\n const c = color(this.schema.fill(d, i) as string);\n return c ? c.darker(1).formatHex() : (this.schema.fill(d, i) as string);\n };\n\n this.schema.activeStyle = {\n stroke: (d: DataPoint, i: number) => {\n let c = this.schema.fill(d, i) as string;\n if ([\"transparent\", \"none\"].includes(c))\n c = this.schema.stroke(d, i) as string;\n const col = color(c);\n return col ? col.darker(1) : c;\n },\n \"stroke-width\": (d: DataPoint, i: number) => {\n const s = (this.schema.strokeWidth(d, i) as number) || 1;\n return s * 3;\n },\n };\n this.schema.hoverStyle = {\n stroke: (d: DataPoint, i: number) => {\n let c = this.schema.fill(d, i) as string;\n if ([\"transparent\", \"none\"].includes(c))\n c = this.schema.stroke(d, i) as string;\n const col = color(c);\n return col ? col.darker(0.5) : c;\n },\n \"stroke-width\": (d: DataPoint, i: number) => {\n const s = (this.schema.strokeWidth(d, i) as number) || 1;\n return s * 2;\n },\n };\n // Shape's label defaults. These are pushed to `_labelClass` via\n // `_labelClass.config(this.schema.labelConfig)` in render() so the\n // TextBox actually picks them up.\n // textAnchor defaults to \"start\" (left-aligned) — Treemap, Pie,\n // etc. rely on this. Bar overrides to \"middle\" in its constructor.\n this.schema.labelConfig = {\n fontColor: (d: DataPoint, i: number) =>\n colorContrast(this.schema.fill(d, i) as string),\n // Fade labels with their shape's opacity (e.g. an axis tick label hides\n // when `shapeConfig.opacity` is 0). Reads `this.schema.opacity` live —\n // like `fontColor` reads `fill` — which unwraps nested label data.\n fontOpacity: (d: DataPoint, i: number) =>\n this.schema.opacity(d, i) as number,\n fontResize: true,\n fontMax: 50,\n fontMin: 8,\n fontSize: 12,\n padding: 5,\n textAnchor: \"start\",\n verticalAlign: \"top\",\n };\n this.schema.textureDefault = {};\n }\n\n /**\n Given a specific data point and index, returns the aesthetic properties of the shape.\n @param data point*\n @param index @private\n*/\n _aes(_d?: DataPoint, _i?: number): ShapeAes {\n return {};\n }\n\n\n /**\n Returns a full JSON string of the texture config for a given data point.\n\n @private\n*/\n _getTextureKey(d: DataPoint, i: number): string | false {\n const textureVal: unknown = this.schema.texture(d, i);\n if (!textureVal) return false;\n\n /**\n Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.\n @private\n*/\n const styleLogic = (_: unknown): unknown => {\n return typeof _ !== \"function\"\n ? _\n : d.nested && d.key && d.values\n ? (_ as AccessorFn)(\n (d.values as unknown as DataPoint[])[0],\n this._data.indexOf((d.values as unknown as DataPoint[])[0]),\n )\n : (_ as AccessorFn)(d, i);\n };\n\n const fallback = this.schema.textureDefault;\n\n let texture: Record<string, unknown>;\n if (!isObject(textureVal))\n texture = {texture: textureVal} as Record<string, unknown>;\n else texture = textureVal as Record<string, unknown>;\n if (!texture.background) texture.background = styleLogic(this.schema.fill);\n if (!texture.stroke && !fallback.stroke)\n texture.stroke = styleLogic(this.schema.stroke);\n const pathNames = [\n \"squares\",\n \"nylon\",\n \"waves\",\n \"woven\",\n \"crosses\",\n \"caps\",\n \"hexagons\",\n ];\n if (\n pathNames.includes(texture.texture as string) ||\n typeof texture.texture === \"function\"\n ) {\n texture.d = texture.texture;\n texture.texture = \"paths\";\n } else if (texture.texture === \"grid\") {\n if (!texture.orientation && !fallback.orientation)\n texture.orientation = [\"vertical\", \"horizontal\"];\n texture.texture = \"lines\";\n }\n if (!texture.fill && texture.texture !== \"paths\")\n texture.fill = texture.stroke;\n const retObj = assign({}, fallback, texture);\n if (typeof retObj.d === \"function\") {\n retObj.d = retObj.d(retObj.size || 20);\n }\n return JSON.stringify(retObj);\n }\n\n /**\n Checks for nested data and uses the appropriate variables for accessor functions.\n @param elem @private\n*/\n _nestWrapper(\n method: AccessorFn,\n ): (d: DataPoint, i: number) => DataPoint[keyof DataPoint] {\n return (d: DataPoint, i: number) =>\n method(\n d.__d3plusShape__ ? (d.data as DataPoint) : d,\n d.__d3plusShape__ ? (d.i as number) : i,\n );\n }\n\n\n /**\n Adds labels to each shape group.\n @private\n*/\n _buildLabelData(): DataPoint[] {\n // Delegates to the pure `buildLabelData()` helper. The helper\n // takes the same inputs `this` exposes but works without a Shape\n // instance — emit functions or other callers that need only the\n // label-record layout can call it directly without instantiating\n // a Shape in compute mode.\n // All Shape methods bound to `this` before handing them to the pure\n // helper — subclasses (e.g. Line._dataFilter) reach for `this.schema.id`\n // and friends inside their bodies.\n return buildLabelData({\n data: this._data,\n dataFilter: this._dataFilter ? this._dataFilter.bind(this) : undefined,\n label: this.schema.label,\n labelBounds: this.schema.labelBounds\n ? this.schema.labelBounds.bind(this)\n : undefined,\n x: this.schema.x,\n y: this.schema.y,\n aes: this._aes.bind(this),\n rotate: this.schema.rotate,\n id: this.schema.id,\n });\n }\n\n\n /**\n Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.\n @param callback Optional callback invoked after rendering completes.\n*/\n /**\n Resolves a style accessor for a data point, mirroring the nested-data logic\n of _applyStyle so scene output matches DOM rendering.\n @private\n*/\n _styleVal(fn: unknown, d: DataPoint, i: number): unknown {\n if (typeof fn !== \"function\") return fn;\n if (d.nested && d.key && d.values) {\n const first = (d.values as unknown as DataPoint[])[0];\n return (fn as AccessorFn)(first, this._data.indexOf(first));\n }\n return (fn as AccessorFn)(d, i);\n }\n\n /**\n Builds the resolved Transform for a data point, mirroring _applyTransform.\n @private\n*/\n _sceneTransform(d: DataPoint, i: number): Transform {\n const wrapped = Boolean(d.__d3plusShape__);\n const dd = (wrapped ? d.data : d) as DataPoint;\n const ii = wrapped ? (d.i as number) : i;\n let x: number, y: number;\n if (wrapped && d.translate) {\n const [tx, ty] = String(d.translate).split(\",\").map(Number);\n x = tx;\n y = ty;\n } else {\n x = Number(this.schema.x(dd, ii));\n y = Number(this.schema.y(dd, ii));\n }\n const scale =\n wrapped && d.scale !== undefined\n ? Number(d.scale)\n : Number(this.schema.scale(dd, ii));\n const rotate =\n wrapped && d.rotate !== undefined\n ? Number(d.rotate)\n : Number(this.schema.rotate((d.data || d) as DataPoint, ii));\n return {x, y, scale, rotate};\n }\n\n /**\n Builds the resolved Paint for a data point, mirroring _applyStyle.\n Texture fills are encoded as a stable \"pattern:<key>\" token at this\n layer; the backend renderers (`SvgRenderer._resolveFill`,\n `CanvasRenderer._resolveFill`) materialize them into a real SVG\n pattern or a Canvas image pattern. The two-stage resolve is\n intentional — Shapes stay backend-free, and texture\n materialization happens once per renderer instead of per-shape.\n @private\n*/\n _scenePaint(d: DataPoint, i: number): Paint {\n // A texture resolves to a stable \"pattern:<key>\" token (the same JSON config\n // render() uses); each backend materializes or degrades it.\n const textureKey = this._getTextureKey(d, i);\n return {\n fill: textureKey\n ? `pattern:${textureKey}`\n : strOrUndef(this._styleVal(this.schema.fill, d, i)),\n fillOpacity: numOrUndef(this._styleVal(this.schema.fillOpacity, d, i)),\n stroke: strOrUndef(this._styleVal(this.schema.stroke, d, i)),\n strokeWidth: numOrUndef(this._styleVal(this.schema.strokeWidth, d, i)),\n strokeOpacity: numOrUndef(this._styleVal(this.schema.strokeOpacity, d, i)),\n strokeDasharray: parseDash(\n this._styleVal(this.schema.strokeDasharray, d, i),\n ),\n strokeLinecap: strOrUndef(\n this._styleVal(this.schema.strokeLinecap, d, i),\n ) as Paint[\"strokeLinecap\"],\n vectorEffect: strOrUndef(\n this._styleVal(this.schema.vectorEffect, d, i),\n ) as Paint[\"vectorEffect\"],\n shapeRendering: strOrUndef(\n this._nestWrapper(this.schema.shapeRendering)(d, i),\n ),\n opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),\n };\n }\n\n /**\n Returns the geometry-specific scene fields for a data point. Overridden by\n each shape subclass; the base provides none.\n @private\n*/\n _sceneGeometry(_d: DataPoint, _i: number): Record<string, unknown> | null {\n return null;\n }\n\n /**\n Produces a backend-agnostic scene graph for this shape's data, reusing the\n same accessors render() applies to the DOM. This is the migration seam toward\n the @d3plus/render pluggable backends; it has no effect on render().\n*/\n toScene(): GroupNode {\n let data: DataPoint[] & {key?: AccessorFn} = this._data;\n if (this._dataFilter)\n data = this._dataFilter(data) as DataPoint[] & {key?: AccessorFn};\n const children: SceneNode[] = [];\n // Collected background images, emitted below (after the geometry) as clipped,\n // transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a\n // truthy URL contributes one spec.\n const bgSpecs: BackgroundImageSpec[] = [];\n // A `sort` comparator becomes per-datum `z` ranks rather than a reorder of\n // `data`: the render backends sort each group's children ascending by `z`\n // (stably), so a lower rank paints first (behind) and a higher rank paints\n // last (on top) — the same back-to-front meaning `.sort()` has always had,\n // without disturbing the keyed data-join order that drives transitions.\n const rank = sortRanks(\n data,\n this.schema.sort as ((a: DataPoint, b: DataPoint) => number) | null,\n );\n data.forEach((d, i) => {\n const geom = this._sceneGeometry(d, i);\n if (!geom) return;\n const key = this._nestWrapper(this.schema.id)(d, i) as string | number;\n const datum = (d.__d3plusShape__ ? d.data : d) as DataPoint;\n const transform = this._sceneTransform(d, i);\n\n // Push the hit area (if any) before the geometry so it sits behind it.\n if (this.schema.hitArea) {\n const ha = hitAreaNode(\n this.schema.hitArea, d, i, this._aes(d, i), key, datum, this._name, transform,\n );\n // Share the datum's rank so the hit area stays paired just behind its\n // own geometry (equal `z`, kept in push order by the stable sort).\n if (ha) children.push(rank ? ({...ha, z: rank[i]} as SceneNode) : ha);\n }\n\n children.push({\n ...geom,\n key,\n datum,\n index: i,\n shapeType: this._name,\n paint: this._scenePaint(d, i),\n transform,\n aria: {\n role: strOrUndef(this._nestWrapper(this.schema.role)(d, i)),\n label: strOrUndef(this._nestWrapper(this.schema.ariaLabel)(d, i)),\n },\n ...(rank ? {z: rank[i]} : {}),\n } as unknown as SceneNode);\n // backgroundImage: collect a per-datum image (see backgroundImageLayout for\n // the cover/contain fit). The wrapping group carries the shape transform,\n // so the image box + clip stay in local space.\n const bg = this._nestWrapper(this.schema.backgroundImage)(d, i) as\n | string\n | false;\n if (bg) {\n const g = geom as Record<string, unknown>;\n // Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle\n // derive their layout from `d`/width/r directly.\n const needsPoints =\n typeof g.d !== \"string\" &&\n typeof g.width !== \"number\" &&\n typeof g.r !== \"number\";\n const points = needsPoints\n ? ((this._aes(d, i).points ?? []) as [number, number][])\n : [];\n const fit = this._nestWrapper(this.schema.backgroundImageFit)(d, i);\n const layout = backgroundImageLayout(\n g, points, fit === \"contain\" ? \"contain\" : \"cover\",\n );\n if (layout) {\n bgSpecs.push({\n key,\n index: i,\n datum,\n url: bg,\n box: layout.box,\n clip: layout.clip,\n preserveAspectRatio: layout.preserveAspectRatio,\n opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),\n transform,\n });\n }\n }\n });\n // Emit background images AFTER shape children so they paint above the\n // shape's fill — matches the DOM order where the <image> was\n // appended as a sibling of the shape.\n if (bgSpecs.length)\n children.push(...emitBackgroundImages(bgSpecs, rank, data.length));\n // NOTE: Labels are NOT pushed here. The canonical aggregation point is\n // `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`\n // AND `shape._labelClass.toScene()` independently. Pushing labels here\n // too would emit them twice in every chart that calls collectComputed\n // (Pie/Donut/Pack/Treemap/Network/Priestley/Radar/RadialMatrix/Geomap…).\n // Standalone shape.render() consumers (no collectComputed wrapper) get\n // labels through Shape.render's own SvgRenderer path below.\n return {type: \"group\", key: `${this._name}-group`, children};\n }\n\n render(callback?: () => void): this {\n // Populate the label TextBox so toScene() reads correct label data. The\n // label class is always in compute mode — the scene path materializes text.\n const lc = this._labelClass as unknown as {renderMode?: (m: string) => unknown};\n if (lc && typeof lc.renderMode === \"function\") lc.renderMode(\"compute\");\n // Apply Shape's labelConfig (fontColor, fontResize, padding, textAnchor,\n // verticalAlign, fontSize, …) to the underlying TextBox. Function\n // accessors receive the LABEL RECORD (with `d.data` = source\n // datum, `d.l` = which label index in a multi-label-per-datum\n // setup, `d.text` = label text, etc.). That gives consumers like\n // Treemap (two labels per cell — title + share %) the context to\n // vary anchor / color / etc. based on which label they're styling.\n // Shape's default `fontColor` uses `this.schema.fill(d, i)` — since\n // `fill` is the configPrep-wrapped accessor, it unwraps `d.data`\n // back to the source datum automatically before invoking the user\n // fill function.\n this._labelClass.config(this.schema.labelConfig as Record<string, unknown>);\n this._labelClass.data(this._buildLabelData());\n\n if (this.schema.renderMode === \"compute\") {\n // A Viz pipeline is driving this shape — Viz.renderScene composes the\n // whole chart's scene itself, so don't spin up our own SvgRenderer.\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n // Standalone shape rendering: route the shape's own toScene() through\n // SvgRenderer. Preserves `new Rect().render()` ergonomics with no\n // d3-selection DOM.\n if (this._select === undefined && typeof document !== \"undefined\") {\n const div = document.createElement(\"div\");\n div.style.cssText = \"display:block;\";\n document.body.appendChild(div);\n this.select(div);\n }\n\n if (this._select) {\n const sel = this._select;\n // `_select` is a D3Selection, but the standalone path historically also\n // accepted a raw element; handle both without widening to `any`.\n const node: Element | null =\n sel && typeof sel.node === \"function\"\n ? (sel.node() as Element | null)\n : (sel as unknown as Element | null);\n if (node) {\n const tag = (node.tagName || \"\").toLowerCase();\n const isSvg = tag === \"svg\";\n // Explicit numeric size first: an <svg>'s width/height attribute, or a\n // non-svg container's client box.\n const rawW = isSvg ? Number(node.getAttribute(\"width\")) : (node as HTMLElement).clientWidth;\n const rawH = isSvg ? Number(node.getAttribute(\"height\")) : (node as HTMLElement).clientHeight;\n // When that isn't a usable number — e.g. width=\"100%\" (Number → NaN)\n // or a 0-size box — measure the container's real rendered size,\n // walking up to the first constrained ancestor. Only fall back to the\n // static 400x300 when nothing is measurable (e.g. no layout in jsdom).\n const [measuredW, measuredH] = rawW && rawH ? [rawW, rawH] : getSize(node as HTMLElement);\n const width = rawW || measuredW || 400;\n const height = rawH || measuredH || 300;\n // Combine the shape's scene + label children. toScene() deliberately\n // omits labels (collectComputed is the canonical aggregator for the\n // chart pipeline); for the standalone render() path we add them here\n // so `new Rect().data(...).render()` still produces label text.\n const shapeGroup = this.toScene();\n const labelChildren: SceneNode[] = [];\n if (\n this._labelClass &&\n typeof (this._labelClass as {toScene?: unknown}).toScene === \"function\" &&\n this._labelClass._data &&\n this._labelClass._data.length\n ) {\n labelChildren.push(\n ...(this._labelClass.toScene().children as SceneNode[]),\n );\n }\n const root: GroupNode = {\n ...shapeGroup,\n children: [...shapeGroup.children, ...labelChildren],\n };\n const scene = {root, width, height};\n // Tear down any previous SvgRenderer so its DOM listeners + timers\n // are cleared instead of leaking on every re-render.\n const prev = this._sceneRenderer;\n if (prev && typeof prev.destroy === \"function\") prev.destroy();\n // Caller's element is preserved (downstream selectors still find it);\n // we mount SvgRenderer INSIDE it. When `node` is a <g> the result is\n // a nested <svg>-in-<g>, which is valid SVG but visually unusual —\n // chart code reaches this path only via the Box/Whisker full-mode\n // fallback, which is not the recommended flow (compute mode is).\n // Only wipe children when this is the FIRST time we're mounting\n // here — re-renders into the same node would otherwise destroy any\n // labels/auxiliary DOM the caller put alongside.\n if (!prev) {\n while (node.firstChild) node.removeChild(node.firstChild);\n }\n const renderer = new SvgRenderer();\n renderer.mount({container: node, width, height});\n renderer.drawScene(scene);\n this._sceneRenderer = renderer;\n }\n }\n\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n /**\n The active callback function for highlighting shapes.\n*/\n active(): ((d: DataPoint, i: number) => boolean) | null;\n active(_: ((d: DataPoint, i: number) => boolean) | null): this;\n active(\n _?: ((d: DataPoint, i: number) => boolean) | null,\n ): ((d: DataPoint, i: number) => boolean) | null | this {\n if (!arguments.length || _ === undefined) return this.schema.active;\n this.schema.active = _;\n // v4: active/hover visuals come from the scene path's paint recomputation\n // on the next render(); no DOM mutation here.\n return this;\n }\n\n /**\n The style to apply to active shapes.\n*/\n activeStyle(): Record<string, unknown>;\n activeStyle(_: Record<string, unknown>): this;\n activeStyle(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.activeStyle = assign({}, this.schema.activeStyle, _!)),\n this)\n : this.schema.activeStyle;\n }\n\n /**\n The data array used to create shapes. A shape will be drawn for each object in the array.\n*/\n data(): DataPoint[];\n data(_: DataPoint[]): this;\n data(_?: DataPoint[]): DataPoint[] | this {\n return arguments.length ? ((this._data = _!), this) : this._data;\n }\n\n /**\n The hover callback function for highlighting shapes on mouseover.\n*/\n hover(): ((d: DataPoint, i: number) => boolean) | null;\n hover(_: ((d: DataPoint, i: number) => boolean) | null): this;\n hover(\n _?: ((d: DataPoint, i: number) => boolean) | null,\n ): ((d: DataPoint, i: number) => boolean) | null | this {\n if (!arguments.length || _ === void 0) return this.schema.hover;\n this.schema.hover = _;\n // v4: hover dim comes from the scene path's paint recomputation; no DOM here.\n return this;\n }\n\n /**\n The style to apply to hovered shapes.\n*/\n hoverStyle(): Record<string, unknown>;\n hoverStyle(_: Record<string, unknown>): this;\n hoverStyle(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.hoverStyle = assign({}, this.schema.hoverStyle, _!)), this)\n : this.schema.hoverStyle;\n }\n\n /**\n A pass-through to the config method of the TextBox class used to create a shape's labels.\n*/\n labelConfig(): Record<string, unknown>;\n labelConfig(_: Record<string, unknown>): this;\n labelConfig(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.labelConfig = assign(this.schema.labelConfig, _!)), this)\n : this.schema.labelConfig;\n }\n\n /**\n The SVG container element as a d3 selector or DOM element.\n*/\n select(): D3Selection;\n select(_: string | HTMLElement | SVGElement | null): this;\n select(_?: string | HTMLElement | SVGElement | null): D3Selection | this {\n return arguments.length\n ? ((this._select = select(_ as string) as unknown as D3Selection), this)\n : this._select;\n }\n\n /**\n A comparator function used to sort shapes for layering order.\n*/\n sort(): ((a: DataPoint, b: DataPoint) => number) | null;\n sort(_: ((a: DataPoint, b: DataPoint) => number) | null): this;\n sort(\n _?: ((a: DataPoint, b: DataPoint) => number) | null,\n ): ((a: DataPoint, b: DataPoint) => number) | null | this {\n return arguments.length\n ? ((this.schema.sort = _ ?? null), this)\n : this.schema.sort;\n }\n\n /**\n A series of global texture methods to be used for all textures (ie. `{stroke: \"darkorange\", strokeWidth: 2}`).\n*/\n textureDefault(): Record<string, unknown>;\n textureDefault(_: Record<string, unknown>): this;\n textureDefault(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.textureDefault = assign(this.schema.textureDefault, _!)),\n this)\n : this.schema.textureDefault;\n }\n\n /**\n Narrowed `.config()` for Shape. Inherited surface from\n `BaseClass.config()`; the override exists only to surface per-shape\n keys (e.g. `width`/`height` for Rect) in autocomplete + type checks.\n */\n config(): BaseShapeConfig;\n config(_: Partial<BaseShapeConfig>): this;\n config(_?: Partial<BaseShapeConfig>): BaseShapeConfig | this {\n if (!arguments.length) return super.config() as BaseShapeConfig;\n super.config(_ as D3plusConfig);\n return this;\n }\n}\n"],"names":["color","select","colorContrast","assign","getSize","isObject","SvgRenderer","TextBox","accessor","BaseClass","constant","installFluent","buildLabelData","hitAreaNode","numOrUndef","v","n","Number","isFinite","undefined","strOrUndef","String","parseDash","parts","split","map","filter","length","backgroundImageLayout","emitBackgroundImages","sortRanks","shapeSchema","key","coerce","default","d","i","id","Shape","tagName","_data","_labelClass","_name","_tagName","_textureDefs","_select","_transition","_group","_update","_enter","_exit","_hoverGroup","_activeGroup","_path","_sceneRenderer","schema","stroke","c","fill","darker","formatHex","activeStyle","includes","col","s","strokeWidth","hoverStyle","labelConfig","fontColor","fontOpacity","opacity","fontResize","fontMax","fontMin","fontSize","padding","textAnchor","verticalAlign","textureDefault","_aes","_d","_i","_getTextureKey","textureVal","texture","styleLogic","_","nested","values","indexOf","fallback","background","pathNames","orientation","retObj","size","JSON","stringify","_nestWrapper","method","__d3plusShape__","data","_buildLabelData","dataFilter","_dataFilter","bind","label","labelBounds","x","y","aes","rotate","_styleVal","fn","first","_sceneTransform","wrapped","Boolean","dd","ii","translate","tx","ty","scale","_scenePaint","textureKey","fillOpacity","strokeOpacity","strokeDasharray","strokeLinecap","vectorEffect","shapeRendering","_sceneGeometry","toScene","children","bgSpecs","rank","sort","forEach","geom","datum","transform","hitArea","ha","push","z","index","shapeType","paint","aria","role","ariaLabel","bg","backgroundImage","g","needsPoints","width","r","points","fit","backgroundImageFit","layout","url","box","clip","preserveAspectRatio","type","render","callback","lc","renderMode","config","setTimeout","document","div","createElement","style","cssText","body","appendChild","sel","node","tag","toLowerCase","isSvg","rawW","getAttribute","clientWidth","rawH","clientHeight","measuredW","measuredH","height","shapeGroup","labelChildren","root","scene","prev","destroy","firstChild","removeChild","renderer","mount","container","drawScene","active","arguments","hover"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AI,CAACkB,OAAO,GAAG5C,OAAOqF,IAAyC,IAAI,AAAD,IACpE,IAAI,CAACzC,OAAO;YAClB;;;YAOA4F,KAAAA;mBAAAA,SAAAA,KACEnD,CAAmD;gBAEnD,OAAOwH,UAAUnL,MAAM,GAClB,CAAA,AAAC,IAAI,CAAC4B,MAAM,CAACkF,IAAI,GAAGnD,cAAAA,eAAAA,IAAK,MAAO,IAAI,AAAD,IACpC,IAAI,CAAC/B,MAAM,CAACkF,IAAI;YACtB;;;YAOA3D,KAAAA;mBAAAA,SAAAA,eAAeQ,CAA2B;gBACxC,OAAOwH,UAAUnL,MAAM,GAClB,CAAA,AAAC,IAAI,CAAC4B,MAAM,CAACuB,cAAc,GAAG3E,OAAO,IAAI,CAACoD,MAAM,CAACuB,cAAc,EAAEQ,IAClE,IAAI,AAAD,IACH,IAAI,CAAC/B,MAAM,CAACuB,cAAc;YAChC;;;YASA6F,KAAAA;mBAAAA,SAAAA,OAAOrF,CAA4B;gBACjC,IAAI,CAACwH,UAAUnL,MAAM,EAAE,OAAO,uBA1nBbW,kBA0nBmBqI,UAAN,IAAK;gBACnC,uBA3nBiBrI,kBA2nBXqI,UAAN,IAAK,aAAQrF;gBACb,OAAO,IAAI;YACb;;;WA7nBmBhD;EAAc7B;AAHnC;;AAEA,GACA,SAAqB6B,mBA8nBpB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/shapes/Shape.ts"],"sourcesContent":["import {color} from \"d3-color\";\nimport {select} from \"d3-selection\";\nimport {transition} from \"d3-transition\";\n\nimport {colorContrast} from \"@d3plus/color\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {assign, getSize, isObject} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\n\nimport {SvgRenderer} from \"@d3plus/render\";\nimport type {GroupNode, Paint, SceneNode, Transform} from \"@d3plus/render\";\n\nimport {TextBox} from \"../components/index.js\";\nimport {accessor, BaseClass, constant} from \"../utils/index.js\";\nimport type {AccessorFn, D3plusConfig} from \"../utils/index.js\";\nimport {installFluent} from \"../fluent.js\";\nimport type {ConfigField} from \"../fluent.js\";\nimport {buildLabelData} from \"./buildLabelData.js\";\nimport {hitAreaNode} from \"./hitAreaNode.js\";\nimport {interactionPoints} from \"./interactionPoints.js\";\nimport type {BaseShapeConfig} from \"./shapeConfig.js\";\n\n/** Coerces a value to a finite number, or undefined. @private */\nexport function numOrUndef(v: unknown): number | undefined {\n const n = Number(v);\n return Number.isFinite(n) ? n : undefined;\n}\n\n/** Returns a non-empty string, or undefined. @private */\nexport function strOrUndef(v: unknown): string | undefined {\n return v == null || v === \"\" ? undefined : String(v);\n}\n\n/** Parses an SVG stroke-dasharray value into an array of numbers. @private */\nexport function parseDash(v: unknown): number[] | undefined {\n if (v == null || v === \"none\" || v === \"\") return undefined;\n if (typeof v === \"number\") return [v];\n const parts = String(v)\n .split(/[\\s,]+/)\n .map(Number)\n .filter(n => Number.isFinite(n));\n return parts.length ? parts : undefined;\n}\n\nexport interface ShapeAes {\n width?: number;\n height?: number;\n points?: [number, number][];\n r?: number;\n x?: number;\n y?: number;\n}\n\n\nimport {\n backgroundImageLayout,\n emitBackgroundImages,\n sortRanks,\n type BackgroundImageSpec,\n} from \"./sceneSort.js\";\n\n/** Shape's fluent accessor schema. Config storage lives on `this.schema.<key>`. */\nconst shapeSchema: ConfigField[] = [\n {key: \"activeOpacity\", coerce: \"identity\", default: 0.25},\n {key: \"ariaLabel\", coerce: \"const\", default: constant(\"\")},\n {key: \"backgroundImage\", coerce: \"const\", default: constant(false)},\n {key: \"backgroundImageFit\", coerce: \"const\", default: constant(\"cover\")},\n {key: \"discrete\", coerce: \"identity\"},\n {key: \"duration\", coerce: \"identity\", default: 600},\n {key: \"fill\", coerce: \"const\", default: constant(\"black\")},\n {key: \"fillOpacity\", coerce: \"const\", default: constant(1)},\n {key: \"hitArea\", coerce: \"const\"},\n {key: \"hoverOpacity\", coerce: \"identity\", default: 0.5},\n {\n key: \"id\",\n coerce: \"accessor\",\n default: (d: DataPoint, i?: number) => (d.id !== void 0 ? d.id : i!),\n },\n {key: \"label\", coerce: \"const\", default: constant(false)},\n {key: \"labelBounds\", coerce: \"const\"},\n {key: \"opacity\", coerce: \"const\", default: constant(1)},\n {key: \"pointerEvents\", coerce: \"const\", default: constant(\"visiblePainted\")},\n {key: \"renderMode\", coerce: \"identity\", default: \"full\"},\n {key: \"role\", coerce: \"const\", default: constant(\"presentation\")},\n {key: \"rotate\", coerce: \"const\", default: constant(0)},\n {key: \"rx\", coerce: \"const\", default: constant(0)},\n {key: \"ry\", coerce: \"const\", default: constant(0)},\n {key: \"scale\", coerce: \"const\", default: constant(1)},\n {key: \"shapeRendering\", coerce: \"const\", default: constant(\"geometricPrecision\")},\n {key: \"stroke\", coerce: \"const\"},\n {key: \"strokeDasharray\", coerce: \"const\", default: constant(\"0\")},\n {key: \"strokeLinecap\", coerce: \"const\", default: constant(\"butt\")},\n {key: \"strokeOpacity\", coerce: \"const\", default: constant(1)},\n {key: \"strokeWidth\", coerce: \"const\", default: constant(0)},\n {key: \"textAnchor\", coerce: \"const\", default: constant(\"start\")},\n {key: \"texture\", coerce: \"const\", default: constant(false)},\n {key: \"vectorEffect\", coerce: \"const\", default: constant(\"non-scaling-stroke\")},\n {key: \"verticalAlign\", coerce: \"const\", default: constant(\"top\")},\n // \"accessor\" (not \"const\"): a string names a data key (`.x(\"year\")`), a\n // number is a constant (`.x(50)`), and a function passes through — so a\n // standalone shape given string accessors (as the pipeline never does, but\n // direct users do) reads the field instead of treating \"x\" as the literal.\n {key: \"x\", coerce: \"accessor\", default: accessor(\"x\", 0)},\n {key: \"y\", coerce: \"accessor\", default: accessor(\"y\", 0)},\n];\n\n/**\n An abstracted class for generating shapes.\n*/\nexport default class Shape extends BaseClass {\n // installFluent generates the config accessors (fill, x, id, …) at runtime;\n // the index signature lets callers reach them through the type.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any;\n\n _data: DataPoint[];\n _labelClass: TextBox;\n _name: string;\n _tagName: string;\n _textureDefs: Record<string, Record<string, unknown>>;\n _select!: D3Selection;\n _transition!: ReturnType<typeof transition>;\n /** @param data The raw data array to filter. */\n _dataFilter?(data: DataPoint[]): DataPoint[];\n _group!: D3Selection;\n _update!: D3Selection;\n _enter!: D3Selection;\n _exit!: D3Selection;\n _hoverGroup!: D3Selection;\n _activeGroup!: D3Selection;\n _path!: Record<string, unknown>;\n /** SvgRenderer mounted by the standalone `render()` path; reused across redraws. */\n _sceneRenderer?: SvgRenderer;\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n*/\n constructor(tagName: string = \"g\") {\n super();\n\n installFluent(this, shapeSchema);\n\n this._data = [];\n this._labelClass = new TextBox();\n this._name = \"Shape\";\n this._tagName = tagName;\n this._textureDefs = {};\n\n // stroke defaults to a darker shade of fill — closes over `this.schema`\n // so it tracks the current fill accessor. A fill that doesn't parse as a\n // color (e.g. \"none\"/\"transparent\", a gradient token) has no darker shade,\n // so fall back to the fill value itself.\n this.schema.stroke = (d: DataPoint, i?: number) => {\n const c = color(this.schema.fill(d, i) as string);\n return c ? c.darker(1).formatHex() : (this.schema.fill(d, i) as string);\n };\n\n this.schema.activeStyle = {\n stroke: (d: DataPoint, i: number) => {\n let c = this.schema.fill(d, i) as string;\n if ([\"transparent\", \"none\"].includes(c))\n c = this.schema.stroke(d, i) as string;\n const col = color(c);\n return col ? col.darker(1) : c;\n },\n \"stroke-width\": (d: DataPoint, i: number) => {\n const s = (this.schema.strokeWidth(d, i) as number) || 1;\n return s * 3;\n },\n };\n this.schema.hoverStyle = {\n stroke: (d: DataPoint, i: number) => {\n let c = this.schema.fill(d, i) as string;\n if ([\"transparent\", \"none\"].includes(c))\n c = this.schema.stroke(d, i) as string;\n const col = color(c);\n return col ? col.darker(0.5) : c;\n },\n \"stroke-width\": (d: DataPoint, i: number) => {\n const s = (this.schema.strokeWidth(d, i) as number) || 1;\n return s * 2;\n },\n };\n // Shape's label defaults. These are pushed to `_labelClass` via\n // `_labelClass.config(this.schema.labelConfig)` in render() so the\n // TextBox actually picks them up.\n // textAnchor defaults to \"start\" (left-aligned) — Treemap, Pie,\n // etc. rely on this. Bar overrides to \"middle\" in its constructor.\n this.schema.labelConfig = {\n fontColor: (d: DataPoint, i: number) =>\n colorContrast(this.schema.fill(d, i) as string),\n // Fade labels with their shape's opacity (e.g. an axis tick label hides\n // when `shapeConfig.opacity` is 0). Reads `this.schema.opacity` live —\n // like `fontColor` reads `fill` — which unwraps nested label data.\n fontOpacity: (d: DataPoint, i: number) =>\n this.schema.opacity(d, i) as number,\n fontResize: true,\n fontMax: 50,\n fontMin: 8,\n fontSize: 12,\n padding: 5,\n textAnchor: \"start\",\n verticalAlign: \"top\",\n };\n this.schema.textureDefault = {};\n }\n\n /**\n Given a specific data point and index, returns the aesthetic properties of the shape.\n @param data point*\n @param index @private\n*/\n _aes(_d?: DataPoint, _i?: number): ShapeAes {\n return {};\n }\n\n\n /**\n Returns a full JSON string of the texture config for a given data point.\n\n @private\n*/\n _getTextureKey(d: DataPoint, i: number): string | false {\n const textureVal: unknown = this.schema.texture(d, i);\n if (!textureVal) return false;\n\n /**\n Determines whether a shape is a nested collection of data points, and uses the appropriate data and index for the given function context.\n @private\n*/\n const styleLogic = (_: unknown): unknown => {\n return typeof _ !== \"function\"\n ? _\n : d.nested && d.key && d.values\n ? (_ as AccessorFn)(\n (d.values as unknown as DataPoint[])[0],\n this._data.indexOf((d.values as unknown as DataPoint[])[0]),\n )\n : (_ as AccessorFn)(d, i);\n };\n\n const fallback = this.schema.textureDefault;\n\n let texture: Record<string, unknown>;\n if (!isObject(textureVal))\n texture = {texture: textureVal} as Record<string, unknown>;\n else texture = textureVal as Record<string, unknown>;\n if (!texture.background) texture.background = styleLogic(this.schema.fill);\n if (!texture.stroke && !fallback.stroke)\n texture.stroke = styleLogic(this.schema.stroke);\n const pathNames = [\n \"squares\",\n \"nylon\",\n \"waves\",\n \"woven\",\n \"crosses\",\n \"caps\",\n \"hexagons\",\n ];\n if (\n pathNames.includes(texture.texture as string) ||\n typeof texture.texture === \"function\"\n ) {\n texture.d = texture.texture;\n texture.texture = \"paths\";\n } else if (texture.texture === \"grid\") {\n if (!texture.orientation && !fallback.orientation)\n texture.orientation = [\"vertical\", \"horizontal\"];\n texture.texture = \"lines\";\n }\n if (!texture.fill && texture.texture !== \"paths\")\n texture.fill = texture.stroke;\n const retObj = assign({}, fallback, texture);\n if (typeof retObj.d === \"function\") {\n retObj.d = retObj.d(retObj.size || 20);\n }\n return JSON.stringify(retObj);\n }\n\n /**\n Checks for nested data and uses the appropriate variables for accessor functions.\n @param elem @private\n*/\n _nestWrapper(\n method: AccessorFn,\n ): (d: DataPoint, i: number) => DataPoint[keyof DataPoint] {\n return (d: DataPoint, i: number) =>\n method(\n d.__d3plusShape__ ? (d.data as DataPoint) : d,\n d.__d3plusShape__ ? (d.i as number) : i,\n );\n }\n\n\n /**\n Adds labels to each shape group.\n @private\n*/\n _buildLabelData(): DataPoint[] {\n // Delegates to the pure `buildLabelData()` helper. The helper\n // takes the same inputs `this` exposes but works without a Shape\n // instance — emit functions or other callers that need only the\n // label-record layout can call it directly without instantiating\n // a Shape in compute mode.\n // All Shape methods bound to `this` before handing them to the pure\n // helper — subclasses (e.g. Line._dataFilter) reach for `this.schema.id`\n // and friends inside their bodies.\n return buildLabelData({\n data: this._data,\n dataFilter: this._dataFilter ? this._dataFilter.bind(this) : undefined,\n label: this.schema.label,\n labelBounds: this.schema.labelBounds\n ? this.schema.labelBounds.bind(this)\n : undefined,\n x: this.schema.x,\n y: this.schema.y,\n aes: this._aes.bind(this),\n rotate: this.schema.rotate,\n id: this.schema.id,\n });\n }\n\n\n /**\n Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.\n @param callback Optional callback invoked after rendering completes.\n*/\n /**\n Resolves a style accessor. For a nested shape (Line/Area) the accessor gets\n the merged aggregate `d.data`/`d.i` — matching `_nestWrapper` + scene datum.\n @private\n*/\n _styleVal(fn: unknown, d: DataPoint, i: number): unknown {\n if (typeof fn !== \"function\") return fn;\n if (d.nested && d.key && d.values)\n return (fn as AccessorFn)(d.data as DataPoint, d.i as number);\n return (fn as AccessorFn)(d, i);\n }\n\n /**\n Builds the resolved Transform for a data point, mirroring _applyTransform.\n @private\n*/\n _sceneTransform(d: DataPoint, i: number): Transform {\n const wrapped = Boolean(d.__d3plusShape__);\n const dd = (wrapped ? d.data : d) as DataPoint;\n const ii = wrapped ? (d.i as number) : i;\n let x: number, y: number;\n if (wrapped && d.translate) {\n const [tx, ty] = String(d.translate).split(\",\").map(Number);\n x = tx;\n y = ty;\n } else {\n x = Number(this.schema.x(dd, ii));\n y = Number(this.schema.y(dd, ii));\n }\n const scale =\n wrapped && d.scale !== undefined\n ? Number(d.scale)\n : Number(this.schema.scale(dd, ii));\n const rotate =\n wrapped && d.rotate !== undefined\n ? Number(d.rotate)\n : Number(this.schema.rotate((d.data || d) as DataPoint, ii));\n return {x, y, scale, rotate};\n }\n\n /**\n Builds the resolved Paint for a data point, mirroring _applyStyle.\n Texture fills are encoded as a stable \"pattern:<key>\" token at this\n layer; the backend renderers (`SvgRenderer._resolveFill`,\n `CanvasRenderer._resolveFill`) materialize them into a real SVG\n pattern or a Canvas image pattern. The two-stage resolve is\n intentional — Shapes stay backend-free, and texture\n materialization happens once per renderer instead of per-shape.\n @private\n*/\n _scenePaint(d: DataPoint, i: number): Paint {\n // A texture resolves to a stable \"pattern:<key>\" token (the same JSON config\n // render() uses); each backend materializes or degrades it.\n const textureKey = this._getTextureKey(d, i);\n return {\n fill: textureKey\n ? `pattern:${textureKey}`\n : strOrUndef(this._styleVal(this.schema.fill, d, i)),\n fillOpacity: numOrUndef(this._styleVal(this.schema.fillOpacity, d, i)),\n stroke: strOrUndef(this._styleVal(this.schema.stroke, d, i)),\n strokeWidth: numOrUndef(this._styleVal(this.schema.strokeWidth, d, i)),\n strokeOpacity: numOrUndef(this._styleVal(this.schema.strokeOpacity, d, i)),\n strokeDasharray: parseDash(\n this._styleVal(this.schema.strokeDasharray, d, i),\n ),\n strokeLinecap: strOrUndef(\n this._styleVal(this.schema.strokeLinecap, d, i),\n ) as Paint[\"strokeLinecap\"],\n vectorEffect: strOrUndef(\n this._styleVal(this.schema.vectorEffect, d, i),\n ) as Paint[\"vectorEffect\"],\n shapeRendering: strOrUndef(\n this._nestWrapper(this.schema.shapeRendering)(d, i),\n ),\n opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),\n };\n }\n\n /**\n Returns the geometry-specific scene fields for a data point. Overridden by\n each shape subclass; the base provides none.\n @private\n*/\n _sceneGeometry(_d: DataPoint, _i: number): Record<string, unknown> | null {\n return null;\n }\n\n /**\n Produces a backend-agnostic scene graph for this shape's data, reusing the\n same accessors render() applies to the DOM. This is the migration seam toward\n the @d3plus/render pluggable backends; it has no effect on render().\n*/\n toScene(): GroupNode {\n let data: DataPoint[] & {key?: AccessorFn} = this._data;\n if (this._dataFilter)\n data = this._dataFilter(data) as DataPoint[] & {key?: AccessorFn};\n const children: SceneNode[] = [];\n // Collected background images, emitted below (after the geometry) as clipped,\n // transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a\n // truthy URL contributes one spec.\n const bgSpecs: BackgroundImageSpec[] = [];\n // A `sort` comparator becomes per-datum `z` ranks rather than a reorder of\n // `data`: the render backends sort each group's children ascending by `z`\n // (stably), so a lower rank paints first (behind) and a higher rank paints\n // last (on top) — the same back-to-front meaning `.sort()` has always had,\n // without disturbing the keyed data-join order that drives transitions.\n const rank = sortRanks(\n data,\n this.schema.sort as ((a: DataPoint, b: DataPoint) => number) | null,\n );\n data.forEach((d, i) => {\n const geom = this._sceneGeometry(d, i);\n if (!geom) return;\n const key = this._nestWrapper(this.schema.id)(d, i) as string | number;\n const datum = (d.__d3plusShape__ ? d.data : d) as DataPoint;\n const transform = this._sceneTransform(d, i);\n\n // Per-point positions (Line/Area) shared by the geometry and its hit area\n // so a hover anywhere on either resolves to the nearest point.\n const iPoints = interactionPoints(d, this.schema.x, this.schema.y, this.schema.defined);\n // Push the hit area (if any) before the geometry so it sits behind it.\n // Line's is a fat path built from the geometry `d`; Bar/legend etc. a rect.\n if (this.schema.hitArea) {\n const ha = hitAreaNode(this.schema.hitArea, d, i, this._aes(d, i), key, datum, this._name, transform, geom.d as string);\n // Share the datum's rank so the hit area stays paired just behind its\n // own geometry (equal `z`, kept in push order by the stable sort).\n if (ha) children.push(rank ? ({...ha, ...iPoints, z: rank[i]} as SceneNode) : ({...ha, ...iPoints} as SceneNode));\n }\n\n children.push({\n ...geom,\n key,\n datum,\n index: i,\n shapeType: this._name,\n paint: this._scenePaint(d, i),\n transform,\n aria: {\n role: strOrUndef(this._nestWrapper(this.schema.role)(d, i)),\n label: strOrUndef(this._nestWrapper(this.schema.ariaLabel)(d, i)),\n },\n ...iPoints,\n ...(rank ? {z: rank[i]} : {}),\n } as unknown as SceneNode);\n // backgroundImage: collect a per-datum image (see backgroundImageLayout for\n // the cover/contain fit). The wrapping group carries the shape transform,\n // so the image box + clip stay in local space.\n const bg = this._nestWrapper(this.schema.backgroundImage)(d, i) as\n | string\n | false;\n if (bg) {\n const g = geom as Record<string, unknown>;\n // Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle\n // derive their layout from `d`/width/r directly.\n const needsPoints =\n typeof g.d !== \"string\" &&\n typeof g.width !== \"number\" &&\n typeof g.r !== \"number\";\n const points = needsPoints\n ? ((this._aes(d, i).points ?? []) as [number, number][])\n : [];\n const fit = this._nestWrapper(this.schema.backgroundImageFit)(d, i);\n const layout = backgroundImageLayout(\n g, points, fit === \"contain\" ? \"contain\" : \"cover\",\n );\n if (layout) {\n bgSpecs.push({\n key,\n index: i,\n datum,\n url: bg,\n box: layout.box,\n clip: layout.clip,\n preserveAspectRatio: layout.preserveAspectRatio,\n opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),\n transform,\n });\n }\n }\n });\n // Emit background images AFTER shape children so they paint above the\n // shape's fill — matches the DOM order where the <image> was\n // appended as a sibling of the shape.\n if (bgSpecs.length)\n children.push(...emitBackgroundImages(bgSpecs, rank, data.length));\n // NOTE: Labels are NOT pushed here. The canonical aggregation point is\n // `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`\n // AND `shape._labelClass.toScene()` independently. Pushing labels here\n // too would emit them twice in every chart that calls collectComputed\n // (Pie/Donut/Pack/Treemap/Network/Priestley/Radar/RadialMatrix/Geomap…).\n // Standalone shape.render() consumers (no collectComputed wrapper) get\n // labels through Shape.render's own SvgRenderer path below.\n return {type: \"group\", key: `${this._name}-group`, children};\n }\n\n render(callback?: () => void): this {\n // Populate the label TextBox so toScene() reads correct label data. The\n // label class is always in compute mode — the scene path materializes text.\n const lc = this._labelClass as unknown as {renderMode?: (m: string) => unknown};\n if (lc && typeof lc.renderMode === \"function\") lc.renderMode(\"compute\");\n // Apply Shape's labelConfig (fontColor, fontResize, padding, textAnchor,\n // verticalAlign, fontSize, …) to the underlying TextBox. Function\n // accessors receive the LABEL RECORD (with `d.data` = source\n // datum, `d.l` = which label index in a multi-label-per-datum\n // setup, `d.text` = label text, etc.). That gives consumers like\n // Treemap (two labels per cell — title + share %) the context to\n // vary anchor / color / etc. based on which label they're styling.\n // Shape's default `fontColor` uses `this.schema.fill(d, i)` — since\n // `fill` is the configPrep-wrapped accessor, it unwraps `d.data`\n // back to the source datum automatically before invoking the user\n // fill function.\n this._labelClass.config(this.schema.labelConfig as Record<string, unknown>);\n this._labelClass.data(this._buildLabelData());\n\n if (this.schema.renderMode === \"compute\") {\n // A Viz pipeline is driving this shape — Viz.renderScene composes the\n // whole chart's scene itself, so don't spin up our own SvgRenderer.\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n // Standalone shape rendering: route the shape's own toScene() through\n // SvgRenderer. Preserves `new Rect().render()` ergonomics with no\n // d3-selection DOM.\n if (this._select === undefined && typeof document !== \"undefined\") {\n const div = document.createElement(\"div\");\n div.style.cssText = \"display:block;\";\n document.body.appendChild(div);\n this.select(div);\n }\n\n if (this._select) {\n const sel = this._select;\n // `_select` is a D3Selection, but the standalone path historically also\n // accepted a raw element; handle both without widening to `any`.\n const node: Element | null =\n sel && typeof sel.node === \"function\"\n ? (sel.node() as Element | null)\n : (sel as unknown as Element | null);\n if (node) {\n const tag = (node.tagName || \"\").toLowerCase();\n const isSvg = tag === \"svg\";\n // Explicit numeric size first: an <svg>'s width/height attribute, or a\n // non-svg container's client box.\n const rawW = isSvg ? Number(node.getAttribute(\"width\")) : (node as HTMLElement).clientWidth;\n const rawH = isSvg ? Number(node.getAttribute(\"height\")) : (node as HTMLElement).clientHeight;\n // When that isn't a usable number — e.g. width=\"100%\" (Number → NaN)\n // or a 0-size box — measure the container's real rendered size,\n // walking up to the first constrained ancestor. Only fall back to the\n // static 400x300 when nothing is measurable (e.g. no layout in jsdom).\n const [measuredW, measuredH] = rawW && rawH ? [rawW, rawH] : getSize(node as HTMLElement);\n const width = rawW || measuredW || 400;\n const height = rawH || measuredH || 300;\n // Combine the shape's scene + label children. toScene() deliberately\n // omits labels (collectComputed is the canonical aggregator for the\n // chart pipeline); for the standalone render() path we add them here\n // so `new Rect().data(...).render()` still produces label text.\n const shapeGroup = this.toScene();\n const labelChildren: SceneNode[] = [];\n if (\n this._labelClass &&\n typeof (this._labelClass as {toScene?: unknown}).toScene === \"function\" &&\n this._labelClass._data &&\n this._labelClass._data.length\n ) {\n labelChildren.push(\n ...(this._labelClass.toScene().children as SceneNode[]),\n );\n }\n const root: GroupNode = {\n ...shapeGroup,\n children: [...shapeGroup.children, ...labelChildren],\n };\n const scene = {root, width, height};\n // Tear down any previous SvgRenderer so its DOM listeners + timers\n // are cleared instead of leaking on every re-render.\n const prev = this._sceneRenderer;\n if (prev && typeof prev.destroy === \"function\") prev.destroy();\n // Caller's element is preserved (downstream selectors still find it);\n // we mount SvgRenderer INSIDE it. When `node` is a <g> the result is\n // a nested <svg>-in-<g>, which is valid SVG but visually unusual —\n // chart code reaches this path only via the Box/Whisker full-mode\n // fallback, which is not the recommended flow (compute mode is).\n // Only wipe children when this is the FIRST time we're mounting\n // here — re-renders into the same node would otherwise destroy any\n // labels/auxiliary DOM the caller put alongside.\n if (!prev) {\n while (node.firstChild) node.removeChild(node.firstChild);\n }\n const renderer = new SvgRenderer();\n renderer.mount({container: node, width, height});\n renderer.drawScene(scene);\n this._sceneRenderer = renderer;\n }\n }\n\n if (callback) setTimeout(callback, 0);\n return this;\n }\n\n /**\n The active callback function for highlighting shapes.\n*/\n active(): ((d: DataPoint, i: number) => boolean) | null;\n active(_: ((d: DataPoint, i: number) => boolean) | null): this;\n active(\n _?: ((d: DataPoint, i: number) => boolean) | null,\n ): ((d: DataPoint, i: number) => boolean) | null | this {\n if (!arguments.length || _ === undefined) return this.schema.active;\n this.schema.active = _;\n // v4: active/hover visuals come from the scene path's paint recomputation\n // on the next render(); no DOM mutation here.\n return this;\n }\n\n /**\n The style to apply to active shapes.\n*/\n activeStyle(): Record<string, unknown>;\n activeStyle(_: Record<string, unknown>): this;\n activeStyle(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.activeStyle = assign({}, this.schema.activeStyle, _!)),\n this)\n : this.schema.activeStyle;\n }\n\n /**\n The data array used to create shapes. A shape will be drawn for each object in the array.\n*/\n data(): DataPoint[];\n data(_: DataPoint[]): this;\n data(_?: DataPoint[]): DataPoint[] | this {\n return arguments.length ? ((this._data = _!), this) : this._data;\n }\n\n /**\n The hover callback function for highlighting shapes on mouseover.\n*/\n hover(): ((d: DataPoint, i: number) => boolean) | null;\n hover(_: ((d: DataPoint, i: number) => boolean) | null): this;\n hover(\n _?: ((d: DataPoint, i: number) => boolean) | null,\n ): ((d: DataPoint, i: number) => boolean) | null | this {\n if (!arguments.length || _ === void 0) return this.schema.hover;\n this.schema.hover = _;\n // v4: hover dim comes from the scene path's paint recomputation; no DOM here.\n return this;\n }\n\n /**\n The style to apply to hovered shapes.\n*/\n hoverStyle(): Record<string, unknown>;\n hoverStyle(_: Record<string, unknown>): this;\n hoverStyle(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.hoverStyle = assign({}, this.schema.hoverStyle, _!)), this)\n : this.schema.hoverStyle;\n }\n\n /**\n A pass-through to the config method of the TextBox class used to create a shape's labels.\n*/\n labelConfig(): Record<string, unknown>;\n labelConfig(_: Record<string, unknown>): this;\n labelConfig(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.labelConfig = assign(this.schema.labelConfig, _!)), this)\n : this.schema.labelConfig;\n }\n\n /**\n The SVG container element as a d3 selector or DOM element.\n*/\n select(): D3Selection;\n select(_: string | HTMLElement | SVGElement | null): this;\n select(_?: string | HTMLElement | SVGElement | null): D3Selection | this {\n return arguments.length\n ? ((this._select = select(_ as string) as unknown as D3Selection), this)\n : this._select;\n }\n\n /**\n A comparator function used to sort shapes for layering order.\n*/\n sort(): ((a: DataPoint, b: DataPoint) => number) | null;\n sort(_: ((a: DataPoint, b: DataPoint) => number) | null): this;\n sort(\n _?: ((a: DataPoint, b: DataPoint) => number) | null,\n ): ((a: DataPoint, b: DataPoint) => number) | null | this {\n return arguments.length\n ? ((this.schema.sort = _ ?? null), this)\n : this.schema.sort;\n }\n\n /**\n A series of global texture methods to be used for all textures (ie. `{stroke: \"darkorange\", strokeWidth: 2}`).\n*/\n textureDefault(): Record<string, unknown>;\n textureDefault(_: Record<string, unknown>): this;\n textureDefault(_?: Record<string, unknown>): Record<string, unknown> | this {\n return arguments.length\n ? ((this.schema.textureDefault = assign(this.schema.textureDefault, _!)),\n this)\n : this.schema.textureDefault;\n }\n\n /**\n Narrowed `.config()` for Shape. Inherited surface from\n `BaseClass.config()`; the override exists only to surface per-shape\n keys (e.g. `width`/`height` for Rect) in autocomplete + type checks.\n */\n config(): BaseShapeConfig;\n config(_: Partial<BaseShapeConfig>): this;\n config(_?: Partial<BaseShapeConfig>): BaseShapeConfig | this {\n if (!arguments.length) return super.config() as BaseShapeConfig;\n super.config(_ as D3plusConfig);\n return this;\n }\n}\n"],"names":["color","select","colorContrast","assign","getSize","isObject","SvgRenderer","TextBox","accessor","BaseClass","constant","installFluent","buildLabelData","hitAreaNode","interactionPoints","numOrUndef","v","n","Number","isFinite","undefined","strOrUndef","String","parseDash","parts","split","map","filter","length","backgroundImageLayout","emitBackgroundImages","sortRanks","shapeSchema","key","coerce","default","d","i","id","Shape","tagName","_data","_labelClass","_name","_tagName","_textureDefs","_select","_transition","_group","_update","_enter","_exit","_hoverGroup","_activeGroup","_path","_sceneRenderer","schema","stroke","c","fill","darker","formatHex","activeStyle","includes","col","s","strokeWidth","hoverStyle","labelConfig","fontColor","fontOpacity","opacity","fontResize","fontMax","fontMin","fontSize","padding","textAnchor","verticalAlign","textureDefault","_aes","_d","_i","_getTextureKey","textureVal","texture","styleLogic","_","nested","values","indexOf","fallback","background","pathNames","orientation","retObj","size","JSON","stringify","_nestWrapper","method","__d3plusShape__","data","_buildLabelData","dataFilter","_dataFilter","bind","label","labelBounds","x","y","aes","rotate","_styleVal","fn","_sceneTransform","wrapped","Boolean","dd","ii","translate","tx","ty","scale","_scenePaint","textureKey","fillOpacity","strokeOpacity","strokeDasharray","strokeLinecap","vectorEffect","shapeRendering","_sceneGeometry","toScene","children","bgSpecs","rank","sort","forEach","geom","datum","transform","iPoints","defined","hitArea","ha","push","z","index","shapeType","paint","aria","role","ariaLabel","bg","backgroundImage","g","needsPoints","width","r","points","fit","backgroundImageFit","layout","url","box","clip","preserveAspectRatio","type","render","callback","lc","renderMode","config","setTimeout","document","div","createElement","style","cssText","body","appendChild","sel","node","tag","toLowerCase","isSvg","rawW","getAttribute","clientWidth","rawH","clientHeight","measuredW","measuredH","height","shapeGroup","labelChildren","root","scene","prev","destroy","firstChild","removeChild","renderer","mount","container","drawScene","active","arguments","hover"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AW;YAC7B;;;YAOAnE,KAAAA;mBAAAA,SAAAA,QAAOsF,CAA4C;gBACjD,OAAOyH,UAAUpL,MAAM,GAClB,CAAA,AAAC,IAAI,CAACkB,OAAO,GAAG7C,OAAOsF,IAAyC,IAAI,AAAD,IACpE,IAAI,CAACzC,OAAO;YAClB;;;YAOA2F,KAAAA;mBAAAA,SAAAA,KACElD,CAAmD;gBAEnD,OAAOyH,UAAUpL,MAAM,GAClB,CAAA,AAAC,IAAI,CAAC4B,MAAM,CAACiF,IAAI,GAAGlD,cAAAA,eAAAA,IAAK,MAAO,IAAI,AAAD,IACpC,IAAI,CAAC/B,MAAM,CAACiF,IAAI;YACtB;;;YAOA1D,KAAAA;mBAAAA,SAAAA,eAAeQ,CAA2B;gBACxC,OAAOyH,UAAUpL,MAAM,GAClB,CAAA,AAAC,IAAI,CAAC4B,MAAM,CAACuB,cAAc,GAAG5E,OAAO,IAAI,CAACqD,MAAM,CAACuB,cAAc,EAAEQ,IAClE,IAAI,AAAD,IACH,IAAI,CAAC/B,MAAM,CAACuB,cAAc;YAChC;;;YASA8F,KAAAA;mBAAAA,SAAAA,OAAOtF,CAA4B;gBACjC,IAAI,CAACyH,UAAUpL,MAAM,EAAE,OAAO,uBA3nBbW,kBA2nBmBsI,UAAN,IAAK;gBACnC,uBA5nBiBtI,kBA4nBXsI,UAAN,IAAK,aAAQtF;gBACb,OAAO,IAAI;YACb;;;WA9nBmBhD;EAAc9B;AAHnC;;AAEA,GACA,SAAqB8B,mBA+nBpB"}
|
|
@@ -8,12 +8,38 @@
|
|
|
8
8
|
the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the
|
|
9
9
|
visible geometry are siblings, and the SVG keyed join can't hold two nodes
|
|
10
10
|
under one key — sharing it made the geometry re-enter (collapse→grow) on every
|
|
11
|
-
redraw (a "pulse" on e.g. every timeline step). Returns null when no
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
redraw (a "pulse" on e.g. every timeline step). Returns null when no hitArea
|
|
12
|
+
is configured. A path-style hitArea (Line: a fat, transparent stroke) reuses
|
|
13
|
+
the resolved geometry `d`/`transform` so the hover target overlaps the
|
|
14
|
+
visible line exactly while extending past its ~1px stroke.
|
|
15
|
+
*/ export function hitAreaNode(hitArea, d, i, aes, key, datum, name, transform, geomD) {
|
|
15
16
|
var bounds = typeof hitArea === "function" ? hitArea(d, i, aes) : hitArea;
|
|
16
|
-
if (!bounds
|
|
17
|
+
if (!bounds) return null;
|
|
18
|
+
// Path-style hitArea (Line): widen the hover target to a fat transparent
|
|
19
|
+
// stroke over the line's own geometry. `stroke: transparent` (not "none") is
|
|
20
|
+
// painted, so it hit-tests across the full width on both backends.
|
|
21
|
+
if (typeof bounds.width !== "number" && typeof geomD === "string") {
|
|
22
|
+
var sw = typeof bounds["stroke-width"] === "number" ? bounds["stroke-width"] : 10;
|
|
23
|
+
return {
|
|
24
|
+
type: "path",
|
|
25
|
+
d: geomD,
|
|
26
|
+
key: "".concat(key, "::hit"),
|
|
27
|
+
datum: datum,
|
|
28
|
+
index: i,
|
|
29
|
+
shapeType: name,
|
|
30
|
+
paint: {
|
|
31
|
+
fill: "none",
|
|
32
|
+
stroke: "transparent",
|
|
33
|
+
strokeWidth: sw,
|
|
34
|
+
vectorEffect: "non-scaling-stroke"
|
|
35
|
+
},
|
|
36
|
+
transform: transform,
|
|
37
|
+
aria: {
|
|
38
|
+
hidden: true
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (typeof bounds.width !== "number" || typeof bounds.height !== "number") return null;
|
|
17
43
|
return {
|
|
18
44
|
type: "rect",
|
|
19
45
|
x: typeof bounds.x === "number" ? bounds.x : -bounds.width / 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/shapes/hitAreaNode.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode, Transform} from \"@d3plus/render\";\n\ntype HitArea =\n | ((d: DataPoint, i: number, aes: unknown) => Record<string, unknown>)\n | Record<string, unknown>\n | undefined;\n\n/**\n Builds the invisible, interactive \"hit area\" rect for a shape datum — a\n transparent box that can extend past the shape's own geometry (e.g. a legend\n swatch reaching across the padding to its label) so the space between them\n stays one continuous hover target instead of firing mouseleave/mouseenter as\n the pointer crosses the gap. Carries the shape's `datum` (so pointer handlers\n treat it as the same item, and the `mouseleave` same-datum suppressor bridges\n the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the\n visible geometry are siblings, and the SVG keyed join can't hold two nodes\n under one key — sharing it made the geometry re-enter (collapse→grow) on every\n redraw (a \"pulse\" on e.g. every timeline step). Returns null when no\n
|
|
1
|
+
{"version":3,"sources":["../../../src/shapes/hitAreaNode.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode, Transform} from \"@d3plus/render\";\n\ntype HitArea =\n | ((d: DataPoint, i: number, aes: unknown) => Record<string, unknown>)\n | Record<string, unknown>\n | undefined;\n\n/**\n Builds the invisible, interactive \"hit area\" rect for a shape datum — a\n transparent box that can extend past the shape's own geometry (e.g. a legend\n swatch reaching across the padding to its label) so the space between them\n stays one continuous hover target instead of firing mouseleave/mouseenter as\n the pointer crosses the gap. Carries the shape's `datum` (so pointer handlers\n treat it as the same item, and the `mouseleave` same-datum suppressor bridges\n the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the\n visible geometry are siblings, and the SVG keyed join can't hold two nodes\n under one key — sharing it made the geometry re-enter (collapse→grow) on every\n redraw (a \"pulse\" on e.g. every timeline step). Returns null when no hitArea\n is configured. A path-style hitArea (Line: a fat, transparent stroke) reuses\n the resolved geometry `d`/`transform` so the hover target overlaps the\n visible line exactly while extending past its ~1px stroke.\n*/\nexport function hitAreaNode(\n hitArea: HitArea,\n d: DataPoint,\n i: number,\n aes: unknown,\n key: string | number,\n datum: DataPoint,\n name: string,\n transform: Transform,\n geomD?: string,\n): SceneNode | null {\n const bounds = (\n typeof hitArea === \"function\" ? hitArea(d, i, aes) : hitArea\n ) as Record<string, unknown> | null | undefined;\n if (!bounds) return null;\n // Path-style hitArea (Line): widen the hover target to a fat transparent\n // stroke over the line's own geometry. `stroke: transparent` (not \"none\") is\n // painted, so it hit-tests across the full width on both backends.\n if (typeof bounds.width !== \"number\" && typeof geomD === \"string\") {\n const sw = typeof bounds[\"stroke-width\"] === \"number\" ? (bounds[\"stroke-width\"] as number) : 10;\n return {\n type: \"path\",\n d: geomD,\n key: `${key}::hit`,\n datum,\n index: i,\n shapeType: name,\n paint: {fill: \"none\", stroke: \"transparent\", strokeWidth: sw, vectorEffect: \"non-scaling-stroke\"},\n transform,\n aria: {hidden: true},\n } as unknown as SceneNode;\n }\n if (typeof bounds.width !== \"number\" || typeof bounds.height !== \"number\")\n return null;\n return {\n type: \"rect\",\n x: typeof bounds.x === \"number\" ? bounds.x : -bounds.width / 2,\n y: typeof bounds.y === \"number\" ? bounds.y : -bounds.height / 2,\n width: bounds.width,\n height: bounds.height,\n key: `${key}::hit`,\n datum,\n index: i,\n shapeType: name,\n paint: {fill: \"transparent\"},\n transform,\n aria: {hidden: true},\n } as unknown as SceneNode;\n}\n"],"names":["hitAreaNode","hitArea","d","i","aes","key","datum","name","transform","geomD","bounds","width","sw","type","index","shapeType","paint","fill","stroke","strokeWidth","vectorEffect","aria","hidden","height","x","y"],"mappings":"AAQA;;;;;;;;;;;;;;AAcA,GACA,OAAO,SAASA,YACdC,OAAgB,EAChBC,CAAY,EACZC,CAAS,EACTC,GAAY,EACZC,GAAoB,EACpBC,KAAgB,EAChBC,IAAY,EACZC,SAAoB,EACpBC,KAAc;IAEd,IAAMC,SACJ,OAAOT,YAAY,aAAaA,QAAQC,GAAGC,GAAGC,OAAOH;IAEvD,IAAI,CAACS,QAAQ,OAAO;IACpB,yEAAyE;IACzE,6EAA6E;IAC7E,mEAAmE;IACnE,IAAI,OAAOA,OAAOC,KAAK,KAAK,YAAY,OAAOF,UAAU,UAAU;QACjE,IAAMG,KAAK,OAAOF,MAAM,CAAC,eAAe,KAAK,WAAYA,MAAM,CAAC,eAAe,GAAc;QAC7F,OAAO;YACLG,MAAM;YACNX,GAAGO;YACHJ,KAAK,AAAC,GAAM,OAAJA,KAAI;YACZC,OAAAA;YACAQ,OAAOX;YACPY,WAAWR;YACXS,OAAO;gBAACC,MAAM;gBAAQC,QAAQ;gBAAeC,aAAaP;gBAAIQ,cAAc;YAAoB;YAChGZ,WAAAA;YACAa,MAAM;gBAACC,QAAQ;YAAI;QACrB;IACF;IACA,IAAI,OAAOZ,OAAOC,KAAK,KAAK,YAAY,OAAOD,OAAOa,MAAM,KAAK,UAC/D,OAAO;IACT,OAAO;QACLV,MAAM;QACNW,GAAG,OAAOd,OAAOc,CAAC,KAAK,WAAWd,OAAOc,CAAC,GAAG,CAACd,OAAOC,KAAK,GAAG;QAC7Dc,GAAG,OAAOf,OAAOe,CAAC,KAAK,WAAWf,OAAOe,CAAC,GAAG,CAACf,OAAOa,MAAM,GAAG;QAC9DZ,OAAOD,OAAOC,KAAK;QACnBY,QAAQb,OAAOa,MAAM;QACrBlB,KAAK,AAAC,GAAM,OAAJA,KAAI;QACZC,OAAAA;QACAQ,OAAOX;QACPY,WAAWR;QACXS,OAAO;YAACC,MAAM;QAAa;QAC3BT,WAAAA;QACAa,MAAM;YAACC,QAAQ;QAAI;IACrB;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
For a nested shape datum (Line/Area, whose datum wraps many points) returns a
|
|
3
|
+
spreadable scene-node fragment carrying each point's content-space position
|
|
4
|
+
paired with its source datum, so the pointer bridge can report the point
|
|
5
|
+
nearest the cursor rather than the whole-series aggregate. Points the
|
|
6
|
+
`defined` accessor rejects, or whose position isn't finite (a missing value),
|
|
7
|
+
are skipped — so the nearest match is always a real, defined point. Returns
|
|
8
|
+
an empty object for non-nested data (spreads to nothing).
|
|
9
|
+
*/ export function interactionPoints(d, x, y, defined) {
|
|
10
|
+
if (!d.__d3plusShape__ || !Array.isArray(d.values)) return {};
|
|
11
|
+
var values = d.values;
|
|
12
|
+
var points = [];
|
|
13
|
+
values.forEach(function(v, k) {
|
|
14
|
+
if (typeof defined === "function" && defined(v, k) === false) return;
|
|
15
|
+
var px = Number(x(v, k));
|
|
16
|
+
var py = Number(y(v, k));
|
|
17
|
+
if (!Number.isFinite(px) || !Number.isFinite(py)) return;
|
|
18
|
+
points.push({
|
|
19
|
+
x: px,
|
|
20
|
+
y: py,
|
|
21
|
+
datum: v,
|
|
22
|
+
index: typeof v.i === "number" ? v.i : k
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
return points.length ? {
|
|
26
|
+
interactionPoints: points
|
|
27
|
+
} : {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=interactionPoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shapes/interactionPoints.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport type {InteractionPoint} from \"@d3plus/render\";\nimport type {AccessorFn} from \"../utils/index.js\";\n\n/**\n For a nested shape datum (Line/Area, whose datum wraps many points) returns a\n spreadable scene-node fragment carrying each point's content-space position\n paired with its source datum, so the pointer bridge can report the point\n nearest the cursor rather than the whole-series aggregate. Points the\n `defined` accessor rejects, or whose position isn't finite (a missing value),\n are skipped — so the nearest match is always a real, defined point. Returns\n an empty object for non-nested data (spreads to nothing).\n*/\nexport function interactionPoints(\n d: DataPoint,\n x: AccessorFn,\n y: AccessorFn,\n defined?: AccessorFn,\n): {interactionPoints?: InteractionPoint[]} {\n if (!d.__d3plusShape__ || !Array.isArray(d.values)) return {};\n const values = d.values as unknown as DataPoint[];\n const points: InteractionPoint[] = [];\n values.forEach((v, k) => {\n if (typeof defined === \"function\" && defined(v, k) === false) return;\n const px = Number(x(v, k));\n const py = Number(y(v, k));\n if (!Number.isFinite(px) || !Number.isFinite(py)) return;\n points.push({\n x: px,\n y: py,\n datum: v,\n index: typeof v.i === \"number\" ? (v.i as number) : k,\n });\n });\n return points.length ? {interactionPoints: points} : {};\n}\n"],"names":["interactionPoints","d","x","y","defined","__d3plusShape__","Array","isArray","values","points","forEach","v","k","px","Number","py","isFinite","push","datum","index","i","length"],"mappings":"AAIA;;;;;;;;AAQA,GACA,OAAO,SAASA,kBACdC,CAAY,EACZC,CAAa,EACbC,CAAa,EACbC,OAAoB;IAEpB,IAAI,CAACH,EAAEI,eAAe,IAAI,CAACC,MAAMC,OAAO,CAACN,EAAEO,MAAM,GAAG,OAAO,CAAC;IAC5D,IAAMA,SAASP,EAAEO,MAAM;IACvB,IAAMC,SAA6B,EAAE;IACrCD,OAAOE,OAAO,CAAC,SAACC,GAAGC;QACjB,IAAI,OAAOR,YAAY,cAAcA,QAAQO,GAAGC,OAAO,OAAO;QAC9D,IAAMC,KAAKC,OAAOZ,EAAES,GAAGC;QACvB,IAAMG,KAAKD,OAAOX,EAAEQ,GAAGC;QACvB,IAAI,CAACE,OAAOE,QAAQ,CAACH,OAAO,CAACC,OAAOE,QAAQ,CAACD,KAAK;QAClDN,OAAOQ,IAAI,CAAC;YACVf,GAAGW;YACHV,GAAGY;YACHG,OAAOP;YACPQ,OAAO,OAAOR,EAAES,CAAC,KAAK,WAAYT,EAAES,CAAC,GAAcR;QACrD;IACF;IACA,OAAOH,OAAOY,MAAM,GAAG;QAACrB,mBAAmBS;IAAM,IAAI,CAAC;AACxD"}
|