@d3plus/core 4.5.0 → 4.6.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.
Files changed (241) hide show
  1. package/README.md +3698 -1074
  2. package/es/index.js +3 -3
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +6 -1
  5. package/es/internal.js.map +1 -1
  6. package/es/src/charts/BarChart/index.js +8 -1
  7. package/es/src/charts/BarChart/index.js.map +1 -1
  8. package/es/src/charts/BoxWhisker/index.js +5 -0
  9. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  10. package/es/src/charts/Chord/emit.js +55 -3
  11. package/es/src/charts/Chord/emit.js.map +1 -1
  12. package/es/src/charts/Chord/index.js +15 -0
  13. package/es/src/charts/Chord/index.js.map +1 -1
  14. package/es/src/charts/Geomap/applyLayout.js +17 -10
  15. package/es/src/charts/Geomap/applyLayout.js.map +1 -1
  16. package/es/src/charts/Geomap/index.js +5 -1
  17. package/es/src/charts/Geomap/index.js.map +1 -1
  18. package/es/src/charts/Histogram/binData.js +225 -0
  19. package/es/src/charts/Histogram/binData.js.map +1 -0
  20. package/es/src/charts/Histogram/index.js +271 -0
  21. package/es/src/charts/Histogram/index.js.map +1 -0
  22. package/es/src/charts/Network/applyLayout.js +52 -4
  23. package/es/src/charts/Network/applyLayout.js.map +1 -1
  24. package/es/src/charts/Network/emit.js +4 -4
  25. package/es/src/charts/Network/emit.js.map +1 -1
  26. package/es/src/charts/Network/index.js +6 -1
  27. package/es/src/charts/Network/index.js.map +1 -1
  28. package/es/src/charts/Pack/emit.js +37 -2
  29. package/es/src/charts/Pack/emit.js.map +1 -1
  30. package/es/src/charts/Pack/index.js +13 -0
  31. package/es/src/charts/Pack/index.js.map +1 -1
  32. package/es/src/charts/Pie/applyLayout.js +20 -2
  33. package/es/src/charts/Pie/applyLayout.js.map +1 -1
  34. package/es/src/charts/Pie/emit.js +274 -33
  35. package/es/src/charts/Pie/emit.js.map +1 -1
  36. package/es/src/charts/Pie/index.js +46 -1
  37. package/es/src/charts/Pie/index.js.map +1 -1
  38. package/es/src/charts/Plot/discreteSpan.js +42 -0
  39. package/es/src/charts/Plot/discreteSpan.js.map +1 -0
  40. package/es/src/charts/Plot/draw.js +3 -1
  41. package/es/src/charts/Plot/draw.js.map +1 -1
  42. package/es/src/charts/Plot/index.js +129 -14
  43. package/es/src/charts/Plot/index.js.map +1 -1
  44. package/es/src/charts/Plot/pipeline.js +47 -20
  45. package/es/src/charts/Plot/pipeline.js.map +1 -1
  46. package/es/src/charts/Plot/pipelineDomains.js +84 -8
  47. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  48. package/es/src/charts/Plot/shapeDefaults.js +3 -3
  49. package/es/src/charts/Plot/shapeDefaults.js.map +1 -1
  50. package/es/src/charts/Plot/sharedHover.js +431 -0
  51. package/es/src/charts/Plot/sharedHover.js.map +1 -0
  52. package/es/src/charts/Plot/sharedHoverScene.js +230 -0
  53. package/es/src/charts/Plot/sharedHoverScene.js.map +1 -0
  54. package/es/src/charts/Plot/sharedTooltip.js +163 -0
  55. package/es/src/charts/Plot/sharedTooltip.js.map +1 -0
  56. package/es/src/charts/Plot/stackShareLabels.js +137 -0
  57. package/es/src/charts/Plot/stackShareLabels.js.map +1 -0
  58. package/es/src/charts/Plot/stackShareTooltip.js +31 -0
  59. package/es/src/charts/Plot/stackShareTooltip.js.map +1 -0
  60. package/es/src/charts/Plot/trendLines.js +367 -0
  61. package/es/src/charts/Plot/trendLines.js.map +1 -0
  62. package/es/src/charts/Plot/trendScene.js +220 -0
  63. package/es/src/charts/Plot/trendScene.js.map +1 -0
  64. package/es/src/charts/Plot/trendTooltip.js +160 -0
  65. package/es/src/charts/Plot/trendTooltip.js.map +1 -0
  66. package/es/src/charts/Priestley/emit.js +32 -3
  67. package/es/src/charts/Priestley/emit.js.map +1 -1
  68. package/es/src/charts/Radar/index.js +15 -2
  69. package/es/src/charts/Radar/index.js.map +1 -1
  70. package/es/src/charts/RadialMatrix/index.js +17 -1
  71. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  72. package/es/src/charts/Rings/applyLayout.js +72 -116
  73. package/es/src/charts/Rings/applyLayout.js.map +1 -1
  74. package/es/src/charts/Rings/emit.js +2 -3
  75. package/es/src/charts/Rings/emit.js.map +1 -1
  76. package/es/src/charts/Rings/index.js +13 -2
  77. package/es/src/charts/Rings/index.js.map +1 -1
  78. package/es/src/charts/Rings/ringsSizing.js +189 -0
  79. package/es/src/charts/Rings/ringsSizing.js.map +1 -0
  80. package/es/src/charts/StackedArea/index.js +8 -1
  81. package/es/src/charts/StackedArea/index.js.map +1 -1
  82. package/es/src/charts/Tree/emit.js +2 -2
  83. package/es/src/charts/Tree/emit.js.map +1 -1
  84. package/es/src/charts/Tree/index.js +5 -3
  85. package/es/src/charts/Tree/index.js.map +1 -1
  86. package/es/src/charts/Treemap/emit.js +56 -3
  87. package/es/src/charts/Treemap/emit.js.map +1 -1
  88. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  89. package/es/src/charts/definition/makeChart.js +8 -1
  90. package/es/src/charts/definition/makeChart.js.map +1 -1
  91. package/es/src/charts/drawSteps/backControl.js +17 -2
  92. package/es/src/charts/drawSteps/backControl.js.map +1 -1
  93. package/es/src/charts/drawSteps/bottomRightControls.js +193 -0
  94. package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
  95. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +161 -0
  96. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -0
  97. package/es/src/charts/drawSteps/minimap.js +34 -9
  98. package/es/src/charts/drawSteps/minimap.js.map +1 -1
  99. package/es/src/charts/drawSteps/zoomControls.js +3 -0
  100. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  101. package/es/src/charts/events/click.shape.js +24 -1
  102. package/es/src/charts/events/click.shape.js.map +1 -1
  103. package/es/src/charts/events/mouseenter.js +3 -0
  104. package/es/src/charts/events/mouseenter.js.map +1 -1
  105. package/es/src/charts/events/mouseleave.js +3 -0
  106. package/es/src/charts/events/mouseleave.js.map +1 -1
  107. package/es/src/charts/events/mousemove.shape.js +2 -0
  108. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  109. package/es/src/charts/features/axes.js +4 -1
  110. package/es/src/charts/features/axes.js.map +1 -1
  111. package/es/src/charts/features/emitHelpers.js +24 -0
  112. package/es/src/charts/features/emitHelpers.js.map +1 -1
  113. package/es/src/charts/features/features.js +6 -2
  114. package/es/src/charts/features/features.js.map +1 -1
  115. package/es/src/charts/features/featuresLegend.js +13 -5
  116. package/es/src/charts/features/featuresLegend.js.map +1 -1
  117. package/es/src/charts/features/plotPaint.js +51 -24
  118. package/es/src/charts/features/plotPaint.js.map +1 -1
  119. package/es/src/charts/features/shapeEmit.js +20 -2
  120. package/es/src/charts/features/shapeEmit.js.map +1 -1
  121. package/es/src/charts/index.js +1 -0
  122. package/es/src/charts/index.js.map +1 -1
  123. package/es/src/charts/pipeline/drillMorph.js +159 -0
  124. package/es/src/charts/pipeline/drillMorph.js.map +1 -0
  125. package/es/src/charts/pipeline/runChartDraw.js +35 -1
  126. package/es/src/charts/pipeline/runChartDraw.js.map +1 -1
  127. package/es/src/charts/pipeline/runVizPipeline.js +16 -1
  128. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  129. package/es/src/charts/pipeline/vizDrawPure.js +20 -0
  130. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  131. package/es/src/charts/viz/Viz.js +64 -8
  132. package/es/src/charts/viz/Viz.js.map +1 -1
  133. package/es/src/charts/viz/VizBase.js +29 -1
  134. package/es/src/charts/viz/VizBase.js.map +1 -1
  135. package/es/src/charts/viz/VizBaseConfig.js +9 -1
  136. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  137. package/es/src/charts/viz/ordinalColor.js +2 -2
  138. package/es/src/charts/viz/ordinalColor.js.map +1 -1
  139. package/es/src/charts/viz/vizDefaults.js +27 -8
  140. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  141. package/es/src/charts/viz/vizRender.js +54 -4
  142. package/es/src/charts/viz/vizRender.js.map +1 -1
  143. package/es/src/charts/viz/vizTypes.js.map +1 -1
  144. package/es/src/charts/viz/vizVisibility.js +145 -0
  145. package/es/src/charts/viz/vizVisibility.js.map +1 -0
  146. package/es/src/components/Axis/Axis.js +8 -8
  147. package/es/src/components/Axis/Axis.js.map +1 -1
  148. package/es/src/components/ColorScale/ColorScale.js +11 -11
  149. package/es/src/components/ColorScale/ColorScale.js.map +1 -1
  150. package/es/src/components/ColorScale/colorScaleScale.js +22 -10
  151. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -1
  152. package/es/src/components/Legend/Legend.js +8 -5
  153. package/es/src/components/Legend/Legend.js.map +1 -1
  154. package/es/src/components/Legend/legendConfig.js +1 -1
  155. package/es/src/components/Legend/legendConfig.js.map +1 -1
  156. package/es/src/components/Legend/legendRender.js +29 -22
  157. package/es/src/components/Legend/legendRender.js.map +1 -1
  158. package/es/src/components/SizeLegend/SizeLegend.js +411 -0
  159. package/es/src/components/SizeLegend/SizeLegend.js.map +1 -0
  160. package/es/src/components/SizeLegend/sizeLegendLayout.js +285 -0
  161. package/es/src/components/SizeLegend/sizeLegendLayout.js.map +1 -0
  162. package/es/src/components/Timeline/timelineConfig.js +8 -4
  163. package/es/src/components/Timeline/timelineConfig.js.map +1 -1
  164. package/es/src/components/Timeline/timelineRender.js +1 -2
  165. package/es/src/components/Timeline/timelineRender.js.map +1 -1
  166. package/es/src/components/Tooltip.js +27 -7
  167. package/es/src/components/Tooltip.js.map +1 -1
  168. package/es/src/components/index.js +1 -0
  169. package/es/src/components/index.js.map +1 -1
  170. package/es/src/shapes/Box.js +4 -2
  171. package/es/src/shapes/Box.js.map +1 -1
  172. package/es/src/shapes/Shape.js +1 -1
  173. package/es/src/shapes/Shape.js.map +1 -1
  174. package/es/src/shapes/Whisker.js +3 -2
  175. package/es/src/shapes/Whisker.js.map +1 -1
  176. package/es/src/shapes/validateShapeConfig.js +141 -0
  177. package/es/src/shapes/validateShapeConfig.js.map +1 -0
  178. package/es/src/utils/BaseClass.js +134 -4
  179. package/es/src/utils/BaseClass.js.map +1 -1
  180. package/es/src/utils/D3plusConfig.js.map +1 -1
  181. package/es/src/utils/configDefault.js +17 -0
  182. package/es/src/utils/configDefault.js.map +1 -0
  183. package/es/src/utils/configPrep.js +2 -1
  184. package/es/src/utils/configPrep.js.map +1 -1
  185. package/es/src/utils/configWarnings.js +37 -0
  186. package/es/src/utils/configWarnings.js.map +1 -0
  187. package/es/src/utils/index.js +1 -0
  188. package/es/src/utils/index.js.map +1 -1
  189. package/package.json +11 -10
  190. package/types/index.d.ts +4 -4
  191. package/types/internal.d.ts +8 -1
  192. package/types/src/charts/BarChart/index.d.ts +2 -1
  193. package/types/src/charts/Geomap/applyLayout.d.ts +9 -1
  194. package/types/src/charts/Histogram/binData.d.ts +37 -0
  195. package/types/src/charts/Histogram/index.d.ts +14 -0
  196. package/types/src/charts/Network/applyLayout.d.ts +8 -0
  197. package/types/src/charts/Plot/discreteSpan.d.ts +9 -0
  198. package/types/src/charts/Plot/index.d.ts +39 -0
  199. package/types/src/charts/Plot/pipeline.d.ts +14 -0
  200. package/types/src/charts/Plot/sharedHover.d.ts +79 -0
  201. package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
  202. package/types/src/charts/Plot/sharedTooltip.d.ts +26 -0
  203. package/types/src/charts/Plot/stackShareLabels.d.ts +21 -0
  204. package/types/src/charts/Plot/stackShareTooltip.d.ts +9 -0
  205. package/types/src/charts/Plot/trendLines.d.ts +70 -0
  206. package/types/src/charts/Plot/trendScene.d.ts +18 -0
  207. package/types/src/charts/Plot/trendTooltip.d.ts +19 -0
  208. package/types/src/charts/Rings/applyLayout.d.ts +9 -0
  209. package/types/src/charts/Rings/ringsSizing.d.ts +49 -0
  210. package/types/src/charts/StackedArea/index.d.ts +2 -1
  211. package/types/src/charts/definition/ChartDefinition.d.ts +30 -0
  212. package/types/src/charts/definition/makeChart.d.ts +2 -1
  213. package/types/src/charts/drawSteps/bottomRightControls.d.ts +26 -0
  214. package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +108 -0
  215. package/types/src/charts/features/emitHelpers.d.ts +8 -0
  216. package/types/src/charts/features/plotPaint.d.ts +25 -0
  217. package/types/src/charts/index.d.ts +1 -0
  218. package/types/src/charts/pipeline/drillMorph.d.ts +29 -0
  219. package/types/src/charts/pipeline/runVizPipeline.d.ts +8 -0
  220. package/types/src/charts/viz/Viz.d.ts +18 -1
  221. package/types/src/charts/viz/VizBase.d.ts +13 -0
  222. package/types/src/charts/viz/VizBaseConfig.d.ts +5 -1
  223. package/types/src/charts/viz/vizTypes.d.ts +147 -3
  224. package/types/src/charts/viz/vizVisibility.d.ts +34 -0
  225. package/types/src/components/Legend/legendRender.d.ts +8 -2
  226. package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
  227. package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
  228. package/types/src/components/Tooltip.d.ts +18 -3
  229. package/types/src/components/index.d.ts +1 -0
  230. package/types/src/shapes/validateShapeConfig.d.ts +10 -0
  231. package/types/src/utils/BaseClass.d.ts +15 -1
  232. package/types/src/utils/D3plusConfig.d.ts +98 -0
  233. package/types/src/utils/configDefault.d.ts +11 -0
  234. package/types/src/utils/configWarnings.d.ts +28 -0
  235. package/types/src/utils/index.d.ts +2 -1
  236. package/umd/d3plus-core.full.js +7104 -2602
  237. package/umd/d3plus-core.full.js.map +1 -1
  238. package/umd/d3plus-core.full.min.js +2860 -1583
  239. package/umd/d3plus-core.js +3682 -441
  240. package/umd/d3plus-core.js.map +1 -1
  241. package/umd/d3plus-core.min.js +1656 -719
