@d3plus/core 4.2.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2137 -953
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/internal.js +7 -1
- package/es/internal.js.map +1 -1
- package/es/src/charts/AreaPlot/index.js +1 -2
- package/es/src/charts/AreaPlot/index.js.map +1 -1
- package/es/src/charts/BarChart/index.js +1 -2
- package/es/src/charts/BarChart/index.js.map +1 -1
- package/es/src/charts/BoxWhisker/index.js +1 -2
- package/es/src/charts/BoxWhisker/index.js.map +1 -1
- package/es/src/charts/BumpChart/index.js +1 -2
- package/es/src/charts/BumpChart/index.js.map +1 -1
- package/es/src/charts/Chord/applyLayout.js +205 -0
- package/es/src/charts/Chord/applyLayout.js.map +1 -0
- package/es/src/charts/Chord/emit.js +168 -0
- package/es/src/charts/Chord/emit.js.map +1 -0
- package/es/src/charts/Chord/index.js +234 -0
- package/es/src/charts/Chord/index.js.map +1 -0
- package/es/src/charts/Geomap/basemapTheme.js +78 -0
- package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
- package/es/src/charts/Geomap/emit.js +58 -9
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +93 -99
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/LinePlot/index.js +1 -2
- package/es/src/charts/LinePlot/index.js.map +1 -1
- package/es/src/charts/Matrix/emit.js +6 -0
- package/es/src/charts/Matrix/emit.js.map +1 -1
- package/es/src/charts/Matrix/index.js +1 -2
- package/es/src/charts/Matrix/index.js.map +1 -1
- package/es/src/charts/Network/emit.js +58 -24
- package/es/src/charts/Network/emit.js.map +1 -1
- package/es/src/charts/Network/index.js +34 -54
- package/es/src/charts/Network/index.js.map +1 -1
- package/es/src/charts/Pack/emit.js +3 -0
- package/es/src/charts/Pack/emit.js.map +1 -1
- package/es/src/charts/Pack/index.js +1 -2
- package/es/src/charts/Pack/index.js.map +1 -1
- package/es/src/charts/Pie/emit.js +6 -2
- package/es/src/charts/Pie/emit.js.map +1 -1
- package/es/src/charts/Pie/index.js +1 -2
- package/es/src/charts/Pie/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +99 -4
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +25 -5
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/Plot/plotZoom.js +278 -0
- package/es/src/charts/Plot/plotZoom.js.map +1 -0
- package/es/src/charts/Priestley/emit.js +4 -0
- package/es/src/charts/Priestley/emit.js.map +1 -1
- package/es/src/charts/Priestley/index.js +1 -2
- package/es/src/charts/Priestley/index.js.map +1 -1
- package/es/src/charts/Radar/emit.js +4 -1
- package/es/src/charts/Radar/emit.js.map +1 -1
- package/es/src/charts/Radar/index.js +1 -2
- package/es/src/charts/Radar/index.js.map +1 -1
- package/es/src/charts/RadialMatrix/emit.js +6 -0
- package/es/src/charts/RadialMatrix/emit.js.map +1 -1
- package/es/src/charts/RadialMatrix/index.js +1 -2
- package/es/src/charts/RadialMatrix/index.js.map +1 -1
- package/es/src/charts/Rings/emit.js +74 -8
- package/es/src/charts/Rings/emit.js.map +1 -1
- package/es/src/charts/Rings/index.js +11 -3
- package/es/src/charts/Rings/index.js.map +1 -1
- package/es/src/charts/Sankey/emit.js +55 -11
- package/es/src/charts/Sankey/emit.js.map +1 -1
- package/es/src/charts/Sankey/index.js +8 -2
- package/es/src/charts/Sankey/index.js.map +1 -1
- package/es/src/charts/StackedArea/index.js +1 -2
- package/es/src/charts/StackedArea/index.js.map +1 -1
- package/es/src/charts/Tree/emit.js +8 -2
- package/es/src/charts/Tree/emit.js.map +1 -1
- package/es/src/charts/Tree/index.js +1 -2
- package/es/src/charts/Tree/index.js.map +1 -1
- package/es/src/charts/Treemap/index.js +1 -2
- package/es/src/charts/Treemap/index.js.map +1 -1
- package/es/src/charts/definition/ChartDefinition.js.map +1 -1
- package/es/src/charts/drawSteps/backControl.js +70 -0
- package/es/src/charts/drawSteps/backControl.js.map +1 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
- package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
- package/es/src/charts/drawSteps/minimap.js +370 -0
- package/es/src/charts/drawSteps/minimap.js.map +1 -0
- package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
- package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/searchControls.js +358 -0
- package/es/src/charts/drawSteps/searchControls.js.map +1 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/tableView.js +173 -0
- package/es/src/charts/drawSteps/tableView.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewControl.js +39 -0
- package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
- package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControls.js +73 -0
- package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
- package/es/src/charts/drawSteps/zoomControls.js +314 -175
- package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
- package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
- package/es/src/charts/features/attributionFeature.js +137 -0
- package/es/src/charts/features/attributionFeature.js.map +1 -0
- package/es/src/charts/features/axes.js +20 -8
- package/es/src/charts/features/axes.js.map +1 -1
- package/es/src/charts/features/chartGeometry.js +16 -2
- package/es/src/charts/features/chartGeometry.js.map +1 -1
- package/es/src/charts/features/edgeArrows.js +155 -0
- package/es/src/charts/features/edgeArrows.js.map +1 -0
- package/es/src/charts/features/emitHelpers.js +8 -0
- package/es/src/charts/features/emitHelpers.js.map +1 -1
- package/es/src/charts/features/ensureZoomDom.js +63 -12
- package/es/src/charts/features/ensureZoomDom.js.map +1 -1
- package/es/src/charts/features/features.js +83 -110
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +45 -17
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/features/plotPaint.js +32 -7
- package/es/src/charts/features/plotPaint.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +3 -1
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/features/zoomExtent.js +185 -0
- package/es/src/charts/features/zoomExtent.js.map +1 -0
- package/es/src/charts/helpers/tileAttributions.js +26 -0
- package/es/src/charts/helpers/tileAttributions.js.map +1 -1
- package/es/src/charts/index.js +1 -0
- package/es/src/charts/index.js.map +1 -1
- package/es/src/charts/pipeline/runVizPipeline.js +33 -14
- package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
- package/es/src/charts/pipeline/vizDrawPure.js +32 -6
- package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
- package/es/src/charts/viz/Viz.js +102 -61
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/VizBase.js +157 -4
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js +32 -2
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +4 -1
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +247 -51
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +7 -3
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/components/Axis/Axis.js +10 -1
- package/es/src/components/Axis/Axis.js.map +1 -1
- package/es/src/components/Axis/axisLayoutLabels.js +2 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
- package/es/src/components/Axis/axisRender.js +5 -1
- package/es/src/components/Axis/axisRender.js.map +1 -1
- package/es/src/components/Legend/legendConfig.js +86 -20
- package/es/src/components/Legend/legendConfig.js.map +1 -1
- package/es/src/shapes/Shape.js +12 -10
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/hitAreaNode.js +31 -5
- package/es/src/shapes/hitAreaNode.js.map +1 -1
- package/es/src/shapes/interactionPoints.js +30 -0
- package/es/src/shapes/interactionPoints.js.map +1 -0
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +11 -10
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +8 -1
- package/types/src/charts/Chord/applyLayout.d.ts +43 -0
- package/types/src/charts/Chord/emit.d.ts +10 -0
- package/types/src/charts/Chord/index.d.ts +19 -0
- package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
- package/types/src/charts/Plot/index.d.ts +32 -2
- package/types/src/charts/Plot/pipeline.d.ts +2 -1
- package/types/src/charts/Plot/plotZoom.d.ts +65 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
- package/types/src/charts/drawSteps/backControl.d.ts +29 -0
- package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
- package/types/src/charts/drawSteps/minimap.d.ts +19 -0
- package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
- package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
- package/types/src/charts/drawSteps/tableView.d.ts +23 -0
- package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
- package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
- package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
- package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
- package/types/src/charts/features/attributionFeature.d.ts +21 -0
- package/types/src/charts/features/axes.d.ts +1 -1
- package/types/src/charts/features/chartGeometry.d.ts +9 -3
- package/types/src/charts/features/edgeArrows.d.ts +92 -0
- package/types/src/charts/features/emitHelpers.d.ts +11 -0
- package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
- package/types/src/charts/features/features.d.ts +32 -17
- package/types/src/charts/features/featuresLegend.d.ts +15 -0
- package/types/src/charts/features/plotPaint.d.ts +15 -2
- package/types/src/charts/features/zoomExtent.d.ts +25 -0
- package/types/src/charts/index.d.ts +1 -0
- package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
- package/types/src/charts/viz/Viz.d.ts +31 -1
- package/types/src/charts/viz/VizBase.d.ts +86 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
- package/types/src/charts/viz/vizDefaults.d.ts +155 -0
- package/types/src/charts/viz/vizTypes.d.ts +75 -1
- package/types/src/components/Axis/Axis.d.ts +2 -0
- package/types/src/shapes/Shape.d.ts +2 -2
- package/types/src/shapes/hitAreaNode.d.ts +5 -4
- package/types/src/shapes/interactionPoints.d.ts +15 -0
- package/types/src/utils/D3plusConfig.d.ts +102 -8
- package/umd/d3plus-core.full.js +39793 -34875
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +5836 -4264
- package/umd/d3plus-core.js +13998 -9927
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +3716 -2264
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array_limit(arr, i) {
|
|
10
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
11
|
+
if (_i == null) return;
|
|
12
|
+
var _arr = [];
|
|
13
|
+
var _n = true;
|
|
14
|
+
var _d = false;
|
|
15
|
+
var _s, _e;
|
|
16
|
+
try {
|
|
17
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
18
|
+
_arr.push(_s.value);
|
|
19
|
+
if (i && _arr.length === i) break;
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
_d = true;
|
|
23
|
+
_e = err;
|
|
24
|
+
} finally{
|
|
25
|
+
try {
|
|
26
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
27
|
+
} finally{
|
|
28
|
+
if (_d) throw _e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return _arr;
|
|
32
|
+
}
|
|
33
|
+
function _non_iterable_rest() {
|
|
34
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
35
|
+
}
|
|
36
|
+
function _sliced_to_array(arr, i) {
|
|
37
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
38
|
+
}
|
|
39
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
|
+
if (!o) return;
|
|
41
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
42
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
43
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
44
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
Automatic maximum zoom scale (#85): how far a chart can zoom depends on
|
|
49
|
+
what it draws. A network of a few large nodes needs little zoom, while a
|
|
50
|
+
detailed map should be able to zoom all the way into its smallest path.
|
|
51
|
+
|
|
52
|
+
@module
|
|
53
|
+
*/ import { pathBounds } from "@d3plus/math";
|
|
54
|
+
import { areaPath, linePath } from "@d3plus/render";
|
|
55
|
+
/**
|
|
56
|
+
Width/height of each measurable piece of a scene node's own geometry
|
|
57
|
+
(before its transform). A Line/Area series spans the whole chart, so its
|
|
58
|
+
detail is the segment between consecutive data points rather than the
|
|
59
|
+
series' own extent.
|
|
60
|
+
*/ function nodeSizes(node) {
|
|
61
|
+
var pts = node.interactionPoints;
|
|
62
|
+
if (pts && pts.length > 1) {
|
|
63
|
+
var sizes = [];
|
|
64
|
+
for(var i = 1; i < pts.length; i++)sizes.push([
|
|
65
|
+
Math.abs(pts[i].x - pts[i - 1].x),
|
|
66
|
+
Math.abs(pts[i].y - pts[i - 1].y)
|
|
67
|
+
]);
|
|
68
|
+
return sizes;
|
|
69
|
+
}
|
|
70
|
+
var size = nodeSize(node);
|
|
71
|
+
return size ? [
|
|
72
|
+
size
|
|
73
|
+
] : [];
|
|
74
|
+
}
|
|
75
|
+
/** Width/height of a scene node's own geometry (before its transform). */ function nodeSize(node) {
|
|
76
|
+
switch(node.type){
|
|
77
|
+
case "rect":
|
|
78
|
+
case "image":
|
|
79
|
+
return [
|
|
80
|
+
node.width,
|
|
81
|
+
node.height
|
|
82
|
+
];
|
|
83
|
+
case "circle":
|
|
84
|
+
return [
|
|
85
|
+
node.r * 2,
|
|
86
|
+
node.r * 2
|
|
87
|
+
];
|
|
88
|
+
case "path":
|
|
89
|
+
{
|
|
90
|
+
var b = pathBounds(node.d);
|
|
91
|
+
return [
|
|
92
|
+
b.width,
|
|
93
|
+
b.height
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
case "line":
|
|
97
|
+
{
|
|
98
|
+
var b1 = pathBounds(linePath(node));
|
|
99
|
+
return [
|
|
100
|
+
b1.width,
|
|
101
|
+
b1.height
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
case "area":
|
|
105
|
+
{
|
|
106
|
+
var b2 = pathBounds(areaPath(node));
|
|
107
|
+
return [
|
|
108
|
+
b2.width,
|
|
109
|
+
b2.height
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
default:
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
The zoom scale at which the chart's smallest data shape fills the chart
|
|
118
|
+
area (less `padding` on each side, matching `zoomToBounds`), floored at 1.
|
|
119
|
+
|
|
120
|
+
Data shapes are the top-level datum-bearing nodes of `_chartScene` (a
|
|
121
|
+
Line/Area series is measured per segment — see `nodeSizes`). Chart
|
|
122
|
+
decorations (axes, gridlines, radar spokes, …) are nested in groups, text
|
|
123
|
+
labels scale with the shapes they annotate, and `::hit` nodes duplicate
|
|
124
|
+
the geometry of the shape they belong to, so none of those are measured.
|
|
125
|
+
|
|
126
|
+
@param nodes The chart's `_chartScene`.
|
|
127
|
+
@param width Chart-area width.
|
|
128
|
+
@param height Chart-area height.
|
|
129
|
+
@param padding Pixel padding kept around a shape zoomed to fill the area.
|
|
130
|
+
@param baseScale Any scale the chart's own transform already applies.
|
|
131
|
+
*/ export function autoZoomMax(nodes, width, height, padding) {
|
|
132
|
+
var baseScale = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
|
|
133
|
+
var fitW = Math.max(1, width - padding * 2), fitH = Math.max(1, height - padding * 2);
|
|
134
|
+
var max = 1;
|
|
135
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
136
|
+
try {
|
|
137
|
+
for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
138
|
+
var node = _step.value;
|
|
139
|
+
var _ref;
|
|
140
|
+
var _node_transform;
|
|
141
|
+
if (node.datum === undefined || node.type === "group" || node.type === "text") continue;
|
|
142
|
+
if (String(node.key).endsWith("::hit")) continue;
|
|
143
|
+
var s = baseScale * ((_ref = (_node_transform = node.transform) === null || _node_transform === void 0 ? void 0 : _node_transform.scale) !== null && _ref !== void 0 ? _ref : 1);
|
|
144
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
145
|
+
try {
|
|
146
|
+
for(var _iterator1 = nodeSizes(node)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
147
|
+
var _step_value = _sliced_to_array(_step1.value, 2), w = _step_value[0], h = _step_value[1];
|
|
148
|
+
// A zero-width (or -height) shape only constrains the other dimension;
|
|
149
|
+
// one with no extent at all can't be zoomed into.
|
|
150
|
+
var k = Math.min(w > 0 ? fitW / (w * s) : Infinity, h > 0 ? fitH / (h * s) : Infinity);
|
|
151
|
+
if (Number.isFinite(k) && k > max) max = k;
|
|
152
|
+
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
_didIteratorError1 = true;
|
|
155
|
+
_iteratorError1 = err;
|
|
156
|
+
} finally{
|
|
157
|
+
try {
|
|
158
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
159
|
+
_iterator1.return();
|
|
160
|
+
}
|
|
161
|
+
} finally{
|
|
162
|
+
if (_didIteratorError1) {
|
|
163
|
+
throw _iteratorError1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch (err) {
|
|
169
|
+
_didIteratorError = true;
|
|
170
|
+
_iteratorError = err;
|
|
171
|
+
} finally{
|
|
172
|
+
try {
|
|
173
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
174
|
+
_iterator.return();
|
|
175
|
+
}
|
|
176
|
+
} finally{
|
|
177
|
+
if (_didIteratorError) {
|
|
178
|
+
throw _iteratorError;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return max;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=zoomExtent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/features/zoomExtent.ts"],"sourcesContent":["/**\n Automatic maximum zoom scale (#85): how far a chart can zoom depends on\n what it draws. A network of a few large nodes needs little zoom, while a\n detailed map should be able to zoom all the way into its smallest path.\n\n @module\n*/\n\nimport {pathBounds} from \"@d3plus/math\";\nimport {areaPath, linePath} from \"@d3plus/render\";\nimport type {SceneNode} from \"@d3plus/render\";\n\n/**\n Width/height of each measurable piece of a scene node's own geometry\n (before its transform). A Line/Area series spans the whole chart, so its\n detail is the segment between consecutive data points rather than the\n series' own extent.\n*/\nfunction nodeSizes(node: SceneNode): [number, number][] {\n const pts = node.interactionPoints;\n if (pts && pts.length > 1) {\n const sizes: [number, number][] = [];\n for (let i = 1; i < pts.length; i++)\n sizes.push([Math.abs(pts[i].x - pts[i - 1].x), Math.abs(pts[i].y - pts[i - 1].y)]);\n return sizes;\n }\n const size = nodeSize(node);\n return size ? [size] : [];\n}\n\n/** Width/height of a scene node's own geometry (before its transform). */\nfunction nodeSize(node: SceneNode): [number, number] | null {\n switch (node.type) {\n case \"rect\":\n case \"image\":\n return [node.width, node.height];\n case \"circle\":\n return [node.r * 2, node.r * 2];\n case \"path\": {\n const b = pathBounds(node.d);\n return [b.width, b.height];\n }\n case \"line\": {\n const b = pathBounds(linePath(node));\n return [b.width, b.height];\n }\n case \"area\": {\n const b = pathBounds(areaPath(node));\n return [b.width, b.height];\n }\n default:\n return null;\n }\n}\n\n/**\n The zoom scale at which the chart's smallest data shape fills the chart\n area (less `padding` on each side, matching `zoomToBounds`), floored at 1.\n\n Data shapes are the top-level datum-bearing nodes of `_chartScene` (a\n Line/Area series is measured per segment — see `nodeSizes`). Chart\n decorations (axes, gridlines, radar spokes, …) are nested in groups, text\n labels scale with the shapes they annotate, and `::hit` nodes duplicate\n the geometry of the shape they belong to, so none of those are measured.\n\n @param nodes The chart's `_chartScene`.\n @param width Chart-area width.\n @param height Chart-area height.\n @param padding Pixel padding kept around a shape zoomed to fill the area.\n @param baseScale Any scale the chart's own transform already applies.\n*/\nexport function autoZoomMax(\n nodes: SceneNode[],\n width: number,\n height: number,\n padding: number,\n baseScale: number = 1,\n): number {\n const fitW = Math.max(1, width - padding * 2),\n fitH = Math.max(1, height - padding * 2);\n let max = 1;\n for (const node of nodes) {\n if (node.datum === undefined || node.type === \"group\" || node.type === \"text\") continue;\n if (String(node.key).endsWith(\"::hit\")) continue;\n const s = baseScale * (node.transform?.scale ?? 1);\n for (const [w, h] of nodeSizes(node)) {\n // A zero-width (or -height) shape only constrains the other dimension;\n // one with no extent at all can't be zoomed into.\n const k = Math.min(w > 0 ? fitW / (w * s) : Infinity, h > 0 ? fitH / (h * s) : Infinity);\n if (Number.isFinite(k) && k > max) max = k;\n }\n }\n return max;\n}\n"],"names":["pathBounds","areaPath","linePath","nodeSizes","node","pts","interactionPoints","length","sizes","i","push","Math","abs","x","y","size","nodeSize","type","width","height","r","b","d","autoZoomMax","nodes","padding","baseScale","fitW","max","fitH","datum","undefined","String","key","endsWith","s","transform","scale","w","h","k","min","Infinity","Number","isFinite"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAMA,GAEA,SAAQA,UAAU,QAAO,eAAe;AACxC,SAAQC,QAAQ,EAAEC,QAAQ,QAAO,iBAAiB;AAGlD;;;;;AAKA,GACA,SAASC,UAAUC,IAAe;IAChC,IAAMC,MAAMD,KAAKE,iBAAiB;IAClC,IAAID,OAAOA,IAAIE,MAAM,GAAG,GAAG;QACzB,IAAMC,QAA4B,EAAE;QACpC,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,IAAIE,MAAM,EAAEE,IAC9BD,MAAME,IAAI,CAAC;YAACC,KAAKC,GAAG,CAACP,GAAG,CAACI,EAAE,CAACI,CAAC,GAAGR,GAAG,CAACI,IAAI,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FvB,IAAIA,KAAK0B,KAAK,KAAKC,aAAa3B,KAAKa,IAAI,KAAK,WAAWb,KAAKa,IAAI,KAAK,QAAQ;YAC/E,IAAIe,OAAO5B,KAAK6B,GAAG,EAAEC,QAAQ,CAAC,UAAU;YACxC,IAAMC,IAAIT,sBAAatB,kBAAAA,KAAKgC,SAAS,cAAdhC,sCAAAA,gBAAgBiC,KAAK,uCAAI;gBAC3C,mCAAA,4BAAA;;gBAAL,QAAK,aAAgBlC,UAAUC,0BAA1B,UAAA,8BAAA,SAAA,0BAAA,kCAAiC;oBAAjC,mCAAA,kBAAOkC,oBAAGC;oBACb,uEAAuE;oBACvE,kDAAkD;oBAClD,IAAMC,IAAI7B,KAAK8B,GAAG,CAACH,IAAI,IAAIX,OAAQW,CAAAA,IAAIH,CAAAA,IAAKO,UAAUH,IAAI,IAAIV,OAAQU,CAAAA,IAAIJ,CAAAA,IAAKO;oBAC/E,IAAIC,OAAOC,QAAQ,CAACJ,MAAMA,IAAIZ,KAAKA,MAAMY;gBAC3C;;gBALK;gBAAA;;;yBAAA,8BAAA;wBAAA;;;wBAAA;8BAAA;;;;QAMP;;QAVK;QAAA;;;iBAAA,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAWL,OAAOZ;AACT"}
|
|
@@ -6,12 +6,38 @@ var tileAttributions = [
|
|
|
6
6
|
],
|
|
7
7
|
text: "© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"
|
|
8
8
|
},
|
|
9
|
+
{
|
|
10
|
+
matches: [
|
|
11
|
+
"tile.openstreetmap.org"
|
|
12
|
+
],
|
|
13
|
+
text: "© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
matches: [
|
|
17
|
+
"openstreetmap.fr/hot"
|
|
18
|
+
],
|
|
19
|
+
text: "© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, tiles by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a>"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
matches: [
|
|
23
|
+
"stadiamaps.com"
|
|
24
|
+
],
|
|
25
|
+
text: "© <a href='https://stadiamaps.com/' target='_blank'>Stadia Maps</a> © <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"
|
|
26
|
+
},
|
|
9
27
|
{
|
|
10
28
|
matches: [
|
|
11
29
|
"opentopomap.org"
|
|
12
30
|
],
|
|
13
31
|
text: "© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"
|
|
14
32
|
},
|
|
33
|
+
{
|
|
34
|
+
// Esri's Canvas basemaps (the default); their service credits, plus Esri's own.
|
|
35
|
+
matches: [
|
|
36
|
+
"World_Light_Gray_Base",
|
|
37
|
+
"World_Dark_Gray_Base"
|
|
38
|
+
],
|
|
39
|
+
text: "Powered by <a href='https://www.esri.com/' target='_blank'>Esri</a> | Esri, HERE, Garmin, © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, and the GIS user community"
|
|
40
|
+
},
|
|
15
41
|
{
|
|
16
42
|
matches: [
|
|
17
43
|
"arcgisonline.com"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/helpers/tileAttributions.ts"],"sourcesContent":["interface TileAttribution {\n matches: string[];\n text: string;\n}\n\nconst tileAttributions: TileAttribution[] = [\n {\n matches: [\"cartodb\", \"cartocdn\"],\n text: \"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>\",\n },\n {\n matches: [\"opentopomap.org\"],\n text: \"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors\",\n },\n {\n matches: [\"arcgisonline.com\"],\n text: \"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>\",\n },\n {\n matches: [\"/watercolor/\"],\n text: \"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>.\",\n },\n {\n matches: [\"stamen-tiles\", \"stamen.com\"],\n text: \"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>.\",\n },\n];\n\nexport default tileAttributions;\n"],"names":["tileAttributions","matches","text"],"mappings":"AAKA,IAAMA,mBAAsC;IAC1C;QACEC,SAAS;YAAC;YAAW;SAAW;QAChCC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAkB;QAC5BC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAmB;QAC7BC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAe;QACzBC,MAAM;IACR;IACA;QACED,SAAS;YAAC;YAAgB;SAAa;QACvCC,MAAM;IACR;CACD;AAED,eAAeF,iBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/helpers/tileAttributions.ts"],"sourcesContent":["interface TileAttribution {\n matches: string[];\n text: string;\n}\n\nconst tileAttributions: TileAttribution[] = [\n {\n matches: [\"cartodb\", \"cartocdn\"],\n text: \"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>\",\n },\n {\n matches: [\"tile.openstreetmap.org\"],\n text: \"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors\",\n },\n {\n matches: [\"openstreetmap.fr/hot\"],\n text: \"© <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, tiles by <a href='https://www.hotosm.org/' target='_blank'>Humanitarian OpenStreetMap Team</a>\",\n },\n {\n matches: [\"stadiamaps.com\"],\n text: \"© <a href='https://stadiamaps.com/' target='_blank'>Stadia Maps</a> © <a href='https://openmaptiles.org/' target='_blank'>OpenMapTiles</a> © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors\",\n },\n {\n matches: [\"opentopomap.org\"],\n text: \"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors\",\n },\n {\n // Esri's Canvas basemaps (the default); their service credits, plus Esri's own.\n matches: [\"World_Light_Gray_Base\", \"World_Dark_Gray_Base\"],\n text: \"Powered by <a href='https://www.esri.com/' target='_blank'>Esri</a> | Esri, HERE, Garmin, © <a href='https://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, and the GIS user community\",\n },\n {\n matches: [\"arcgisonline.com\"],\n text: \"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>\",\n },\n {\n matches: [\"/watercolor/\"],\n text: \"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>.\",\n },\n {\n matches: [\"stamen-tiles\", \"stamen.com\"],\n text: \"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>.\",\n },\n];\n\nexport default tileAttributions;\n"],"names":["tileAttributions","matches","text"],"mappings":"AAKA,IAAMA,mBAAsC;IAC1C;QACEC,SAAS;YAAC;YAAW;SAAW;QAChCC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAyB;QACnCC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAuB;QACjCC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAiB;QAC3BC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAkB;QAC5BC,MAAM;IACR;IACA;QACE,gFAAgF;QAChFD,SAAS;YAAC;YAAyB;SAAuB;QAC1DC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAmB;QAC7BC,MAAM;IACR;IACA;QACED,SAAS;YAAC;SAAe;QACzBC,MAAM;IACR;IACA;QACED,SAAS;YAAC;YAAgB;SAAa;QACvCC,MAAM;IACR;CACD;AAED,eAAeF,iBAAiB"}
|
package/es/src/charts/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { default as AreaPlot } from "./AreaPlot/index.js";
|
|
|
2
2
|
export { default as BarChart } from "./BarChart/index.js";
|
|
3
3
|
export { default as BoxWhisker } from "./BoxWhisker/index.js";
|
|
4
4
|
export { default as BumpChart } from "./BumpChart/index.js";
|
|
5
|
+
export { default as Chord } from "./Chord/index.js";
|
|
5
6
|
export { default as Donut } from "./Donut/index.js";
|
|
6
7
|
export { default as Geomap } from "./Geomap/index.js";
|
|
7
8
|
export { default as LinePlot } from "./LinePlot/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/charts/index.ts"],"sourcesContent":["export {default as AreaPlot} from \"./AreaPlot/index.js\";\nexport {default as BarChart} from \"./BarChart/index.js\";\nexport {default as BoxWhisker} from \"./BoxWhisker/index.js\";\nexport {default as BumpChart} from \"./BumpChart/index.js\";\nexport {default as Donut} from \"./Donut/index.js\";\nexport {default as Geomap} from \"./Geomap/index.js\";\nexport {default as LinePlot} from \"./LinePlot/index.js\";\nexport {default as Matrix} from \"./Matrix/index.js\";\nexport {default as Network} from \"./Network/index.js\";\nexport {default as Pack} from \"./Pack/index.js\";\nexport {default as Pie} from \"./Pie/index.js\";\nexport {default as Plot} from \"./Plot/index.js\";\nexport {default as Priestley} from \"./Priestley/index.js\";\nexport {default as Radar} from \"./Radar/index.js\";\nexport {default as RadialMatrix} from \"./RadialMatrix/index.js\";\nexport {default as Rings} from \"./Rings/index.js\";\nexport {default as Sankey} from \"./Sankey/index.js\";\nexport {default as StackedArea} from \"./StackedArea/index.js\";\nexport {default as Tree} from \"./Tree/index.js\";\nexport {default as Treemap} from \"./Treemap/index.js\";\nexport {default as Viz} from \"./viz/Viz.js\";\n"],"names":["default","AreaPlot","BarChart","BoxWhisker","BumpChart","Donut","Geomap","LinePlot","Matrix","Network","Pack","Pie","Plot","Priestley","Radar","RadialMatrix","Rings","Sankey","StackedArea","Tree","Treemap","Viz"],"mappings":"AAAA,SAAQA,WAAWC,QAAQ,QAAO,sBAAsB;AACxD,SAAQD,WAAWE,QAAQ,QAAO,sBAAsB;AACxD,SAAQF,WAAWG,UAAU,QAAO,wBAAwB;AAC5D,SAAQH,WAAWI,SAAS,QAAO,uBAAuB;AAC1D,SAAQJ,WAAWK,KAAK,QAAO,mBAAmB;AAClD,SAAQL,WAAWM,MAAM,QAAO,oBAAoB;AACpD,
|
|
1
|
+
{"version":3,"sources":["../../../src/charts/index.ts"],"sourcesContent":["export {default as AreaPlot} from \"./AreaPlot/index.js\";\nexport {default as BarChart} from \"./BarChart/index.js\";\nexport {default as BoxWhisker} from \"./BoxWhisker/index.js\";\nexport {default as BumpChart} from \"./BumpChart/index.js\";\nexport {default as Chord} from \"./Chord/index.js\";\nexport {default as Donut} from \"./Donut/index.js\";\nexport {default as Geomap} from \"./Geomap/index.js\";\nexport {default as LinePlot} from \"./LinePlot/index.js\";\nexport {default as Matrix} from \"./Matrix/index.js\";\nexport {default as Network} from \"./Network/index.js\";\nexport {default as Pack} from \"./Pack/index.js\";\nexport {default as Pie} from \"./Pie/index.js\";\nexport {default as Plot} from \"./Plot/index.js\";\nexport {default as Priestley} from \"./Priestley/index.js\";\nexport {default as Radar} from \"./Radar/index.js\";\nexport {default as RadialMatrix} from \"./RadialMatrix/index.js\";\nexport {default as Rings} from \"./Rings/index.js\";\nexport {default as Sankey} from \"./Sankey/index.js\";\nexport {default as StackedArea} from \"./StackedArea/index.js\";\nexport {default as Tree} from \"./Tree/index.js\";\nexport {default as Treemap} from \"./Treemap/index.js\";\nexport {default as Viz} from \"./viz/Viz.js\";\n"],"names":["default","AreaPlot","BarChart","BoxWhisker","BumpChart","Chord","Donut","Geomap","LinePlot","Matrix","Network","Pack","Pie","Plot","Priestley","Radar","RadialMatrix","Rings","Sankey","StackedArea","Tree","Treemap","Viz"],"mappings":"AAAA,SAAQA,WAAWC,QAAQ,QAAO,sBAAsB;AACxD,SAAQD,WAAWE,QAAQ,QAAO,sBAAsB;AACxD,SAAQF,WAAWG,UAAU,QAAO,wBAAwB;AAC5D,SAAQH,WAAWI,SAAS,QAAO,uBAAuB;AAC1D,SAAQJ,WAAWK,KAAK,QAAO,mBAAmB;AAClD,SAAQL,WAAWM,KAAK,QAAO,mBAAmB;AAClD,SAAQN,WAAWO,MAAM,QAAO,oBAAoB;AACpD,SAAQP,WAAWQ,QAAQ,QAAO,sBAAsB;AACxD,SAAQR,WAAWS,MAAM,QAAO,oBAAoB;AACpD,SAAQT,WAAWU,OAAO,QAAO,qBAAqB;AACtD,SAAQV,WAAWW,IAAI,QAAO,kBAAkB;AAChD,SAAQX,WAAWY,GAAG,QAAO,iBAAiB;AAC9C,SAAQZ,WAAWa,IAAI,QAAO,kBAAkB;AAChD,SAAQb,WAAWc,SAAS,QAAO,uBAAuB;AAC1D,SAAQd,WAAWe,KAAK,QAAO,mBAAmB;AAClD,SAAQf,WAAWgB,YAAY,QAAO,0BAA0B;AAChE,SAAQhB,WAAWiB,KAAK,QAAO,mBAAmB;AAClD,SAAQjB,WAAWkB,MAAM,QAAO,oBAAoB;AACpD,SAAQlB,WAAWmB,WAAW,QAAO,yBAAyB;AAC9D,SAAQnB,WAAWoB,IAAI,QAAO,kBAAkB;AAChD,SAAQpB,WAAWqB,OAAO,QAAO,qBAAqB;AACtD,SAAQrB,WAAWsB,GAAG,QAAO,eAAe"}
|
|
@@ -40,19 +40,25 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
40
40
|
1. `viz._preDraw()` — data filtering + legend-data + drawDepth
|
|
41
41
|
2. `viz._draw()` — chart-specific layout + scene absorption
|
|
42
42
|
3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)
|
|
43
|
-
4. `
|
|
44
|
-
5. `
|
|
43
|
+
4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator
|
|
44
|
+
5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel
|
|
45
|
+
6. `attributionFeature.layout(viz)` — bottom-right attribution panel
|
|
46
|
+
7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay
|
|
47
|
+
8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer
|
|
45
48
|
|
|
46
49
|
Future work:
|
|
47
50
|
- Extract a `ResolvedSpec` so step 1 takes (config) not (this).
|
|
48
51
|
- Decouple step 2 so it takes (ctx) not (this); stages already follow
|
|
49
52
|
this pattern but `_draw` itself doesn't.
|
|
50
|
-
- Replace step
|
|
53
|
+
- Replace step 8's `this._sceneRenderer` slot with a returned handle
|
|
51
54
|
so callers can pick/destroy/diff without instance lookup.
|
|
52
55
|
|
|
53
56
|
@param viz A Viz instance (or any subclass: Plot, Treemap, Pack, …).
|
|
54
57
|
*/ import { attributionFeature, runLayout } from "../features/features.js";
|
|
58
|
+
import { minimapFeature } from "../drawSteps/minimap.js";
|
|
55
59
|
import { zoomFeature } from "../drawSteps/zoomControls.js";
|
|
60
|
+
import { topLeftControlsFeature } from "../drawSteps/topLeftControls.js";
|
|
61
|
+
import { tableViewFeature } from "../drawSteps/tableView.js";
|
|
56
62
|
export function runVizPipeline(viz) {
|
|
57
63
|
// Goes through `viz._preDraw()` / `viz._draw()` (not the free functions
|
|
58
64
|
// directly) so subclass overrides (Plot._preDraw, Treemap._draw, Plot._draw,
|
|
@@ -61,21 +67,34 @@ export function runVizPipeline(viz) {
|
|
|
61
67
|
// calls hit the shim which delegates to the free functions.
|
|
62
68
|
viz._preDraw();
|
|
63
69
|
viz._draw();
|
|
64
|
-
// Post-draw features: zoom + brush event wiring
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// `
|
|
69
|
-
// `
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
// the
|
|
73
|
-
//
|
|
70
|
+
// Post-draw features: zoom + brush event wiring, the minimap, the shared
|
|
71
|
+
// top-left controls panel (back / table-view button / search), the
|
|
72
|
+
// attribution overlay, and the table-view data-table overlay. All run
|
|
73
|
+
// after `_draw()` (zoom needs the rendered chart body + `_container`/
|
|
74
|
+
// `_zoomGroup`), claim zero margin, and wire DOM the serializable scene
|
|
75
|
+
// graph can't carry. `minimapFeature` runs right after `zoomFeature` — it
|
|
76
|
+
// needs `_zoomBehavior`'s `translateExtent()`/`scaleExtent()` already
|
|
77
|
+
// configured for this draw — and before `attributionFeature` to preserve
|
|
78
|
+
// the prior step order; `topLeftControlsFeature` has no ordering
|
|
79
|
+
// dependency on either. `tableViewFeature` runs LAST so its panel — a
|
|
80
|
+
// chart-sized overlay, present only while table view is active — stacks
|
|
81
|
+
// above every other panel in the overlay host (siblings paint in scene
|
|
82
|
+
// order), covering zoom/minimap/top-left-controls/attribution while
|
|
83
|
+
// showing.
|
|
84
|
+
// Each of these returns its overlay as a panel rather than mutating
|
|
85
|
+
// `viz._featurePanels` from inside `layout()` (the FeatureModule
|
|
86
|
+
// contract). The engine appends the returned panels to the instance
|
|
87
|
+
// buffer that `toScene()` reads — including on later repaints (a zoom
|
|
88
|
+
// event, a table-view toggle), which re-walk `toScene()` outside this
|
|
89
|
+
// pipeline pass.
|
|
74
90
|
var post = runLayout({
|
|
75
91
|
viz: viz
|
|
76
92
|
}, [
|
|
77
93
|
zoomFeature,
|
|
78
|
-
|
|
94
|
+
minimapFeature,
|
|
95
|
+
topLeftControlsFeature,
|
|
96
|
+
attributionFeature,
|
|
97
|
+
tableViewFeature
|
|
79
98
|
]);
|
|
80
99
|
if (post.panels.length) viz._featurePanels = _to_consumable_array(viz._featurePanels || []).concat(_to_consumable_array(post.panels));
|
|
81
100
|
viz._drawSceneToTarget();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/pipeline/runVizPipeline.ts"],"sourcesContent":["/**\n `runVizPipeline(viz)` — the chart pipeline as a free function.\n\n Draws the boundary between \"lifecycle/DOM/data-loading\" (which lives on\n `Viz.render()`, inherently instance-bound) and\n \"transform-the-data-into-a-scene\" (callable without the lifecycle). The\n transform side isn't fully pure yet — `_preDraw`/`_draw` still mutate\n `this` rather than threading an explicit context\n (`UserConfig → ResolvedSpec → transform stages → SceneGraph → renderer`).\n\n Calling this function on a Viz instance runs the same four steps\n `Viz.render()` previously inlined inside its `Promise.all().then()`\n callback:\n\n 1. `viz._preDraw()` — data filtering + legend-data + drawDepth\n 2. `viz._draw()` — chart-specific layout + scene absorption\n 3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)\n 4. `attributionFeature.layout(viz)` — bottom-right attribution panel\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/pipeline/runVizPipeline.ts"],"sourcesContent":["/**\n `runVizPipeline(viz)` — the chart pipeline as a free function.\n\n Draws the boundary between \"lifecycle/DOM/data-loading\" (which lives on\n `Viz.render()`, inherently instance-bound) and\n \"transform-the-data-into-a-scene\" (callable without the lifecycle). The\n transform side isn't fully pure yet — `_preDraw`/`_draw` still mutate\n `this` rather than threading an explicit context\n (`UserConfig → ResolvedSpec → transform stages → SceneGraph → renderer`).\n\n Calling this function on a Viz instance runs the same four steps\n `Viz.render()` previously inlined inside its `Promise.all().then()`\n callback:\n\n 1. `viz._preDraw()` — data filtering + legend-data + drawDepth\n 2. `viz._draw()` — chart-specific layout + scene absorption\n 3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)\n 4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator\n 5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel\n 6. `attributionFeature.layout(viz)` — bottom-right attribution panel\n 7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay\n 8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer\n\n Future work:\n - Extract a `ResolvedSpec` so step 1 takes (config) not (this).\n - Decouple step 2 so it takes (ctx) not (this); stages already follow\n this pattern but `_draw` itself doesn't.\n - Replace step 8's `this._sceneRenderer` slot with a returned handle\n so callers can pick/destroy/diff without instance lookup.\n\n @param viz A Viz instance (or any subclass: Plot, Treemap, Pack, …).\n*/\n\nimport {attributionFeature, runLayout} from \"../features/features.js\";\nimport {minimapFeature} from \"../drawSteps/minimap.js\";\nimport {zoomFeature} from \"../drawSteps/zoomControls.js\";\nimport {topLeftControlsFeature} from \"../drawSteps/topLeftControls.js\";\nimport {tableViewFeature} from \"../drawSteps/tableView.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runVizPipeline(viz: Viz): void {\n // Goes through `viz._preDraw()` / `viz._draw()` (not the free functions\n // directly) so subclass overrides (Plot._preDraw, Treemap._draw, Plot._draw,\n // Pack/Pie/Matrix/…) still run. The free functions `vizPreDraw` / `vizDraw`\n // hold the BASE Viz behavior; subclasses' `super._preDraw()`/`super._draw()`\n // calls hit the shim which delegates to the free functions.\n viz._preDraw();\n viz._draw();\n // Post-draw features: zoom + brush event wiring, the minimap, the shared\n // top-left controls panel (back / table-view button / search), the\n // attribution overlay, and the table-view data-table overlay. All run\n // after `_draw()` (zoom needs the rendered chart body + `_container`/\n // `_zoomGroup`), claim zero margin, and wire DOM the serializable scene\n // graph can't carry. `minimapFeature` runs right after `zoomFeature` — it\n // needs `_zoomBehavior`'s `translateExtent()`/`scaleExtent()` already\n // configured for this draw — and before `attributionFeature` to preserve\n // the prior step order; `topLeftControlsFeature` has no ordering\n // dependency on either. `tableViewFeature` runs LAST so its panel — a\n // chart-sized overlay, present only while table view is active — stacks\n // above every other panel in the overlay host (siblings paint in scene\n // order), covering zoom/minimap/top-left-controls/attribution while\n // showing.\n // Each of these returns its overlay as a panel rather than mutating\n // `viz._featurePanels` from inside `layout()` (the FeatureModule\n // contract). The engine appends the returned panels to the instance\n // buffer that `toScene()` reads — including on later repaints (a zoom\n // event, a table-view toggle), which re-walk `toScene()` outside this\n // pipeline pass.\n const post = runLayout({viz}, [zoomFeature, minimapFeature, topLeftControlsFeature, attributionFeature, tableViewFeature]);\n if (post.panels.length)\n viz._featurePanels = [...(viz._featurePanels || []), ...post.panels];\n viz._drawSceneToTarget();\n}\n"],"names":["attributionFeature","runLayout","minimapFeature","zoomFeature","topLeftControlsFeature","tableViewFeature","runVizPipeline","viz","_preDraw","_draw","post","panels","length","_featurePanels","_drawSceneToTarget"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,GAEA,SAAQA,kBAAkB,EAAEC,SAAS,QAAO,0BAA0B;AACtE,SAAQC,cAAc,QAAO,0BAA0B;AACvD,SAAQC,WAAW,QAAO,+BAA+B;AACzD,SAAQC,sBAAsB,QAAO,kCAAkC;AACvE,SAAQC,gBAAgB,QAAO,4BAA4B;AAG3D,OAAO,SAASC,eAAeC,GAAQ;IACrC,wEAAwE;IACxE,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,4DAA4D;IAC5DA,IAAIC,QAAQ;IACZD,IAAIE,KAAK;IACT,yEAAyE;IACzE,mEAAmE;IACnE,sEAAsE;IACtE,sEAAsE;IACtE,wEAAwE;IACxE,0EAA0E;IAC1E,sEAAsE;IACtE,yEAAyE;IACzE,iEAAiE;IACjE,sEAAsE;IACtE,wEAAwE;IACxE,uEAAuE;IACvE,oEAAoE;IACpE,WAAW;IACX,oEAAoE;IACpE,iEAAiE;IACjE,oEAAoE;IACpE,sEAAsE;IACtE,sEAAsE;IACtE,iBAAiB;IACjB,IAAMC,OAAOT,UAAU;QAACM,KAAAA;IAAG,GAAG;QAACJ;QAAaD;QAAgBE;QAAwBJ;QAAoBK;KAAiB;IACzH,IAAIK,KAAKC,MAAM,CAACC,MAAM,EACpBL,IAAIM,cAAc,GAAG,AAAC,qBAAIN,IAAIM,cAAc,IAAI,EAAE,SAAG,qBAAGH,KAAKC,MAAM;IACrEJ,IAAIO,kBAAkB;AACxB"}
|
|
@@ -50,7 +50,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
50
50
|
- `featurePanels` — final aggregated panel list
|
|
51
51
|
- `resetChartScene`/`resetChartTransform`/`resetShapes` (always true)
|
|
52
52
|
- `legendPosition`/`colorScalePosition` — sanitized values
|
|
53
|
-
*/ import {
|
|
53
|
+
*/ import { colorScaleFeature, legendFeature, runLayout, sanitizePosition, subtitleFeature, timelineFeature, titleFeature, totalFeature } from "../features/features.js";
|
|
54
|
+
import { zoomControlsBox } from "../drawSteps/zoomControlsMarkup.js";
|
|
55
|
+
import { getTopLeftContributions } from "../drawSteps/topLeftControls.js";
|
|
56
|
+
import { topLeftControlsBox } from "../drawSteps/topLeftControlsMarkup.js";
|
|
54
57
|
import { resolveSpec } from "./resolveSpec.js";
|
|
55
58
|
export function vizDrawPure(viz) {
|
|
56
59
|
var _prevCtx = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
@@ -96,14 +99,16 @@ export function vizDrawPure(viz) {
|
|
|
96
99
|
bottom: viz._margin.bottom,
|
|
97
100
|
left: viz._margin.left
|
|
98
101
|
};
|
|
99
|
-
// Top blocks first (
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
102
|
+
// Top blocks first (title / subtitle / total) so the running margin.top
|
|
103
|
+
// grows BEFORE the left/right legend lays out — the legend positions
|
|
104
|
+
// against it. Title must lay out first or the left legend overlaps the
|
|
105
|
+
// title at y=0. "← Back" no longer claims margin here — it's a
|
|
106
|
+
// zero-margin contribution to the shared top-left controls panel
|
|
107
|
+
// (`topLeftControlsFeature`, registered post-draw in `runVizPipeline`),
|
|
108
|
+
// the same way zoom's buttons float rather than claim margin.
|
|
103
109
|
var topBlocks = runLayout({
|
|
104
110
|
viz: viz
|
|
105
111
|
}, [
|
|
106
|
-
backFeature,
|
|
107
112
|
titleFeature,
|
|
108
113
|
subtitleFeature,
|
|
109
114
|
totalFeature
|
|
@@ -166,6 +171,27 @@ export function vizDrawPure(viz) {
|
|
|
166
171
|
running.top += claim3.margin.top;
|
|
167
172
|
running.bottom += claim3.margin.bottom;
|
|
168
173
|
}
|
|
174
|
+
// The corner controls (zoom, back/search) deliberately claim zero
|
|
175
|
+
// margin of their own — they float at y:0, and normally whatever's
|
|
176
|
+
// ABOVE the chart body (title/subtitle/total, a top legend/colorScale)
|
|
177
|
+
// already pushed it down clear of them. But when NONE of those claimed
|
|
178
|
+
// any margin.top, the chart body starts at y:0 too, and the buttons
|
|
179
|
+
// paint directly over its top edge — a Treemap's very top row, most
|
|
180
|
+
// visibly, since there's no dead space up there to absorb it. Reserve
|
|
181
|
+
// just enough room for the taller of the two corner rows in that one
|
|
182
|
+
// case; a chart with a title/legend already has (at minimum) that same
|
|
183
|
+
// room from its own claim, so this never adds on top of one.
|
|
184
|
+
if (!out.marginDelta.top) {
|
|
185
|
+
var _ref, _ref1;
|
|
186
|
+
var _zoomControlsBox, _topLeftControlsBox;
|
|
187
|
+
var zoomHeight = (_ref = (_zoomControlsBox = zoomControlsBox(viz)) === null || _zoomControlsBox === void 0 ? void 0 : _zoomControlsBox.height) !== null && _ref !== void 0 ? _ref : 0;
|
|
188
|
+
var topLeftHeight = (_ref1 = (_topLeftControlsBox = topLeftControlsBox(viz, getTopLeftContributions(viz))) === null || _topLeftControlsBox === void 0 ? void 0 : _topLeftControlsBox.height) !== null && _ref1 !== void 0 ? _ref1 : 0;
|
|
189
|
+
var cornerHeight = Math.max(zoomHeight, topLeftHeight);
|
|
190
|
+
if (cornerHeight) {
|
|
191
|
+
out.marginDelta.top += cornerHeight;
|
|
192
|
+
running.top += cornerHeight;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
169
195
|
// Snapshot final featurePanels onto the returned ctx.
|
|
170
196
|
out.featurePanels = viz._featurePanels.slice();
|
|
171
197
|
return out;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/charts/pipeline/vizDrawPure.ts"],"sourcesContent":["/**\n `vizDrawPure(viz, prevCtx)` — the returning form of `vizDraw`.\n\n NAMING CAVEAT: the suffix `Pure` here means **\"returns a Partial<\n VizContext> describing the layout intent\"**, not \"free of side effects\n in the FP sense.\" The OUTER orchestration (margin computation,\n legendPosition resolution, panel aggregation, reset signals) is pure\n in the returned-ctx sense — its observable output is the ctx. The\n inner `runLayout([features])` calls write through to viz directly:\n - reset writes (`viz._featurePanels = []`, `viz._chartScene = []`,\n `viz._chartTransform = undefined`, `viz._shapes = []`)\n - margin claims (`viz._margin.X += claim.margin.X`) so the next\n runLayout sees the updated margins\n - FeatureModule layouts that mount/measure their components\n These writes are part of the contract: subclasses and feature\n modules consume live viz state during the layout body, and the shim\n pattern (`vizDraw` calling `vizDrawPure`) is what bridges the\n free-function surface to the class instances that still hold the\n components.\n\n The shim (`vizDraw`) wraps this and serves as the public surface.\n\n Returns a context with:\n - `marginDelta` (top/bottom/left/right) — total added to viz._margin\n - `featurePanels` — final aggregated panel list\n - `resetChartScene`/`resetChartTransform`/`resetShapes` (always true)\n - `legendPosition`/`colorScalePosition` — sanitized values\n*/\n\nimport {\n backFeature,\n colorScaleFeature,\n legendFeature,\n runLayout,\n sanitizePosition,\n subtitleFeature,\n timelineFeature,\n titleFeature,\n totalFeature,\n} from \"../features/features.js\";\n\nimport {resolveSpec} from \"./resolveSpec.js\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {VizContext} from \"./vizContext.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport interface VizDrawCtx extends VizContext {\n marginDelta?: {top: number; bottom: number; left: number; right: number};\n featurePanels?: SceneNode[];\n legendPosition?: string | false;\n colorScalePosition?: string | false;\n resetChartScene?: boolean;\n resetChartTransform?: boolean;\n resetShapes?: boolean;\n}\n\nexport function vizDrawPure(\n viz: Viz,\n _prevCtx: Partial<VizContext> = {},\n): Partial<VizDrawCtx> {\n const out: Partial<VizDrawCtx> = {\n resetChartScene: true,\n resetChartTransform: true,\n resetShapes: true,\n marginDelta: {top: 0, bottom: 0, left: 0, right: 0},\n featurePanels: [],\n };\n\n // Reset side effects before features run. `viz._featurePanels` is a\n // cross-stage accumulator: seeded here, appended to later by the\n // zoomControls feature, and read by Viz.toScene — so it has to live on\n // the instance, not in a local. The shim RE-reads viz._featurePanels\n // into out.featurePanels for callers.\n viz._featurePanels = [];\n viz._chartScene = [];\n viz._chartTransform = undefined;\n viz._shapes = [];\n\n // Sanitize positions via the shared `sanitizePosition` helper (same\n // function legendFeature / colorScaleFeature use) so the three sites\n // can't drift. One frozen `resolveSpec` snapshot feeds both accessors:\n // the position accessors take the resolved config as their argument, so\n // a single snapshot reflects config once instead of twice.\n const spec = resolveSpec(viz);\n const legendPosition = sanitizePosition(\n viz.schema.legendPosition.bind(viz)(spec),\n );\n const colorScalePosition = sanitizePosition(\n viz.schema.colorScalePosition.bind(viz)(spec),\n );\n out.legendPosition = legendPosition;\n out.colorScalePosition = colorScalePosition;\n\n // `running` is the cross-call margin accumulator, threaded into each\n // runLayout as its baseMargin so features read the live running total via\n // ctx.layoutMargin (not viz._margin). Seeded from viz._margin so the math\n // matches whatever base the instance carried in.\n const running = {\n top: viz._margin.top,\n right: viz._margin.right,\n bottom: viz._margin.bottom,\n left: viz._margin.left,\n };\n\n // Top blocks first (back / title / subtitle / total) so the running\n // margin.top grows BEFORE the left/right legend lays out — the legend\n // positions against it. Title must lay out first or the left legend\n // overlaps the title at y=0.\n const topBlocks = runLayout({viz}, [\n backFeature,\n titleFeature,\n subtitleFeature,\n totalFeature,\n ], running);\n viz._featurePanels.push(...topBlocks.panels);\n out.marginDelta!.top += topBlocks.margin.top;\n running.top += topBlocks.margin.top;\n\n const timelineClaim = runLayout({viz}, [timelineFeature], running);\n out.marginDelta!.bottom += timelineClaim.margin.bottom;\n running.bottom += timelineClaim.margin.bottom;\n\n // Left/right legend + colorScale claims. Includes `=== false` (mirrors\n // colorScale below) so a previously-rendered left/right legend tears\n // down its DOM when the user toggles off via `.legendPosition(false)`.\n if (\n legendPosition === \"left\" ||\n legendPosition === \"right\" ||\n legendPosition === false\n ) {\n const claim = runLayout({viz}, [legendFeature], running);\n out.marginDelta!.left += claim.margin.left;\n out.marginDelta!.right += claim.margin.right;\n running.left += claim.margin.left;\n running.right += claim.margin.right;\n }\n if (\n colorScalePosition === \"left\" ||\n colorScalePosition === \"right\" ||\n colorScalePosition === false\n ) {\n const claim = runLayout({viz}, [colorScaleFeature], running);\n out.marginDelta!.left += claim.margin.left;\n out.marginDelta!.right += claim.margin.right;\n running.left += claim.margin.left;\n running.right += claim.margin.right;\n }\n\n // Top/bottom legend + colorScale.\n if (legendPosition === \"top\" || legendPosition === \"bottom\") {\n const claim = runLayout({viz}, [legendFeature], running);\n out.marginDelta!.top += claim.margin.top;\n out.marginDelta!.bottom += claim.margin.bottom;\n running.top += claim.margin.top;\n running.bottom += claim.margin.bottom;\n }\n if (colorScalePosition === \"top\" || colorScalePosition === \"bottom\") {\n const claim = runLayout({viz}, [colorScaleFeature], running);\n out.marginDelta!.top += claim.margin.top;\n out.marginDelta!.bottom += claim.margin.bottom;\n running.top += claim.margin.top;\n running.bottom += claim.margin.bottom;\n }\n\n // Snapshot final featurePanels onto the returned ctx.\n out.featurePanels = viz._featurePanels.slice();\n\n return out;\n}\n"],"names":["backFeature","colorScaleFeature","legendFeature","runLayout","sanitizePosition","subtitleFeature","timelineFeature","titleFeature","totalFeature","resolveSpec","vizDrawPure","viz","_prevCtx","out","resetChartScene","resetChartTransform","resetShapes","marginDelta","top","bottom","left","right","featurePanels","_featurePanels","_chartScene","_chartTransform","undefined","_shapes","spec","legendPosition","schema","bind","colorScalePosition","running","_margin","topBlocks","push","panels","margin","timelineClaim","claim","slice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,GAEA,SACEA,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,YAAY,QACP,0BAA0B;AAEjC,SAAQC,WAAW,QAAO,mBAAmB;AAiB7C,OAAO,SAASC,YACdC,GAAQ;QACRC,WAAAA,iEAAgC,CAAC;QAwDjCD;IAtDA,IAAME,MAA2B;QAC/BC,iBAAiB;QACjBC,qBAAqB;QACrBC,aAAa;QACbC,aAAa;YAACC,KAAK;YAAGC,QAAQ;YAAGC,MAAM;YAAGC,OAAO;QAAC;QAClDC,eAAe,EAAE;IACnB;IAEA,oEAAoE;IACpE,iEAAiE;IACjE,uEAAuE;IACvE,qEAAqE;IACrE,sCAAsC;IACtCX,IAAIY,cAAc,GAAG,EAAE;IACvBZ,IAAIa,WAAW,GAAG,EAAE;IACpBb,IAAIc,eAAe,GAAGC;IACtBf,IAAIgB,OAAO,GAAG,EAAE;IAEhB,oEAAoE;IACpE,qEAAqE;IACrE,uEAAuE;IACvE,wEAAwE;IACxE,2DAA2D;IAC3D,IAAMC,OAAOnB,YAAYE;IACzB,IAAMkB,iBAAiBzB,iBACrBO,IAAImB,MAAM,CAACD,cAAc,CAACE,IAAI,CAACpB,KAAKiB;IAEtC,IAAMI,qBAAqB5B,iBACzBO,IAAImB,MAAM,CAACE,kBAAkB,CAACD,IAAI,CAACpB,KAAKiB;IAE1Cf,IAAIgB,cAAc,GAAGA;IACrBhB,IAAImB,kBAAkB,GAAGA;IAEzB,qEAAqE;IACrE,0EAA0E;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}
|
|
1
|
+
{"version":3,"sources":["../../../../src/charts/pipeline/vizDrawPure.ts"],"sourcesContent":["/**\n `vizDrawPure(viz, prevCtx)` — the returning form of `vizDraw`.\n\n NAMING CAVEAT: the suffix `Pure` here means **\"returns a Partial<\n VizContext> describing the layout intent\"**, not \"free of side effects\n in the FP sense.\" The OUTER orchestration (margin computation,\n legendPosition resolution, panel aggregation, reset signals) is pure\n in the returned-ctx sense — its observable output is the ctx. The\n inner `runLayout([features])` calls write through to viz directly:\n - reset writes (`viz._featurePanels = []`, `viz._chartScene = []`,\n `viz._chartTransform = undefined`, `viz._shapes = []`)\n - margin claims (`viz._margin.X += claim.margin.X`) so the next\n runLayout sees the updated margins\n - FeatureModule layouts that mount/measure their components\n These writes are part of the contract: subclasses and feature\n modules consume live viz state during the layout body, and the shim\n pattern (`vizDraw` calling `vizDrawPure`) is what bridges the\n free-function surface to the class instances that still hold the\n components.\n\n The shim (`vizDraw`) wraps this and serves as the public surface.\n\n Returns a context with:\n - `marginDelta` (top/bottom/left/right) — total added to viz._margin\n - `featurePanels` — final aggregated panel list\n - `resetChartScene`/`resetChartTransform`/`resetShapes` (always true)\n - `legendPosition`/`colorScalePosition` — sanitized values\n*/\n\nimport {\n colorScaleFeature,\n legendFeature,\n runLayout,\n sanitizePosition,\n subtitleFeature,\n timelineFeature,\n titleFeature,\n totalFeature,\n} from \"../features/features.js\";\nimport {zoomControlsBox} from \"../drawSteps/zoomControlsMarkup.js\";\nimport {getTopLeftContributions} from \"../drawSteps/topLeftControls.js\";\nimport {topLeftControlsBox} from \"../drawSteps/topLeftControlsMarkup.js\";\n\nimport {resolveSpec} from \"./resolveSpec.js\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {VizContext} from \"./vizContext.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport interface VizDrawCtx extends VizContext {\n marginDelta?: {top: number; bottom: number; left: number; right: number};\n featurePanels?: SceneNode[];\n legendPosition?: string | false;\n colorScalePosition?: string | false;\n resetChartScene?: boolean;\n resetChartTransform?: boolean;\n resetShapes?: boolean;\n}\n\nexport function vizDrawPure(\n viz: Viz,\n _prevCtx: Partial<VizContext> = {},\n): Partial<VizDrawCtx> {\n const out: Partial<VizDrawCtx> = {\n resetChartScene: true,\n resetChartTransform: true,\n resetShapes: true,\n marginDelta: {top: 0, bottom: 0, left: 0, right: 0},\n featurePanels: [],\n };\n\n // Reset side effects before features run. `viz._featurePanels` is a\n // cross-stage accumulator: seeded here, appended to later by the\n // zoomControls feature, and read by Viz.toScene — so it has to live on\n // the instance, not in a local. The shim RE-reads viz._featurePanels\n // into out.featurePanels for callers.\n viz._featurePanels = [];\n viz._chartScene = [];\n viz._chartTransform = undefined;\n viz._shapes = [];\n\n // Sanitize positions via the shared `sanitizePosition` helper (same\n // function legendFeature / colorScaleFeature use) so the three sites\n // can't drift. One frozen `resolveSpec` snapshot feeds both accessors:\n // the position accessors take the resolved config as their argument, so\n // a single snapshot reflects config once instead of twice.\n const spec = resolveSpec(viz);\n const legendPosition = sanitizePosition(\n viz.schema.legendPosition.bind(viz)(spec),\n );\n const colorScalePosition = sanitizePosition(\n viz.schema.colorScalePosition.bind(viz)(spec),\n );\n out.legendPosition = legendPosition;\n out.colorScalePosition = colorScalePosition;\n\n // `running` is the cross-call margin accumulator, threaded into each\n // runLayout as its baseMargin so features read the live running total via\n // ctx.layoutMargin (not viz._margin). Seeded from viz._margin so the math\n // matches whatever base the instance carried in.\n const running = {\n top: viz._margin.top,\n right: viz._margin.right,\n bottom: viz._margin.bottom,\n left: viz._margin.left,\n };\n\n // Top blocks first (title / subtitle / total) so the running margin.top\n // grows BEFORE the left/right legend lays out — the legend positions\n // against it. Title must lay out first or the left legend overlaps the\n // title at y=0. \"← Back\" no longer claims margin here — it's a\n // zero-margin contribution to the shared top-left controls panel\n // (`topLeftControlsFeature`, registered post-draw in `runVizPipeline`),\n // the same way zoom's buttons float rather than claim margin.\n const topBlocks = runLayout({viz}, [\n titleFeature,\n subtitleFeature,\n totalFeature,\n ], running);\n viz._featurePanels.push(...topBlocks.panels);\n out.marginDelta!.top += topBlocks.margin.top;\n running.top += topBlocks.margin.top;\n\n const timelineClaim = runLayout({viz}, [timelineFeature], running);\n out.marginDelta!.bottom += timelineClaim.margin.bottom;\n running.bottom += timelineClaim.margin.bottom;\n\n // Left/right legend + colorScale claims. Includes `=== false` (mirrors\n // colorScale below) so a previously-rendered left/right legend tears\n // down its DOM when the user toggles off via `.legendPosition(false)`.\n if (\n legendPosition === \"left\" ||\n legendPosition === \"right\" ||\n legendPosition === false\n ) {\n const claim = runLayout({viz}, [legendFeature], running);\n out.marginDelta!.left += claim.margin.left;\n out.marginDelta!.right += claim.margin.right;\n running.left += claim.margin.left;\n running.right += claim.margin.right;\n }\n if (\n colorScalePosition === \"left\" ||\n colorScalePosition === \"right\" ||\n colorScalePosition === false\n ) {\n const claim = runLayout({viz}, [colorScaleFeature], running);\n out.marginDelta!.left += claim.margin.left;\n out.marginDelta!.right += claim.margin.right;\n running.left += claim.margin.left;\n running.right += claim.margin.right;\n }\n\n // Top/bottom legend + colorScale.\n if (legendPosition === \"top\" || legendPosition === \"bottom\") {\n const claim = runLayout({viz}, [legendFeature], running);\n out.marginDelta!.top += claim.margin.top;\n out.marginDelta!.bottom += claim.margin.bottom;\n running.top += claim.margin.top;\n running.bottom += claim.margin.bottom;\n }\n if (colorScalePosition === \"top\" || colorScalePosition === \"bottom\") {\n const claim = runLayout({viz}, [colorScaleFeature], running);\n out.marginDelta!.top += claim.margin.top;\n out.marginDelta!.bottom += claim.margin.bottom;\n running.top += claim.margin.top;\n running.bottom += claim.margin.bottom;\n }\n\n // The corner controls (zoom, back/search) deliberately claim zero\n // margin of their own — they float at y:0, and normally whatever's\n // ABOVE the chart body (title/subtitle/total, a top legend/colorScale)\n // already pushed it down clear of them. But when NONE of those claimed\n // any margin.top, the chart body starts at y:0 too, and the buttons\n // paint directly over its top edge — a Treemap's very top row, most\n // visibly, since there's no dead space up there to absorb it. Reserve\n // just enough room for the taller of the two corner rows in that one\n // case; a chart with a title/legend already has (at minimum) that same\n // room from its own claim, so this never adds on top of one.\n if (!out.marginDelta!.top) {\n const zoomHeight = zoomControlsBox(viz as never)?.height ?? 0;\n const topLeftHeight =\n topLeftControlsBox(viz as never, getTopLeftContributions(viz as never))?.height ?? 0;\n const cornerHeight = Math.max(zoomHeight, topLeftHeight);\n if (cornerHeight) {\n out.marginDelta!.top += cornerHeight;\n running.top += cornerHeight;\n }\n }\n\n // Snapshot final featurePanels onto the returned ctx.\n out.featurePanels = viz._featurePanels.slice();\n\n return out;\n}\n"],"names":["colorScaleFeature","legendFeature","runLayout","sanitizePosition","subtitleFeature","timelineFeature","titleFeature","totalFeature","zoomControlsBox","getTopLeftContributions","topLeftControlsBox","resolveSpec","vizDrawPure","viz","_prevCtx","out","resetChartScene","resetChartTransform","resetShapes","marginDelta","top","bottom","left","right","featurePanels","_featurePanels","_chartScene","_chartTransform","undefined","_shapes","spec","legendPosition","schema","bind","colorScalePosition","running","_margin","topBlocks","push","panels","margin","timelineClaim","claim","zoomHeight","height","topLeftHeight","cornerHeight","Math","max","slice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,GAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,SAAS,EACTC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,YAAY,QACP,0BAA0B;AACjC,SAAQC,eAAe,QAAO,qCAAqC;AACnE,SAAQC,uBAAuB,QAAO,kCAAkC;AACxE,SAAQC,kBAAkB,QAAO,wCAAwC;AAEzE,SAAQC,WAAW,QAAO,mBAAmB;AAiB7C,OAAO,SAASC,YACdC,GAAQ;QACRC,WAAAA,iEAAgC,CAAC;QA0DjCD;IAxDA,IAAME,MAA2B;QAC/BC,iBAAiB;QACjBC,qBAAqB;QACrBC,aAAa;QACbC,aAAa;YAACC,KAAK;YAAGC,QAAQ;YA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