@d3plus/core 4.3.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 +1820 -714
- 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 +18 -9
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +69 -104
- 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 +26 -6
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +1 -2
- 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/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 +39 -51
- 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/vizDefaults.js +243 -50
- package/es/src/charts/viz/vizDefaults.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/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 +12 -3
- 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/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 +57 -1
- package/types/src/components/Axis/Axis.d.ts +2 -0
- package/types/src/utils/D3plusConfig.d.ts +102 -8
- package/umd/d3plus-core.full.js +39613 -35374
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +5747 -4361
- package/umd/d3plus-core.js +13132 -9289
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +3658 -2302
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _instanceof(left, right) {
|
|
2
|
+
"@swc/helpers - instanceof";
|
|
3
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
4
|
+
return !!right[Symbol.hasInstance](left);
|
|
5
|
+
} else {
|
|
6
|
+
return left instanceof right;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
1
9
|
/**
|
|
2
10
|
`ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +
|
|
3
11
|
hitArea that d3-zoom and tile-loading need.
|
|
@@ -20,18 +28,61 @@
|
|
|
20
28
|
scene-graph-native interaction path (renderer.on(...) dispatch +
|
|
21
29
|
tile-data → image scene nodes) would let this go away; until then,
|
|
22
30
|
it's the documented home for the imperative half of v4 zoom.
|
|
23
|
-
*/
|
|
31
|
+
*/ import { select } from "d3-selection";
|
|
32
|
+
/** The HTML element the chart's <svg> (and, on canvas, its <canvas>) mount in. */ function hostElement(viz) {
|
|
33
|
+
var _ref;
|
|
34
|
+
var _viz__select_node, _viz__select;
|
|
35
|
+
var host = (_ref = (_viz__select = viz._select) === null || _viz__select === void 0 ? void 0 : (_viz__select_node = _viz__select.node()) === null || _viz__select_node === void 0 ? void 0 : _viz__select_node.parentNode) !== null && _ref !== void 0 ? _ref : null;
|
|
36
|
+
while(host && !_instanceof(host, HTMLElement))host = host.parentNode;
|
|
37
|
+
return _instanceof(host, HTMLElement) ? host : null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
Where the zoom DOM mounts. Normally the chart's own <svg>, beneath the
|
|
41
|
+
painted scene. On the Canvas backend that <svg> overlays the <canvas>, so
|
|
42
|
+
Geomap's opaque ocean and basemap tiles would hide the geography painted
|
|
43
|
+
on it; they mount instead in an underlay <svg> stacked beneath the canvas
|
|
44
|
+
(the canvas is transparent wherever there is no geography).
|
|
45
|
+
*/ function zoomDomParent(viz, kind) {
|
|
46
|
+
var host = kind === "geomap" && viz._renderer === "canvas" && !viz._ssr ? hostElement(viz) : null;
|
|
47
|
+
if (!host) return viz._select;
|
|
48
|
+
// `isolation` makes the host a stacking context, so the underlay's
|
|
49
|
+
// negative z-index puts it beneath the (in-flow) canvas but not beneath
|
|
50
|
+
// the host's own background.
|
|
51
|
+
host.style.isolation = "isolate";
|
|
52
|
+
var underlay = select(host).selectAll(":scope > svg.d3plus-geomap-underlay").data([
|
|
53
|
+
0
|
|
54
|
+
]);
|
|
55
|
+
return underlay.enter().insert("svg", ":first-child").attr("class", "d3plus-geomap-underlay").style("position", "absolute").style("top", "0").style("left", "0").style("z-index", "-1").style("overflow", "hidden").style("pointer-events", "none").merge(underlay).attr("width", viz.schema.width).attr("height", viz.schema.height);
|
|
56
|
+
}
|
|
57
|
+
/** Drops a canvas-mode tile underlay once the chart renders to SVG again. */ function removeTileUnderlay(viz) {
|
|
58
|
+
var _host_querySelector;
|
|
59
|
+
var host = hostElement(viz);
|
|
60
|
+
if (host) (_host_querySelector = host.querySelector(":scope > svg.d3plus-geomap-underlay")) === null || _host_querySelector === void 0 ? void 0 : _host_querySelector.remove();
|
|
61
|
+
}
|
|
62
|
+
export function ensureZoomDom(viz, opts) {
|
|
24
63
|
var kind = opts.kind, width = opts.width, height = opts.height, duration = opts.duration, ocean = opts.ocean;
|
|
25
|
-
var cls = kind === "
|
|
64
|
+
var cls = "d3plus-".concat(kind === "generic" ? "zoom" : kind);
|
|
26
65
|
var bg = kind === "geomap" ? ocean || "transparent" : "transparent";
|
|
27
|
-
var
|
|
28
|
-
|
|
66
|
+
var parent = zoomDomParent(viz, kind);
|
|
67
|
+
// Adopt a container mounted under the other parent (the renderer changed).
|
|
68
|
+
var existing = viz._container && viz._container.classed(cls) ? viz._container.node() : null;
|
|
69
|
+
if (existing && existing.parentNode !== parent.node()) parent.node().insertBefore(existing, parent.node().firstChild);
|
|
70
|
+
if (parent !== viz._select) viz._select.selectAll(":scope > svg.d3plus-geomap").remove();
|
|
71
|
+
else removeTileUnderlay(viz);
|
|
72
|
+
var container = parent.selectAll(":scope > svg.".concat(cls)).data([
|
|
29
73
|
0
|
|
30
74
|
]);
|
|
31
|
-
container = container.enter()
|
|
75
|
+
container = container.enter()// First child: beneath the scene, which the renderer paints after it.
|
|
76
|
+
.insert("svg", ":first-child").attr("class", cls).attr("opacity", 0).attr("width", width).attr("height", height).attr("x", viz._margin.left).attr("y", viz._margin.top).style("background-color", bg).merge(container);
|
|
32
77
|
viz._container = container;
|
|
33
78
|
container.transition().duration(duration).attr("opacity", 1).attr("width", width).attr("height", height).attr("x", viz._margin.left).attr("y", viz._margin.top);
|
|
34
|
-
if (kind === "
|
|
79
|
+
if (kind === "generic") {
|
|
80
|
+
var zoomGroup = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
|
|
81
|
+
0
|
|
82
|
+
]);
|
|
83
|
+
zoomGroup = zoomGroup.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup);
|
|
84
|
+
viz._zoomGroup = zoomGroup;
|
|
85
|
+
} else if (kind === "network") {
|
|
35
86
|
// Hit-area for "click outside any node" → reset focus + zoom.
|
|
36
87
|
var hitArea = container.selectAll("rect.".concat(cls, "-hitArea")).data([
|
|
37
88
|
0
|
|
@@ -43,11 +94,11 @@
|
|
|
43
94
|
viz._zoomToBounds(null);
|
|
44
95
|
}
|
|
45
96
|
});
|
|
46
|
-
var
|
|
97
|
+
var zoomGroup1 = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
|
|
47
98
|
0
|
|
48
99
|
]);
|
|
49
|
-
|
|
50
|
-
viz._zoomGroup =
|
|
100
|
+
zoomGroup1 = zoomGroup1.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup1);
|
|
101
|
+
viz._zoomGroup = zoomGroup1;
|
|
51
102
|
} else {
|
|
52
103
|
// Geomap also needs an ocean rect (under tiles + paths) and the tile
|
|
53
104
|
// group that `_renderTiles` mutates with map imagery.
|
|
@@ -60,11 +111,11 @@
|
|
|
60
111
|
]);
|
|
61
112
|
tileGroup = tileGroup.enter().append("g").attr("class", "".concat(cls, "-tileGroup")).merge(tileGroup);
|
|
62
113
|
viz._tileGroup = tileGroup;
|
|
63
|
-
var
|
|
114
|
+
var zoomGroup2 = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
|
|
64
115
|
0
|
|
65
116
|
]);
|
|
66
|
-
|
|
67
|
-
viz._zoomGroup =
|
|
117
|
+
zoomGroup2 = zoomGroup2.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup2);
|
|
118
|
+
viz._zoomGroup = zoomGroup2;
|
|
68
119
|
}
|
|
69
120
|
}
|
|
70
121
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/features/ensureZoomDom.ts"],"sourcesContent":["/**\n `ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +\n hitArea that d3-zoom and tile-loading need.\n\n This is the lifecycle half of v4 zoom support. The CONTROLS (zoom-in/\n zoom-out/etc.) ride the scene graph as an HtmlOverlay (see\n `drawSteps/zoomControls.ts`). The zoom-transform application also\n rides the scene graph (`viz._zoomTransform` composed into\n `Viz.toScene()`). But d3-zoom's *event binding* needs a real DOM\n element to bind to, and Geomap's tile-loading mutates the inner\n `<g>` directly — so this helper exists as the documented home for\n that imperative setup.\n\n Idempotent: calling it again returns the existing nodes. Mutates the\n viz instance with `_container` / `_zoomGroup` (and the Network\n variant also wires the hitArea click handler).\n\n The helper stays as long as d3-zoom owns event binding and Geomap's\n tile-loading mounts `<g>` elements directly. An eventual fully\n scene-graph-native interaction path (renderer.on(...) dispatch +\n tile-data → image scene nodes) would let this go away; until then,\n it's the documented home for the imperative half of v4 zoom.\n*/\n\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport type ZoomDomKind = \"network\" | \"geomap\";\n\ninterface SetupOpts {\n /** \"network\" or \"geomap\" — picks the css class + behavior tweaks. */\n kind: ZoomDomKind;\n /** Chart-area width (margin-adjusted). */\n width: number;\n /** Chart-area height (margin-adjusted). */\n height: number;\n /** Transition duration for fade-in. */\n duration: number;\n /** Geomap-only: ocean fill color (also used as the svg background). */\n ocean?: string;\n}\n\nexport function ensureZoomDom(viz: Viz, opts: SetupOpts): void {\n const {kind, width, height, duration, ocean} = opts;\n const cls = kind === \"network\" ? \"d3plus-network\" : \"d3plus-geomap\";\n const bg = kind === \"geomap\" ? ocean || \"transparent\" : \"transparent\";\n\n const select = viz._select!;\n let container = select.selectAll(`svg.${cls}`).data([0]);\n container = container\n .enter()\n .append(\"svg\")\n .attr(\"class\", cls)\n .attr(\"opacity\", 0)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top)\n .style(\"background-color\", bg)\n .merge(container);\n viz._container = container;\n\n container\n .transition()\n .duration(duration)\n .attr(\"opacity\", 1)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top);\n\n if (kind === \"network\") {\n // Hit-area for \"click outside any node\" → reset focus + zoom.\n const hitArea = container.selectAll(`rect.${cls}-hitArea`).data([0]);\n hitArea\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-hitArea`)\n .merge(hitArea)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", \"transparent\")\n .on(\"click\", () => {\n if (viz._focus) {\n viz.active!(false);\n viz._focus = undefined;\n viz._zoomToBounds!(null);\n }\n });\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n } else {\n // Geomap also needs an ocean rect (under tiles + paths) and the tile\n // group that `_renderTiles` mutates with map imagery.\n const oceanRect = container.selectAll(`rect.${cls}-ocean`).data([0]);\n oceanRect\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-ocean`)\n .merge(oceanRect)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", ocean || \"transparent\");\n\n let tileGroup = container.selectAll(`g.${cls}-tileGroup`).data([0]);\n tileGroup = tileGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-tileGroup`)\n .merge(tileGroup);\n viz._tileGroup = tileGroup;\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n }\n}\n"],"names":["ensureZoomDom","viz","opts","kind","width","height","duration","ocean","cls","bg","select","_select","container","selectAll","data","enter","append","attr","_margin","left","top","style","merge","_container","transition","hitArea","on","_focus","active","undefined","_zoomToBounds","zoomGroup","_zoomGroup","oceanRect","tileGroup","_tileGroup"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,GAmBA,OAAO,SAASA,cAAcC,GAAQ,EAAEC,IAAe;IACrD,IAAOC,OAAwCD,KAAxCC,MAAMC,QAAkCF,KAAlCE,OAAOC,SAA2BH,KAA3BG,QAAQC,WAAmBJ,KAAnBI,UAAUC,QAASL,KAATK;IACtC,IAAMC,MAAML,SAAS,YAAY,mBAAmB;IACpD,IAAMM,KAAKN,SAAS,WAAWI,SAAS,gBAAgB;IAExD,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CAAC;YAAC;SAAE;QAClEiB,YAAYA,UACThB,KAAK,GACLC,MAAM,CAAC,KACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,eACrBc,KAAK,CAACS;QACT9B,IAAI+B,UAAU,GAAGD;IACnB,OAAO;QACL,qEAAqE;QACrE,sDAAsD;QACtD,IAAME,YAAYrB,UAAUC,SAAS,CAAC,AAAC,QAAW,OAAJL,KAAI,WAASM,IAAI,CAAC;YAAC;SAAE;QACnEmB,UACGlB,KAAK,GACLC,MAAM,CAAC,QACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,WACrBc,KAAK,CAACW,WACNhB,IAAI,CAAC,SAASb,OACda,IAAI,CAAC,UAAUZ,QACfY,IAAI,CAAC,QAAQV,SAAS;QAEzB,IAAI2B,YAAYtB,UAAUC,SAAS,CAAC,AAAC,KAAQ,OAAJL,KAAI,eAAaM,IAAI,CAAC;YAAC;SAAE;QAClEoB,YAAYA,UACTnB,KAAK,GACLC,MAAM,CAAC,KACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,eACrBc,KAAK,CAACY;QACTjC,IAAIkC,UAAU,GAAGD;QAEjB,IAAIH,aAAYnB,UAAUC,SAAS,CAAC,AAAC,KAAQ,OAAJL,KAAI,eAAaM,IAAI,CAAC;YAAC;SAAE;QAClEiB,aAAYA,WACThB,KAAK,GACLC,MAAM,CAAC,KACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,eACrBc,KAAK,CAACS;QACT9B,IAAI+B,UAAU,GAAGD;IACnB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/features/ensureZoomDom.ts"],"sourcesContent":["/**\n `ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +\n hitArea that d3-zoom and tile-loading need.\n\n This is the lifecycle half of v4 zoom support. The CONTROLS (zoom-in/\n zoom-out/etc.) ride the scene graph as an HtmlOverlay (see\n `drawSteps/zoomControls.ts`). The zoom-transform application also\n rides the scene graph (`viz._zoomTransform` composed into\n `Viz.toScene()`). But d3-zoom's *event binding* needs a real DOM\n element to bind to, and Geomap's tile-loading mutates the inner\n `<g>` directly — so this helper exists as the documented home for\n that imperative setup.\n\n Idempotent: calling it again returns the existing nodes. Mutates the\n viz instance with `_container` / `_zoomGroup` (and the Network\n variant also wires the hitArea click handler).\n\n The helper stays as long as d3-zoom owns event binding and Geomap's\n tile-loading mounts `<g>` elements directly. An eventual fully\n scene-graph-native interaction path (renderer.on(...) dispatch +\n tile-data → image scene nodes) would let this go away; until then,\n it's the documented home for the imperative half of v4 zoom.\n*/\n\nimport {select} from \"d3-selection\";\n\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport type ZoomDomKind = \"network\" | \"geomap\" | \"generic\";\n\ninterface SetupOpts {\n /**\n \"network\" or \"geomap\" — picks the css class + behavior tweaks. \"generic\"\n is the bare surface (zoom group + brush host) every other chart gets\n when `zoom` is enabled.\n */\n kind: ZoomDomKind;\n /** Chart-area width (margin-adjusted). */\n width: number;\n /** Chart-area height (margin-adjusted). */\n height: number;\n /** Transition duration for fade-in. */\n duration: number;\n /** Geomap-only: ocean fill color (also used as the svg background). */\n ocean?: string;\n}\n\n/** The HTML element the chart's <svg> (and, on canvas, its <canvas>) mount in. */\nfunction hostElement(viz: Viz): HTMLElement | null {\n let host = viz._select?.node()?.parentNode ?? null;\n while (host && !(host instanceof HTMLElement)) host = host.parentNode;\n return host instanceof HTMLElement ? host : null;\n}\n\n/**\n Where the zoom DOM mounts. Normally the chart's own <svg>, beneath the\n painted scene. On the Canvas backend that <svg> overlays the <canvas>, so\n Geomap's opaque ocean and basemap tiles would hide the geography painted\n on it; they mount instead in an underlay <svg> stacked beneath the canvas\n (the canvas is transparent wherever there is no geography).\n*/\nfunction zoomDomParent(viz: Viz, kind: ZoomDomKind): NonNullable<Viz[\"_select\"]> {\n const host = kind === \"geomap\" && viz._renderer === \"canvas\" && !viz._ssr ? hostElement(viz) : null;\n if (!host) return viz._select!;\n // `isolation` makes the host a stacking context, so the underlay's\n // negative z-index puts it beneath the (in-flow) canvas but not beneath\n // the host's own background.\n host.style.isolation = \"isolate\";\n const underlay = select(host).selectAll<SVGSVGElement, number>(\":scope > svg.d3plus-geomap-underlay\").data([0]);\n return underlay\n .enter()\n .insert(\"svg\", \":first-child\")\n .attr(\"class\", \"d3plus-geomap-underlay\")\n .style(\"position\", \"absolute\")\n .style(\"top\", \"0\")\n .style(\"left\", \"0\")\n .style(\"z-index\", \"-1\")\n .style(\"overflow\", \"hidden\")\n .style(\"pointer-events\", \"none\")\n .merge(underlay)\n .attr(\"width\", viz.schema.width)\n .attr(\"height\", viz.schema.height) as unknown as NonNullable<Viz[\"_select\"]>;\n}\n\n/** Drops a canvas-mode tile underlay once the chart renders to SVG again. */\nfunction removeTileUnderlay(viz: Viz): void {\n const host = hostElement(viz);\n if (host) host.querySelector(\":scope > svg.d3plus-geomap-underlay\")?.remove();\n}\n\nexport function ensureZoomDom(viz: Viz, opts: SetupOpts): void {\n const {kind, width, height, duration, ocean} = opts;\n const cls = `d3plus-${kind === \"generic\" ? \"zoom\" : kind}`;\n const bg = kind === \"geomap\" ? ocean || \"transparent\" : \"transparent\";\n\n const parent = zoomDomParent(viz, kind);\n // Adopt a container mounted under the other parent (the renderer changed).\n const existing = viz._container && viz._container.classed(cls) ? viz._container.node() : null;\n if (existing && existing.parentNode !== parent.node())\n parent.node().insertBefore(existing, parent.node().firstChild);\n if (parent !== viz._select) viz._select!.selectAll(\":scope > svg.d3plus-geomap\").remove();\n else removeTileUnderlay(viz);\n\n let container = parent.selectAll(`:scope > svg.${cls}`).data([0]);\n container = container\n .enter()\n // First child: beneath the scene, which the renderer paints after it.\n .insert(\"svg\", \":first-child\")\n .attr(\"class\", cls)\n .attr(\"opacity\", 0)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top)\n .style(\"background-color\", bg)\n .merge(container);\n viz._container = container;\n\n container\n .transition()\n .duration(duration)\n .attr(\"opacity\", 1)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top);\n\n if (kind === \"generic\") {\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n } else if (kind === \"network\") {\n // Hit-area for \"click outside any node\" → reset focus + zoom.\n const hitArea = container.selectAll(`rect.${cls}-hitArea`).data([0]);\n hitArea\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-hitArea`)\n .merge(hitArea)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", \"transparent\")\n .on(\"click\", () => {\n if (viz._focus) {\n viz.active!(false);\n viz._focus = undefined;\n viz._zoomToBounds!(null);\n }\n });\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n } else {\n // Geomap also needs an ocean rect (under tiles + paths) and the tile\n // group that `_renderTiles` mutates with map imagery.\n const oceanRect = container.selectAll(`rect.${cls}-ocean`).data([0]);\n oceanRect\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-ocean`)\n .merge(oceanRect)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", ocean || \"transparent\");\n\n let tileGroup = container.selectAll(`g.${cls}-tileGroup`).data([0]);\n tileGroup = tileGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-tileGroup`)\n .merge(tileGroup);\n viz._tileGroup = tileGroup;\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n }\n}\n"],"names":["select","hostElement","viz","host","_select","node","parentNode","HTMLElement","zoomDomParent","kind","_renderer","_ssr","style","isolation","underlay","selectAll","data","enter","insert","attr","merge","schema","width","height","removeTileUnderlay","querySelector","remove","ensureZoomDom","opts","duration","ocean","cls","bg","parent","existing","_container","classed","insertBefore","firstChild","container","_margin","left","top","transition","zoomGroup","append","_zoomGroup","hitArea","on","_focus","active","undefined","_zoomToBounds","oceanRect","tileGroup","_tileGroup"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,GAEA,SAAQA,MAAM,QAAO,eAAe;AAuBpC,gFAAgF,GAChF,SAASC,YAAYC,GAAQ;;QAChBA,mBAAAA;IAAX,IAAIC,gBAAOD,eAAAA,IAAIE,OAAO,cAAXF,oCAAAA,oBAAAA,aAAaG,IAAI,gBAAjBH,wCAAAA,kBAAqBI,UAAU,uCAAI;IAC9C,MAAOH,QAAQ,CAAEA,AAAI,YAAJA,MAAgBI,aAAcJ,OAAOA,KAAKG,UAAU;IACrE,OAAOH,AAAI,YAAJA,MAAgBI,eAAcJ,OAAO;AAC9C;AAEA;;;;;;AAMA,GACA,SAASK,cAAcN,GAAQ,EAAEO,IAAiB;IAChD,IAAMN,OAAOM,SAAS,YAAYP,IAAIQ,SAAS,KAAK,YAAY,CAACR,IAAIS,IAAI,GAAGV,YAAYC,OAAO;IAC/F,IAAI,CAACC,MAAM,OAAOD,IAAIE,OAAO;IAC7B,mEAAmE;IACnE,wEAAwE;IACxE,6BAA6B;IAC7BD,KAAKS,KAAK,CAACC,SAAS,GAAG;IACvB,IAAMC,WAAWd,OAAOG,MAAMY,SAAS,CAAwB,uCAAuCC,IAAI,CAAC;QAAC;KAAE;IAC9G,OAAOF,SACJG,KAAK,GACLC,MAAM,CAAC,OAAO,gBACdC,IAAI,CAAC,SAAS,0BACdP,KAAK,CAAC,YAAY,YAClBA,KA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function _object_spread_props(target, source) {
|
|
|
61
61
|
Every Plot-family + chart-shell feature here is wired into
|
|
62
62
|
`vizDrawPure` via `runLayout(ctx, [...features])`.
|
|
63
63
|
*/ import { extent, min, rollup, sum } from "d3-array";
|
|
64
|
-
import { select } from "d3-selection";
|
|
65
64
|
import { merge, unique } from "@d3plus/data";
|
|
66
|
-
import { date, elem
|
|
65
|
+
import { date, elem } from "@d3plus/dom";
|
|
67
66
|
import { resolveSpec } from "../pipeline/resolveSpec.js";
|
|
67
|
+
import { zoomControlsBox } from "../drawSteps/zoomControlsMarkup.js";
|
|
68
|
+
import { getTopLeftContributions } from "../drawSteps/topLeftControls.js";
|
|
69
|
+
import { topLeftControlsInset as topLeftControlsInsetRaw } from "../drawSteps/topLeftControlsMarkup.js";
|
|
68
70
|
var VALID_POSITIONS = new Set([
|
|
69
71
|
false,
|
|
70
72
|
"top",
|
|
@@ -189,7 +191,55 @@ var VALID_POSITIONS = new Set([
|
|
|
189
191
|
margin: claims
|
|
190
192
|
};
|
|
191
193
|
}
|
|
192
|
-
|
|
194
|
+
/**
|
|
195
|
+
A little breathing room added to a NON-zero corner inset, on top of the
|
|
196
|
+
exact pixel width the corner panel measured at. Without it, content
|
|
197
|
+
insets to EXACTLY the corner box's edge — any tiny discrepancy between
|
|
198
|
+
that hidden-probe measurement and the real rendered box (sub-pixel
|
|
199
|
+
rounding, a font metric quirk) then reads as the text visibly, if
|
|
200
|
+
slightly, running under the buttons.
|
|
201
|
+
*/ var CORNER_INSET_GAP = 6;
|
|
202
|
+
/**
|
|
203
|
+
How far content starting `top` px down the chart, whose right edge sits
|
|
204
|
+
`right` px in from the chart's right edge, must pull in its right edge to
|
|
205
|
+
clear the zoom-control panel pinned to the chart's top-right corner. Zero
|
|
206
|
+
when the chart shows no controls or the content starts below them.
|
|
207
|
+
*/ export function zoomControlsInset(viz, top, right) {
|
|
208
|
+
var box = zoomControlsBox(viz);
|
|
209
|
+
if (!box || top >= box.height) return 0;
|
|
210
|
+
var inset = box.width - right;
|
|
211
|
+
return inset > 0 ? inset + CORNER_INSET_GAP : 0;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
The left-side mirror of `zoomControlsInset`: how far content starting
|
|
215
|
+
`top` px down the chart, whose left edge sits `left` px in from the
|
|
216
|
+
chart's left edge, must pull in to clear the shared top-left controls
|
|
217
|
+
panel (back / table-view / search). Zero when nothing is showing there
|
|
218
|
+
or content starts below the panel's height.
|
|
219
|
+
*/ export function topLeftControlsInset(viz, top, left) {
|
|
220
|
+
var contributions = getTopLeftContributions(viz);
|
|
221
|
+
var inset = topLeftControlsInsetRaw(viz, top, left, contributions);
|
|
222
|
+
return inset > 0 ? inset + CORNER_INSET_GAP : 0;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
The combined left+right corner-panel insets for content starting `top`
|
|
226
|
+
px down the chart, plus the single symmetric amount CENTERED content
|
|
227
|
+
should inset both sides by to stay centered on the full chart width even
|
|
228
|
+
when only one corner has something to avoid (the larger of the two —
|
|
229
|
+
see `textBlockLayout`'s doc comment for why). Shared by `textBlockLayout`
|
|
230
|
+
(title/subtitle/total) and the legend's own top-position layout
|
|
231
|
+
(`featuresLegend.ts`), which independently needed this exact same
|
|
232
|
+
"combine the two corners' insets" math before this existed.
|
|
233
|
+
*/ export function cornerInsets(viz, top, left, right) {
|
|
234
|
+
var leftInset = topLeftControlsInset(viz, top, left);
|
|
235
|
+
var rightInset = zoomControlsInset(viz, top, right);
|
|
236
|
+
return {
|
|
237
|
+
left: leftInset,
|
|
238
|
+
right: rightInset,
|
|
239
|
+
symmetric: Math.max(leftInset, rightInset)
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
193
243
|
Shared layout logic for any "single line of text claiming margin.top" feature
|
|
194
244
|
(title, subtitle, total). Each feature passes the viz fields that source its
|
|
195
245
|
text + TextBox + config; the helper computes the panel + margin claim using
|
|
@@ -218,16 +268,43 @@ var VALID_POSITIONS = new Set([
|
|
|
218
268
|
}
|
|
219
269
|
]).locale(viz.schema.locale).width(width).config(viz.schema[opts.configKey]);
|
|
220
270
|
var boxes = textClass._textData();
|
|
271
|
+
// Text alongside the zoom controls (right) and/or the shared top-left
|
|
272
|
+
// controls panel (left — back/table-view/search) wraps short of them.
|
|
273
|
+
// Centered text insets both sides by the SAME (larger) amount so it stays
|
|
274
|
+
// centered on the full chart width, matching how it already behaved
|
|
275
|
+
// relative to zoom alone; start/end-aligned text instead just narrows the
|
|
276
|
+
// true available box (its unaffected edge stays exactly where it was).
|
|
277
|
+
var x = layoutMargin.left + padding.left;
|
|
278
|
+
var _cornerInsets = cornerInsets(viz, layoutMargin.top, layoutMargin.left + padding.left, layoutMargin.right + padding.right), leftInset = _cornerInsets.left, rightInset = _cornerInsets.right, symmetric = _cornerInsets.symmetric;
|
|
279
|
+
if ((rightInset || leftInset) && boxes.length) {
|
|
280
|
+
var centered = boxes[0].tA === "middle";
|
|
281
|
+
if (centered) {
|
|
282
|
+
x += symmetric;
|
|
283
|
+
width -= symmetric * 2;
|
|
284
|
+
} else {
|
|
285
|
+
x += leftInset;
|
|
286
|
+
width -= leftInset + rightInset;
|
|
287
|
+
}
|
|
288
|
+
textClass.width(width);
|
|
289
|
+
boxes = textClass._textData();
|
|
290
|
+
}
|
|
221
291
|
if (!boxes.length) return {
|
|
222
292
|
panel: null,
|
|
223
293
|
margin: {}
|
|
224
294
|
};
|
|
225
295
|
var box = boxes[0];
|
|
226
|
-
var x = layoutMargin.left + padding.left;
|
|
227
|
-
var y = layoutMargin.top;
|
|
228
296
|
var lineHeight = box.lH;
|
|
229
297
|
var blockPadding = (_ref = (_viz_schema_opts_configKey = viz.schema[opts.configKey]) === null || _viz_schema_opts_configKey === void 0 ? void 0 : _viz_schema_opts_configKey.padding) !== null && _ref !== void 0 ? _ref : 0;
|
|
230
298
|
var height = box.lines.length * lineHeight + blockPadding * 2;
|
|
299
|
+
// The claimed margin (below) already reserves `blockPadding` above AND
|
|
300
|
+
// below the text — shifting the panel down by that same amount is what
|
|
301
|
+
// actually centers the text within that reserved band, rather than
|
|
302
|
+
// pinning it flush to the very top of it. Previously `blockPadding` only
|
|
303
|
+
// grew/shrank the claimed space; it never moved the text within it,
|
|
304
|
+
// which is why the default title padding (5px) had no visible effect —
|
|
305
|
+
// the title sat at the top of its claim regardless, reading noticeably
|
|
306
|
+
// higher than the same-row zoom/back/search buttons beside it.
|
|
307
|
+
var y = layoutMargin.top + blockPadding;
|
|
231
308
|
var lines = box.lines.map(function(str, i) {
|
|
232
309
|
var _ref;
|
|
233
310
|
var _box_widths;
|
|
@@ -307,82 +384,6 @@ var VALID_POSITIONS = new Set([
|
|
|
307
384
|
});
|
|
308
385
|
}
|
|
309
386
|
};
|
|
310
|
-
/**
|
|
311
|
-
Converts `drawBack.ts` to a FeatureModule. Visible only when there are
|
|
312
|
-
drill-down history entries; emits a "← Back" TextNode at the chart's
|
|
313
|
-
top-left and claims its line height + padding × 2 from `margin.top`.
|
|
314
|
-
*/ export var backFeature = {
|
|
315
|
-
name: "back",
|
|
316
|
-
configFields: [
|
|
317
|
-
"backConfig"
|
|
318
|
-
],
|
|
319
|
-
layout: function layout(param) {
|
|
320
|
-
var viz = param.viz, layoutMargin = param.layoutMargin;
|
|
321
|
-
if (!viz._history || !viz._history.length) return {
|
|
322
|
-
panel: null,
|
|
323
|
-
margin: {}
|
|
324
|
-
};
|
|
325
|
-
var text = "← ".concat(viz.schema.translate("Back"));
|
|
326
|
-
viz._backClass.data([
|
|
327
|
-
{
|
|
328
|
-
text: text,
|
|
329
|
-
x: 0,
|
|
330
|
-
y: 0
|
|
331
|
-
}
|
|
332
|
-
]).config(viz.schema.backConfig);
|
|
333
|
-
var boxes = viz._backClass._textData();
|
|
334
|
-
// _backClass might have a fontSize/padding only style (no wrapping data),
|
|
335
|
-
// in which case _textData may be empty; fall back to direct accessor reads
|
|
336
|
-
// for the margin claim to match drawBack's math precisely.
|
|
337
|
-
var fontSize = viz._backClass.fontSize()();
|
|
338
|
-
var padding = viz._backClass.padding()();
|
|
339
|
-
var height = fontSize + padding * 2;
|
|
340
|
-
if (!boxes.length) {
|
|
341
|
-
return {
|
|
342
|
-
panel: null,
|
|
343
|
-
margin: {
|
|
344
|
-
top: height
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
var box = boxes[0];
|
|
349
|
-
var panel = {
|
|
350
|
-
type: "text",
|
|
351
|
-
key: "viz-back",
|
|
352
|
-
x: 0,
|
|
353
|
-
y: 0,
|
|
354
|
-
lines: box.lines.map(function(str, i) {
|
|
355
|
-
var _ref;
|
|
356
|
-
var _box_widths;
|
|
357
|
-
return {
|
|
358
|
-
text: str,
|
|
359
|
-
x: 0,
|
|
360
|
-
y: (i + 1) * box.lH - (box.lH - box.fS),
|
|
361
|
-
width: (_ref = (_box_widths = box.widths) === null || _box_widths === void 0 ? void 0 : _box_widths[i]) !== null && _ref !== void 0 ? _ref : 0
|
|
362
|
-
};
|
|
363
|
-
}),
|
|
364
|
-
font: {
|
|
365
|
-
family: box.fF,
|
|
366
|
-
size: box.fS,
|
|
367
|
-
baseline: "alphabetic"
|
|
368
|
-
},
|
|
369
|
-
paint: {
|
|
370
|
-
fill: box.fC,
|
|
371
|
-
opacity: box.fO
|
|
372
|
-
},
|
|
373
|
-
transform: {
|
|
374
|
-
x: layoutMargin.left,
|
|
375
|
-
y: layoutMargin.top
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
return {
|
|
379
|
-
panel: panel,
|
|
380
|
-
margin: {
|
|
381
|
-
top: height
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
};
|
|
386
387
|
/* -------------------------------- Legend --------------------------------- */ export { legendFeature } from "./featuresLegend.js";
|
|
387
388
|
/* -------------------------------- Timeline ------------------------------- */ /**
|
|
388
389
|
Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when
|
|
@@ -591,35 +592,7 @@ var VALID_POSITIONS = new Set([
|
|
|
591
592
|
};
|
|
592
593
|
}
|
|
593
594
|
};
|
|
594
|
-
/* ------------------------------ Attribution ------------------------------ */
|
|
595
|
-
Converts `drawAttribution.ts` to a FeatureModule.
|
|
596
|
-
|
|
597
|
-
Attribution is an HTML `<div>` overlay positioned absolutely outside the SVG
|
|
598
|
-
plane — it doesn't fit naturally as a SceneNode in the chart scene graph.
|
|
599
|
-
Rather than encode an HTML overlay into the scene graph, this feature runs
|
|
600
|
-
the DOM-creating side effect imperatively from inside `layout()`, so
|
|
601
|
-
invocation is funneled through `runLayout` for consistency with the
|
|
602
|
-
other features. It claims zero margin and emits no panel.
|
|
603
|
-
*/ export var attributionFeature = {
|
|
604
|
-
name: "attribution",
|
|
605
|
-
configFields: [
|
|
606
|
-
"attribution",
|
|
607
|
-
"attributionStyle"
|
|
608
|
-
],
|
|
609
|
-
layout: function layout(param) {
|
|
610
|
-
var viz = param.viz;
|
|
611
|
-
var attr = select(viz._select.node().parentNode).selectAll("div.d3plus-attribution").data(viz.schema.attribution ? [
|
|
612
|
-
0
|
|
613
|
-
] : []);
|
|
614
|
-
var attrEnter = attr.enter().append("div").attr("class", "d3plus-attribution");
|
|
615
|
-
attr.exit().remove();
|
|
616
|
-
attr = attr.merge(attrEnter).style("position", "absolute").html(viz.schema.attribution).style("right", "".concat(viz._margin.right, "px")).style("bottom", "".concat(viz._margin.bottom, "px")).call(stylize, viz.schema.attributionStyle);
|
|
617
|
-
return {
|
|
618
|
-
panel: null,
|
|
619
|
-
margin: {}
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
};
|
|
595
|
+
/* ------------------------------ Attribution ------------------------------ */ export { attributionFeature } from "./attributionFeature.js";
|
|
623
596
|
/**
|
|
624
597
|
Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/
|
|
625
598
|
subtitle: the text comes from `sum()` over the filtered data when `_total`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/features/features.ts"],"sourcesContent":["/**\n FeatureModule + layout engine. The chart-level features (title,\n subtitle, total, legend, timeline, colorScale, back) are\n `FeatureModule` values composed by `runLayout`, which performs\n **explicit margin negotiation** — each feature returns a `MarginClaim`\n + optional `panel` scene node + optional declarative `vizUpdate`\n writes, and the engine accumulates margins across features in order.\n\n Every Plot-family + chart-shell feature here is wired into\n `vizDrawPure` via `runLayout(ctx, [...features])`.\n*/\nimport {extent, min, rollup, sum} from \"d3-array\";\nimport {select} from \"d3-selection\";\n\nimport {merge, unique} from \"@d3plus/data\";\nimport type {DataPoint, MergedDataPoint} from \"@d3plus/data\";\nimport {date, elem, stylize} from \"@d3plus/dom\";\nimport type {D3Selection} from \"@d3plus/dom\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {resolveSpec} from \"../pipeline/resolveSpec.js\";\nimport type {VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n/** A margin claim, in pixels along each side. Unclaimed sides default to 0. */\nexport interface MarginClaim {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\n/** The shape a `layout` step returns: optional panel node + margin claim + optional viz writebacks. */\nexport interface FeatureLayout {\n panel: SceneNode | null;\n margin: MarginClaim;\n /**\n v4 purity: features that need to publish CROSS-FEATURE state — a\n write that a DIFFERENT feature or downstream stage will read — return\n those writes here as declarative key→value pairs. `runLayout`\n applies them to viz after the layout call so the next feature in\n the chain sees them.\n\n Key convention: keys are auto-prefixed with `_` to match viz's\n internal field convention. Return `{drawDepth: 2}` to write\n `viz._drawDepth`; explicitly-underscored keys (`{_drawDepth: 2}`)\n pass through unchanged for the rare case where the engine\n shouldn't prepend. This rule exists because a leading underscore\n is easy to forget and writing `viz.drawDepth` (no underscore) is\n almost never what callers want.\n\n Intra-feature local writes (a feature setting state that its OWN\n component instance reads inside the same `layout()` body) are\n legitimate direct mutations on viz — `vizUpdate` would defer the\n write past the local read. legendFeature's `_legendDepth` is an\n example of an intra-feature local; timelineFeature's\n `_timelineSelection` similarly mutates from its event handler\n context. The contract is about CROSS-feature mutation, not all\n mutation.\n */\n vizUpdate?: Record<string, unknown>;\n}\n\n/**\n @interface FeatureModule\n A chart-level component (title, subtitle, total, legend, timeline,\n colorScale, back, attribution) expressed as a pure value. Each feature:\n - contributes config keys to the chart's schema (`configFields`),\n - optionally derives extra fields onto the pipeline context (`derive`),\n - optionally claims a margin region + emits its panel scene (`layout`),\n - optionally registers event reducers (`events`).\n*/\nexport interface FeatureModule {\n name: string;\n /** Keys the chart's config inherits from this feature (used by E4 fluent gen). */\n configFields?: string[];\n /** Extra derivations to add into the pipeline context. */\n derive?: (ctx: VizContext) => Partial<VizContext>;\n /**\n Pure layout: read the (possibly updated-by-earlier-features) context and\n return the panel scene + margin this feature claims. The layoutEngine\n threads the margin claims through `ctx.layoutMargin` so a feature can\n read what earlier features already took.\n */\n layout?: (\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n ) => FeatureLayout;\n /**\n Event reducers `(ctx, event) => Partial<VizConfig>`. Fire when a\n user interaction occurs on a node tagged with this feature's name.\n */\n events?: Record<string, (ctx: VizContext, event: unknown) => unknown>;\n}\n\n/**\n Result of running a list of features through the layout engine.\n*/\nexport interface LayoutResult {\n /** Panel nodes in feature order, ready to compose into the scene root. */\n panels: SceneNode[];\n /** Final margin after every feature claimed its space. */\n margin: Required<MarginClaim>;\n}\n\n/**\n The allowed values for `legendPosition` and `colorScalePosition`.\n `false` means \"hidden\" (the feature still runs to tear down DOM); the\n four strings are the four sides.\n*/\nexport type PanelPosition = false | \"top\" | \"right\" | \"bottom\" | \"left\";\n\nconst VALID_POSITIONS: ReadonlySet<PanelPosition | string> = new Set([\n false as unknown as string,\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n]);\n\n/**\n Canonical sanitizer for `legendPosition` / `colorScalePosition`.\n Falls back to `\"bottom\"` when the user-supplied accessor returns\n something outside the allowed set. Single source of truth — used by\n `vizDrawPure` (for sanitized ctx publication) and by `legendFeature`\n + `colorScaleFeature` (for their internal positioning math).\n*/\nexport function sanitizePosition(raw: unknown): PanelPosition {\n return (VALID_POSITIONS.has(raw as string) ? raw : \"bottom\") as PanelPosition;\n}\n\n/**\n Runs each feature's `layout` in order, accumulating margin claims so that\n later features see the space already taken by earlier ones. The order of\n `features` is the layout order — this is how implicit `this._margin +=`\n side effects become *explicit* data flow.\n\n Today's order in `Viz._draw` (`drawTitle`, `drawSubtitle`, `drawTotal`,\n `drawBack`, `drawAttribution`, `drawColorScale`, `drawLegend`,\n `drawTimeline`) should be ported verbatim as the default sequence — port\n the math first, then improve.\n*/\nexport function runLayout(\n ctx: VizContext,\n features: FeatureModule[],\n baseMargin: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0},\n): LayoutResult {\n // `claims` is this call's accumulated margin (the returned delta).\n // `layoutMargin` handed to each feature is the running TOTAL —\n // `baseMargin` (margin already taken by prior runLayout calls in the same\n // draw) plus the claims taken so far in this call — so a feature reads\n // the true current margin without touching viz._margin.\n const claims: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0};\n const panels: SceneNode[] = [];\n for (const f of features) {\n if (!f.layout) continue;\n const layoutMargin: Required<MarginClaim> = {\n top: baseMargin.top + claims.top,\n right: baseMargin.right + claims.right,\n bottom: baseMargin.bottom + claims.bottom,\n left: baseMargin.left + claims.left,\n };\n const result = f.layout({...ctx, layoutMargin});\n const {panel, margin: claim, vizUpdate} = result;\n if (panel) panels.push(panel);\n claims.top += claim.top ?? 0;\n claims.right += claim.right ?? 0;\n claims.bottom += claim.bottom ?? 0;\n claims.left += claim.left ?? 0;\n // v4 purity: features publish cross-feature viz writes declaratively\n // via `vizUpdate`. The engine applies them — features don't mutate\n // viz directly from layout(). Skips own component-instance config\n // calls (those are local mutation, not cross-feature). Use\n // `Object.keys` (not `for...in`) so inherited enumerable properties\n // on a class-instance vizUpdate don't leak onto viz.\n //\n // Key convention: keys are auto-prefixed with `_` to land on the\n // viz's internal field convention (`viz._drawDepth`, `viz._legendDepth`).\n // Features should return UNPREFIXED keys (`{drawDepth: 2}`); the\n // engine normalizes — so feature authors can't accidentally write\n // `viz.drawDepth` (a different non-underscore property) instead of\n // `viz._drawDepth`. Keys that already start with `_` are passed\n // through unchanged so future explicit-internal writes still work.\n if (vizUpdate && ctx.viz) {\n const target = ctx.viz as Record<string, unknown>;\n for (const k of Object.keys(vizUpdate)) {\n const key = k.startsWith(\"_\") ? k : `_${k}`;\n target[key] = vizUpdate[k];\n }\n }\n }\n return {panels, margin: claims};\n}\n\n/* --------------------------- text-block features --------------------------- */\n\n/**\n Shared layout logic for any \"single line of text claiming margin.top\" feature\n (title, subtitle, total). Each feature passes the viz fields that source its\n text + TextBox + config; the helper computes the panel + margin claim using\n the TextBox's pure `_textData()` (no DOM).\n*/\nfunction textBlockLayout(\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n opts: {\n panelKey: string;\n getText: (viz: VizInstance) => string | false;\n textClassKey: string; // e.g. \"_titleClass\"\n configKey: string; // schema key, e.g. \"titleConfig\"\n paddingMethod: string; // schema key, e.g. \"titlePadding\"\n },\n): FeatureLayout {\n const {viz, layoutMargin} = ctx;\n const text = opts.getText(viz);\n if (!text) return {panel: null, margin: {}};\n\n const usesPadding = (viz.schema[opts.paddingMethod] as (viz: VizInstance) => boolean)(viz);\n const padding = usesPadding\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n const width =\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right);\n\n const textClass = viz[opts.textClassKey];\n textClass\n .data([{text}])\n .locale(viz.schema.locale)\n .width(width)\n .config(viz.schema[opts.configKey]);\n const boxes = textClass._textData() as Array<{\n lines: string[];\n lH: number;\n fS: number;\n fF: string;\n fC: string;\n fO: number;\n tA: string;\n widths: number[];\n }>;\n if (!boxes.length) return {panel: null, margin: {}};\n const box = boxes[0];\n\n const x = layoutMargin.left + padding.left;\n const y = layoutMargin.top;\n const lineHeight = box.lH;\n const blockPadding = (viz.schema[opts.configKey]?.padding as number) ?? 0;\n const height = box.lines.length * lineHeight + blockPadding * 2;\n\n const lines = box.lines.map((str: string, i: number) => ({\n text: str,\n x:\n box.tA === \"middle\"\n ? width / 2\n : box.tA === \"end\"\n ? width\n : 0,\n y: (i + 1) * lineHeight - (lineHeight - box.fS),\n width: box.widths?.[i] ?? 0,\n }));\n\n const panel: SceneNode = {\n type: \"text\",\n key: opts.panelKey,\n x: 0,\n y: 0,\n lines,\n font: {\n family: box.fF,\n size: box.fS,\n anchor:\n box.tA === \"middle\" || box.tA === \"end\" || box.tA === \"start\"\n ? (box.tA as \"middle\" | \"end\" | \"start\")\n : \"start\",\n baseline: \"alphabetic\",\n },\n paint: {fill: box.fC, opacity: box.fO},\n transform: {x, y},\n };\n\n return {panel, margin: {top: height}};\n}\n\n/**\n Title as a FeatureModule. Uses `_titleClass._textData()` for height\n (pure compute, no DOM) and returns the margin claim explicitly.\n*/\nexport const titleFeature: FeatureModule = {\n name: \"title\",\n configFields: [\"title\", \"titleConfig\", \"titlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-title\",\n getText: viz => (viz.schema.title ? viz.schema.title(viz._filteredData || []) : false),\n textClassKey: \"_titleClass\",\n configKey: \"titleConfig\",\n paddingMethod: \"titlePadding\",\n }),\n};\n\n/** Converts `drawSubtitle.ts` to a FeatureModule. Mirrors titleFeature. */\nexport const subtitleFeature: FeatureModule = {\n name: \"subtitle\",\n configFields: [\"subtitle\", \"subtitleConfig\", \"subtitlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-subtitle\",\n getText: viz => (viz.schema.subtitle ? viz.schema.subtitle(viz._filteredData || []) : false),\n textClassKey: \"_subtitleClass\",\n configKey: \"subtitleConfig\",\n paddingMethod: \"subtitlePadding\",\n }),\n};\n\n/**\n Converts `drawBack.ts` to a FeatureModule. Visible only when there are\n drill-down history entries; emits a \"← Back\" TextNode at the chart's\n top-left and claims its line height + padding × 2 from `margin.top`.\n*/\nexport const backFeature: FeatureModule = {\n name: \"back\",\n configFields: [\"backConfig\"],\n layout: ({viz, layoutMargin}) => {\n if (!viz._history || !viz._history.length) return {panel: null, margin: {}};\n\n const text = `← ${viz.schema.translate(\"Back\")}`;\n viz._backClass.data([{text, x: 0, y: 0}]).config(viz.schema.backConfig);\n const boxes = viz._backClass._textData() as Array<{\n lines: string[];\n lH: number;\n fS: number;\n fF: string;\n fC: string;\n fO: number;\n tA: string;\n widths: number[];\n }>;\n // _backClass might have a fontSize/padding only style (no wrapping data),\n // in which case _textData may be empty; fall back to direct accessor reads\n // for the margin claim to match drawBack's math precisely.\n const fontSize = viz._backClass.fontSize()();\n const padding = viz._backClass.padding()();\n const height = fontSize + padding * 2;\n\n if (!boxes.length) {\n return {panel: null, margin: {top: height}};\n }\n const box = boxes[0];\n\n const panel: SceneNode = {\n type: \"text\",\n key: \"viz-back\",\n x: 0,\n y: 0,\n lines: box.lines.map((str, i) => ({\n text: str,\n x: 0,\n y: (i + 1) * box.lH - (box.lH - box.fS),\n width: box.widths?.[i] ?? 0,\n })),\n font: {family: box.fF, size: box.fS, baseline: \"alphabetic\"},\n paint: {fill: box.fC, opacity: box.fO},\n transform: {x: layoutMargin.left, y: layoutMargin.top},\n };\n return {panel, margin: {top: height}};\n },\n};\n\n/* -------------------------------- Legend --------------------------------- */\n\nexport {legendFeature} from \"./featuresLegend.js\";\n\n/* -------------------------------- Timeline ------------------------------- */\n\n/**\n Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when\n the brush selection changes — kept here so the feature owns its event flow.\n*/\nfunction setTimeFilter(viz: VizInstance, s: Date | Date[] | number[]): void {\n if (!Array.isArray(s)) s = [s, s] as Date[];\n if (JSON.stringify(s) !== JSON.stringify(viz._timelineSelection)) {\n viz._timelineSelection = s;\n const nums = (s as Array<Date | number>).map(Number) as number[];\n viz\n .timeFilter!((d: DataPoint) => {\n const ms = (date(viz.schema.time(d)) as Date).getTime();\n return ms >= nums[0] && ms <= nums[1];\n })\n .render!();\n }\n}\n\n/**\n Converts `drawTimeline.ts` to a FeatureModule.\n\n Visible only when `_time` is set, `_timeline` is truthy, and there is more\n than one distinct tick. Renders the chart's `_timelineClass` Timeline\n instance (compute mode — scene comes from Timeline.toScene via Viz.toScene's\n components collection) and claims `margin.bottom` from its outerBounds.\n*/\nexport const timelineFeature: FeatureModule = {\n name: \"timeline\",\n configFields: [\"timeline\", \"timelineConfig\", \"timelinePadding\"],\n layout: ({viz, layoutMargin}) => {\n let timelinePossible = viz.schema.time && viz.schema.timeline;\n const ticks = (\n timelinePossible\n ? unique(viz._data.map(viz.schema.time)).map(\n (d: unknown) => date(d as string | number),\n )\n : []\n ) as Date[];\n timelinePossible = timelinePossible && ticks.length > 1;\n const padding = viz.schema.timelinePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n const transform = {\n transform: `translate(${layoutMargin.left + padding.left}, 0)`,\n };\n\n const timelineGroup = elem(\"g.d3plus-viz-timeline\", {\n condition: timelinePossible,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!timelinePossible) return {panel: null, margin: {}};\n\n const timeline = viz._timelineClass\n .renderMode(\"compute\")\n .domain(extent(ticks) as [Date, Date])\n .duration(viz.schema.duration)\n .height(viz.schema.height - layoutMargin.bottom)\n .locale(viz.schema.locale)\n .select(timelineGroup)\n .ticks(ticks.sort((a: Date, b: Date) => +a - +b))\n .width(\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right),\n );\n\n // Clamp bound = the full time range (every tick); it never goes stale\n // mid-render. Clamping to `viz._filteredData`'s extent instead collapsed a\n // freshly-committed range down to the previous selection — the release\n // snap-back (e.g. [2017,2024] clamped to a stale [2022,2022]).\n const fullExtent = extent(ticks) as [Date, Date];\n if (!viz._timelineSelection) {\n // First render only: default to the *filtered* extent, which the\n // synthesized default timeFilter pins to the latest period (see\n // vizPreDraw) — the historical default. `timelineDefault` overrides it.\n const filtered = extent(\n (viz._filteredData || [])\n .map(viz.schema.time)\n .map((d: unknown) => date(d as string | number)) as Date[],\n ) as [Date, Date];\n viz._timelineSelection =\n viz.schema.timelineDefault || (filtered[0] ? filtered : fullExtent);\n } else {\n if (viz._timelineSelection[0] < fullExtent[0])\n viz._timelineSelection[0] = fullExtent[0];\n if (viz._timelineSelection[1] > fullExtent[1])\n viz._timelineSelection[1] = fullExtent[1];\n }\n timeline.selection(viz._timelineSelection);\n\n // Repaint the scene when playback toggles without moving the selection\n // (e.g. a manual pause), so the play/pause glyph refreshes immediately.\n timeline._onPlayToggle = () => viz._scheduleSceneRepaint();\n\n const config = viz.schema.timelineConfig;\n timeline\n .config(config)\n .on(\"brush\", (s: Date[]) => {\n // Filter on \"end\", not on every brush move. Re-rendering the whole Viz\n // mid-drag re-creates the d3-brush (and starts a brush transition),\n // which fights the active gesture and can make the selection snap back\n // on release — and it re-lays-out the chart on every pixel of the drag,\n // which is costly for large data. The brush still tracks the cursor\n // live; the chart updates when the drag finishes. User `on.brush`\n // callbacks still fire for custom live behavior.\n if (config.on && config.on.brush) config.on.brush(s);\n })\n .on(\"end\", (s: Date[]) => {\n setTimeFilter(viz, s);\n if (config.on && config.on.end) config.on.end(s);\n })\n .render();\n\n return {\n panel: null,\n margin: {bottom: timeline.outerBounds().height + timeline.padding() * 2},\n };\n },\n};\n\n/* ------------------------------- ColorScale ------------------------------ */\n\n/**\n Converts `drawColorScale.ts` to a FeatureModule.\n\n Visible only when `_colorScale` is truthy and `_colorScalePosition` resolves\n to a side. Renders the chart's `_colorScaleClass` ColorScale instance and\n claims margin along its position side.\n*/\nexport const colorScaleFeature: FeatureModule = {\n name: \"colorScale\",\n configFields: [\n \"colorScale\",\n \"colorScaleConfig\",\n \"colorScaleMaxSize\",\n \"colorScalePadding\",\n \"colorScalePosition\",\n ],\n layout: ({viz, layoutMargin}) => {\n const data = Array.from(\n rollup(\n viz._data,\n (leaves: DataPoint[]) => merge(leaves, viz.schema.aggs),\n (d: DataPoint, i: number) =>\n `${viz.schema.time ? viz.schema.time(d, i) : \"all\"}-${viz._ids(d, i).join(\"_\")}`,\n ).values(),\n );\n\n const position = sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz)));\n const wide = [\"top\", \"bottom\"].includes(position as string);\n const showColorScale = viz.schema.colorScale && position;\n const padding = viz.schema.colorScalePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n const availableWidth =\n viz.schema.width - (layoutMargin.left + layoutMargin.right + padding.left + padding.right);\n const width = wide\n ? min([viz.schema.colorScaleMaxSize, availableWidth])!\n : viz.schema.width - (layoutMargin.left + layoutMargin.right);\n\n const availableHeight =\n viz.schema.height - (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top);\n const height = !wide\n ? min([viz.schema.colorScaleMaxSize, availableHeight])!\n : viz.schema.height - (layoutMargin.bottom + layoutMargin.top);\n\n const transform = {\n opacity: position ? 1 : 0,\n transform: `translate(${\n wide\n ? layoutMargin.left + padding.left + (availableWidth - width) / 2\n : layoutMargin.left\n }, ${\n wide\n ? layoutMargin.top\n : layoutMargin.top + padding.top + (availableHeight - height) / 2\n })`,\n };\n\n const scaleGroup = elem(\"g.d3plus-viz-colorScale\", {\n condition: showColorScale && !viz.schema.colorScaleConfig.select,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!viz.schema.colorScale) return {panel: null, margin: {}};\n\n const scaleData = data.filter((d: MergedDataPoint, i: number) => {\n const c = viz.schema.colorScale(d as unknown as DataPoint, i);\n return c !== undefined && c !== null;\n });\n\n // Discrete (bucket/jenks/quantile) colorScales render their swatches via an\n // internal Legend, which composes cleanly through the Viz scene — so run\n // them in compute mode (like the legend) so the Viz's toScene owns them and\n // hover/active dimming applies. Without this they render full-mode, where\n // paintComponentScene paints a full-opacity copy that overlays and defeats\n // the dimming. The smooth-gradient variant stays full-mode: its gradient\n // fill is materialized through paintComponentScene, not the Viz scene.\n const csCfg = (viz.schema.colorScaleConfig || {}) as {\n scale?: string;\n bucketAxis?: boolean;\n };\n const csDiscrete =\n !csCfg.bucketAxis &&\n [\"buckets\", \"jenks\", \"quantile\"].includes(\n typeof csCfg.scale === \"string\" ? csCfg.scale : \"\",\n );\n\n viz._colorScaleClass\n .renderMode(csDiscrete ? \"compute\" : \"full\")\n .align(\n ({bottom: \"end\", left: \"start\", right: \"end\", top: \"start\"} as Record<string, string>)[\n position as string\n ] || \"bottom\",\n )\n .duration(viz.schema.duration)\n .data(scaleData)\n .height(height)\n .locale(viz.schema.locale)\n .orient(position)\n .select(scaleGroup)\n .value(viz.schema.colorScale)\n .width(width)\n .config(viz.schema.colorScaleConfig)\n .render();\n\n const margin: Record<string, number> = {};\n if (showColorScale) {\n const scaleBounds = viz._colorScaleClass.outerBounds();\n if (!viz.schema.colorScaleConfig.select && scaleBounds.height) {\n // Use the colorScale's OWN padding for its margin claim — not the\n // legend's, so a custom legendPadding doesn't shift the\n // colorScale's claim when the legend is hidden. The colorScale\n // class is the source of truth.\n const csPadding =\n typeof viz._colorScaleClass.padding === \"function\"\n ? viz._colorScaleClass.padding()\n : viz._legendClass.padding();\n if (wide) margin[position] = scaleBounds.height + csPadding * 2;\n else margin[position] = scaleBounds.width + csPadding * 2;\n }\n }\n return {panel: null, margin};\n },\n};\n\n/* ------------------------------ Attribution ------------------------------ */\n\n/**\n Converts `drawAttribution.ts` to a FeatureModule.\n\n Attribution is an HTML `<div>` overlay positioned absolutely outside the SVG\n plane — it doesn't fit naturally as a SceneNode in the chart scene graph.\n Rather than encode an HTML overlay into the scene graph, this feature runs\n the DOM-creating side effect imperatively from inside `layout()`, so\n invocation is funneled through `runLayout` for consistency with the\n other features. It claims zero margin and emits no panel.\n*/\nexport const attributionFeature: FeatureModule = {\n name: \"attribution\",\n configFields: [\"attribution\", \"attributionStyle\"],\n layout: ({viz}) => {\n let attr: D3Selection = select(viz._select.node().parentNode)\n .selectAll(\"div.d3plus-attribution\")\n .data(viz.schema.attribution ? [0] : []) as unknown as D3Selection;\n\n const attrEnter = attr\n .enter()\n .append(\"div\")\n .attr(\"class\", \"d3plus-attribution\");\n\n attr.exit().remove();\n\n attr = attr\n .merge(attrEnter as never)\n .style(\"position\", \"absolute\")\n .html(viz.schema.attribution)\n .style(\"right\", `${viz._margin.right}px`)\n .style(\"bottom\", `${viz._margin.bottom}px`)\n .call(stylize as never, viz.schema.attributionStyle);\n\n return {panel: null, margin: {}};\n },\n};\n\n/**\n Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/\n subtitle: the text comes from `sum()` over the filtered data when `_total`\n is a function, or from `sum(data.map(_size))` when `_total === true`.\n*/\nexport const totalFeature: FeatureModule = {\n name: \"total\",\n configFields: [\"total\", \"totalConfig\", \"totalFormat\", \"totalPadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-total\",\n getText: viz => {\n const data = viz._filteredData || [];\n const total =\n typeof viz.schema.total === \"function\"\n ? sum(data.map(viz.schema.total))\n : viz.schema.total === true && viz._size\n ? sum(data.map(viz._size))\n : false;\n return total ? viz.schema.totalFormat(total) : false;\n },\n textClassKey: \"_totalClass\",\n configKey: \"totalConfig\",\n paddingMethod: \"totalPadding\",\n }),\n};\n"],"names":["extent","min","rollup","sum","select","merge","unique","date","elem","stylize","resolveSpec","VALID_POSITIONS","Set","sanitizePosition","raw","has","runLayout","ctx","features","baseMargin","top","right","bottom","left","claims","panels","f","claim","layout","layoutMargin","result","panel","margin","vizUpdate","push","viz","target","Object","keys","k","key","startsWith","textBlockLayout","opts","text","getText","usesPadding","schema","paddingMethod","padding","_padding","width","textClass","textClassKey","data","locale","config","configKey","boxes","_textData","length","box","x","y","lineHeight","lH","blockPadding","height","lines","map","str","i","tA","fS","widths","type","panelKey","font","family","fF","size","anchor","baseline","paint","fill","fC","opacity","fO","transform","titleFeature","name","configFields","title","_filteredData","subtitleFeature","subtitle","backFeature","_history","translate","_backClass","backConfig","fontSize","legendFeature","setTimeFilter","s","Array","isArray","JSON","stringify","_timelineSelection","nums","Number","timeFilter","d","ms","time","getTime","render","timelineFeature","timelinePossible","timeline","ticks","_data","timelinePadding","timelineGroup","condition","enter","parent","_select","duration","update","node","_timelineClass","renderMode","domain","sort","a","b","fullExtent","filtered","timelineDefault","selection","_onPlayToggle","_scheduleSceneRepaint","timelineConfig","on","brush","end","outerBounds","colorScaleFeature","from","leaves","aggs","_ids","join","values","position","colorScalePosition","bind","wide","includes","showColorScale","colorScale","colorScalePadding","availableWidth","colorScaleMaxSize","availableHeight","scaleGroup","colorScaleConfig","scaleData","filter","c","undefined","csCfg","csDiscrete","bucketAxis","scale","_colorScaleClass","align","orient","value","scaleBounds","csPadding","_legendClass","attributionFeature","attr","parentNode","selectAll","attribution","attrEnter","append","exit","remove","style","html","_margin","call","attributionStyle","totalFeature","total","_size","totalFormat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUA,GACA,SAAQA,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,GAAG,QAAO,WAAW;AAClD,SAAQC,MAAM,QAAO,eAAe;AAEpC,SAAQC,KAAK,EAAEC,MAAM,QAAO,eAAe;AAE3C,SAAQC,IAAI,EAAEC,IAAI,EAAEC,OAAO,QAAO,cAAc;AAKhD,SAAQC,WAAW,QAAO,6BAA6B;AA2FvD,IAAMC,kBAAuD,IAAIC,IAAI;IACnE;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;AAMA,GACA,OAAO,SAASC,iBAAiBC,GAAY;IAC3C,OAAQH,gBAAgBI,GAAG,CAACD,OAAiBA,MAAM;AACrD;AAEA;;;;;;;;;;AAUA,GACA,OAAO,SAASE,UACdC,GAAe,EACfC,QAAyB;QACzBC,aAAAA,iEAAoC;QAACC,KAAK;QAAGC,OAAO;QAAGC,QAAQ;QAAGC,MAAM;IAAC;IAEzE,mEAAmE;IACnE,+DAA+D;IAC/D,0EAA0E;IAC1E,uEAAuE;IACvE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KAC7BpK,IAAIY,MAAM,CAACwJ,KAAK,KAAK,QAAQpK,IAAIqK,KAAK,GACpCrM,IAAImD,KAAKe,GAAG,CAAClC,IAAIqK,KAAK,KACtB;gBACR,OAAOD,QAAQpK,IAAIY,MAAM,CAAC0J,WAAW,CAACF,SAAS;YACjD;YACAlJ,cAAc;YACdI,WAAW;YACXT,eAAe;QACjB;;AACJ,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/features/features.ts"],"sourcesContent":["/**\n FeatureModule + layout engine. The chart-level features (title,\n subtitle, total, legend, timeline, colorScale, back) are\n `FeatureModule` values composed by `runLayout`, which performs\n **explicit margin negotiation** — each feature returns a `MarginClaim`\n + optional `panel` scene node + optional declarative `vizUpdate`\n writes, and the engine accumulates margins across features in order.\n\n Every Plot-family + chart-shell feature here is wired into\n `vizDrawPure` via `runLayout(ctx, [...features])`.\n*/\nimport {extent, min, rollup, sum} from \"d3-array\";\n\nimport {merge, unique} from \"@d3plus/data\";\nimport type {DataPoint, MergedDataPoint} from \"@d3plus/data\";\nimport {date, elem} from \"@d3plus/dom\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {resolveSpec} from \"../pipeline/resolveSpec.js\";\nimport type {VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {zoomControlsBox} from \"../drawSteps/zoomControlsMarkup.js\";\nimport {getTopLeftContributions} from \"../drawSteps/topLeftControls.js\";\nimport {topLeftControlsInset as topLeftControlsInsetRaw} from \"../drawSteps/topLeftControlsMarkup.js\";\n\n/** A margin claim, in pixels along each side. Unclaimed sides default to 0. */\nexport interface MarginClaim {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\n/** The shape a `layout` step returns: optional panel node + margin claim + optional viz writebacks. */\nexport interface FeatureLayout {\n panel: SceneNode | null;\n margin: MarginClaim;\n /**\n v4 purity: features that need to publish CROSS-FEATURE state — a\n write that a DIFFERENT feature or downstream stage will read — return\n those writes here as declarative key→value pairs. `runLayout`\n applies them to viz after the layout call so the next feature in\n the chain sees them.\n\n Key convention: keys are auto-prefixed with `_` to match viz's\n internal field convention. Return `{drawDepth: 2}` to write\n `viz._drawDepth`; explicitly-underscored keys (`{_drawDepth: 2}`)\n pass through unchanged for the rare case where the engine\n shouldn't prepend. This rule exists because a leading underscore\n is easy to forget and writing `viz.drawDepth` (no underscore) is\n almost never what callers want.\n\n Intra-feature local writes (a feature setting state that its OWN\n component instance reads inside the same `layout()` body) are\n legitimate direct mutations on viz — `vizUpdate` would defer the\n write past the local read. legendFeature's `_legendDepth` is an\n example of an intra-feature local; timelineFeature's\n `_timelineSelection` similarly mutates from its event handler\n context. The contract is about CROSS-feature mutation, not all\n mutation.\n */\n vizUpdate?: Record<string, unknown>;\n}\n\n/**\n @interface FeatureModule\n A chart-level component (title, subtitle, total, legend, timeline,\n colorScale, back, attribution) expressed as a pure value. Each feature:\n - contributes config keys to the chart's schema (`configFields`),\n - optionally derives extra fields onto the pipeline context (`derive`),\n - optionally claims a margin region + emits its panel scene (`layout`),\n - optionally registers event reducers (`events`).\n*/\nexport interface FeatureModule {\n name: string;\n /** Keys the chart's config inherits from this feature (used by E4 fluent gen). */\n configFields?: string[];\n /** Extra derivations to add into the pipeline context. */\n derive?: (ctx: VizContext) => Partial<VizContext>;\n /**\n Pure layout: read the (possibly updated-by-earlier-features) context and\n return the panel scene + margin this feature claims. The layoutEngine\n threads the margin claims through `ctx.layoutMargin` so a feature can\n read what earlier features already took.\n */\n layout?: (\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n ) => FeatureLayout;\n /**\n Event reducers `(ctx, event) => Partial<VizConfig>`. Fire when a\n user interaction occurs on a node tagged with this feature's name.\n */\n events?: Record<string, (ctx: VizContext, event: unknown) => unknown>;\n}\n\n/**\n Result of running a list of features through the layout engine.\n*/\nexport interface LayoutResult {\n /** Panel nodes in feature order, ready to compose into the scene root. */\n panels: SceneNode[];\n /** Final margin after every feature claimed its space. */\n margin: Required<MarginClaim>;\n}\n\n/**\n The allowed values for `legendPosition` and `colorScalePosition`.\n `false` means \"hidden\" (the feature still runs to tear down DOM); the\n four strings are the four sides.\n*/\nexport type PanelPosition = false | \"top\" | \"right\" | \"bottom\" | \"left\";\n\nconst VALID_POSITIONS: ReadonlySet<PanelPosition | string> = new Set([\n false as unknown as string,\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n]);\n\n/**\n Canonical sanitizer for `legendPosition` / `colorScalePosition`.\n Falls back to `\"bottom\"` when the user-supplied accessor returns\n something outside the allowed set. Single source of truth — used by\n `vizDrawPure` (for sanitized ctx publication) and by `legendFeature`\n + `colorScaleFeature` (for their internal positioning math).\n*/\nexport function sanitizePosition(raw: unknown): PanelPosition {\n return (VALID_POSITIONS.has(raw as string) ? raw : \"bottom\") as PanelPosition;\n}\n\n/**\n Runs each feature's `layout` in order, accumulating margin claims so that\n later features see the space already taken by earlier ones. The order of\n `features` is the layout order — this is how implicit `this._margin +=`\n side effects become *explicit* data flow.\n\n Today's order in `Viz._draw` (`drawTitle`, `drawSubtitle`, `drawTotal`,\n `drawBack`, `drawAttribution`, `drawColorScale`, `drawLegend`,\n `drawTimeline`) should be ported verbatim as the default sequence — port\n the math first, then improve.\n*/\nexport function runLayout(\n ctx: VizContext,\n features: FeatureModule[],\n baseMargin: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0},\n): LayoutResult {\n // `claims` is this call's accumulated margin (the returned delta).\n // `layoutMargin` handed to each feature is the running TOTAL —\n // `baseMargin` (margin already taken by prior runLayout calls in the same\n // draw) plus the claims taken so far in this call — so a feature reads\n // the true current margin without touching viz._margin.\n const claims: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0};\n const panels: SceneNode[] = [];\n for (const f of features) {\n if (!f.layout) continue;\n const layoutMargin: Required<MarginClaim> = {\n top: baseMargin.top + claims.top,\n right: baseMargin.right + claims.right,\n bottom: baseMargin.bottom + claims.bottom,\n left: baseMargin.left + claims.left,\n };\n const result = f.layout({...ctx, layoutMargin});\n const {panel, margin: claim, vizUpdate} = result;\n if (panel) panels.push(panel);\n claims.top += claim.top ?? 0;\n claims.right += claim.right ?? 0;\n claims.bottom += claim.bottom ?? 0;\n claims.left += claim.left ?? 0;\n // v4 purity: features publish cross-feature viz writes declaratively\n // via `vizUpdate`. The engine applies them — features don't mutate\n // viz directly from layout(). Skips own component-instance config\n // calls (those are local mutation, not cross-feature). Use\n // `Object.keys` (not `for...in`) so inherited enumerable properties\n // on a class-instance vizUpdate don't leak onto viz.\n //\n // Key convention: keys are auto-prefixed with `_` to land on the\n // viz's internal field convention (`viz._drawDepth`, `viz._legendDepth`).\n // Features should return UNPREFIXED keys (`{drawDepth: 2}`); the\n // engine normalizes — so feature authors can't accidentally write\n // `viz.drawDepth` (a different non-underscore property) instead of\n // `viz._drawDepth`. Keys that already start with `_` are passed\n // through unchanged so future explicit-internal writes still work.\n if (vizUpdate && ctx.viz) {\n const target = ctx.viz as Record<string, unknown>;\n for (const k of Object.keys(vizUpdate)) {\n const key = k.startsWith(\"_\") ? k : `_${k}`;\n target[key] = vizUpdate[k];\n }\n }\n }\n return {panels, margin: claims};\n}\n\n/* --------------------------- text-block features --------------------------- */\n\n/** A TextBox `_textData()` row, as the text-block features read it. */\ninterface TextDatum {\n lines: string[];\n lH: number;\n fS: number;\n fF: string;\n fC: string;\n fO: number;\n tA: string;\n widths: number[];\n}\n\n/**\n A little breathing room added to a NON-zero corner inset, on top of the\n exact pixel width the corner panel measured at. Without it, content\n insets to EXACTLY the corner box's edge — any tiny discrepancy between\n that hidden-probe measurement and the real rendered box (sub-pixel\n rounding, a font metric quirk) then reads as the text visibly, if\n slightly, running under the buttons.\n*/\nconst CORNER_INSET_GAP = 6;\n\n/**\n How far content starting `top` px down the chart, whose right edge sits\n `right` px in from the chart's right edge, must pull in its right edge to\n clear the zoom-control panel pinned to the chart's top-right corner. Zero\n when the chart shows no controls or the content starts below them.\n*/\nexport function zoomControlsInset(viz: VizInstance, top: number, right: number): number {\n const box = zoomControlsBox(viz as never);\n if (!box || top >= box.height) return 0;\n const inset = box.width - right;\n return inset > 0 ? inset + CORNER_INSET_GAP : 0;\n}\n\n/**\n The left-side mirror of `zoomControlsInset`: how far content starting\n `top` px down the chart, whose left edge sits `left` px in from the\n chart's left edge, must pull in to clear the shared top-left controls\n panel (back / table-view / search). Zero when nothing is showing there\n or content starts below the panel's height.\n*/\nexport function topLeftControlsInset(viz: VizInstance, top: number, left: number): number {\n const contributions = getTopLeftContributions(viz as never);\n const inset = topLeftControlsInsetRaw(viz as never, top, left, contributions);\n return inset > 0 ? inset + CORNER_INSET_GAP : 0;\n}\n\n/**\n The combined left+right corner-panel insets for content starting `top`\n px down the chart, plus the single symmetric amount CENTERED content\n should inset both sides by to stay centered on the full chart width even\n when only one corner has something to avoid (the larger of the two —\n see `textBlockLayout`'s doc comment for why). Shared by `textBlockLayout`\n (title/subtitle/total) and the legend's own top-position layout\n (`featuresLegend.ts`), which independently needed this exact same\n \"combine the two corners' insets\" math before this existed.\n*/\nexport function cornerInsets(\n viz: VizInstance,\n top: number,\n left: number,\n right: number,\n): {left: number; right: number; symmetric: number} {\n const leftInset = topLeftControlsInset(viz, top, left);\n const rightInset = zoomControlsInset(viz, top, right);\n return {left: leftInset, right: rightInset, symmetric: Math.max(leftInset, rightInset)};\n}\n\n/**\n Shared layout logic for any \"single line of text claiming margin.top\" feature\n (title, subtitle, total). Each feature passes the viz fields that source its\n text + TextBox + config; the helper computes the panel + margin claim using\n the TextBox's pure `_textData()` (no DOM).\n*/\nfunction textBlockLayout(\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n opts: {\n panelKey: string;\n getText: (viz: VizInstance) => string | false;\n textClassKey: string; // e.g. \"_titleClass\"\n configKey: string; // schema key, e.g. \"titleConfig\"\n paddingMethod: string; // schema key, e.g. \"titlePadding\"\n },\n): FeatureLayout {\n const {viz, layoutMargin} = ctx;\n const text = opts.getText(viz);\n if (!text) return {panel: null, margin: {}};\n\n const usesPadding = (viz.schema[opts.paddingMethod] as (viz: VizInstance) => boolean)(viz);\n const padding = usesPadding\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n let width =\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right);\n\n const textClass = viz[opts.textClassKey];\n textClass\n .data([{text}])\n .locale(viz.schema.locale)\n .width(width)\n .config(viz.schema[opts.configKey]);\n let boxes = textClass._textData() as TextDatum[];\n\n // Text alongside the zoom controls (right) and/or the shared top-left\n // controls panel (left — back/table-view/search) wraps short of them.\n // Centered text insets both sides by the SAME (larger) amount so it stays\n // centered on the full chart width, matching how it already behaved\n // relative to zoom alone; start/end-aligned text instead just narrows the\n // true available box (its unaffected edge stays exactly where it was).\n let x = layoutMargin.left + padding.left;\n const {left: leftInset, right: rightInset, symmetric} = cornerInsets(\n viz,\n layoutMargin.top,\n layoutMargin.left + padding.left,\n layoutMargin.right + padding.right,\n );\n if ((rightInset || leftInset) && boxes.length) {\n const centered = boxes[0].tA === \"middle\";\n if (centered) {\n x += symmetric;\n width -= symmetric * 2;\n } else {\n x += leftInset;\n width -= leftInset + rightInset;\n }\n textClass.width(width);\n boxes = textClass._textData() as TextDatum[];\n }\n if (!boxes.length) return {panel: null, margin: {}};\n const box = boxes[0];\n\n const lineHeight = box.lH;\n const blockPadding = (viz.schema[opts.configKey]?.padding as number) ?? 0;\n const height = box.lines.length * lineHeight + blockPadding * 2;\n // The claimed margin (below) already reserves `blockPadding` above AND\n // below the text — shifting the panel down by that same amount is what\n // actually centers the text within that reserved band, rather than\n // pinning it flush to the very top of it. Previously `blockPadding` only\n // grew/shrank the claimed space; it never moved the text within it,\n // which is why the default title padding (5px) had no visible effect —\n // the title sat at the top of its claim regardless, reading noticeably\n // higher than the same-row zoom/back/search buttons beside it.\n const y = layoutMargin.top + blockPadding;\n\n const lines = box.lines.map((str: string, i: number) => ({\n text: str,\n x:\n box.tA === \"middle\"\n ? width / 2\n : box.tA === \"end\"\n ? width\n : 0,\n y: (i + 1) * lineHeight - (lineHeight - box.fS),\n width: box.widths?.[i] ?? 0,\n }));\n\n const panel: SceneNode = {\n type: \"text\",\n key: opts.panelKey,\n x: 0,\n y: 0,\n lines,\n font: {\n family: box.fF,\n size: box.fS,\n anchor:\n box.tA === \"middle\" || box.tA === \"end\" || box.tA === \"start\"\n ? (box.tA as \"middle\" | \"end\" | \"start\")\n : \"start\",\n baseline: \"alphabetic\",\n },\n paint: {fill: box.fC, opacity: box.fO},\n transform: {x, y},\n };\n\n return {panel, margin: {top: height}};\n}\n\n/**\n Title as a FeatureModule. Uses `_titleClass._textData()` for height\n (pure compute, no DOM) and returns the margin claim explicitly.\n*/\nexport const titleFeature: FeatureModule = {\n name: \"title\",\n configFields: [\"title\", \"titleConfig\", \"titlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-title\",\n getText: viz => (viz.schema.title ? viz.schema.title(viz._filteredData || []) : false),\n textClassKey: \"_titleClass\",\n configKey: \"titleConfig\",\n paddingMethod: \"titlePadding\",\n }),\n};\n\n/** Converts `drawSubtitle.ts` to a FeatureModule. Mirrors titleFeature. */\nexport const subtitleFeature: FeatureModule = {\n name: \"subtitle\",\n configFields: [\"subtitle\", \"subtitleConfig\", \"subtitlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-subtitle\",\n getText: viz => (viz.schema.subtitle ? viz.schema.subtitle(viz._filteredData || []) : false),\n textClassKey: \"_subtitleClass\",\n configKey: \"subtitleConfig\",\n paddingMethod: \"subtitlePadding\",\n }),\n};\n\n/* -------------------------------- Legend --------------------------------- */\n\nexport {legendFeature} from \"./featuresLegend.js\";\n\n/* -------------------------------- Timeline ------------------------------- */\n\n/**\n Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when\n the brush selection changes — kept here so the feature owns its event flow.\n*/\nfunction setTimeFilter(viz: VizInstance, s: Date | Date[] | number[]): void {\n if (!Array.isArray(s)) s = [s, s] as Date[];\n if (JSON.stringify(s) !== JSON.stringify(viz._timelineSelection)) {\n viz._timelineSelection = s;\n const nums = (s as Array<Date | number>).map(Number) as number[];\n viz\n .timeFilter!((d: DataPoint) => {\n const ms = (date(viz.schema.time(d)) as Date).getTime();\n return ms >= nums[0] && ms <= nums[1];\n })\n .render!();\n }\n}\n\n/**\n Converts `drawTimeline.ts` to a FeatureModule.\n\n Visible only when `_time` is set, `_timeline` is truthy, and there is more\n than one distinct tick. Renders the chart's `_timelineClass` Timeline\n instance (compute mode — scene comes from Timeline.toScene via Viz.toScene's\n components collection) and claims `margin.bottom` from its outerBounds.\n*/\nexport const timelineFeature: FeatureModule = {\n name: \"timeline\",\n configFields: [\"timeline\", \"timelineConfig\", \"timelinePadding\"],\n layout: ({viz, layoutMargin}) => {\n let timelinePossible = viz.schema.time && viz.schema.timeline;\n const ticks = (\n timelinePossible\n ? unique(viz._data.map(viz.schema.time)).map(\n (d: unknown) => date(d as string | number),\n )\n : []\n ) as Date[];\n timelinePossible = timelinePossible && ticks.length > 1;\n const padding = viz.schema.timelinePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n const transform = {\n transform: `translate(${layoutMargin.left + padding.left}, 0)`,\n };\n\n const timelineGroup = elem(\"g.d3plus-viz-timeline\", {\n condition: timelinePossible,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!timelinePossible) return {panel: null, margin: {}};\n\n const timeline = viz._timelineClass\n .renderMode(\"compute\")\n .domain(extent(ticks) as [Date, Date])\n .duration(viz.schema.duration)\n .height(viz.schema.height - layoutMargin.bottom)\n .locale(viz.schema.locale)\n .select(timelineGroup)\n .ticks(ticks.sort((a: Date, b: Date) => +a - +b))\n .width(\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right),\n );\n\n // Clamp bound = the full time range (every tick); it never goes stale\n // mid-render. Clamping to `viz._filteredData`'s extent instead collapsed a\n // freshly-committed range down to the previous selection — the release\n // snap-back (e.g. [2017,2024] clamped to a stale [2022,2022]).\n const fullExtent = extent(ticks) as [Date, Date];\n if (!viz._timelineSelection) {\n // First render only: default to the *filtered* extent, which the\n // synthesized default timeFilter pins to the latest period (see\n // vizPreDraw) — the historical default. `timelineDefault` overrides it.\n const filtered = extent(\n (viz._filteredData || [])\n .map(viz.schema.time)\n .map((d: unknown) => date(d as string | number)) as Date[],\n ) as [Date, Date];\n viz._timelineSelection =\n viz.schema.timelineDefault || (filtered[0] ? filtered : fullExtent);\n } else {\n if (viz._timelineSelection[0] < fullExtent[0])\n viz._timelineSelection[0] = fullExtent[0];\n if (viz._timelineSelection[1] > fullExtent[1])\n viz._timelineSelection[1] = fullExtent[1];\n }\n timeline.selection(viz._timelineSelection);\n\n // Repaint the scene when playback toggles without moving the selection\n // (e.g. a manual pause), so the play/pause glyph refreshes immediately.\n timeline._onPlayToggle = () => viz._scheduleSceneRepaint();\n\n const config = viz.schema.timelineConfig;\n timeline\n .config(config)\n .on(\"brush\", (s: Date[]) => {\n // Filter on \"end\", not on every brush move. Re-rendering the whole Viz\n // mid-drag re-creates the d3-brush (and starts a brush transition),\n // which fights the active gesture and can make the selection snap back\n // on release — and it re-lays-out the chart on every pixel of the drag,\n // which is costly for large data. The brush still tracks the cursor\n // live; the chart updates when the drag finishes. User `on.brush`\n // callbacks still fire for custom live behavior.\n if (config.on && config.on.brush) config.on.brush(s);\n })\n .on(\"end\", (s: Date[]) => {\n setTimeFilter(viz, s);\n if (config.on && config.on.end) config.on.end(s);\n })\n .render();\n\n return {\n panel: null,\n margin: {bottom: timeline.outerBounds().height + timeline.padding() * 2},\n };\n },\n};\n\n/* ------------------------------- ColorScale ------------------------------ */\n\n/**\n Converts `drawColorScale.ts` to a FeatureModule.\n\n Visible only when `_colorScale` is truthy and `_colorScalePosition` resolves\n to a side. Renders the chart's `_colorScaleClass` ColorScale instance and\n claims margin along its position side.\n*/\nexport const colorScaleFeature: FeatureModule = {\n name: \"colorScale\",\n configFields: [\n \"colorScale\",\n \"colorScaleConfig\",\n \"colorScaleMaxSize\",\n \"colorScalePadding\",\n \"colorScalePosition\",\n ],\n layout: ({viz, layoutMargin}) => {\n const data = Array.from(\n rollup(\n viz._data,\n (leaves: DataPoint[]) => merge(leaves, viz.schema.aggs),\n (d: DataPoint, i: number) =>\n `${viz.schema.time ? viz.schema.time(d, i) : \"all\"}-${viz._ids(d, i).join(\"_\")}`,\n ).values(),\n );\n\n const position = sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz)));\n const wide = [\"top\", \"bottom\"].includes(position as string);\n const showColorScale = viz.schema.colorScale && position;\n const padding = viz.schema.colorScalePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n const availableWidth =\n viz.schema.width - (layoutMargin.left + layoutMargin.right + padding.left + padding.right);\n const width = wide\n ? min([viz.schema.colorScaleMaxSize, availableWidth])!\n : viz.schema.width - (layoutMargin.left + layoutMargin.right);\n\n const availableHeight =\n viz.schema.height - (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top);\n const height = !wide\n ? min([viz.schema.colorScaleMaxSize, availableHeight])!\n : viz.schema.height - (layoutMargin.bottom + layoutMargin.top);\n\n const transform = {\n opacity: position ? 1 : 0,\n transform: `translate(${\n wide\n ? layoutMargin.left + padding.left + (availableWidth - width) / 2\n : layoutMargin.left\n }, ${\n wide\n ? layoutMargin.top\n : layoutMargin.top + padding.top + (availableHeight - height) / 2\n })`,\n };\n\n const scaleGroup = elem(\"g.d3plus-viz-colorScale\", {\n condition: showColorScale && !viz.schema.colorScaleConfig.select,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!viz.schema.colorScale) return {panel: null, margin: {}};\n\n const scaleData = data.filter((d: MergedDataPoint, i: number) => {\n const c = viz.schema.colorScale(d as unknown as DataPoint, i);\n return c !== undefined && c !== null;\n });\n\n // Discrete (bucket/jenks/quantile) colorScales render their swatches via an\n // internal Legend, which composes cleanly through the Viz scene — so run\n // them in compute mode (like the legend) so the Viz's toScene owns them and\n // hover/active dimming applies. Without this they render full-mode, where\n // paintComponentScene paints a full-opacity copy that overlays and defeats\n // the dimming. The smooth-gradient variant stays full-mode: its gradient\n // fill is materialized through paintComponentScene, not the Viz scene.\n const csCfg = (viz.schema.colorScaleConfig || {}) as {\n scale?: string;\n bucketAxis?: boolean;\n };\n const csDiscrete =\n !csCfg.bucketAxis &&\n [\"buckets\", \"jenks\", \"quantile\"].includes(\n typeof csCfg.scale === \"string\" ? csCfg.scale : \"\",\n );\n\n viz._colorScaleClass\n .renderMode(csDiscrete ? \"compute\" : \"full\")\n .align(\n ({bottom: \"end\", left: \"start\", right: \"end\", top: \"start\"} as Record<string, string>)[\n position as string\n ] || \"bottom\",\n )\n .duration(viz.schema.duration)\n .data(scaleData)\n .height(height)\n .locale(viz.schema.locale)\n .orient(position)\n .select(scaleGroup)\n .value(viz.schema.colorScale)\n .width(width)\n .config(viz.schema.colorScaleConfig)\n .render();\n\n const margin: Record<string, number> = {};\n if (showColorScale) {\n const scaleBounds = viz._colorScaleClass.outerBounds();\n if (!viz.schema.colorScaleConfig.select && scaleBounds.height) {\n // Use the colorScale's OWN padding for its margin claim — not the\n // legend's, so a custom legendPadding doesn't shift the\n // colorScale's claim when the legend is hidden. The colorScale\n // class is the source of truth.\n const csPadding =\n typeof viz._colorScaleClass.padding === \"function\"\n ? viz._colorScaleClass.padding()\n : viz._legendClass.padding();\n if (wide) margin[position] = scaleBounds.height + csPadding * 2;\n else margin[position] = scaleBounds.width + csPadding * 2;\n }\n }\n return {panel: null, margin};\n },\n};\n\n/* ------------------------------ Attribution ------------------------------ */\n\nexport {attributionFeature} from \"./attributionFeature.js\";\n\n/**\n Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/\n subtitle: the text comes from `sum()` over the filtered data when `_total`\n is a function, or from `sum(data.map(_size))` when `_total === true`.\n*/\nexport const totalFeature: FeatureModule = {\n name: \"total\",\n configFields: [\"total\", \"totalConfig\", \"totalFormat\", \"totalPadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-total\",\n getText: viz => {\n const data = viz._filteredData || [];\n const total =\n typeof viz.schema.total === \"function\"\n ? sum(data.map(viz.schema.total))\n : viz.schema.total === true && viz._size\n ? sum(data.map(viz._size))\n : false;\n return total ? viz.schema.totalFormat(total) : false;\n },\n textClassKey: \"_totalClass\",\n configKey: \"totalConfig\",\n paddingMethod: \"totalPadding\",\n }),\n};\n"],"names":["extent","min","rollup","sum","merge","unique","date","elem","resolveSpec","zoomControlsBox","getTopLeftContributions","topLeftControlsInset","topLeftControlsInsetRaw","VALID_POSITIONS","Set","sanitizePosition","raw","has","runLayout","ctx","features","baseMargin","top","right","bottom","left","claims","panels","f","claim","layout","layoutMargin","result","panel","margin","vizUpdate","push","viz","target","Object","keys","k","key","startsWith","CORNER_INSET_GAP","zoomControlsInset","box","height","inset","width","contributions","cornerInsets","leftInset","rightInset","symmetric","Math","max","textBlockLayout","opts","text","getText","usesPadding","schema","paddingMethod","padding","_padding","textClass","textClassKey","data","locale","config","configKey","boxes","_textData","x","length","centered","tA","lineHeight","lH","blockPadding","lines","y","map","str","i","fS","widths","type","panelKey","font","family","fF","size","anchor","baseline","paint","fill","fC","opacity","fO","transform","titleFeature","name","configFields","title","_filteredData","subtitleFeature","subtitle","legendFeature","setTimeFilter","s","Array","isArray","JSON","stringify","_timelineSelection","nums","Number","timeFilter","d","ms","time","getTime","render","timelineFeature","timelinePossible","timeline","ticks","_data","timelinePadding","timelineGroup","condition","enter","parent","_select","duration","update","node","_timelineClass","renderMode","domain","select","sort","a","b","fullExtent","filtered","timelineDefault","selection","_onPlayToggle","_scheduleSceneRepaint","timelineConfig","on","brush","end","outerBounds","colorScaleFeature","from","leaves","aggs","_ids","join","values","position","colorScalePosition","bind","wide","includes","showColorScale","colorScale","colorScalePadding","availableWidth","colorScaleMaxSize","availableHeight","scaleGroup","colorScaleConfig","scaleData","filter","c","undefined","csCfg","csDiscrete","bucketAxis","scale","_colorScaleClass","align","orient","value","scaleBounds","csPadding","_legendClass","attributionFeature","totalFeature","total","_size","totalFormat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUA,GACA,SAAQA,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,GAAG,QAAO,WAAW;AAElD,SAAQC,KAAK,EAAEC,MAAM,QAAO,eAAe;AAE3C,SAAQC,IAAI,EAAEC,IAAI,QAAO,cAAc;AAIvC,SAAQC,WAAW,QAAO,6BAA6B;AAGvD,SAAQC,eAAe,QAAO,qCAAqC;AACnE,SAAQC,uBAAuB,QAAO,kCAAkC;AACxE,SAAQC,wBAAwBC,uBAAuB,QAAO,wCAAwC;AAyFtG,IAAMC,kBAAuD,IAAIC,IAAI;IACnE;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;AAMA,GACA,OAAO,SAASC,iBAAiBC,GAAY;IAC3C,OAAQH,gBAAgBI,GAAG,CAACD,OAAiBA,MAAM;AACrD;AAEA;;;;;;;;;;AAUA,GACA,OAAO,SAASE,UACdC,GAAe,EACfC,QAAyB;QACzBC,aAAAA,iEAAoC;QAACC,KAAK;QAAGC,OAAO;QAAGC,QAAQ;QAAGC,MAAM;IAAC;IAEzE,mEAAmE;IACnE,+DAA+D;IAC/D,0EAA0E;IAC1E,uEAAuE;IACvE,wDAAwD;IACxD,IAAMC,SAAgC;QAACJ,KAAK;QAAGC,OAAO;QAAGC,QAAQ;QAAGC,MAAM;IAAC;IAC3E,IAAME,SAAsB,EAAE;QACzB,kCAAA,2BAAA;;QAAL,QAAK,YAAWP,6BAAX,SAAA,6BAAA,QAAA,yBAAA,iCAAqB;YAArB,IAAMQ,IAAN;gBAWWC,YACEA,cACCA,eACFA;YAbf,IAAI,CAACD,EAAEE,MAAM,EAAE;YACf,IAAMC,eAAsC;gBAC1CT,KAAKD,WAAWC,GAAG,GAAGI,OAAOJ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