@@ -0,0 +1,159 @@
1
+ /**
2
+ `resolveDrillMorph(viz)` — resolves the one-shot drill-down morph state
3
+ armed by `clickShape`'s forward capture or a Back click's reunion lookup
4
+ (see `events/click.shape.ts`, `viz/vizDefaults.ts`, `viz/Viz.ts`) into the
5
+ `_resolvedEnterFrom`/`_resolvedExitTo` boxes `_drawSceneToTarget` passes to
6
+ `drawScene`, using the *current* draw's `_bodyRect`/`_chartScene` — the
7
+ ones the layout/paint step just produced.
8
+
9
+ Chart-family-agnostic: every emitted rect/circle node already carries
10
+ `.datum`/`.index` (Treemap/Pack hand-built, or Plot's Shape-based), so the
11
+ Back-click reunion lookup needs no per-chart code — beyond unwrapping the
12
+ datum the same way every other interaction handler does (see
13
+ `unwrapDatum` below). Call once per draw, after `_draw()`/post-draw
14
+ features and before `_drawSceneToTarget()` (`runVizPipeline`) — by then
15
+ `_bodyRect`/`_chartScene` reflect the new frame, and both pending fields
16
+ are cleared unconditionally so a later, unrelated repaint (hover, resize,
17
+ legend toggle) never inherits a stale morph.
18
+ */ import { pathBounds } from "@d3plus/math";
19
+ import { areaPath, isFlipEligible } from "@d3plus/render";
20
+ /**
21
+ A flip-eligible node's geometry as a plain bounding box — every type
22
+ `isFlipEligible` (render package) approves: rect, circle, the `AreaNode`
23
+ type, and a `path` node stamped `shapeType: "Area"` (StackedArea/
24
+ AreaPlot's actual band representation). Shared with `click.shape.ts`'s
25
+ forward capture, which needs the identical conversion for the clicked node.
26
+ */ export function nodeRect(node) {
27
+ if (!isFlipEligible(node)) return null;
28
+ if (node.type === "rect") return {
29
+ x: node.x,
30
+ y: node.y,
31
+ width: node.width,
32
+ height: node.height
33
+ };
34
+ if (node.type === "circle") return {
35
+ x: node.cx - node.r,
36
+ y: node.cy - node.r,
37
+ width: node.r * 2,
38
+ height: node.r * 2
39
+ };
40
+ if (node.type === "area") return pathBounds(areaPath(node));
41
+ // Only reached for shapeType === "Area" — isFlipEligible excludes every
42
+ // other path (a plain path, or a Sankey Link) above.
43
+ if (node.type === "path") return pathBounds(node.d);
44
+ return null;
45
+ }
46
+ /**
47
+ Unwraps a node's raw `.datum` to the source row `groupBy` accessors
48
+ expect — mirroring `Viz._interactionDatum`'s exact rule, since that's
49
+ what originally produced `reunion.groupId` (via clickShape's `filterId`).
50
+ Treemap/Pack stamp `.datum` with the plain merged row directly; a Plot
51
+ shape's `.datum` is the wrapped record `{data, i, …internal fields}` —
52
+ unwrapping only on a truthy `.data` avoids misreading a plain row that
53
+ happens to have its own unrelated `data` field.
54
+ */ function unwrapDatum(datum) {
55
+ var raw = datum;
56
+ return raw && raw.data ? raw.data : raw;
57
+ }
58
+ /** The index paired with an unwrapped datum — `_interactionDatum`'s same precedence: the wrapper's own `.i` first, else the node's `.index`. */ function unwrappedIndex(datum, nodeIndex) {
59
+ var raw = datum;
60
+ return raw && typeof raw.i === "number" ? raw.i : nodeIndex !== null && nodeIndex !== void 0 ? nodeIndex : 0;
61
+ }
62
+ /**
63
+ Finds the first rect/circle node satisfying `matches`, searching group
64
+ children recursively — needed because `_chartScene` isn't always a flat
65
+ list: Treemap/Pack emit cells directly at the top level, but the
66
+ paint-driven Plot family nests its bars/points inside a `plot-zoom-content`
67
+ group alongside sibling axis groups.
68
+ */ function findReunionNode(nodes, matches) {
69
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
70
+ try {
71
+ for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
72
+ var n = _step.value;
73
+ if (isFlipEligible(n) && matches(n)) return n;
74
+ if (n.type === "group" && n.children.length) {
75
+ var found = findReunionNode(n.children, matches);
76
+ if (found) return found;
77
+ }
78
+ }
79
+ } catch (err) {
80
+ _didIteratorError = true;
81
+ _iteratorError = err;
82
+ } finally{
83
+ try {
84
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
85
+ _iterator.return();
86
+ }
87
+ } finally{
88
+ if (_didIteratorError) {
89
+ throw _iteratorError;
90
+ }
91
+ }
92
+ }
93
+ return undefined;
94
+ }
95
+ export function resolveDrillMorph(viz) {
96
+ var origin = viz._pendingEnterOrigin;
97
+ viz._pendingEnterOrigin = undefined;
98
+ if (origin && viz._bodyRect) {
99
+ var b = viz._bodyRect;
100
+ viz._resolvedEnterFrom = {
101
+ x: b.x + origin.fx * b.width,
102
+ y: b.y + origin.fy * b.height,
103
+ width: origin.fw * b.width,
104
+ height: origin.fh * b.height
105
+ };
106
+ // The entering nodes' own (fresh, just-laid-out) geometry is already
107
+ // expressed within this SAME frame — collapseTo's proportional remap
108
+ // (Treemap cells, Pack circles, Pie wedges) reads each one's position
109
+ // within it, not just the target box itself.
110
+ viz._resolvedEnterFromBody = b;
111
+ // The clicked node itself is now excluded by the new filter, so it's in
112
+ // this draw's exit set — remove it instantly rather than letting it
113
+ // animate its own collapse on top of the children replacing it.
114
+ viz._resolvedInstantExitKey = origin.key;
115
+ } else {
116
+ viz._resolvedEnterFrom = undefined;
117
+ viz._resolvedEnterFromBody = undefined;
118
+ viz._resolvedInstantExitKey = undefined;
119
+ }
120
+ var reunion = viz._pendingExitReunion;
121
+ viz._pendingExitReunion = undefined;
122
+ if (reunion && viz._chartScene) {
123
+ var _nodeRect;
124
+ var _viz_schema_groupBy;
125
+ var accessor = (_viz_schema_groupBy = viz.schema.groupBy) === null || _viz_schema_groupBy === void 0 ? void 0 : _viz_schema_groupBy[reunion.groupDepth];
126
+ var match = accessor ? findReunionNode(viz._chartScene, function(n) {
127
+ var d = unwrapDatum(n.datum);
128
+ return d !== undefined && accessor(d, unwrappedIndex(n.datum, n.index)) === reunion.groupId;
129
+ }) : undefined;
130
+ // Not found (thresholded away, filtered out, etc.) degrades to a plain
131
+ // fade — never throws.
132
+ viz._resolvedExitTo = match ? (_nodeRect = nodeRect(match)) !== null && _nodeRect !== void 0 ? _nodeRect : undefined : undefined;
133
+ // The exiting nodes' own geometry is frozen from the OLD (pre-click)
134
+ // draw, captured at the moment Back was clicked — passed through as-is,
135
+ // no cross-frame math needed (unlike _resolvedEnterFrom's fractions,
136
+ // this was never normalized against a different frame to begin with).
137
+ viz._resolvedExitToBody = reunion.body;
138
+ // A match means the reappearing parent stands in for its whole former
139
+ // child set: it starts at the FULL size those children currently occupy
140
+ // (reunion.body — the old, pre-Back body rect) and animates down to its
141
+ // own real target (reunionEnterKey/reunionEnterFrom), while the vanishing
142
+ // children drop immediately (instantExitAll) instead of a cross-fade —
143
+ // the mirror of the forward click's entering children starting confined
144
+ // within the clicked parent's box (instantExitKey handles that
145
+ // direction's parent). No match (degraded fade above) keeps the plain
146
+ // animated exit too — there's no specific node to swap in for.
147
+ viz._resolvedReunionEnterKey = match === null || match === void 0 ? void 0 : match.key;
148
+ viz._resolvedReunionEnterFrom = match ? reunion.body : undefined;
149
+ viz._resolvedInstantExitAll = Boolean(match);
150
+ } else {
151
+ viz._resolvedExitTo = undefined;
152
+ viz._resolvedExitToBody = undefined;
153
+ viz._resolvedReunionEnterKey = undefined;
154
+ viz._resolvedReunionEnterFrom = undefined;
155
+ viz._resolvedInstantExitAll = undefined;
156
+ }
157
+ }
158
+
159
+ //# sourceMappingURL=drillMorph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/pipeline/drillMorph.ts"],"sourcesContent":["/**\n `resolveDrillMorph(viz)` — resolves the one-shot drill-down morph state\n armed by `clickShape`'s forward capture or a Back click's reunion lookup\n (see `events/click.shape.ts`, `viz/vizDefaults.ts`, `viz/Viz.ts`) into the\n `_resolvedEnterFrom`/`_resolvedExitTo` boxes `_drawSceneToTarget` passes to\n `drawScene`, using the *current* draw's `_bodyRect`/`_chartScene` — the\n ones the layout/paint step just produced.\n\n Chart-family-agnostic: every emitted rect/circle node already carries\n `.datum`/`.index` (Treemap/Pack hand-built, or Plot's Shape-based), so the\n Back-click reunion lookup needs no per-chart code — beyond unwrapping the\n datum the same way every other interaction handler does (see\n `unwrapDatum` below). Call once per draw, after `_draw()`/post-draw\n features and before `_drawSceneToTarget()` (`runVizPipeline`) — by then\n `_bodyRect`/`_chartScene` reflect the new frame, and both pending fields\n are cleared unconditionally so a later, unrelated repaint (hover, resize,\n legend toggle) never inherits a stale morph.\n*/\n\nimport {pathBounds} from \"@d3plus/math\";\nimport {areaPath, isFlipEligible} from \"@d3plus/render\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode, TransitionRect} from \"@d3plus/render\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\n/**\n A flip-eligible node's geometry as a plain bounding box — every type\n `isFlipEligible` (render package) approves: rect, circle, the `AreaNode`\n type, and a `path` node stamped `shapeType: \"Area\"` (StackedArea/\n AreaPlot's actual band representation). Shared with `click.shape.ts`'s\n forward capture, which needs the identical conversion for the clicked node.\n*/\nexport function nodeRect(node: SceneNode): TransitionRect | null {\n if (!isFlipEligible(node)) return null;\n if (node.type === \"rect\") return {x: node.x, y: node.y, width: node.width, height: node.height};\n if (node.type === \"circle\")\n return {x: node.cx - node.r, y: node.cy - node.r, width: node.r * 2, height: node.r * 2};\n if (node.type === \"area\") return pathBounds(areaPath(node));\n // Only reached for shapeType === \"Area\" — isFlipEligible excludes every\n // other path (a plain path, or a Sankey Link) above.\n if (node.type === \"path\") return pathBounds(node.d);\n return null;\n}\n\n/**\n Unwraps a node's raw `.datum` to the source row `groupBy` accessors\n expect — mirroring `Viz._interactionDatum`'s exact rule, since that's\n what originally produced `reunion.groupId` (via clickShape's `filterId`).\n Treemap/Pack stamp `.datum` with the plain merged row directly; a Plot\n shape's `.datum` is the wrapped record `{data, i, …internal fields}` —\n unwrapping only on a truthy `.data` avoids misreading a plain row that\n happens to have its own unrelated `data` field.\n*/\nfunction unwrapDatum(datum: unknown): DataPoint | undefined {\n const raw = datum as {data?: DataPoint} | undefined;\n return raw && raw.data ? raw.data : (raw as DataPoint | undefined);\n}\n\n/** The index paired with an unwrapped datum — `_interactionDatum`'s same precedence: the wrapper's own `.i` first, else the node's `.index`. */\nfunction unwrappedIndex(datum: unknown, nodeIndex: number | undefined): number {\n const raw = datum as {i?: number} | undefined;\n return raw && typeof raw.i === \"number\" ? raw.i : (nodeIndex ?? 0);\n}\n\n/**\n Finds the first rect/circle node satisfying `matches`, searching group\n children recursively — needed because `_chartScene` isn't always a flat\n list: Treemap/Pack emit cells directly at the top level, but the\n paint-driven Plot family nests its bars/points inside a `plot-zoom-content`\n group alongside sibling axis groups.\n*/\nfunction findReunionNode(nodes: SceneNode[], matches: (n: SceneNode) => boolean): SceneNode | undefined {\n for (const n of nodes) {\n if (isFlipEligible(n) && matches(n)) return n;\n if (n.type === \"group\" && n.children.length) {\n const found = findReunionNode(n.children, matches);\n if (found) return found;\n }\n }\n return undefined;\n}\n\nexport function resolveDrillMorph(viz: Viz): void {\n const origin = viz._pendingEnterOrigin;\n viz._pendingEnterOrigin = undefined;\n if (origin && viz._bodyRect) {\n const b = viz._bodyRect;\n viz._resolvedEnterFrom = {\n x: b.x + origin.fx * b.width,\n y: b.y + origin.fy * b.height,\n width: origin.fw * b.width,\n height: origin.fh * b.height,\n };\n // The entering nodes' own (fresh, just-laid-out) geometry is already\n // expressed within this SAME frame — collapseTo's proportional remap\n // (Treemap cells, Pack circles, Pie wedges) reads each one's position\n // within it, not just the target box itself.\n viz._resolvedEnterFromBody = b;\n // The clicked node itself is now excluded by the new filter, so it's in\n // this draw's exit set — remove it instantly rather than letting it\n // animate its own collapse on top of the children replacing it.\n viz._resolvedInstantExitKey = origin.key;\n } else {\n viz._resolvedEnterFrom = undefined;\n viz._resolvedEnterFromBody = undefined;\n viz._resolvedInstantExitKey = undefined;\n }\n\n const reunion = viz._pendingExitReunion;\n viz._pendingExitReunion = undefined;\n if (reunion && viz._chartScene) {\n const accessor = viz.schema.groupBy?.[reunion.groupDepth];\n const match = accessor\n ? findReunionNode(viz._chartScene, n => {\n const d = unwrapDatum(n.datum);\n return d !== undefined && accessor(d, unwrappedIndex(n.datum, n.index)) === reunion.groupId;\n })\n : undefined;\n // Not found (thresholded away, filtered out, etc.) degrades to a plain\n // fade — never throws.\n viz._resolvedExitTo = match ? (nodeRect(match) ?? undefined) : undefined;\n // The exiting nodes' own geometry is frozen from the OLD (pre-click)\n // draw, captured at the moment Back was clicked — passed through as-is,\n // no cross-frame math needed (unlike _resolvedEnterFrom's fractions,\n // this was never normalized against a different frame to begin with).\n viz._resolvedExitToBody = reunion.body;\n // A match means the reappearing parent stands in for its whole former\n // child set: it starts at the FULL size those children currently occupy\n // (reunion.body — the old, pre-Back body rect) and animates down to its\n // own real target (reunionEnterKey/reunionEnterFrom), while the vanishing\n // children drop immediately (instantExitAll) instead of a cross-fade —\n // the mirror of the forward click's entering children starting confined\n // within the clicked parent's box (instantExitKey handles that\n // direction's parent). No match (degraded fade above) keeps the plain\n // animated exit too — there's no specific node to swap in for.\n viz._resolvedReunionEnterKey = match?.key;\n viz._resolvedReunionEnterFrom = match ? reunion.body : undefined;\n viz._resolvedInstantExitAll = Boolean(match);\n } else {\n viz._resolvedExitTo = undefined;\n viz._resolvedExitToBody = undefined;\n viz._resolvedReunionEnterKey = undefined;\n viz._resolvedReunionEnterFrom = undefined;\n viz._resolvedInstantExitAll = undefined;\n }\n}\n"],"names":["pathBounds","areaPath","isFlipEligible","nodeRect","node","type","x","y","width","height","cx","r","cy","d","unwrapDatum","datum","raw","data","unwrappedIndex","nodeIndex","i","findReunionNode","nodes","matches","n","children","length","found","undefined","resolveDrillMorph","viz","origin","_pendingEnterOrigin","_bodyRect","b","_resolvedEnterFrom","fx","fy","fw","fh","_resolvedEnterFromBody","_resolvedInstantExitKey","key","reunion","_pendingExitReunion","_chartScene","accessor","schema","groupBy","groupDepth","match","index","groupId","_resolvedExitTo","_resolvedExitToBody","body","_resolvedReunionEnterKey","_resolvedReunionEnterFrom","_resolvedInstantExitAll","Boolean"],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAiBA,GAEA,SAAQA,UAAU,QAAO,eAAe;AACxC,SAAQC,QAAQ,EAAEC,cAAc,QAAO,iBAAiB;AAKxD;;;;;;AAMA,GACA,OAAO,SAASC,SAASC,IAAe;IACtC,IAAI,CAACF,eAAeE,OAAO,OAAO;IAClC,IAAIA,KAAKC,IAAI,KAAK,QAAQ,OAAO;QAACC,GAAGF,KAAKE,CAAC;QAAEC,GAAGH,KAAKG,CAAC;QAAEC,O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uB,eAAe,GAAGH,SAAS/C,YAAAA,SAAS+C,oBAAT/C,uBAAAA,YAAmByB,YAAaA;QAC/D,qEAAqE;QACrE,wEAAwE;QACxE,qEAAqE;QACrE,sEAAsE;QACtEE,IAAIwB,mBAAmB,GAAGX,QAAQY,IAAI;QACtC,sEAAsE;QACtE,wEAAwE;QACxE,wEAAwE;QACxE,0EAA0E;QAC1E,uEAAuE;QACvE,wEAAwE;QACxE,+DAA+D;QAC/D,sEAAsE;QACtE,+DAA+D;QAC/DzB,IAAI0B,wBAAwB,GAAGN,kBAAAA,4BAAAA,MAAOR,GAAG;QACzCZ,IAAI2B,yBAAyB,GAAGP,QAAQP,QAAQY,IAAI,GAAG3B;QACvDE,IAAI4B,uBAAuB,GAAGC,QAAQT;IACxC,OAAO;QACLpB,IAAIuB,eAAe,GAAGzB;QACtBE,IAAIwB,mBAAmB,GAAG1B;QAC1BE,IAAI0B,wBAAwB,GAAG5B;QAC/BE,IAAI2B,yBAAyB,GAAG7B;QAChCE,IAAI4B,uBAAuB,GAAG9B;IAChC;AACF"}
@@ -6,12 +6,40 @@ function _array_like_to_array(arr, len) {
6
6
  function _array_without_holes(arr) {
7
7
  if (Array.isArray(arr)) return _array_like_to_array(arr);
8
8
  }
9
+ function _define_property(obj, key, value) {
10
+ if (key in obj) {
11
+ Object.defineProperty(obj, key, {
12
+ value: value,
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true
16
+ });
17
+ } else {
18
+ obj[key] = value;
19
+ }
20
+ return obj;
21
+ }
9
22
  function _iterable_to_array(iter) {
10
23
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
24
  }
12
25
  function _non_iterable_spread() {
13
26
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
27
  }
28
+ function _object_spread(target) {
29
+ for(var i = 1; i < arguments.length; i++){
30
+ var source = arguments[i] != null ? arguments[i] : {};
31
+ var ownKeys = Object.keys(source);
32
+ if (typeof Object.getOwnPropertySymbols === "function") {
33
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
34
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
35
+ }));
36
+ }
37
+ ownKeys.forEach(function(key) {
38
+ _define_property(target, key, source[key]);
39
+ });
40
+ }
41
+ return target;
42
+ }
15
43
  function _to_consumable_array(arr) {
16
44
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
45
  }
@@ -60,7 +88,7 @@ function _unsupported_iterable_to_array(o, minLen) {
60
88
  @param transformFn Optional builder for `_chartTransform`. Default:
61
89
  margin-origin (`{x: margin.left, y: margin.top}`).
62
90
  */ import { runStages } from "./stages.js";
63
- import { marginOriginTransform } from "../features/chartGeometry.js";
91
+ import { chartBounds, marginOriginTransform } from "../features/chartGeometry.js";
64
92
  import { isPaintDriven } from "../definition/ChartDefinition.js";
65
93
  export function runChartDraw(viz, def, stage, transformFn) {
66
94
  // Invariant: this helper OWNS `_chartScene` for the current draw — it
@@ -104,6 +132,12 @@ export function runChartDraw(viz, def, stage, transformFn) {
104
132
  viz._chartScene = _to_consumable_array(stagePushed).concat(_to_consumable_array(emitted));
105
133
  viz._chartTransform = transformFn ? transformFn(viz) : marginOriginTransform(viz);
106
134
  viz._chartClip = def.chartClip ? def.chartClip(viz) : undefined;
135
+ // The box the drill-down morph transition (enterFrom/exitTo) measures its
136
+ // fractions against — see ChartDefinition.chartBodyRect.
137
+ viz._bodyRect = def.chartBodyRect ? def.chartBodyRect(viz) : _object_spread({
138
+ x: 0,
139
+ y: 0
140
+ }, chartBounds(viz));
107
141
  }
108
142
 
109
143
  //# sourceMappingURL=runChartDraw.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/pipeline/runChartDraw.ts"],"sourcesContent":["/**\n `runChartDraw(viz, def, stage, transform?)` — collapses the canonical\n chart-subclass `_draw` body into a single call.\n\n Every Viz-extending chart subclass (Tree, Pie, Pack, Treemap, Matrix,\n RadialMatrix, Priestley, Network, Rings, Geomap, Radar) has the same\n three-line sequence after `super._draw(callback)`:\n\n const {shapeData} = runStages({viz: this}, [layoutStage]);\n this._chartScene = def.emit({viz: this, shapeData});\n this._chartTransform = { ... };\n\n This helper inlines that. The chart's `_draw` becomes:\n\n _draw(callback) {\n super._draw(callback);\n runChartDraw(this, myDef, applyMyLayout);\n return this;\n }\n\n For charts that compute a non-default `_chartTransform` (Pie centers,\n Radar centers, etc.), pass a third arg that returns the transform.\n\n Doesn't reach into chart-specific stash patterns (e.g. Pack writes\n `_packOffsetX`/`_packOffsetY` from its stage; the transform fn can\n read those off `viz` if needed).\n\n @param viz The chart instance (`this` from `_draw`).\n @param def The chart's `ChartDefinition` (e.g. `treeDef`, `pieDef`).\n @param stage The chart-specific layout `TransformStage`.\n @param transformFn Optional builder for `_chartTransform`. Default:\n margin-origin (`{x: margin.left, y: margin.top}`).\n*/\n\nimport {runStages} from \"./stages.js\";\nimport {marginOriginTransform} from \"../features/chartGeometry.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {Transform} from \"@d3plus/render\";\nimport type {ChartDefinition} from \"../definition/ChartDefinition.js\";\nimport {isPaintDriven} from \"../definition/ChartDefinition.js\";\nimport type {TransformStage, VizContext} from \"./stages.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runChartDraw(\n viz: Viz,\n def: ChartDefinition,\n stage: TransformStage,\n transformFn?: (viz: Viz) => Transform | undefined,\n): void {\n // Invariant: this helper OWNS `_chartScene` for the current draw — it\n // overwrites with `def.emit(ctx)`. The Plot family takes a different\n // flow: `Plot._paint` populates `_chartScene` directly from `plotPaint`\n // (which builds the scene from its paint context), and paint-driven defs\n // carry no `emit`. Calling `runChartDraw` on a paint-driven chart would\n // clobber that scene. The ChartDefinition.paintDriven discriminant is the\n // structural signal — failing loud so future contributors who try to\n // \"unify\" Plot with runChartDraw can't silently clobber the chart scene.\n if (isPaintDriven(def)) {\n throw new Error(\n `runChartDraw cannot drive ${def.name} — it's a paint-driven chart ` +\n \"(ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, \" +\n \"AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely \" +\n \"on Plot._paint to populate _chartScene imperatively; their _draw \" +\n \"should NOT call runChartDraw.\",\n );\n }\n // Reset _chartScene BEFORE the stage so its body has a known starting\n // point for any decoration nodes it pushes (axes, grids, spokes).\n viz._chartScene = [];\n const ctx = runStages({viz}, [stage]);\n if (!Array.isArray(viz._chartScene)) {\n // A stage reassigned `viz._chartScene` to a non-array (or replaced\n // it with undefined). Without this guard, the silent `[]` fallback\n // would discard the stage's intent — and the comment at the\n // concat below promises \"decorations are preserved\". Fail loud so\n // accidental reassignment surfaces instead of stealth-dropping\n // axis/grid nodes.\n throw new Error(\n `runChartDraw: stage for ${def.name} replaced viz._chartScene with ` +\n `a non-array value (got ${typeof viz._chartScene}). Stages should ` +\n \"use `(v._chartScene ||= []).push(...)` rather than reassigning.\",\n );\n }\n const stagePushed = viz._chartScene.slice();\n // ctx.shapeData is the generic layout bag (`unknown[]`); ChartEmit reads it\n // as DataPoint[] — each chart's layout stage produced rows it understands.\n const emitted = def.emit(ctx as VizContext & {shapeData?: DataPoint[]});\n // Preserve decorations the stage pushed (Matrix/Priestley/Radar/\n // RadialMatrix push axis/grid groups via `(v._chartScene ||= []).push`)\n // by concatenating them with the emit output. Without this, the\n // overwrite at the line below would silently discard every\n // decoration — Matrix renders bare cells with no row/column axes.\n // Stage decorations come FIRST so emit shapes paint on top.\n viz._chartScene = [...stagePushed, ...emitted];\n viz._chartTransform = transformFn\n ? transformFn(viz)\n : marginOriginTransform(viz);\n viz._chartClip = def.chartClip ? def.chartClip(viz) : undefined;\n}\n"],"names":["runStages","marginOriginTransform","isPaintDriven","runChartDraw","viz","def","stage","transformFn","Error","name","_chartScene","ctx","Array","isArray","stagePushed","slice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AGX,cAClBA,YAAYH,OACZH,sBAAsBG;IAC1BA,IAAIe,UAAU,GAAGd,IAAIe,SAAS,GAAGf,IAAIe,SAAS,CAAChB,OAAOiB;AACxD"}
1
+ {"version":3,"sources":["../../../../src/charts/pipeline/runChartDraw.ts"],"sourcesContent":["/**\n `runChartDraw(viz, def, stage, transform?)` — collapses the canonical\n chart-subclass `_draw` body into a single call.\n\n Every Viz-extending chart subclass (Tree, Pie, Pack, Treemap, Matrix,\n RadialMatrix, Priestley, Network, Rings, Geomap, Radar) has the same\n three-line sequence after `super._draw(callback)`:\n\n const {shapeData} = runStages({viz: this}, [layoutStage]);\n this._chartScene = def.emit({viz: this, shapeData});\n this._chartTransform = { ... };\n\n This helper inlines that. The chart's `_draw` becomes:\n\n _draw(callback) {\n super._draw(callback);\n runChartDraw(this, myDef, applyMyLayout);\n return this;\n }\n\n For charts that compute a non-default `_chartTransform` (Pie centers,\n Radar centers, etc.), pass a third arg that returns the transform.\n\n Doesn't reach into chart-specific stash patterns (e.g. Pack writes\n `_packOffsetX`/`_packOffsetY` from its stage; the transform fn can\n read those off `viz` if needed).\n\n @param viz The chart instance (`this` from `_draw`).\n @param def The chart's `ChartDefinition` (e.g. `treeDef`, `pieDef`).\n @param stage The chart-specific layout `TransformStage`.\n @param transformFn Optional builder for `_chartTransform`. Default:\n margin-origin (`{x: margin.left, y: margin.top}`).\n*/\n\nimport {runStages} from \"./stages.js\";\nimport {chartBounds, marginOriginTransform} from \"../features/chartGeometry.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {Transform} from \"@d3plus/render\";\nimport type {ChartDefinition} from \"../definition/ChartDefinition.js\";\nimport {isPaintDriven} from \"../definition/ChartDefinition.js\";\nimport type {TransformStage, VizContext} from \"./stages.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runChartDraw(\n viz: Viz,\n def: ChartDefinition,\n stage: TransformStage,\n transformFn?: (viz: Viz) => Transform | undefined,\n): void {\n // Invariant: this helper OWNS `_chartScene` for the current draw — it\n // overwrites with `def.emit(ctx)`. The Plot family takes a different\n // flow: `Plot._paint` populates `_chartScene` directly from `plotPaint`\n // (which builds the scene from its paint context), and paint-driven defs\n // carry no `emit`. Calling `runChartDraw` on a paint-driven chart would\n // clobber that scene. The ChartDefinition.paintDriven discriminant is the\n // structural signal — failing loud so future contributors who try to\n // \"unify\" Plot with runChartDraw can't silently clobber the chart scene.\n if (isPaintDriven(def)) {\n throw new Error(\n `runChartDraw cannot drive ${def.name} — it's a paint-driven chart ` +\n \"(ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, \" +\n \"AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely \" +\n \"on Plot._paint to populate _chartScene imperatively; their _draw \" +\n \"should NOT call runChartDraw.\",\n );\n }\n // Reset _chartScene BEFORE the stage so its body has a known starting\n // point for any decoration nodes it pushes (axes, grids, spokes).\n viz._chartScene = [];\n const ctx = runStages({viz}, [stage]);\n if (!Array.isArray(viz._chartScene)) {\n // A stage reassigned `viz._chartScene` to a non-array (or replaced\n // it with undefined). Without this guard, the silent `[]` fallback\n // would discard the stage's intent — and the comment at the\n // concat below promises \"decorations are preserved\". Fail loud so\n // accidental reassignment surfaces instead of stealth-dropping\n // axis/grid nodes.\n throw new Error(\n `runChartDraw: stage for ${def.name} replaced viz._chartScene with ` +\n `a non-array value (got ${typeof viz._chartScene}). Stages should ` +\n \"use `(v._chartScene ||= []).push(...)` rather than reassigning.\",\n );\n }\n const stagePushed = viz._chartScene.slice();\n // ctx.shapeData is the generic layout bag (`unknown[]`); ChartEmit reads it\n // as DataPoint[] — each chart's layout stage produced rows it understands.\n const emitted = def.emit(ctx as VizContext & {shapeData?: DataPoint[]});\n // Preserve decorations the stage pushed (Matrix/Priestley/Radar/\n // RadialMatrix push axis/grid groups via `(v._chartScene ||= []).push`)\n // by concatenating them with the emit output. Without this, the\n // overwrite at the line below would silently discard every\n // decoration — Matrix renders bare cells with no row/column axes.\n // Stage decorations come FIRST so emit shapes paint on top.\n viz._chartScene = [...stagePushed, ...emitted];\n viz._chartTransform = transformFn\n ? transformFn(viz)\n : marginOriginTransform(viz);\n viz._chartClip = def.chartClip ? def.chartClip(viz) : undefined;\n // The box the drill-down morph transition (enterFrom/exitTo) measures its\n // fractions against — see ChartDefinition.chartBodyRect.\n viz._bodyRect = def.chartBodyRect\n ? def.chartBodyRect(viz)\n : {x: 0, y: 0, ...chartBounds(viz)};\n}\n"],"names":["runStages","chartBounds","marginOriginTransform","isPaintDriven","runChartDraw","viz","def","stage","transformFn","Error","name","_chartScene","ctx","Array","isArray","stagePushed","slice","emitted","emit","_chartTransform","_chartClip","chartClip","undefined","_bodyRect","chartBodyRect","x","y"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,GAEA,SAAQA,SAAS,QAAO,cAAc;AACtC,SAAQC,WAAW,EAAEC,qBAAqB,QAAO,+BAA+B;AAKhF,SAAQC,aAAa,QAAO,mCAAmC;AAI/D,OAAO,SAASC,aACdC,GAAQ,EACRC,GAAoB,EACpBC,KAAqB,EACrBC,WAAiD;IAEjD,sEAAsE;IACtE,qEAAqE;IACrE,wEAAwE;IACxE,yEAAyE;IACzE,wEAAwE;IACxE,0EAA0E;IAC1E,qEAAqE;IACrE,yEAAyE;IACzE,IAAIL,cAAcG,MAAM;QACtB,MAAM,IAAIG,MACR,AAAC,6BAAqC,OAATH,IAAII,IAAI,EAAC,mCACtC,wEACA,wEACA,sEACA;IAEJ;IACA,sEAAsE;IACtE,kEAAkE;IAClEL,IAAIM,WAAW,GAAG,EAAE;IACpB,IAAMC,MAAMZ,UAAU;QAACK,KAAAA;IAAG,GAAG;QAACE;KAAM;IACpC,IAAI,CAACM,MAAMC,OAAO,CAACT,IAAIM,WAAW,GAAG;QACnC,mEAAmE;QACnE,mEAAmE;QACnE,4DAA4D;QAC5D,kEAAkE;QAClE,+DAA+D;QAC/D,mBAAmB;QACnB,MAAM,IAAIF,MACR,AAAC,2BAAmC,OAATH,IAAII,IAAI,EAAC,qCACpC,AAAC,0BAAgD,OAAvB,SAAOL,IAAIM,WAAW,GAAC,uBACjD;IAEJ;IACA,IAAMI,cAAcV,IAAIM,WAAW,CAACK,KAAK;IACzC,4EAA4E;IAC5E,2EAA2E;IAC3E,IAAMC,UAAUX,IAAIY,IAAI,CAACN;IACzB,iEAAiE;IACjE,wEAAwE;IACxE,gEAAgE;IAChE,2DAA2D;IAC3D,kEAAkE;IAClE,4DAA4D;IAC5DP,IAAIM,WAAW,GAAG,AAAC,qBAAGI,oBAAa,qBAAGE;IACtCZ,IAAIc,eAAe,GAAGX,cAClBA,YAAYH,OACZH,sBAAsBG;IAC1BA,IAAIe,UAAU,GAAGd,IAAIe,SAAS,GAAGf,IAAIe,SAAS,CAAChB,OAAOiB;IACtD,0EAA0E;IAC1E,yDAAyD;IACzDjB,IAAIkB,SAAS,GAAGjB,IAAIkB,aAAa,GAC7BlB,IAAIkB,aAAa,CAACnB,OAClB;QAACoB,GAAG;QAAGC,GAAG;OAAMzB,YAAYI;AAClC"}
@@ -42,6 +42,7 @@ function _unsupported_iterable_to_array(o, minLen) {
42
42
  3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)
43
43
  4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator
44
44
  5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel
45
+ 5b. `bottomRightControlsFeature.layout(viz)` — size-legend corner panel
45
46
  6. `attributionFeature.layout(viz)` — bottom-right attribution panel
46
47
  7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay
47
48
  8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer
@@ -57,7 +58,9 @@ function _unsupported_iterable_to_array(o, minLen) {
57
58
  */ import { attributionFeature, runLayout } from "../features/features.js";
58
59
  import { minimapFeature } from "../drawSteps/minimap.js";
59
60
  import { zoomFeature } from "../drawSteps/zoomControls.js";
61
+ import { resolveDrillMorph } from "./drillMorph.js";
60
62
  import { topLeftControlsFeature } from "../drawSteps/topLeftControls.js";
63
+ import { bottomRightControlsFeature } from "../drawSteps/bottomRightControls.js";
61
64
  import { tableViewFeature } from "../drawSteps/tableView.js";
62
65
  export function runVizPipeline(viz) {
63
66
  // Goes through `viz._preDraw()` / `viz._draw()` (not the free functions
@@ -87,17 +90,29 @@ export function runVizPipeline(viz) {
87
90
  // buffer that `toScene()` reads — including on later repaints (a zoom
88
91
  // event, a table-view toggle), which re-walk `toScene()` outside this
89
92
  // pipeline pass.
93
+ runPostDrawFeatures(viz);
94
+ // Resolve the drill-down morph's enter/exit boxes (if a drill click armed
95
+ // one) now that this draw's _bodyRect/_chartScene are final.
96
+ resolveDrillMorph(viz);
97
+ viz._drawSceneToTarget();
98
+ }
99
+ /**
100
+ Runs the post-draw features (see above) and appends their panels. Anything
101
+ that re-runs `viz._draw()` outside this pipeline — Rings re-centering on a
102
+ click, say — must call this after it: `_draw()` resets the feature panels,
103
+ so skipping it drops the corner controls, size legend, and attribution.
104
+ */ export function runPostDrawFeatures(viz) {
90
105
  var post = runLayout({
91
106
  viz: viz
92
107
  }, [
93
108
  zoomFeature,
94
109
  minimapFeature,
95
110
  topLeftControlsFeature,
111
+ bottomRightControlsFeature,
96
112
  attributionFeature,
97
113
  tableViewFeature
98
114
  ]);
99
115
  if (post.panels.length) viz._featurePanels = _to_consumable_array(viz._featurePanels || []).concat(_to_consumable_array(post.panels));
100
- viz._drawSceneToTarget();
101
116
  }
102
117
 
103
118
  //# sourceMappingURL=runVizPipeline.js.map
@@ -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. `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"}
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 5b. `bottomRightControlsFeature.layout(viz)` — size-legend corner 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 {resolveDrillMorph} from \"./drillMorph.js\";\nimport {topLeftControlsFeature} from \"../drawSteps/topLeftControls.js\";\nimport {bottomRightControlsFeature} from \"../drawSteps/bottomRightControls.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 runPostDrawFeatures(viz);\n // Resolve the drill-down morph's enter/exit boxes (if a drill click armed\n // one) now that this draw's _bodyRect/_chartScene are final.\n resolveDrillMorph(viz);\n viz._drawSceneToTarget();\n}\n\n/**\n Runs the post-draw features (see above) and appends their panels. Anything\n that re-runs `viz._draw()` outside this pipeline — Rings re-centering on a\n click, say — must call this after it: `_draw()` resets the feature panels,\n so skipping it drops the corner controls, size legend, and attribution.\n*/\nexport function runPostDrawFeatures(viz: Viz): void {\n const post = runLayout({viz}, [\n zoomFeature,\n minimapFeature,\n topLeftControlsFeature,\n bottomRightControlsFeature,\n attributionFeature,\n tableViewFeature,\n ]);\n if (post.panels.length)\n viz._featurePanels = [...(viz._featurePanels || []), ...post.panels];\n}\n"],"names":["attributionFeature","runLayout","minimapFeature","zoomFeature","resolveDrillMorph","topLeftControlsFeature","bottomRightControlsFeature","tableViewFeature","runVizPipeline","viz","_preDraw","_draw","runPostDrawFeatures","_drawSceneToTarget","post","panels","length","_featurePanels"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,GAEA,SAAQA,kBAAkB,EAAEC,SAAS,QAAO,0BAA0B;AACtE,SAAQC,cAAc,QAAO,0BAA0B;AACvD,SAAQC,WAAW,QAAO,+BAA+B;AACzD,SAAQC,iBAAiB,QAAO,kBAAkB;AAClD,SAAQC,sBAAsB,QAAO,kCAAkC;AACvE,SAAQC,0BAA0B,QAAO,sCAAsC;AAC/E,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;IACjBC,oBAAoBH;IACpB,0EAA0E;IAC1E,6DAA6D;IAC7DL,kBAAkBK;IAClBA,IAAII,kBAAkB;AACxB;AAEA;;;;;AAKA,GACA,OAAO,SAASD,oBAAoBH,GAAQ;IAC1C,IAAMK,OAAOb,UAAU;QAACQ,KAAAA;IAAG,GAAG;QAC5BN;QACAD;QACAG;QACAC;QACAN;QACAO;KACD;IACD,IAAIO,KAAKC,MAAM,CAACC,MAAM,EACpBP,IAAIQ,cAAc,GAAG,AAAC,qBAAIR,IAAIQ,cAAc,IAAI,EAAE,SAAG,qBAAGH,KAAKC,MAAM;AACvE"}
@@ -54,6 +54,8 @@ function _unsupported_iterable_to_array(o, minLen) {
54
54
  import { zoomControlsBox } from "../drawSteps/zoomControlsMarkup.js";
55
55
  import { getTopLeftContributions } from "../drawSteps/topLeftControls.js";
56
56
  import { topLeftControlsBox } from "../drawSteps/topLeftControlsMarkup.js";
57
+ import { reserveBottomRight } from "../drawSteps/bottomRightControls.js";
58
+ import { bottomRightControlsRightShortfall, bottomRightControlsShortfall } from "../drawSteps/bottomRightControlsMarkup.js";
57
59
  import { resolveSpec } from "./resolveSpec.js";
58
60
  export function vizDrawPure(viz) {
59
61
  var _prevCtx = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
@@ -123,6 +125,13 @@ export function vizDrawPure(viz) {
123
125
  ], running);
124
126
  out.marginDelta.bottom += timelineClaim.margin.bottom;
125
127
  running.bottom += timelineClaim.margin.bottom;
128
+ // The bottom-right corner panel (the size legend) measures next, above the
129
+ // timeline and against the area left so far, so the legend/colorScale
130
+ // blocks below can inset around it (see `bottomRightControlsInset`).
131
+ reserveBottomRight(viz, running.bottom, {
132
+ width: viz.schema.width - running.left - running.right,
133
+ height: viz.schema.height - running.top - running.bottom
134
+ });
126
135
  // Left/right legend + colorScale claims. Includes `=== false` (mirrors
127
136
  // colorScale below) so a previously-rendered left/right legend tears
128
137
  // down its DOM when the user toggles off via `.legendPosition(false)`.
@@ -148,6 +157,12 @@ export function vizDrawPure(viz) {
148
157
  running.left += claim1.margin.left;
149
158
  running.right += claim1.margin.right;
150
159
  }
160
+ // A right-side bottom-right panel (the size legend's default) shares the
161
+ // right column: widen the right margin to it, if the left/right claims
162
+ // above didn't already, before the bottom blocks lay out against it.
163
+ var rightShortfall = bottomRightControlsRightShortfall(viz, running.right);
164
+ out.marginDelta.right += rightShortfall;
165
+ running.right += rightShortfall;
151
166
  // Top/bottom legend + colorScale.
152
167
  if (legendPosition === "top" || legendPosition === "bottom") {
153
168
  var claim2 = runLayout({
@@ -171,6 +186,11 @@ export function vizDrawPure(viz) {
171
186
  running.top += claim3.margin.top;
172
187
  running.bottom += claim3.margin.bottom;
173
188
  }
189
+ // A bottom-side panel: the chart body must end above it, so if the bottom
190
+ // claims so far are shorter than it, top the bottom margin up.
191
+ var shortfall = bottomRightControlsShortfall(viz, running.bottom);
192
+ out.marginDelta.bottom += shortfall;
193
+ running.bottom += shortfall;
174
194
  // The corner controls (zoom, back/search) deliberately claim zero
175
195
  // margin of their own — they float at y:0, and normally whatever's
176
196
  // ABOVE the chart body (title/subtitle/total, a top legend/colorScale)
@@ -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 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;YAAGC,MAAM;YAAGC,OAAO;QAAC;QAClDC,eAAe,EAAE;IACnB;IAEA,oEAAoE;IACpE,iEAAiE;IACjE,uEAAuE;IACvE,qEAAqE;IACrE,sCAAsC;IACtCX,IAAIY,cAAc,GAAG,EAAE;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AIqB,OAAMF,MAAM,CAACnB,MAAM;IACvC;IACA,IAAIa,uBAAuB,SAASA,uBAAuB,UAAU;QACnE,IAAMQ,SAAQxC,UAAU;YAACW,KAAAA;QAAG,GAAG;YAACb;SAAkB,EAAEmC;QACpDpB,IAAII,WAAW,CAAEC,GAAG,IAAIsB,OAAMF,MAAM,CAACpB,GAAG;QACxCL,IAAII,WAAW,CAAEE,MAAM,IAAIqB,OAAMF,MAAM,CAACnB,MAAM;QAC9Cc,QAAQf,GAAG,IAAIsB,OAAMF,MAAM,CAACpB,GAAG;QAC/Be,QAAQd,MAAM,IAAIqB,OAAMF,MAAM,CAACnB,MAAM;IACvC;IAEA,kEAAkE;IAClE,mEAAmE;IACnE,uEAAuE;IACvE,uEAAuE;IACvE,oEAAoE;IACpE,oEAAoE;IACpE,sEAAsE;IACtE,qEAAqE;IACrE,uEAAuE;IACvE,6DAA6D;IAC7D,IAAI,CAACN,IAAII,WAAW,CAAEC,GAAG,EAAE;;YACNZ,kBAEjBE;QAFF,IAAMiC,sBAAanC,mBAAAA,gBAAgBK,kBAAhBL,uCAAAA,iBAA+BoC,MAAM,uCAAI;QAC5D,IAAMC,0BACJnC,sBAAAA,mBAAmBG,KAAcJ,wBAAwBI,mBAAzDH,0CAAAA,oBAAyEkC,MAAM,yCAAI;QACrF,IAAME,eAAeC,KAAKC,GAAG,CAACL,YAAYE;QAC1C,IAAIC,cAAc;YAChB/B,IAAII,WAAW,CAAEC,GAAG,IAAI0B;YACxBX,QAAQf,GAAG,IAAI0B;QACjB;IACF;IAEA,sDAAsD;IACtD/B,IAAIS,aAAa,GAAGX,IAAIY,cAAc,CAACwB,KAAK;IAE5C,OAAOlC;AACT"}
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\";\nimport {reserveBottomRight} from \"../drawSteps/bottomRightControls.js\";\nimport {\n bottomRightControlsRightShortfall,\n bottomRightControlsShortfall,\n} from \"../drawSteps/bottomRightControlsMarkup.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 // The bottom-right corner panel (the size legend) measures next, above the\n // timeline and against the area left so far, so the legend/colorScale\n // blocks below can inset around it (see `bottomRightControlsInset`).\n reserveBottomRight(viz, running.bottom, {\n width: viz.schema.width - running.left - running.right,\n height: viz.schema.height - running.top - running.bottom,\n });\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 // A right-side bottom-right panel (the size legend's default) shares the\n // right column: widen the right margin to it, if the left/right claims\n // above didn't already, before the bottom blocks lay out against it.\n const rightShortfall = bottomRightControlsRightShortfall(viz, running.right);\n out.marginDelta!.right += rightShortfall;\n running.right += rightShortfall;\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 // A bottom-side panel: the chart body must end above it, so if the bottom\n // claims so far are shorter than it, top the bottom margin up.\n const shortfall = bottomRightControlsShortfall(viz, running.bottom);\n out.marginDelta!.bottom += shortfall;\n running.bottom += shortfall;\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","reserveBottomRight","bottomRightControlsRightShortfall","bottomRightControlsShortfall","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","width","height","claim","rightShortfall","shortfall","zoomHeight","topLeftHeight","cornerHeight","Math","max","slice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;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580
+ The chart's size-legend radius scale (see `ChartDefinition.sizeLegendScale`).
581
+ Charts that size marks override this; the base chart sizes nothing.
582
+ @private
583
+ */ key: "_sizeLegendScale",
584
+ value: function _sizeLegendScale(_available) {
585
+ return null;
586
+ }
587
+ },
588
+ {
589
+ /**
580
590
  * Applies the threshold algorithm according to the type of chart used.
581
591
  * @param {Array} data The data to process.
582
592
  * @private
@@ -771,7 +781,7 @@ var Viz = /*#__PURE__*/ function(VizBase) {
771
781
  // re-renders. Interaction handlers (zoomed, hover, etc.) pass 0 to
772
782
  // skip the transition machinery — animating every wheel/drag tick
773
783
  // accumulates `setTimeout(duration+10)` per event.
774
- var drawDuration = durationOverride !== undefined ? durationOverride : this.schema.duration;
784
+ var drawDuration = durationOverride !== undefined ? durationOverride : this._instantNextDraw ? 0 : this.schema.duration;
775
785
  // A duration>0 render (drill-down, zoom, re-center) must win over any
776
786
  // pending coalesced duration-0 repaint — otherwise that repaint fires on
777
787
  // the next frame and interrupts this transition, snapping shapes to their
@@ -808,8 +818,30 @@ var Viz = /*#__PURE__*/ function(VizBase) {
808
818
  this._sceneRenderer.drawScene(scene, {
809
819
  duration: drawDuration,
810
820
  sequence: sequence,
811
- trailCatchup: trailCatchup
821
+ trailCatchup: trailCatchup,
822
+ // The drill-down morph's resolved boxes for this draw, if a drill
823
+ // click armed one (resolveDrillMorph, run just before this method via
824
+ // runVizPipeline). One-shot: cleared right below so a later repaint
825
+ // that reaches this method by some OTHER path (a zoom/pan tick, a
826
+ // coalesced hover repaint, Rings' click-to-recenter) never inherits a
827
+ // stale box from an earlier drill click.
828
+ enterFrom: this._resolvedEnterFrom,
829
+ enterFromBody: this._resolvedEnterFromBody,
830
+ exitTo: this._resolvedExitTo,
831
+ exitToBody: this._resolvedExitToBody,
832
+ instantExitKey: this._resolvedInstantExitKey,
833
+ reunionEnterKey: this._resolvedReunionEnterKey,
834
+ reunionEnterFrom: this._resolvedReunionEnterFrom,
835
+ instantExitAll: this._resolvedInstantExitAll
812
836
  });
837
+ this._resolvedEnterFrom = undefined;
838
+ this._resolvedEnterFromBody = undefined;
839
+ this._resolvedExitTo = undefined;
840
+ this._resolvedExitToBody = undefined;
841
+ this._resolvedInstantExitKey = undefined;
842
+ this._resolvedReunionEnterKey = undefined;
843
+ this._resolvedReunionEnterFrom = undefined;
844
+ this._resolvedInstantExitAll = undefined;
813
845
  this._lastSceneRendered = scene;
814
846
  // Canvas backend: the compute <svg> (`_select`) is an emptied overlay
815
847
  // sitting on top of the <canvas>. An svg root hit-tests its whole box, so
@@ -865,6 +897,15 @@ var Viz = /*#__PURE__*/ function(VizBase) {
865
897
  },
866
898
  {
867
899
  /**
900
+ Pointer hook run by `_routeSceneEvent` before any handler routing, for
901
+ every event including ones over empty space. No-op here; Plot overrides
902
+ it to drive the shared multi-series tooltip and crosshair.
903
+ @private
904
+ */ key: "_sharedHover",
905
+ value: function _sharedHover(_event) {}
906
+ },
907
+ {
908
+ /**
868
909
  Routes a renderer pointer event to the matching `viz.schema.on` handlers.
869
910
  Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
870
911
  compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`
@@ -883,6 +924,10 @@ var Viz = /*#__PURE__*/ function(VizBase) {
883
924
  // — the glitchy jump. `_transitionEndsAt` is stamped by `_drawSceneToTarget`
884
925
  // for the transition's duration; it lapses on its own, so interaction
885
926
  // resumes the instant the transition settles.
927
+ // Runs for every event, picked or not, so a chart can track the pointer
928
+ // across empty space (Plot's shared tooltip + crosshair) — and ahead of
929
+ // the transition guard below, so leaving mid-transition still clears it.
930
+ this._sharedHover(event);
886
931
  if (this._transitionEndsAt && Date.now() < this._transitionEndsAt) return;
887
932
  var pick = event.pick;
888
933
  // Dispatch helper shared by the live-pick path and the leave path.
@@ -915,9 +960,10 @@ var Viz = /*#__PURE__*/ function(VizBase) {
915
960
  if (!pick || !pick.node) return;
916
961
  // Scene nodes carry interaction metadata stamped by Viz.toScene.
917
962
  var nodeAny = pick.node;
918
- // Axis ticks/labels and the timeline are chrome — they carry data but
919
- // are not chart shapes, so they must not fire shape tooltips/handlers.
920
- if (nodeAny.interactionGroup === "axis" || nodeAny.interactionGroup === "timeline") return;
963
+ // Axis ticks/labels, the timeline, and Plot's trend lines are chrome —
964
+ // they carry data but are not chart shapes, so they must not fire shape
965
+ // tooltips/handlers (a trend line's own tooltip runs in `_sharedHover`).
966
+ if (nodeAny.interactionGroup === "axis" || nodeAny.interactionGroup === "timeline" || nodeAny.interactionGroup === "trend") return;
921
967
  // Prefer the node's stamped interaction group (set by Viz.toScene), so
922
968
  // legend swatches route to legend handlers on Canvas too — where the
923
969
  // single canvas element has no per-shape DOM to walk. Fall back to SVG
@@ -938,7 +984,11 @@ var Viz = /*#__PURE__*/ function(VizBase) {
938
984
  i: sourceIndex,
939
985
  x: rawDatum,
940
986
  isLegend: isLegendNode,
941
- shapeType: shapeType
987
+ shapeType: shapeType,
988
+ // The live picked node's own geometry, read synchronously by clickShape
989
+ // (before the drill-down re-render replaces this frame) to arm the
990
+ // forward drill-down morph.
991
+ node: pick.node
942
992
  };
943
993
  this._hoverDatum = rawDatum;
944
994
  fire(handlerKey, sourceDatum, sourceIndex, rawDatum);
@@ -981,11 +1031,13 @@ var Viz = /*#__PURE__*/ function(VizBase) {
981
1031
  },
982
1032
  {
983
1033
  /**
984
- Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
1034
+ Tears down the visualization: disconnects the ResizeObserver, stops listening for web font loads, and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
985
1035
  */ key: "destroy",
986
1036
  value: function destroy() {
987
- var _this__resizeObserver;
1037
+ var _this__resizeObserver, _this__fontsUnsubscribe, _this, _this__visibleUnobserve, _this1, _this__unloadUnobserve, _this2;
988
1038
  (_this__resizeObserver = this._resizeObserver) === null || _this__resizeObserver === void 0 ? void 0 : _this__resizeObserver.disconnect();
1039
+ (_this__fontsUnsubscribe = (_this = this)._fontsUnsubscribe) === null || _this__fontsUnsubscribe === void 0 ? void 0 : _this__fontsUnsubscribe.call(_this);
1040
+ this._fontsUnsubscribe = undefined;
989
1041
  this._tooltipClass.data([]).render();
990
1042
  select("body").on("touchstart.".concat(this._uuid), null);
991
1043
  // Clear the visibility/resize/scroll poll timers + scroll listener
@@ -1002,6 +1054,10 @@ var Viz = /*#__PURE__*/ function(VizBase) {
1002
1054
  if (this._scrollPoll) {
1003
1055
  this._scrollPoll = clearTimeout(this._scrollPoll);
1004
1056
  }
1057
+ (_this__visibleUnobserve = (_this1 = this)._visibleUnobserve) === null || _this__visibleUnobserve === void 0 ? void 0 : _this__visibleUnobserve.call(_this1);
1058
+ this._visibleUnobserve = undefined;
1059
+ (_this__unloadUnobserve = (_this2 = this)._unloadUnobserve) === null || _this__unloadUnobserve === void 0 ? void 0 : _this__unloadUnobserve.call(_this2);
1060
+ this._unloadUnobserve = undefined;
1005
1061
  if (this._sceneRepaintRAF != null) {
1006
1062
  if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this._sceneRepaintRAF);
1007
1063
  this._sceneRepaintRAF = undefined;