@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.
Files changed (214) hide show
  1. package/README.md +2137 -953
  2. package/es/index.js +1 -1
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +7 -1
  5. package/es/internal.js.map +1 -1
  6. package/es/src/charts/AreaPlot/index.js +1 -2
  7. package/es/src/charts/AreaPlot/index.js.map +1 -1
  8. package/es/src/charts/BarChart/index.js +1 -2
  9. package/es/src/charts/BarChart/index.js.map +1 -1
  10. package/es/src/charts/BoxWhisker/index.js +1 -2
  11. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  12. package/es/src/charts/BumpChart/index.js +1 -2
  13. package/es/src/charts/BumpChart/index.js.map +1 -1
  14. package/es/src/charts/Chord/applyLayout.js +205 -0
  15. package/es/src/charts/Chord/applyLayout.js.map +1 -0
  16. package/es/src/charts/Chord/emit.js +168 -0
  17. package/es/src/charts/Chord/emit.js.map +1 -0
  18. package/es/src/charts/Chord/index.js +234 -0
  19. package/es/src/charts/Chord/index.js.map +1 -0
  20. package/es/src/charts/Geomap/basemapTheme.js +78 -0
  21. package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
  22. package/es/src/charts/Geomap/emit.js +58 -9
  23. package/es/src/charts/Geomap/emit.js.map +1 -1
  24. package/es/src/charts/Geomap/index.js +93 -99
  25. package/es/src/charts/Geomap/index.js.map +1 -1
  26. package/es/src/charts/LinePlot/index.js +1 -2
  27. package/es/src/charts/LinePlot/index.js.map +1 -1
  28. package/es/src/charts/Matrix/emit.js +6 -0
  29. package/es/src/charts/Matrix/emit.js.map +1 -1
  30. package/es/src/charts/Matrix/index.js +1 -2
  31. package/es/src/charts/Matrix/index.js.map +1 -1
  32. package/es/src/charts/Network/emit.js +58 -24
  33. package/es/src/charts/Network/emit.js.map +1 -1
  34. package/es/src/charts/Network/index.js +34 -54
  35. package/es/src/charts/Network/index.js.map +1 -1
  36. package/es/src/charts/Pack/emit.js +3 -0
  37. package/es/src/charts/Pack/emit.js.map +1 -1
  38. package/es/src/charts/Pack/index.js +1 -2
  39. package/es/src/charts/Pack/index.js.map +1 -1
  40. package/es/src/charts/Pie/emit.js +6 -2
  41. package/es/src/charts/Pie/emit.js.map +1 -1
  42. package/es/src/charts/Pie/index.js +1 -2
  43. package/es/src/charts/Pie/index.js.map +1 -1
  44. package/es/src/charts/Plot/index.js +99 -4
  45. package/es/src/charts/Plot/index.js.map +1 -1
  46. package/es/src/charts/Plot/pipeline.js +25 -5
  47. package/es/src/charts/Plot/pipeline.js.map +1 -1
  48. package/es/src/charts/Plot/plotZoom.js +278 -0
  49. package/es/src/charts/Plot/plotZoom.js.map +1 -0
  50. package/es/src/charts/Priestley/emit.js +4 -0
  51. package/es/src/charts/Priestley/emit.js.map +1 -1
  52. package/es/src/charts/Priestley/index.js +1 -2
  53. package/es/src/charts/Priestley/index.js.map +1 -1
  54. package/es/src/charts/Radar/emit.js +4 -1
  55. package/es/src/charts/Radar/emit.js.map +1 -1
  56. package/es/src/charts/Radar/index.js +1 -2
  57. package/es/src/charts/Radar/index.js.map +1 -1
  58. package/es/src/charts/RadialMatrix/emit.js +6 -0
  59. package/es/src/charts/RadialMatrix/emit.js.map +1 -1
  60. package/es/src/charts/RadialMatrix/index.js +1 -2
  61. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  62. package/es/src/charts/Rings/emit.js +74 -8
  63. package/es/src/charts/Rings/emit.js.map +1 -1
  64. package/es/src/charts/Rings/index.js +11 -3
  65. package/es/src/charts/Rings/index.js.map +1 -1
  66. package/es/src/charts/Sankey/emit.js +55 -11
  67. package/es/src/charts/Sankey/emit.js.map +1 -1
  68. package/es/src/charts/Sankey/index.js +8 -2
  69. package/es/src/charts/Sankey/index.js.map +1 -1
  70. package/es/src/charts/StackedArea/index.js +1 -2
  71. package/es/src/charts/StackedArea/index.js.map +1 -1
  72. package/es/src/charts/Tree/emit.js +8 -2
  73. package/es/src/charts/Tree/emit.js.map +1 -1
  74. package/es/src/charts/Tree/index.js +1 -2
  75. package/es/src/charts/Tree/index.js.map +1 -1
  76. package/es/src/charts/Treemap/index.js +1 -2
  77. package/es/src/charts/Treemap/index.js.map +1 -1
  78. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  79. package/es/src/charts/drawSteps/backControl.js +70 -0
  80. package/es/src/charts/drawSteps/backControl.js.map +1 -0
  81. package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
  82. package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
  83. package/es/src/charts/drawSteps/minimap.js +370 -0
  84. package/es/src/charts/drawSteps/minimap.js.map +1 -0
  85. package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
  86. package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
  87. package/es/src/charts/drawSteps/searchControls.js +358 -0
  88. package/es/src/charts/drawSteps/searchControls.js.map +1 -0
  89. package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
  90. package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
  91. package/es/src/charts/drawSteps/tableView.js +173 -0
  92. package/es/src/charts/drawSteps/tableView.js.map +1 -0
  93. package/es/src/charts/drawSteps/tableViewControl.js +39 -0
  94. package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
  95. package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
  96. package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
  97. package/es/src/charts/drawSteps/topLeftControls.js +73 -0
  98. package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
  99. package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
  100. package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
  101. package/es/src/charts/drawSteps/zoomControls.js +314 -175
  102. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  103. package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
  104. package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
  105. package/es/src/charts/features/attributionFeature.js +137 -0
  106. package/es/src/charts/features/attributionFeature.js.map +1 -0
  107. package/es/src/charts/features/axes.js +20 -8
  108. package/es/src/charts/features/axes.js.map +1 -1
  109. package/es/src/charts/features/chartGeometry.js +16 -2
  110. package/es/src/charts/features/chartGeometry.js.map +1 -1
  111. package/es/src/charts/features/edgeArrows.js +155 -0
  112. package/es/src/charts/features/edgeArrows.js.map +1 -0
  113. package/es/src/charts/features/emitHelpers.js +8 -0
  114. package/es/src/charts/features/emitHelpers.js.map +1 -1
  115. package/es/src/charts/features/ensureZoomDom.js +63 -12
  116. package/es/src/charts/features/ensureZoomDom.js.map +1 -1
  117. package/es/src/charts/features/features.js +83 -110
  118. package/es/src/charts/features/features.js.map +1 -1
  119. package/es/src/charts/features/featuresLegend.js +45 -17
  120. package/es/src/charts/features/featuresLegend.js.map +1 -1
  121. package/es/src/charts/features/plotPaint.js +32 -7
  122. package/es/src/charts/features/plotPaint.js.map +1 -1
  123. package/es/src/charts/features/shapeEmit.js +3 -1
  124. package/es/src/charts/features/shapeEmit.js.map +1 -1
  125. package/es/src/charts/features/zoomExtent.js +185 -0
  126. package/es/src/charts/features/zoomExtent.js.map +1 -0
  127. package/es/src/charts/helpers/tileAttributions.js +26 -0
  128. package/es/src/charts/helpers/tileAttributions.js.map +1 -1
  129. package/es/src/charts/index.js +1 -0
  130. package/es/src/charts/index.js.map +1 -1
  131. package/es/src/charts/pipeline/runVizPipeline.js +33 -14
  132. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  133. package/es/src/charts/pipeline/vizDrawPure.js +32 -6
  134. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  135. package/es/src/charts/viz/Viz.js +102 -61
  136. package/es/src/charts/viz/Viz.js.map +1 -1
  137. package/es/src/charts/viz/VizBase.js +157 -4
  138. package/es/src/charts/viz/VizBase.js.map +1 -1
  139. package/es/src/charts/viz/VizBaseConfig.js +32 -2
  140. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  141. package/es/src/charts/viz/interactionOpacity.js +4 -1
  142. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  143. package/es/src/charts/viz/vizDefaults.js +247 -51
  144. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  145. package/es/src/charts/viz/vizRender.js +7 -3
  146. package/es/src/charts/viz/vizRender.js.map +1 -1
  147. package/es/src/charts/viz/vizTypes.js.map +1 -1
  148. package/es/src/components/Axis/Axis.js +10 -1
  149. package/es/src/components/Axis/Axis.js.map +1 -1
  150. package/es/src/components/Axis/axisLayoutLabels.js +2 -1
  151. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  152. package/es/src/components/Axis/axisRender.js +5 -1
  153. package/es/src/components/Axis/axisRender.js.map +1 -1
  154. package/es/src/components/Legend/legendConfig.js +86 -20
  155. package/es/src/components/Legend/legendConfig.js.map +1 -1
  156. package/es/src/shapes/Shape.js +12 -10
  157. package/es/src/shapes/Shape.js.map +1 -1
  158. package/es/src/shapes/hitAreaNode.js +31 -5
  159. package/es/src/shapes/hitAreaNode.js.map +1 -1
  160. package/es/src/shapes/interactionPoints.js +30 -0
  161. package/es/src/shapes/interactionPoints.js.map +1 -0
  162. package/es/src/utils/D3plusConfig.js.map +1 -1
  163. package/package.json +11 -10
  164. package/types/index.d.ts +1 -1
  165. package/types/internal.d.ts +8 -1
  166. package/types/src/charts/Chord/applyLayout.d.ts +43 -0
  167. package/types/src/charts/Chord/emit.d.ts +10 -0
  168. package/types/src/charts/Chord/index.d.ts +19 -0
  169. package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
  170. package/types/src/charts/Plot/index.d.ts +32 -2
  171. package/types/src/charts/Plot/pipeline.d.ts +2 -1
  172. package/types/src/charts/Plot/plotZoom.d.ts +65 -0
  173. package/types/src/charts/definition/ChartDefinition.d.ts +3 -1
  174. package/types/src/charts/drawSteps/backControl.d.ts +29 -0
  175. package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
  176. package/types/src/charts/drawSteps/minimap.d.ts +19 -0
  177. package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
  178. package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
  179. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
  180. package/types/src/charts/drawSteps/tableView.d.ts +23 -0
  181. package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
  182. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
  183. package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
  184. package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
  185. package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
  186. package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
  187. package/types/src/charts/features/attributionFeature.d.ts +21 -0
  188. package/types/src/charts/features/axes.d.ts +1 -1
  189. package/types/src/charts/features/chartGeometry.d.ts +9 -3
  190. package/types/src/charts/features/edgeArrows.d.ts +92 -0
  191. package/types/src/charts/features/emitHelpers.d.ts +11 -0
  192. package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
  193. package/types/src/charts/features/features.d.ts +32 -17
  194. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  195. package/types/src/charts/features/plotPaint.d.ts +15 -2
  196. package/types/src/charts/features/zoomExtent.d.ts +25 -0
  197. package/types/src/charts/index.d.ts +1 -0
  198. package/types/src/charts/pipeline/runVizPipeline.d.ts +6 -3
  199. package/types/src/charts/viz/Viz.d.ts +31 -1
  200. package/types/src/charts/viz/VizBase.d.ts +86 -4
  201. package/types/src/charts/viz/VizBaseConfig.d.ts +20 -2
  202. package/types/src/charts/viz/vizDefaults.d.ts +155 -0
  203. package/types/src/charts/viz/vizTypes.d.ts +75 -1
  204. package/types/src/components/Axis/Axis.d.ts +2 -0
  205. package/types/src/shapes/Shape.d.ts +2 -2
  206. package/types/src/shapes/hitAreaNode.d.ts +5 -4
  207. package/types/src/shapes/interactionPoints.d.ts +15 -0
  208. package/types/src/utils/D3plusConfig.d.ts +102 -8
  209. package/umd/d3plus-core.full.js +39793 -34875
  210. package/umd/d3plus-core.full.js.map +1 -1
  211. package/umd/d3plus-core.full.min.js +5836 -4264
  212. package/umd/d3plus-core.js +13998 -9927
  213. package/umd/d3plus-core.js.map +1 -1
  214. package/umd/d3plus-core.min.js +3716 -2264
@@ -323,6 +323,8 @@ import { computeTrailCatchup } from "./trailCatchup.js";
323
323
  import { CanvasRenderer, SvgRenderer } from "@d3plus/render";
324
324
  import VizBase from "./VizBase.js";
325
325
  import { applyColorScaleBucketOpacity, applyInteractionOpacity } from "./interactionOpacity.js";
326
+ import { chartAreaRect } from "../features/chartGeometry.js";
327
+ import { applyZoomPointerEvents, bindCanvasZoom } from "../drawSteps/zoomControls.js";
326
328
  import { initVizDefaults } from "./vizDefaults.js";
327
329
  import { vizRender } from "./vizRender.js";
328
330
  import { vizDraw } from "../pipeline/vizDraw.js";
@@ -399,15 +401,19 @@ var Viz = /*#__PURE__*/ function(VizBase) {
399
401
  var children = [];
400
402
  // Chart cells stashed on _chartScene — via `chartDef.emit(ctx)` for
401
403
  // data-driven charts, or `Plot._paint` for the paint-driven Plot family.
402
- // Wraps in two groups when a zoom transform is active:
403
- // viz-chart-cells (chart-positioning transform)
404
+ // Wraps in three groups:
405
+ // viz-chart-cells (clip window, untransformed)
404
406
  // viz-zoom (zoom transform — pan/scale from d3-zoom)
405
- // … chart scene children
407
+ // viz-chart-body (chart-positioning transform)
408
+ // … chart scene children
406
409
  // This lets zoom apply to the chart content WITHOUT moving legend/
407
410
  // title/total/etc. (which live in sibling viz-* groups, not under
408
- // viz-chart-cells).
411
+ // viz-chart-cells). The zoom transform sits above the chart transform so
412
+ // it lives in the same surface space d3-zoom measures the pointer in —
413
+ // a wheel zoom stays anchored under the cursor regardless of margins or
414
+ // a chart's own centering transform (Pie, Radar, …).
409
415
  if (this._chartScene && this._chartScene.length) {
410
- var _this__zoomTransform;
416
+ var _this__zoomTransform, _this__chartClip;
411
417
  var sliced = applyInteractionOpacity(this._chartScene, this);
412
418
  // Always emit the viz-zoom group (identity transform when no zoom is
413
419
  // active) so its key is stable across the first zoom. Otherwise the first
@@ -423,16 +429,28 @@ var Viz = /*#__PURE__*/ function(VizBase) {
423
429
  y: 0,
424
430
  scale: 1
425
431
  },
426
- children: sliced
432
+ children: [
433
+ _object_spread_props(_object_spread({
434
+ type: "group",
435
+ key: "viz-chart-body"
436
+ }, this._chartTransform ? {
437
+ transform: this._chartTransform
438
+ } : {}), {
439
+ children: sliced
440
+ })
441
+ ]
427
442
  }
428
443
  ];
444
+ // Fixed clip window (e.g. Geomap's map rect): stays put in scene space
445
+ // while the viz-zoom child transform pans/scales content beneath it.
446
+ // Any zoomable chart without its own clip is clipped to the chart area,
447
+ // so zoomed content can't spill over the legend/title/timeline.
448
+ var clip = (_this__chartClip = this._chartClip) !== null && _this__chartClip !== void 0 ? _this__chartClip : this.schema.zoom && this._margin ? chartAreaRect(this) : undefined;
429
449
  children.push(_object_spread_props(_object_spread({
430
450
  type: "group",
431
451
  key: "viz-chart-cells"
432
- }, this._chartTransform ? {
433
- transform: this._chartTransform
434
- } : {}, this._chartClip ? {
435
- clip: this._chartClip
452
+ }, clip ? {
453
+ clip: clip
436
454
  } : {}), {
437
455
  children: zoomNode
438
456
  }));
@@ -528,34 +546,13 @@ var Viz = /*#__PURE__*/ function(VizBase) {
528
546
  }
529
547
  }
530
548
  }
531
- // E2: FeatureModule.layout() panels (title/subtitle/total/back).
549
+ // E2: FeatureModule.layout() panels (title/subtitle/total, plus the
550
+ // zoom/top-left-controls/attribution overlays appended post-draw).
532
551
  if (this._featurePanels && this._featurePanels.length) {
533
- var panels = this._featurePanels.slice();
534
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
535
- try {
536
- // Tag the back-button panel so the pointer bridge can route its click.
537
- for(var _iterator1 = panels[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
538
- var panel = _step1.value;
539
- if (panel && typeof panel.key === "string" && panel.key.toLowerCase().includes("back")) tagInteractionGroup(panel, "back");
540
- }
541
- } catch (err) {
542
- _didIteratorError1 = true;
543
- _iteratorError1 = err;
544
- } finally{
545
- try {
546
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
547
- _iterator1.return();
548
- }
549
- } finally{
550
- if (_didIteratorError1) {
551
- throw _iteratorError1;
552
- }
553
- }
554
- }
555
552
  children.push({
556
553
  type: "group",
557
554
  key: "viz-features",
558
- children: panels
555
+ children: this._featurePanels
559
556
  });
560
557
  }
561
558
  return {
@@ -621,6 +618,32 @@ var Viz = /*#__PURE__*/ function(VizBase) {
621
618
  return vizRender(this, callback);
622
619
  }
623
620
  },
621
+ {
622
+ /**
623
+ Serializes the most recently rendered output to an SVG string. Returns
624
+ `""` if the chart has not been rendered yet. Both backends support this:
625
+ the SVG backend returns its live `<svg>`, the canvas backend re-renders the
626
+ retained scene through a throwaway SVG backend. Primarily used for
627
+ server-side rendering (see `@d3plus/ssr`).
628
+ */ key: "toSVGString",
629
+ value: function toSVGString() {
630
+ var _ref;
631
+ var _this__sceneRenderer_toSVGString, _this__sceneRenderer;
632
+ return (_ref = (_this__sceneRenderer = this._sceneRenderer) === null || _this__sceneRenderer === void 0 ? void 0 : (_this__sceneRenderer_toSVGString = _this__sceneRenderer.toSVGString) === null || _this__sceneRenderer_toSVGString === void 0 ? void 0 : _this__sceneRenderer_toSVGString.call(_this__sceneRenderer)) !== null && _ref !== void 0 ? _ref : "";
633
+ }
634
+ },
635
+ {
636
+ /**
637
+ Returns the underlying canvas element of the most recent render when the
638
+ canvas backend is active (`renderer("canvas")`), or `undefined` otherwise.
639
+ Server-side callers cast this to their native canvas to encode a raster
640
+ (see `@d3plus/ssr`).
641
+ */ key: "toCanvas",
642
+ value: function toCanvas() {
643
+ var _this__sceneRenderer_toCanvas, _this__sceneRenderer;
644
+ return this._renderer === "canvas" ? (_this__sceneRenderer = this._sceneRenderer) === null || _this__sceneRenderer === void 0 ? void 0 : (_this__sceneRenderer_toCanvas = _this__sceneRenderer.toCanvas) === null || _this__sceneRenderer_toCanvas === void 0 ? void 0 : _this__sceneRenderer_toCanvas.call(_this__sceneRenderer) : undefined;
645
+ }
646
+ },
624
647
  {
625
648
  key: "renderer",
626
649
  value: function renderer(_) {
@@ -719,10 +742,14 @@ var Viz = /*#__PURE__*/ function(VizBase) {
719
742
  if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") this._sceneRenderer.destroy();
720
743
  var Ctor = kind === "canvas" ? CanvasRenderer : SvgRenderer;
721
744
  this._sceneRenderer = new Ctor();
745
+ // `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),
746
+ // fixes the canvas backing-store scale; otherwise the renderer falls back
747
+ // to `devicePixelRatio`.
722
748
  this._sceneRenderer.mount({
723
749
  container: mountTarget,
724
750
  width: w,
725
- height: h
751
+ height: h,
752
+ pixelRatio: this._scenePixelRatio
726
753
  });
727
754
  // Bridge renderer pointer events → viz.schema.on handlers. Without this,
728
755
  // tooltips never fire on the v4 scene-rendered path because
@@ -792,12 +819,11 @@ var Viz = /*#__PURE__*/ function(VizBase) {
792
819
  // is the sole interaction surface. The only interactive DOM that still
793
820
  // lives in this svg is the timeline's d3-brush (the canvas can't host the
794
821
  // native brush handles), so re-enable events on just that group. On the
795
- // SVG backend `_select` IS the scene host, so events must stay enabled.
796
- if (this._select) {
797
- this._select.style("pointer-events", kind === "canvas" ? "none" : null);
798
- if (this._container) this._container.style("pointer-events", kind === "canvas" ? "none" : null);
799
- if (kind === "canvas") this._select.select("g.d3plus-viz-timeline").style("pointer-events", "auto");
800
- }
822
+ // SVG backend `_select` IS the scene host, so events must stay enabled
823
+ // (except while the zoom brush is active — see `applyZoomPointerEvents`).
824
+ applyZoomPointerEvents(this);
825
+ if (this._select && kind === "canvas") this._select.select("g.d3plus-viz-timeline").style("pointer-events", "auto");
826
+ if (kind === "canvas") bindCanvasZoom(this);
801
827
  // The timeline brush (d3-brush DOM, mounted in `g.d3plus-viz-timeline` in
802
828
  // the outer svg) must paint above the scene-rendered timeline buttons/ticks
803
829
  // so its selection tint + handles sit on top of them (matching v3). The
@@ -808,11 +834,37 @@ var Viz = /*#__PURE__*/ function(VizBase) {
808
834
  var host = userTarget && typeof userTarget.querySelector === "function" ? userTarget : null;
809
835
  var tlGroup = host ? host.querySelector(":scope > g.d3plus-viz-timeline") : null;
810
836
  if (tlGroup) host.appendChild(tlGroup);
837
+ // Likewise the zoom brush, so its selection box draws over the shapes.
838
+ var zoomBrush = host ? host.querySelector(":scope > g.d3plus-zoom-brush") : null;
839
+ if (zoomBrush && zoomBrush !== host.lastElementChild) host.appendChild(zoomBrush);
811
840
  }
812
841
  }
813
842
  },
814
843
  {
815
844
  /**
845
+ Resolves the `(d, i, x)` a picked scene node reports to interaction
846
+ handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw
847
+ scene datum; for a Plot shape that's the wrapped record `{data, i}`, which
848
+ handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that
849
+ unwrap; Plot overrides this to report the point nearest the cursor for
850
+ multi-point shapes (Line/Area) so a series tooltip reflects the hovered
851
+ x rather than the whole-series aggregate.
852
+ @private
853
+ */ key: "_interactionDatum",
854
+ value: function _interactionDatum(pick, _event) {
855
+ var _pick_index;
856
+ var rawDatum = pick.datum;
857
+ var sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;
858
+ var sourceIndex = rawDatum && typeof rawDatum.i === "number" ? rawDatum.i : (_pick_index = pick.index) !== null && _pick_index !== void 0 ? _pick_index : 0;
859
+ return {
860
+ d: sourceDatum,
861
+ i: sourceIndex,
862
+ x: rawDatum
863
+ };
864
+ }
865
+ },
866
+ {
867
+ /**
816
868
  Routes a renderer pointer event to the matching `viz.schema.on` handlers.
817
869
  Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
818
870
  compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`
@@ -824,7 +876,6 @@ var Viz = /*#__PURE__*/ function(VizBase) {
824
876
  */ key: "_routeSceneEvent",
825
877
  value: function _routeSceneEvent(event) {
826
878
  var _this = this;
827
- var _pick_index;
828
879
  // Ignore all pointer interaction while an animated transition (zoom,
829
880
  // re-center, drill-down, entrance) is in flight. Hovering or clicking a
830
881
  // shape mid-transition would fire a handler that schedules a duration-0
@@ -864,17 +915,6 @@ var Viz = /*#__PURE__*/ function(VizBase) {
864
915
  if (!pick || !pick.node) return;
865
916
  // Scene nodes carry interaction metadata stamped by Viz.toScene.
866
917
  var nodeAny = pick.node;
867
- // Back-button panel: its d3-selection click listener never fires in the
868
- // scene path (it's a plain text node), so route its click here to pop
869
- // the drill-down history / step up a level.
870
- if (nodeAny.interactionGroup === "back") {
871
- if (event.type === "click") {
872
- var self = this;
873
- if (self._history.length) self.config(self._history.pop()).render();
874
- else self.depth(self._drawDepth - 1).filter(false).render();
875
- }
876
- return;
877
- }
878
918
  // Axis ticks/labels and the timeline are chrome — they carry data but
879
919
  // are not chart shapes, so they must not fire shape tooltips/handlers.
880
920
  if (nodeAny.interactionGroup === "axis" || nodeAny.interactionGroup === "timeline") return;
@@ -886,12 +926,12 @@ var Viz = /*#__PURE__*/ function(VizBase) {
886
926
  var isLegendNode = nodeAny.interactionGroup === "legend" || (target && typeof target.closest === "function" ? !!target.closest('[data-key="viz-legend"]') : false);
887
927
  var suffix = isLegendNode ? "legend" : "shape";
888
928
  var handlerKey = "".concat(event.type, ".").concat(suffix);
889
- // Resolve the source datum + index. `pick.datum` is the raw scene datum
890
- // (which Shape._sceneXxx populated). For Plot shapes that's the wrapped
891
- // record; the handlers expect `(d.data, d.i, x, event)`.
892
- var rawDatum = pick.datum;
893
- var sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;
894
- var sourceIndex = rawDatum && typeof rawDatum.i === "number" ? rawDatum.i : (_pick_index = pick.index) !== null && _pick_index !== void 0 ? _pick_index : 0;
929
+ // Resolve the datum + index this pick reports to handlers, ONCE, and reuse
930
+ // it for every handler fired below so tooltip/click/user handlers agree on
931
+ // which datum the pointer is over. The base unwraps the node's raw datum to
932
+ // its source row; Plot overrides `_interactionDatum` to report the point
933
+ // nearest the cursor for multi-point shapes (Line/Area).
934
+ var _this__interactionDatum = this._interactionDatum(pick, event), sourceDatum = _this__interactionDatum.d, sourceIndex = _this__interactionDatum.i, rawDatum = _this__interactionDatum.x;
895
935
  var shapeType = typeof nodeAny.shapeType === "string" ? nodeAny.shapeType : null;
896
936
  this._lastScenePick = {
897
937
  d: sourceDatum,
@@ -944,7 +984,8 @@ var Viz = /*#__PURE__*/ function(VizBase) {
944
984
  Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
945
985
  */ key: "destroy",
946
986
  value: function destroy() {
947
- this._resizeObserver.disconnect();
987
+ var _this__resizeObserver;
988
+ (_this__resizeObserver = this._resizeObserver) === null || _this__resizeObserver === void 0 ? void 0 : _this__resizeObserver.disconnect();
948
989
  this._tooltipClass.data([]).render();
949
990
  select("body").on("touchstart.".concat(this._uuid), null);
950
991
  // Clear the visibility/resize/scroll poll timers + scroll listener
@@ -965,7 +1006,7 @@ var Viz = /*#__PURE__*/ function(VizBase) {
965
1006
  if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this._sceneRepaintRAF);
966
1007
  this._sceneRepaintRAF = undefined;
967
1008
  }
968
- select(this.schema.scrollContainer).on("scroll.".concat(this._uuid), null);
1009
+ if (this.schema.scrollContainer) select(this.schema.scrollContainer).on("scroll.".concat(this._uuid), null);
969
1010
  // Destroy the active scene renderer (clears its own pointer-rect
970
1011
  // listeners, overlay host, canvas/svg DOM, timers).
971
1012
  if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/viz/Viz.ts"],"sourcesContent":["import {select} from \"d3-selection\";\n\nimport {date, getSize} from \"@d3plus/dom\";\n\nimport {computeTrailCatchup} from \"./trailCatchup.js\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {CanvasRenderer, SvgRenderer} from \"@d3plus/render\";\nimport type {Renderer, Scene, SceneEvent, SceneNode, Transform} from \"@d3plus/render\";\n\nimport VizBase from \"./VizBase.js\";\nimport type {ColorScale, Legend, Timeline} from \"../../components/index.js\";\nimport type Shape from \"../../shapes/Shape.js\";\nimport {applyColorScaleBucketOpacity, applyInteractionOpacity} from \"./interactionOpacity.js\";\nimport {initVizDefaults} from \"./vizDefaults.js\";\nimport {vizRender} from \"./vizRender.js\";\nimport {vizDraw} from \"../pipeline/vizDraw.js\";\nimport {vizPreDraw} from \"../pipeline/vizPreDraw.js\";\nimport type {VizInstance} from \"./vizTypes.js\";\n\n/**\n Stamps `interactionGroup` onto a component's scene subtree so the pointer\n bridge can route its nodes to component-scoped handlers (e.g. legend) on\n every backend — including Canvas, where there is no per-shape DOM to walk.\n*/\nfunction tagInteractionGroup(node: SceneNode, group: string): void {\n (node as {interactionGroup?: string}).interactionGroup = group;\n const kids = (node as {children?: SceneNode[]}).children;\n if (kids) for (const child of kids) tagInteractionGroup(child, group);\n}\n\n/**\n Resolves the element a renderer mounts into. A `<canvas>` cannot paint inside\n an `<svg>`, so when the scene target is the compute svg, the canvas mounts\n into that svg's parent (the user's element); the emptied, position:absolute\n compute svg overlays the same top-left box. SVG mounts into the target as-is.\n*/\nfunction mountTargetFor(kind: string, target: Element): Element {\n if (\n kind === \"canvas\" &&\n typeof Element !== \"undefined\" &&\n target instanceof Element &&\n target.tagName.toLowerCase() === \"svg\"\n )\n return (target.parentNode as Element | null) ?? target;\n return target;\n}\n\n/**\n Creates an x/y plot based on an array of data. See [this example](https://d3plus.org/examples/d3plus-treemap/getting-started/) for help getting started using the treemap generator.\n*/\nexport default class Viz extends VizBase {\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n */\n constructor() {\n super();\n initVizDefaults(this);\n }\n\n /**\n Called by draw before anything is drawn. Formats the data and performs preparations for draw.\n @private\n */\n _preDraw(): void {\n vizPreDraw(this as unknown as VizInstance);\n }\n\n /**\n Composes a backend-agnostic scene graph from the shapes/features produced\n by the most recent render. Combines:\n - `_chartScene` (cells from `chartDef.emit`, or `Plot._paint` for the\n paint-driven Plot family) wrapped in viz-chart-cells\n - `_shapes` (still used by some charts) — each shape's toScene\n - chart-level components (Legend/ColorScale/Timeline) via their toScene\n - `_featurePanels` (from FeatureModule layouts) wrapped in viz-features\n */\n toScene(): Scene {\n const children: SceneNode[] = [];\n // Chart cells stashed on _chartScene — via `chartDef.emit(ctx)` for\n // data-driven charts, or `Plot._paint` for the paint-driven Plot family.\n // Wraps in two groups when a zoom transform is active:\n // viz-chart-cells (chart-positioning transform)\n // viz-zoom (zoom transform — pan/scale from d3-zoom)\n // … chart scene children\n // This lets zoom apply to the chart content WITHOUT moving legend/\n // title/total/etc. (which live in sibling viz-* groups, not under\n // viz-chart-cells).\n if (this._chartScene && this._chartScene.length) {\n const sliced = applyInteractionOpacity(\n this._chartScene,\n this as unknown as VizInstance,\n );\n // Always emit the viz-zoom group (identity transform when no zoom is\n // active) so its key is stable across the first zoom. Otherwise the first\n // zoom adds a brand-new group → the renderer treats the chart cells as\n // exit+enter (teardown/rebuild) instead of tweening the group transform,\n // so the zoom snaps in instead of animating.\n const zoomNode = [{\n type: \"group\" as const,\n key: \"viz-zoom\",\n transform: this._zoomTransform ?? {x: 0, y: 0, scale: 1},\n children: sliced,\n }];\n children.push({\n type: \"group\",\n key: \"viz-chart-cells\",\n ...(this._chartTransform ? {transform: this._chartTransform} : {}),\n // Fixed clip window (e.g. Geomap's map rect): stays put in scene space\n // while the viz-zoom child transform pans/scales content beneath it.\n ...(this._chartClip ? {clip: this._chartClip} : {}),\n children: zoomNode,\n });\n }\n // `_shapes` collection (Treemap/Pack/etc. route through `_chartScene`\n // instead, as does Plot's `absorbShapeIntoChartScene`). Any caller\n // pushing into `_shapes` gets its `toScene()` walked here; we read the\n // shape's `_select` transform via d3's transform baseVal if present,\n // otherwise emit without a transform.\n (this._shapes || []).forEach((shape: Shape, si: number) => {\n if (!shape || typeof shape.toScene !== \"function\") return;\n const group = shape.toScene();\n let transform: Transform | undefined;\n const sel = shape._select;\n if (sel && typeof sel.attr === \"function\") {\n // Parse `translate(x, y)` from the selection's transform attr.\n // Falls back to undefined for non-translate transforms — the\n // `_shapes` path only uses translate.\n const t = sel.attr(\"transform\");\n if (typeof t === \"string\") {\n const m = t.match(/translate\\(\\s*(-?[\\d.]+)[, ]\\s*(-?[\\d.]+)\\s*\\)/);\n if (m) transform = {x: parseFloat(m[1]), y: parseFloat(m[2])};\n }\n }\n children.push({\n type: \"group\",\n key: `${group.key || \"shape\"}-${si}`,\n ...(transform ? {transform} : {}),\n children: group.children,\n });\n });\n // Chart-level components that have their own toScene.\n const components: [string, Legend | ColorScale | Timeline | undefined][] = [\n [\"legend\", this._legendClass],\n [\"colorScale\", this._colorScaleClass],\n [\"timeline\", this._timelineClass],\n ];\n for (const [name, comp] of components) {\n if (\n comp &&\n typeof comp.toScene === \"function\" &&\n comp._select &&\n typeof comp._select.node === \"function\" &&\n comp._select.node()\n ) {\n let compScene: SceneNode = comp.toScene();\n // Tag the legend subtree so its swatches route to legend handlers via\n // the node stamp (renderer-independent), not just SVG DOM ancestry.\n if (name === \"legend\") {\n tagInteractionGroup(compScene, \"legend\");\n // Hovering a legend swatch dims the others, like the chart marks:\n // run the legend subtree through the same interaction-opacity pass\n // (a no-op when no hover/active predicate is set).\n compScene = applyInteractionOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Hovering a colorScale swatch (or a data shape) dims the sibling\n // swatches by bucket color — leaving the colorScale title/axis/gradient\n // untouched. Not tagged \"legend\": colorScale swatches keep the shape\n // event path (range-based tooltip + hover), unlike groupBy legend items.\n else if (name === \"colorScale\") {\n compScene = applyColorScaleBucketOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Tag the timeline subtree so its ticks/labels are exempt from shape\n // tooltips and hover/active dimming (it's chrome, not data marks).\n else if (name === \"timeline\") tagInteractionGroup(compScene, \"timeline\");\n children.push({\n type: \"group\",\n key: `viz-${name}`,\n children: [compScene],\n });\n }\n }\n // E2: FeatureModule.layout() panels (title/subtitle/total/back).\n if (this._featurePanels && this._featurePanels.length) {\n const panels = this._featurePanels.slice();\n // Tag the back-button panel so the pointer bridge can route its click.\n for (const panel of panels) {\n if (\n panel &&\n typeof (panel as {key?: string}).key === \"string\" &&\n (panel as {key: string}).key.toLowerCase().includes(\"back\")\n )\n tagInteractionGroup(panel as SceneNode, \"back\");\n }\n children.push({type: \"group\", key: \"viz-features\", children: panels});\n }\n return {\n width: this.schema.width,\n height: this.schema.height,\n root: {type: \"group\", key: \"viz-root\", children},\n };\n }\n\n /**\n Called by render once all checks are passed.\n @private\n */\n _draw(): void {\n vizDraw(this as unknown as VizInstance);\n }\n\n /**\n * Applies the threshold algorithm according to the type of chart used.\n * @param {Array} data The data to process.\n * @private\n */\n _thresholdFunction(data: DataPoint[], _tree?: unknown): DataPoint[] {\n return data;\n }\n\n /**\n * Detects width and height and sets SVG properties\n * @private\n */\n _setSVGSize(width?: number, height?: number): void {\n let [w, h] =\n width && height\n ? [width, height]\n : getSize(this._select.node().parentNode);\n w! -= parseFloat(this._select.style(\"border-left-width\"));\n w! -= parseFloat(this._select.style(\"border-right-width\"));\n h! -= parseFloat(this._select.style(\"border-top-width\"));\n h! -= parseFloat(this._select.style(\"border-bottom-width\"));\n \n if (this._autoWidth && this.schema.width !== w) {\n this.width(w);\n this._select\n .style(\"width\", `${this.schema.width}px`)\n .attr(\"width\", `${this.schema.width}px`);\n }\n if (this._autoHeight && this.schema.height !== h) {\n this.height(h);\n this._select\n .style(\"height\", `${this.schema.height}px`)\n .attr(\"height\", `${this.schema.height}px`);\n }\n }\n\n /**\n Draws the visualization given the specified configuration.\n @param callback Optional callback invoked after rendering completes.\n */\n render(callback?: () => void): this {\n return vizRender(this, callback) as this;\n }\n\n /**\n Selects which @d3plus/render backend paints the visible output.\n `\"svg\"` = SvgRenderer (default), `\"canvas\"` = CanvasRenderer.\n Boolean arguments both normalize to `\"svg\"`.\n */\n renderer(): \"svg\" | \"canvas\";\n renderer(_: \"svg\" | \"canvas\" | true | false): this;\n renderer(_?: \"svg\" | \"canvas\" | true | false): \"svg\" | \"canvas\" | this {\n if (!arguments.length) return this._renderer;\n this._renderer = _ === \"canvas\" ? \"canvas\" : \"svg\";\n return this;\n }\n\n /**\n \"full\" runs the DOM enter/update/exit for every shape; \"compute\"\n skips DOM work and only populates the scene data (`_textData`,\n `_shapes[i]._select`, etc.) for `toScene()` to read. Set automatically by\n `renderScene` callers; users can also opt-in.\n */\n renderMode(): \"full\" | \"compute\";\n renderMode(_: \"full\" | \"compute\"): this;\n renderMode(_?: \"full\" | \"compute\"): \"full\" | \"compute\" | this {\n if (!arguments.length) return this._renderMode || \"full\";\n this._renderMode = _!;\n return this;\n }\n\n /**\n Public entry point that renders this chart through the @d3plus/render\n pluggable backends. The compute pass happens via render() (in an svg\n auto-created inside the target div); SvgRenderer/CanvasRenderer paints\n the scene to the target. Returns `{renderer, scene}` so callers can\n interact with the renderer (e.g. for picking) or read the scene data.\n */\n async renderScene(\n target: Element,\n opts?: {kind?: \"svg\" | \"canvas\"},\n ): Promise<{renderer: Renderer; scene: Scene}> {\n const kind = opts?.kind || (this._renderer === \"canvas\" ? \"canvas\" : \"svg\");\n this._sceneTarget = target;\n this._renderer = kind;\n this.select(target as HTMLElement);\n await new Promise<void>(resolve => this.render(() => resolve()));\n return {\n renderer: this._sceneRenderer as Renderer,\n scene: this._lastSceneRendered as Scene,\n };\n }\n\n /**\n Renders this chart through the @d3plus/render pluggable backends. Called\n automatically by `render()`. The compute pass draws into `this._select`\n (an auto-created svg INSIDE the user's target div) — that svg is the\n off-stage detached compute svg. SvgRenderer mounts to the user's target\n div (the parent), as a sibling to the detached compute svg. The compute\n svg's children get cleared so only the scene output is visible.\n */\n _drawSceneToTarget(durationOverride?: number): void {\n const kind = this._renderer === \"canvas\" ? \"canvas\" : \"svg\";\n const computeSvg = this._select && this._select.node ? this._select.node() : null;\n if (!computeSvg) return;\n // Mount renderer INSIDE the user's `_select` (svg or div). Tests like\n // `svgA.querySelector('[data-key=\"viz-legend\"]')` need the scene output\n // to live inside the user's container, not as a sibling.\n const userTarget = this._sceneTarget || computeSvg;\n if (!userTarget) return;\n const mountTarget = mountTargetFor(kind, userTarget as Element);\n const scene = this.toScene();\n const w = this.schema.width || 400;\n const h = this.schema.height || 300;\n // Reuse the renderer instance if it matches the kind, to avoid mount\n // churn. `target()` is the public Renderer-interface method (no\n // reaching into renderer-private slots). It's optional on the\n // interface; third-party renderers without it fall through to\n // remount on every draw — correct but with mount churn.\n const currentContainer = this._sceneRenderer?.target\n ? this._sceneRenderer.target()?.container\n : undefined;\n const containerChanged = this._sceneRenderer?.target\n ? currentContainer !== mountTarget\n : false;\n if (\n !this._sceneRenderer ||\n this._sceneRenderer.kind !== kind ||\n containerChanged\n ) {\n // Tear down the outgoing renderer before mounting a fresh one. It owns\n // its own DOM (canvas/svg + overlay host), pointer listeners, and\n // transition timers; without this, switching kind (svg<->canvas) or\n // container orphans that DOM in the user's element, stacking the old\n // mode's output behind the new one and accumulating on every switch.\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\")\n this._sceneRenderer.destroy();\n const Ctor = kind === \"canvas\" ? CanvasRenderer : SvgRenderer;\n this._sceneRenderer = new Ctor();\n this._sceneRenderer.mount({container: mountTarget, width: w, height: h});\n // Bridge renderer pointer events → viz.schema.on handlers. Without this,\n // tooltips never fire on the v4 scene-rendered path because\n // `shape.on(evt, fn)` in plotPaint only wires d3-selection\n // listeners on DOM nodes the scene renderer doesn't create.\n // Renderer events carry the picked scene node; the routing lives in\n // `_routeSceneEvent` (kept out of this method so the mount path stays\n // readable). `_lastScenePick` remembers the most recently hovered node\n // so `mouseleave` — fired with a null pick — can still tell the matching\n // handlers which shape/legend item was left (so the tooltip clears).\n this._lastScenePick = null;\n this._sceneRenderer.on((event: SceneEvent) => this._routeSceneEvent(event));\n } else {\n this._sceneRenderer.resize(w, h);\n }\n // `durationOverride` defaults to the chart's `_duration` for normal\n // re-renders. Interaction handlers (zoomed, hover, etc.) pass 0 to\n // skip the transition machinery — animating every wheel/drag tick\n // accumulates `setTimeout(duration+10)` per event.\n const drawDuration =\n durationOverride !== undefined ? durationOverride : this.schema.duration;\n // A duration>0 render (drill-down, zoom, re-center) must win over any\n // pending coalesced duration-0 repaint — otherwise that repaint fires on\n // the next frame and interrupts this transition, snapping shapes to their\n // final geometry.\n if (drawDuration > 0 && this._sceneRepaintRAF != null) {\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n // Mark the window during which an animated transition is in flight, so the\n // pointer bridge can ignore interaction until it settles. A hover/click\n // mid-transition would schedule a duration-0 repaint that interrupts the\n // running transition and snaps it to its end (the glitchy jump). Matches\n // the SvgRenderer/CanvasRenderer `duration + 10` end timer, plus a small\n // buffer so events re-enable just after the paint completes.\n if (drawDuration > 0)\n this._transitionEndsAt = Date.now() + drawDuration + 30;\n // Order persistent motion trails in time by the current timeline period, so\n // they grow only as playback moves forward and rewind when it steps back.\n // Only when the timeline selects a single period (`brushing: false`): a range\n // selection has no single \"current time\", which would scramble the step\n // logic, so we withhold the sequence and trails fall back to ephemeral.\n // Normalize to milliseconds via `date()` — the selection mixes Date objects\n // (brush/initial) and raw period numbers (playback), which compare on wildly\n // different scales otherwise, scrambling the forward/backward test.\n const sel = this._timelineSelection;\n const brushing = this._timelineClass\n ? (this._timelineClass.schema as {brushing?: boolean}).brushing !== false\n : true;\n const sequence = !brushing && Array.isArray(sel) && sel.length\n ? Math.max(...sel.map(v => Number(date(Number(v)))))\n : undefined;\n // A forward jump that skips periods (manual click, not single-step play) draws\n // one coarse segment; compute the marks' real positions at the skipped periods\n // so the trail bends through them (see render commitTrailCatchups).\n const trailCatchup =\n sequence !== undefined && this._trailSeq !== undefined && sequence > this._trailSeq\n ? computeTrailCatchup(this as unknown as VizInstance, scene, this._trailSeq, sequence)\n : undefined;\n if (sequence !== undefined) this._trailSeq = sequence;\n this._sceneRenderer.drawScene(scene, {duration: drawDuration, sequence, trailCatchup});\n this._lastSceneRendered = scene;\n\n // Canvas backend: the compute <svg> (`_select`) is an emptied overlay\n // sitting on top of the <canvas>. An svg root hit-tests its whole box, so\n // even empty it swallows the pointer events the canvas needs for\n // tooltip/hover/legend picking — the symptom being \"renders fine, no\n // tooltips.\" Make the overlay transparent to pointer events so the canvas\n // is the sole interaction surface. The only interactive DOM that still\n // lives in this svg is the timeline's d3-brush (the canvas can't host the\n // native brush handles), so re-enable events on just that group. On the\n // SVG backend `_select` IS the scene host, so events must stay enabled.\n if (this._select) {\n this._select.style(\"pointer-events\", kind === \"canvas\" ? \"none\" : null);\n if (this._container)\n this._container.style(\"pointer-events\", kind === \"canvas\" ? \"none\" : null);\n if (kind === \"canvas\")\n this._select\n .select(\"g.d3plus-viz-timeline\")\n .style(\"pointer-events\", \"auto\");\n }\n\n // The timeline brush (d3-brush DOM, mounted in `g.d3plus-viz-timeline` in\n // the outer svg) must paint above the scene-rendered timeline buttons/ticks\n // so its selection tint + handles sit on top of them (matching v3). The\n // renderer appends its scene <svg> last, so without this the brush layer\n // ends up behind it — the selection's translucent fill is then hidden by\n // the opaque buttons and only the edge handles peek out.\n if (kind === \"svg\") {\n const host =\n userTarget && typeof (userTarget as Element).querySelector === \"function\"\n ? (userTarget as Element)\n : null;\n const tlGroup = host\n ? host.querySelector(\":scope > g.d3plus-viz-timeline\")\n : null;\n if (tlGroup) host!.appendChild(tlGroup);\n }\n }\n\n /**\n Routes a renderer pointer event to the matching `viz.schema.on` handlers.\n Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where\n compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`\n listeners never fire. We look up the appropriate `on` key from the picked\n scene node: legend swatches route to legend handlers, chart shapes to\n shape (+ shape-class-scoped) handlers, and chrome (axis/timeline/back) is\n excluded. Split out of `_drawSceneToTarget` to keep that method small.\n @private\n */\n _routeSceneEvent(event: SceneEvent): void {\n // Ignore all pointer interaction while an animated transition (zoom,\n // re-center, drill-down, entrance) is in flight. Hovering or clicking a\n // shape mid-transition would fire a handler that schedules a duration-0\n // repaint, interrupting the running transition and snapping it to its end\n // — the glitchy jump. `_transitionEndsAt` is stamped by `_drawSceneToTarget`\n // for the transition's duration; it lapses on its own, so interaction\n // resumes the instant the transition settles.\n if (this._transitionEndsAt && Date.now() < this._transitionEndsAt) return;\n const pick = event.pick;\n // Dispatch helper shared by the live-pick path and the leave path.\n const fire = (\n key: string,\n d: unknown,\n i: number,\n x: unknown,\n ): void => {\n const fn = this.schema.on && this.schema.on[key];\n if (typeof fn === \"function\") {\n try {\n fn.call(this, d, i, x, event.nativeEvent);\n } catch {\n // swallow per-event errors so one bad handler doesn't\n // break subsequent events.\n }\n }\n };\n if (event.type === \"mouseleave\") {\n const lastPick = this._lastScenePick;\n if (lastPick) {\n fire(\n `mouseleave.${lastPick.isLegend ? \"legend\" : \"shape\"}`,\n lastPick.d,\n lastPick.i,\n lastPick.x,\n );\n if (!lastPick.isLegend && lastPick.shapeType)\n fire(`mouseleave.${lastPick.shapeType}`, lastPick.d, lastPick.i, lastPick.x);\n fire(\"mouseleave\", lastPick.d, lastPick.i, lastPick.x);\n }\n this._lastScenePick = null;\n // Cleared here, then re-set by the enter/move the renderer fires\n // synchronously when the pointer crosses to an adjacent node — so a\n // shape→label hand-off leaves `_hoverDatum` pointing at the new node\n // (same datum), which `mouseleave` reads to suppress a flicker.\n this._hoverDatum = null;\n return;\n }\n if (!pick || !pick.node) return;\n // Scene nodes carry interaction metadata stamped by Viz.toScene.\n const nodeAny = pick.node as {\n interactionGroup?: string;\n shapeType?: string;\n };\n // Back-button panel: its d3-selection click listener never fires in the\n // scene path (it's a plain text node), so route its click here to pop\n // the drill-down history / step up a level.\n if (nodeAny.interactionGroup === \"back\") {\n if (event.type === \"click\") {\n const self = this;\n if (self._history.length) self.config(self._history.pop()).render();\n else self.depth(self._drawDepth - 1).filter(false).render();\n }\n return;\n }\n // Axis ticks/labels and the timeline are chrome — they carry data but\n // are not chart shapes, so they must not fire shape tooltips/handlers.\n if (\n nodeAny.interactionGroup === \"axis\" ||\n nodeAny.interactionGroup === \"timeline\"\n )\n return;\n // Prefer the node's stamped interaction group (set by Viz.toScene), so\n // legend swatches route to legend handlers on Canvas too — where the\n // single canvas element has no per-shape DOM to walk. Fall back to SVG\n // DOM ancestry for nodes the stamp didn't reach.\n const target =\n event.nativeEvent && (event.nativeEvent as Event).target;\n const isLegendNode =\n nodeAny.interactionGroup === \"legend\" ||\n (target && typeof (target as Element).closest === \"function\"\n ? !!(target as Element).closest('[data-key=\"viz-legend\"]')\n : false);\n const suffix = isLegendNode ? \"legend\" : \"shape\";\n const handlerKey = `${event.type}.${suffix}`;\n // Resolve the source datum + index. `pick.datum` is the raw scene datum\n // (which Shape._sceneXxx populated). For Plot shapes that's the wrapped\n // record; the handlers expect `(d.data, d.i, x, event)`.\n const rawDatum = pick.datum as\n | {data?: unknown; i?: number}\n | null\n | undefined;\n const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;\n const sourceIndex =\n rawDatum && typeof rawDatum.i === \"number\" ? rawDatum.i : pick.index ?? 0;\n const shapeType =\n typeof nodeAny.shapeType === \"string\" ? nodeAny.shapeType : null;\n this._lastScenePick = {\n d: sourceDatum, i: sourceIndex, x: rawDatum, isLegend: isLegendNode, shapeType,\n };\n this._hoverDatum = rawDatum;\n fire(handlerKey, sourceDatum, sourceIndex, rawDatum);\n // Shape-class-scoped handlers (`\"click.Bar\"`, `\"mousemove.Circle\"`). The\n // emitting shape stamps its type onto the node; on the scene path this is\n // the only place these fire (compute-mode shapes wire no DOM listeners).\n // Legend nodes are excluded so a legend swatch's shape type can't\n // masquerade as a chart-shape handler.\n if (!isLegendNode && shapeType) {\n fire(`${event.type}.${shapeType}`, sourceDatum, sourceIndex, rawDatum);\n }\n // Also fire the un-suffixed handler (e.g. \"mousemove\") so user-registered\n // global handlers see the event too.\n fire(event.type, sourceDatum, sourceIndex, rawDatum);\n }\n\n /**\n Coalesces interaction-driven scene repaints (hover/active dimming) into a\n single paint per animation frame. A fast pointer sweep across a dense\n chart fires a hover transition per shape crossed; painting each one\n synchronously rebuilt the whole scene back-to-back, saturating the main\n thread (~200ms stalls) so the tooltip couldn't reposition and appeared\n stuck at its last spot. Only the latest hover state is visible, so the\n intermediate paints are wasted — collapse them to one rAF-scheduled draw.\n */\n _scheduleSceneRepaint(): void {\n if (!this._sceneRenderer) return;\n if (typeof requestAnimationFrame !== \"function\") {\n this._drawSceneToTarget(0);\n return;\n }\n if (this._sceneRepaintRAF != null) return;\n this._sceneRepaintRAF = requestAnimationFrame(() => {\n this._sceneRepaintRAF = undefined;\n this._drawSceneToTarget(0);\n });\n }\n\n /**\n Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.\n */\n destroy(): this {\n this._resizeObserver.disconnect();\n this._tooltipClass.data([]).render();\n select(\"body\").on(`touchstart.${this._uuid}`, null);\n // Clear the visibility/resize/scroll poll timers + scroll listener\n // so a destroyed chart doesn't keep firing intervals/timeouts that\n // hold the entire viz instance alive. Without this, an SPA that\n // mounts/unmounts charts on tab switches leaks the scene tree +\n // a 200ms-interval timer per leaked chart.\n if (this._visiblePoll) {\n this._visiblePoll = clearInterval(this._visiblePoll) as never;\n }\n if (this._resizePoll) {\n this._resizePoll = clearTimeout(this._resizePoll) as never;\n }\n if (this._scrollPoll) {\n this._scrollPoll = clearTimeout(this._scrollPoll) as never;\n }\n if (this._sceneRepaintRAF != null) {\n if (typeof cancelAnimationFrame === \"function\")\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);\n // Destroy the active scene renderer (clears its own pointer-rect\n // listeners, overlay host, canvas/svg DOM, timers).\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\") {\n this._sceneRenderer.destroy();\n this._sceneRenderer = undefined;\n }\n return this;\n }\n\n}\n"],"names":["select","date","getSize","computeTrailCatchup","CanvasRenderer","SvgRenderer","VizBase","applyColorScaleBucketOpacity","applyInteractionOpacity","initVizDefaults","vizRender","vizDraw","vizPreDraw","tagInteractionGroup","node","group","interactionGroup","kids","children","child","mountTargetFor","kind","target","Element","tagName","toLowerCase","parentNode","Viz","_preDraw","toScene","_chartScene","length","sliced","zoomNode","type","key","transform","_zoomTransform","x","y","scale","push","_chartTransform","_chartClip","clip","_shapes","forEach","shape","si","sel","_select","attr","t","m","match","parseFloat","components","_legendClass","_colorScaleClass","_timelineClass","name","comp","compScene","_featurePanels","panels","slice","panel","includes","width","schema","height","root","_draw","_thresholdFunction","data","_tree","_setSVGSize","w","h","style","_autoWidth","_autoHeight","render","callback","renderer","_","arguments","_renderer","renderMode","_renderMode","renderScene","opts","_sceneTarget","Promise","resolve","_sceneRenderer","scene","_lastSceneRendered","_drawSceneToTarget","durationOverride","Math","computeSvg","userTarget","mountTarget","currentContainer","container","undefined","containerChanged","destroy","Ctor","mount","_lastScenePick","on","event","_routeSceneEvent","resize","drawDuration","duration","_sceneRepaintRAF","cancelAnimationFrame","_transitionEndsAt","Date","now","_timelineSelection","brushing","sequence","Array","isArray","max","map","v","Number","trailCatchup","_trailSeq","drawScene","_container","host","querySelector","tlGroup","appendChild","pick","fire","d","i","fn","call","nativeEvent","lastPick","isLegend","shapeType","_hoverDatum","nodeAny","self","_history","config","pop","depth","_drawDepth","filter","isLegendNode","closest","suffix","handlerKey","rawDatum","datum","sourceDatum","sourceIndex","index","_scheduleSceneRepaint","requestAnimationFrame","_resizeObserver","disconnect","_tooltipClass","_uuid","_visiblePoll","clearInterval","_resizePoll","clearTimeout","_scrollPoll","scrollContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC8D,eAAe,CAACC,UAAU;gBAC/B,IAAI,CAACC,aAAa,CAAClG,IAAI,CAAC,EAAE,EAAEQ,MAAM;gBAClClF,OAAO,QAAQgH,EAAE,CAAC,AAAC,cAAwB,OAAX,IAAI,CAAC6D,KAAK,GAAI;gBAC9C,mEAAmE;gBACnE,mEAAmE;gBACnE,gEAAgE;gBAChE,gEAAgE;gBAChE,2CAA2C;gBAC3C,IAAI,IAAI,CAACC,YAAY,EAAE;oBACrB,IAAI,CAACA,YAAY,GAAGC,cAAc,IAAI,CAACD,YAAY;gBACrD;gBACA,IAAI,IAAI,CAACE,WAAW,EAAE;oBACpB,IAAI,CAACA,WAAW,GAAGC,aAAa,IAAI,CAACD,WAAW;gBAClD;gBACA,IAAI,IAAI,CAACE,WAAW,EAAE;oBACpB,IAAI,CAACA,WAAW,GAAGD,aAAa,IAAI,CAACC,WAAW;gBAClD;gBACA,IAAI,IAAI,CAAC5D,gBAAgB,IAAI,MAAM;oBACjC,IAAI,OAAOC,yBAAyB,YAClCA,qBAAqB,IAAI,CAACD,gBAAgB;oBAC5C,IAAI,CAACA,gBAAgB,GAAGZ;gBAC1B;gBACA1G,OAAO,IAAI,CAACqE,MAAM,CAAC8G,eAAe,EAAEnE,EAAE,CAAC,AAAC,UAAoB,OAAX,IAAI,CAAC6D,KAAK,GAAI;gBAC/D,iEAAiE;gBACjE,oDAAoD;gBACpD,IAAI,IAAI,CAAC9E,cAAc,IAAI,OAAO,IAAI,CAACA,cAAc,CAACa,OAAO,KAAK,YAAY;oBAC5E,IAAI,CAACb,cAAc,CAACa,OAAO;oBAC3B,IAAI,CAACb,cAAc,GAAGW;gBACxB;gBACA,OAAO,IAAI;YACb;;;WA7kBmB/E;EAAYrB;AAHjC;;AAEA,GACA,SAAqBqB,iBA+kBpB"}
1
+ {"version":3,"sources":["../../../../src/charts/viz/Viz.ts"],"sourcesContent":["import {select} from \"d3-selection\";\n\nimport {date, getSize} from \"@d3plus/dom\";\n\nimport {computeTrailCatchup} from \"./trailCatchup.js\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {CanvasRenderer, SvgRenderer} from \"@d3plus/render\";\nimport type {PickResult, Renderer, Scene, SceneEvent, SceneNode, Transform} from \"@d3plus/render\";\n\nimport VizBase from \"./VizBase.js\";\nimport type {ColorScale, Legend, Timeline} from \"../../components/index.js\";\nimport type Shape from \"../../shapes/Shape.js\";\nimport {applyColorScaleBucketOpacity, applyInteractionOpacity} from \"./interactionOpacity.js\";\nimport {chartAreaRect} from \"../features/chartGeometry.js\";\nimport {applyZoomPointerEvents, bindCanvasZoom} from \"../drawSteps/zoomControls.js\";\nimport {initVizDefaults} from \"./vizDefaults.js\";\nimport {vizRender} from \"./vizRender.js\";\nimport {vizDraw} from \"../pipeline/vizDraw.js\";\nimport {vizPreDraw} from \"../pipeline/vizPreDraw.js\";\nimport type {VizInstance} from \"./vizTypes.js\";\n\n/**\n Stamps `interactionGroup` onto a component's scene subtree so the pointer\n bridge can route its nodes to component-scoped handlers (e.g. legend) on\n every backend — including Canvas, where there is no per-shape DOM to walk.\n*/\nfunction tagInteractionGroup(node: SceneNode, group: string): void {\n (node as {interactionGroup?: string}).interactionGroup = group;\n const kids = (node as {children?: SceneNode[]}).children;\n if (kids) for (const child of kids) tagInteractionGroup(child, group);\n}\n\n/**\n Resolves the element a renderer mounts into. A `<canvas>` cannot paint inside\n an `<svg>`, so when the scene target is the compute svg, the canvas mounts\n into that svg's parent (the user's element); the emptied, position:absolute\n compute svg overlays the same top-left box. SVG mounts into the target as-is.\n*/\nfunction mountTargetFor(kind: string, target: Element): Element {\n if (\n kind === \"canvas\" &&\n typeof Element !== \"undefined\" &&\n target instanceof Element &&\n target.tagName.toLowerCase() === \"svg\"\n )\n return (target.parentNode as Element | null) ?? target;\n return target;\n}\n\n/**\n Creates an x/y plot based on an array of data. See [this example](https://d3plus.org/examples/d3plus-treemap/getting-started/) for help getting started using the treemap generator.\n*/\nexport default class Viz extends VizBase {\n\n /**\n Invoked when creating a new class instance, and sets any default parameters.\n @private\n */\n constructor() {\n super();\n initVizDefaults(this);\n }\n\n /**\n Called by draw before anything is drawn. Formats the data and performs preparations for draw.\n @private\n */\n _preDraw(): void {\n vizPreDraw(this as unknown as VizInstance);\n }\n\n /**\n Composes a backend-agnostic scene graph from the shapes/features produced\n by the most recent render. Combines:\n - `_chartScene` (cells from `chartDef.emit`, or `Plot._paint` for the\n paint-driven Plot family) wrapped in viz-chart-cells\n - `_shapes` (still used by some charts) — each shape's toScene\n - chart-level components (Legend/ColorScale/Timeline) via their toScene\n - `_featurePanels` (from FeatureModule layouts) wrapped in viz-features\n */\n toScene(): Scene {\n const children: SceneNode[] = [];\n // Chart cells stashed on _chartScene — via `chartDef.emit(ctx)` for\n // data-driven charts, or `Plot._paint` for the paint-driven Plot family.\n // Wraps in three groups:\n // viz-chart-cells (clip window, untransformed)\n // viz-zoom (zoom transform — pan/scale from d3-zoom)\n // viz-chart-body (chart-positioning transform)\n // … chart scene children\n // This lets zoom apply to the chart content WITHOUT moving legend/\n // title/total/etc. (which live in sibling viz-* groups, not under\n // viz-chart-cells). The zoom transform sits above the chart transform so\n // it lives in the same surface space d3-zoom measures the pointer in —\n // a wheel zoom stays anchored under the cursor regardless of margins or\n // a chart's own centering transform (Pie, Radar, …).\n if (this._chartScene && this._chartScene.length) {\n const sliced = applyInteractionOpacity(\n this._chartScene,\n this as unknown as VizInstance,\n );\n // Always emit the viz-zoom group (identity transform when no zoom is\n // active) so its key is stable across the first zoom. Otherwise the first\n // zoom adds a brand-new group → the renderer treats the chart cells as\n // exit+enter (teardown/rebuild) instead of tweening the group transform,\n // so the zoom snaps in instead of animating.\n const zoomNode = [{\n type: \"group\" as const,\n key: \"viz-zoom\",\n transform: this._zoomTransform ?? {x: 0, y: 0, scale: 1},\n children: [{\n type: \"group\" as const,\n key: \"viz-chart-body\",\n ...(this._chartTransform ? {transform: this._chartTransform} : {}),\n children: sliced,\n }],\n }];\n // Fixed clip window (e.g. Geomap's map rect): stays put in scene space\n // while the viz-zoom child transform pans/scales content beneath it.\n // Any zoomable chart without its own clip is clipped to the chart area,\n // so zoomed content can't spill over the legend/title/timeline.\n const clip = this._chartClip ?? (this.schema.zoom && this._margin ? chartAreaRect(this as unknown as VizInstance) : undefined);\n children.push({\n type: \"group\",\n key: \"viz-chart-cells\",\n ...(clip ? {clip} : {}),\n children: zoomNode,\n });\n }\n // `_shapes` collection (Treemap/Pack/etc. route through `_chartScene`\n // instead, as does Plot's `absorbShapeIntoChartScene`). Any caller\n // pushing into `_shapes` gets its `toScene()` walked here; we read the\n // shape's `_select` transform via d3's transform baseVal if present,\n // otherwise emit without a transform.\n (this._shapes || []).forEach((shape: Shape, si: number) => {\n if (!shape || typeof shape.toScene !== \"function\") return;\n const group = shape.toScene();\n let transform: Transform | undefined;\n const sel = shape._select;\n if (sel && typeof sel.attr === \"function\") {\n // Parse `translate(x, y)` from the selection's transform attr.\n // Falls back to undefined for non-translate transforms — the\n // `_shapes` path only uses translate.\n const t = sel.attr(\"transform\");\n if (typeof t === \"string\") {\n const m = t.match(/translate\\(\\s*(-?[\\d.]+)[, ]\\s*(-?[\\d.]+)\\s*\\)/);\n if (m) transform = {x: parseFloat(m[1]), y: parseFloat(m[2])};\n }\n }\n children.push({\n type: \"group\",\n key: `${group.key || \"shape\"}-${si}`,\n ...(transform ? {transform} : {}),\n children: group.children,\n });\n });\n // Chart-level components that have their own toScene.\n const components: [string, Legend | ColorScale | Timeline | undefined][] = [\n [\"legend\", this._legendClass],\n [\"colorScale\", this._colorScaleClass],\n [\"timeline\", this._timelineClass],\n ];\n for (const [name, comp] of components) {\n if (\n comp &&\n typeof comp.toScene === \"function\" &&\n comp._select &&\n typeof comp._select.node === \"function\" &&\n comp._select.node()\n ) {\n let compScene: SceneNode = comp.toScene();\n // Tag the legend subtree so its swatches route to legend handlers via\n // the node stamp (renderer-independent), not just SVG DOM ancestry.\n if (name === \"legend\") {\n tagInteractionGroup(compScene, \"legend\");\n // Hovering a legend swatch dims the others, like the chart marks:\n // run the legend subtree through the same interaction-opacity pass\n // (a no-op when no hover/active predicate is set).\n compScene = applyInteractionOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Hovering a colorScale swatch (or a data shape) dims the sibling\n // swatches by bucket color — leaving the colorScale title/axis/gradient\n // untouched. Not tagged \"legend\": colorScale swatches keep the shape\n // event path (range-based tooltip + hover), unlike groupBy legend items.\n else if (name === \"colorScale\") {\n compScene = applyColorScaleBucketOpacity(\n [compScene],\n this as unknown as VizInstance,\n )[0];\n }\n // Tag the timeline subtree so its ticks/labels are exempt from shape\n // tooltips and hover/active dimming (it's chrome, not data marks).\n else if (name === \"timeline\") tagInteractionGroup(compScene, \"timeline\");\n children.push({\n type: \"group\",\n key: `viz-${name}`,\n children: [compScene],\n });\n }\n }\n // E2: FeatureModule.layout() panels (title/subtitle/total, plus the\n // zoom/top-left-controls/attribution overlays appended post-draw).\n if (this._featurePanels && this._featurePanels.length) {\n children.push({type: \"group\", key: \"viz-features\", children: this._featurePanels});\n }\n return {\n width: this.schema.width,\n height: this.schema.height,\n root: {type: \"group\", key: \"viz-root\", children},\n };\n }\n\n /**\n Called by render once all checks are passed.\n @private\n */\n _draw(): void {\n vizDraw(this as unknown as VizInstance);\n }\n\n /**\n * Applies the threshold algorithm according to the type of chart used.\n * @param {Array} data The data to process.\n * @private\n */\n _thresholdFunction(data: DataPoint[], _tree?: unknown): DataPoint[] {\n return data;\n }\n\n /**\n * Detects width and height and sets SVG properties\n * @private\n */\n _setSVGSize(width?: number, height?: number): void {\n let [w, h] =\n width && height\n ? [width, height]\n : getSize(this._select.node().parentNode);\n w! -= parseFloat(this._select.style(\"border-left-width\"));\n w! -= parseFloat(this._select.style(\"border-right-width\"));\n h! -= parseFloat(this._select.style(\"border-top-width\"));\n h! -= parseFloat(this._select.style(\"border-bottom-width\"));\n \n if (this._autoWidth && this.schema.width !== w) {\n this.width(w);\n this._select\n .style(\"width\", `${this.schema.width}px`)\n .attr(\"width\", `${this.schema.width}px`);\n }\n if (this._autoHeight && this.schema.height !== h) {\n this.height(h);\n this._select\n .style(\"height\", `${this.schema.height}px`)\n .attr(\"height\", `${this.schema.height}px`);\n }\n }\n\n /**\n Draws the visualization given the specified configuration.\n @param callback Optional callback invoked after rendering completes.\n */\n render(callback?: () => void): this {\n return vizRender(this, callback) as this;\n }\n\n /**\n Serializes the most recently rendered output to an SVG string. Returns\n `\"\"` if the chart has not been rendered yet. Both backends support this:\n the SVG backend returns its live `<svg>`, the canvas backend re-renders the\n retained scene through a throwaway SVG backend. Primarily used for\n server-side rendering (see `@d3plus/ssr`).\n */\n toSVGString(): string {\n return this._sceneRenderer?.toSVGString?.() ?? \"\";\n }\n\n /**\n Returns the underlying canvas element of the most recent render when the\n canvas backend is active (`renderer(\"canvas\")`), or `undefined` otherwise.\n Server-side callers cast this to their native canvas to encode a raster\n (see `@d3plus/ssr`).\n */\n toCanvas(): unknown {\n return this._renderer === \"canvas\"\n ? this._sceneRenderer?.toCanvas?.()\n : undefined;\n }\n\n /**\n Selects which @d3plus/render backend paints the visible output.\n `\"svg\"` = SvgRenderer (default), `\"canvas\"` = CanvasRenderer.\n Boolean arguments both normalize to `\"svg\"`.\n */\n renderer(): \"svg\" | \"canvas\";\n renderer(_: \"svg\" | \"canvas\" | true | false): this;\n renderer(_?: \"svg\" | \"canvas\" | true | false): \"svg\" | \"canvas\" | this {\n if (!arguments.length) return this._renderer;\n this._renderer = _ === \"canvas\" ? \"canvas\" : \"svg\";\n return this;\n }\n\n /**\n \"full\" runs the DOM enter/update/exit for every shape; \"compute\"\n skips DOM work and only populates the scene data (`_textData`,\n `_shapes[i]._select`, etc.) for `toScene()` to read. Set automatically by\n `renderScene` callers; users can also opt-in.\n */\n renderMode(): \"full\" | \"compute\";\n renderMode(_: \"full\" | \"compute\"): this;\n renderMode(_?: \"full\" | \"compute\"): \"full\" | \"compute\" | this {\n if (!arguments.length) return this._renderMode || \"full\";\n this._renderMode = _!;\n return this;\n }\n\n /**\n Public entry point that renders this chart through the @d3plus/render\n pluggable backends. The compute pass happens via render() (in an svg\n auto-created inside the target div); SvgRenderer/CanvasRenderer paints\n the scene to the target. Returns `{renderer, scene}` so callers can\n interact with the renderer (e.g. for picking) or read the scene data.\n */\n async renderScene(\n target: Element,\n opts?: {kind?: \"svg\" | \"canvas\"},\n ): Promise<{renderer: Renderer; scene: Scene}> {\n const kind = opts?.kind || (this._renderer === \"canvas\" ? \"canvas\" : \"svg\");\n this._sceneTarget = target;\n this._renderer = kind;\n this.select(target as HTMLElement);\n await new Promise<void>(resolve => this.render(() => resolve()));\n return {\n renderer: this._sceneRenderer as Renderer,\n scene: this._lastSceneRendered as Scene,\n };\n }\n\n /**\n Renders this chart through the @d3plus/render pluggable backends. Called\n automatically by `render()`. The compute pass draws into `this._select`\n (an auto-created svg INSIDE the user's target div) — that svg is the\n off-stage detached compute svg. SvgRenderer mounts to the user's target\n div (the parent), as a sibling to the detached compute svg. The compute\n svg's children get cleared so only the scene output is visible.\n */\n _drawSceneToTarget(durationOverride?: number): void {\n const kind = this._renderer === \"canvas\" ? \"canvas\" : \"svg\";\n const computeSvg = this._select && this._select.node ? this._select.node() : null;\n if (!computeSvg) return;\n // Mount renderer INSIDE the user's `_select` (svg or div). Tests like\n // `svgA.querySelector('[data-key=\"viz-legend\"]')` need the scene output\n // to live inside the user's container, not as a sibling.\n const userTarget = this._sceneTarget || computeSvg;\n if (!userTarget) return;\n const mountTarget = mountTargetFor(kind, userTarget as Element);\n const scene = this.toScene();\n const w = this.schema.width || 400;\n const h = this.schema.height || 300;\n // Reuse the renderer instance if it matches the kind, to avoid mount\n // churn. `target()` is the public Renderer-interface method (no\n // reaching into renderer-private slots). It's optional on the\n // interface; third-party renderers without it fall through to\n // remount on every draw — correct but with mount churn.\n const currentContainer = this._sceneRenderer?.target\n ? this._sceneRenderer.target()?.container\n : undefined;\n const containerChanged = this._sceneRenderer?.target\n ? currentContainer !== mountTarget\n : false;\n if (\n !this._sceneRenderer ||\n this._sceneRenderer.kind !== kind ||\n containerChanged\n ) {\n // Tear down the outgoing renderer before mounting a fresh one. It owns\n // its own DOM (canvas/svg + overlay host), pointer listeners, and\n // transition timers; without this, switching kind (svg<->canvas) or\n // container orphans that DOM in the user's element, stacking the old\n // mode's output behind the new one and accumulating on every switch.\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\")\n this._sceneRenderer.destroy();\n const Ctor = kind === \"canvas\" ? CanvasRenderer : SvgRenderer;\n this._sceneRenderer = new Ctor();\n // `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),\n // fixes the canvas backing-store scale; otherwise the renderer falls back\n // to `devicePixelRatio`.\n this._sceneRenderer.mount({\n container: mountTarget,\n width: w,\n height: h,\n pixelRatio: this._scenePixelRatio,\n });\n // Bridge renderer pointer events → viz.schema.on handlers. Without this,\n // tooltips never fire on the v4 scene-rendered path because\n // `shape.on(evt, fn)` in plotPaint only wires d3-selection\n // listeners on DOM nodes the scene renderer doesn't create.\n // Renderer events carry the picked scene node; the routing lives in\n // `_routeSceneEvent` (kept out of this method so the mount path stays\n // readable). `_lastScenePick` remembers the most recently hovered node\n // so `mouseleave` — fired with a null pick — can still tell the matching\n // handlers which shape/legend item was left (so the tooltip clears).\n this._lastScenePick = null;\n this._sceneRenderer.on((event: SceneEvent) => this._routeSceneEvent(event));\n } else {\n this._sceneRenderer.resize(w, h);\n }\n // `durationOverride` defaults to the chart's `_duration` for normal\n // re-renders. Interaction handlers (zoomed, hover, etc.) pass 0 to\n // skip the transition machinery — animating every wheel/drag tick\n // accumulates `setTimeout(duration+10)` per event.\n const drawDuration =\n durationOverride !== undefined ? durationOverride : this.schema.duration;\n // A duration>0 render (drill-down, zoom, re-center) must win over any\n // pending coalesced duration-0 repaint — otherwise that repaint fires on\n // the next frame and interrupts this transition, snapping shapes to their\n // final geometry.\n if (drawDuration > 0 && this._sceneRepaintRAF != null) {\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n // Mark the window during which an animated transition is in flight, so the\n // pointer bridge can ignore interaction until it settles. A hover/click\n // mid-transition would schedule a duration-0 repaint that interrupts the\n // running transition and snaps it to its end (the glitchy jump). Matches\n // the SvgRenderer/CanvasRenderer `duration + 10` end timer, plus a small\n // buffer so events re-enable just after the paint completes.\n if (drawDuration > 0)\n this._transitionEndsAt = Date.now() + drawDuration + 30;\n // Order persistent motion trails in time by the current timeline period, so\n // they grow only as playback moves forward and rewind when it steps back.\n // Only when the timeline selects a single period (`brushing: false`): a range\n // selection has no single \"current time\", which would scramble the step\n // logic, so we withhold the sequence and trails fall back to ephemeral.\n // Normalize to milliseconds via `date()` — the selection mixes Date objects\n // (brush/initial) and raw period numbers (playback), which compare on wildly\n // different scales otherwise, scrambling the forward/backward test.\n const sel = this._timelineSelection;\n const brushing = this._timelineClass\n ? (this._timelineClass.schema as {brushing?: boolean}).brushing !== false\n : true;\n const sequence = !brushing && Array.isArray(sel) && sel.length\n ? Math.max(...sel.map(v => Number(date(Number(v)))))\n : undefined;\n // A forward jump that skips periods (manual click, not single-step play) draws\n // one coarse segment; compute the marks' real positions at the skipped periods\n // so the trail bends through them (see render commitTrailCatchups).\n const trailCatchup =\n sequence !== undefined && this._trailSeq !== undefined && sequence > this._trailSeq\n ? computeTrailCatchup(this as unknown as VizInstance, scene, this._trailSeq, sequence)\n : undefined;\n if (sequence !== undefined) this._trailSeq = sequence;\n this._sceneRenderer.drawScene(scene, {duration: drawDuration, sequence, trailCatchup});\n this._lastSceneRendered = scene;\n\n // Canvas backend: the compute <svg> (`_select`) is an emptied overlay\n // sitting on top of the <canvas>. An svg root hit-tests its whole box, so\n // even empty it swallows the pointer events the canvas needs for\n // tooltip/hover/legend picking — the symptom being \"renders fine, no\n // tooltips.\" Make the overlay transparent to pointer events so the canvas\n // is the sole interaction surface. The only interactive DOM that still\n // lives in this svg is the timeline's d3-brush (the canvas can't host the\n // native brush handles), so re-enable events on just that group. On the\n // SVG backend `_select` IS the scene host, so events must stay enabled\n // (except while the zoom brush is active — see `applyZoomPointerEvents`).\n applyZoomPointerEvents(this);\n if (this._select && kind === \"canvas\")\n this._select\n .select(\"g.d3plus-viz-timeline\")\n .style(\"pointer-events\", \"auto\");\n if (kind === \"canvas\") bindCanvasZoom(this);\n\n // The timeline brush (d3-brush DOM, mounted in `g.d3plus-viz-timeline` in\n // the outer svg) must paint above the scene-rendered timeline buttons/ticks\n // so its selection tint + handles sit on top of them (matching v3). The\n // renderer appends its scene <svg> last, so without this the brush layer\n // ends up behind it — the selection's translucent fill is then hidden by\n // the opaque buttons and only the edge handles peek out.\n if (kind === \"svg\") {\n const host =\n userTarget && typeof (userTarget as Element).querySelector === \"function\"\n ? (userTarget as Element)\n : null;\n const tlGroup = host\n ? host.querySelector(\":scope > g.d3plus-viz-timeline\")\n : null;\n if (tlGroup) host!.appendChild(tlGroup);\n // Likewise the zoom brush, so its selection box draws over the shapes.\n const zoomBrush = host ? host.querySelector(\":scope > g.d3plus-zoom-brush\") : null;\n if (zoomBrush && zoomBrush !== host!.lastElementChild) host!.appendChild(zoomBrush);\n }\n }\n\n /**\n Resolves the `(d, i, x)` a picked scene node reports to interaction\n handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw\n scene datum; for a Plot shape that's the wrapped record `{data, i}`, which\n handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that\n unwrap; Plot overrides this to report the point nearest the cursor for\n multi-point shapes (Line/Area) so a series tooltip reflects the hovered\n x rather than the whole-series aggregate.\n @private\n */\n _interactionDatum(\n pick: PickResult,\n _event: SceneEvent,\n ): {d: unknown; i: number; x: unknown} {\n const rawDatum = pick.datum as {data?: unknown; i?: number} | null | undefined;\n const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;\n const sourceIndex =\n rawDatum && typeof rawDatum.i === \"number\" ? rawDatum.i : pick.index ?? 0;\n return {d: sourceDatum, i: sourceIndex, x: rawDatum};\n }\n\n /**\n Routes a renderer pointer event to the matching `viz.schema.on` handlers.\n Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where\n compute-mode shapes mount no per-shape DOM, so `shape.on(evt, fn)`\n listeners never fire. We look up the appropriate `on` key from the picked\n scene node: legend swatches route to legend handlers, chart shapes to\n shape (+ shape-class-scoped) handlers, and chrome (axis/timeline/back) is\n excluded. Split out of `_drawSceneToTarget` to keep that method small.\n @private\n */\n _routeSceneEvent(event: SceneEvent): void {\n // Ignore all pointer interaction while an animated transition (zoom,\n // re-center, drill-down, entrance) is in flight. Hovering or clicking a\n // shape mid-transition would fire a handler that schedules a duration-0\n // repaint, interrupting the running transition and snapping it to its end\n // — the glitchy jump. `_transitionEndsAt` is stamped by `_drawSceneToTarget`\n // for the transition's duration; it lapses on its own, so interaction\n // resumes the instant the transition settles.\n if (this._transitionEndsAt && Date.now() < this._transitionEndsAt) return;\n const pick = event.pick;\n // Dispatch helper shared by the live-pick path and the leave path.\n const fire = (\n key: string,\n d: unknown,\n i: number,\n x: unknown,\n ): void => {\n const fn = this.schema.on && this.schema.on[key];\n if (typeof fn === \"function\") {\n try {\n fn.call(this, d, i, x, event.nativeEvent);\n } catch {\n // swallow per-event errors so one bad handler doesn't\n // break subsequent events.\n }\n }\n };\n if (event.type === \"mouseleave\") {\n const lastPick = this._lastScenePick;\n if (lastPick) {\n fire(\n `mouseleave.${lastPick.isLegend ? \"legend\" : \"shape\"}`,\n lastPick.d,\n lastPick.i,\n lastPick.x,\n );\n if (!lastPick.isLegend && lastPick.shapeType)\n fire(`mouseleave.${lastPick.shapeType}`, lastPick.d, lastPick.i, lastPick.x);\n fire(\"mouseleave\", lastPick.d, lastPick.i, lastPick.x);\n }\n this._lastScenePick = null;\n // Cleared here, then re-set by the enter/move the renderer fires\n // synchronously when the pointer crosses to an adjacent node — so a\n // shape→label hand-off leaves `_hoverDatum` pointing at the new node\n // (same datum), which `mouseleave` reads to suppress a flicker.\n this._hoverDatum = null;\n return;\n }\n if (!pick || !pick.node) return;\n // Scene nodes carry interaction metadata stamped by Viz.toScene.\n const nodeAny = pick.node as {\n interactionGroup?: string;\n shapeType?: string;\n };\n // Axis ticks/labels and the timeline are chrome — they carry data but\n // are not chart shapes, so they must not fire shape tooltips/handlers.\n if (\n nodeAny.interactionGroup === \"axis\" ||\n nodeAny.interactionGroup === \"timeline\"\n )\n return;\n // Prefer the node's stamped interaction group (set by Viz.toScene), so\n // legend swatches route to legend handlers on Canvas too — where the\n // single canvas element has no per-shape DOM to walk. Fall back to SVG\n // DOM ancestry for nodes the stamp didn't reach.\n const target =\n event.nativeEvent && (event.nativeEvent as Event).target;\n const isLegendNode =\n nodeAny.interactionGroup === \"legend\" ||\n (target && typeof (target as Element).closest === \"function\"\n ? !!(target as Element).closest('[data-key=\"viz-legend\"]')\n : false);\n const suffix = isLegendNode ? \"legend\" : \"shape\";\n const handlerKey = `${event.type}.${suffix}`;\n // Resolve the datum + index this pick reports to handlers, ONCE, and reuse\n // it for every handler fired below so tooltip/click/user handlers agree on\n // which datum the pointer is over. The base unwraps the node's raw datum to\n // its source row; Plot overrides `_interactionDatum` to report the point\n // nearest the cursor for multi-point shapes (Line/Area).\n const {d: sourceDatum, i: sourceIndex, x: rawDatum} = this._interactionDatum(\n pick,\n event,\n );\n const shapeType =\n typeof nodeAny.shapeType === \"string\" ? nodeAny.shapeType : null;\n this._lastScenePick = {\n d: sourceDatum, i: sourceIndex, x: rawDatum, isLegend: isLegendNode, shapeType,\n };\n this._hoverDatum = rawDatum;\n fire(handlerKey, sourceDatum, sourceIndex, rawDatum);\n // Shape-class-scoped handlers (`\"click.Bar\"`, `\"mousemove.Circle\"`). The\n // emitting shape stamps its type onto the node; on the scene path this is\n // the only place these fire (compute-mode shapes wire no DOM listeners).\n // Legend nodes are excluded so a legend swatch's shape type can't\n // masquerade as a chart-shape handler.\n if (!isLegendNode && shapeType) {\n fire(`${event.type}.${shapeType}`, sourceDatum, sourceIndex, rawDatum);\n }\n // Also fire the un-suffixed handler (e.g. \"mousemove\") so user-registered\n // global handlers see the event too.\n fire(event.type, sourceDatum, sourceIndex, rawDatum);\n }\n\n /**\n Coalesces interaction-driven scene repaints (hover/active dimming) into a\n single paint per animation frame. A fast pointer sweep across a dense\n chart fires a hover transition per shape crossed; painting each one\n synchronously rebuilt the whole scene back-to-back, saturating the main\n thread (~200ms stalls) so the tooltip couldn't reposition and appeared\n stuck at its last spot. Only the latest hover state is visible, so the\n intermediate paints are wasted — collapse them to one rAF-scheduled draw.\n */\n _scheduleSceneRepaint(): void {\n if (!this._sceneRenderer) return;\n if (typeof requestAnimationFrame !== \"function\") {\n this._drawSceneToTarget(0);\n return;\n }\n if (this._sceneRepaintRAF != null) return;\n this._sceneRepaintRAF = requestAnimationFrame(() => {\n this._sceneRepaintRAF = undefined;\n this._drawSceneToTarget(0);\n });\n }\n\n /**\n Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.\n */\n destroy(): this {\n this._resizeObserver?.disconnect();\n this._tooltipClass.data([]).render();\n select(\"body\").on(`touchstart.${this._uuid}`, null);\n // Clear the visibility/resize/scroll poll timers + scroll listener\n // so a destroyed chart doesn't keep firing intervals/timeouts that\n // hold the entire viz instance alive. Without this, an SPA that\n // mounts/unmounts charts on tab switches leaks the scene tree +\n // a 200ms-interval timer per leaked chart.\n if (this._visiblePoll) {\n this._visiblePoll = clearInterval(this._visiblePoll) as never;\n }\n if (this._resizePoll) {\n this._resizePoll = clearTimeout(this._resizePoll) as never;\n }\n if (this._scrollPoll) {\n this._scrollPoll = clearTimeout(this._scrollPoll) as never;\n }\n if (this._sceneRepaintRAF != null) {\n if (typeof cancelAnimationFrame === \"function\")\n cancelAnimationFrame(this._sceneRepaintRAF);\n this._sceneRepaintRAF = undefined;\n }\n if (this.schema.scrollContainer)\n select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);\n // Destroy the active scene renderer (clears its own pointer-rect\n // listeners, overlay host, canvas/svg DOM, timers).\n if (this._sceneRenderer && typeof this._sceneRenderer.destroy === \"function\") {\n this._sceneRenderer.destroy();\n this._sceneRenderer = undefined;\n }\n return this;\n }\n\n}\n"],"names":["select","date","getSize","computeTrailCatchup","CanvasRenderer","SvgRenderer","VizBase","applyColorScaleBucketOpacity","applyInteractionOpacity","chartAreaRect","applyZoomPointerEvents","bindCanvasZoom","initVizDefaults","vizRender","vizDraw","vizPreDraw","tagInteractionGroup","node","group","interactionGroup","kids","children","child","mountTargetFor","kind","target","Element","tagName","toLowerCase","parentNode","Viz","_preDraw","toScene","_chartScene","length","sliced","zoomNode","type","key","transform","_zoomTransform","x","y","scale","_chartTransform","clip","_chartClip","schema","zoom","_margin","undefined","push","_shapes","forEach","shape","si","sel","_select","attr","t","m","match","parseFloat","components","_legendClass","_colorScaleClass","_timelineClass","name","comp","compScene","_featurePanels","width","height","root","_draw","_thresholdFunction","data","_tree","_setSVGSize","w","h","style","_autoWidth","_autoHeight","render","callback","toSVGString","_sceneRenderer","toCanvas","_renderer","renderer","_","arguments","renderMode","_renderMode","renderScene","opts","_sceneTarget","Promise","resolve","scene","_lastSceneRendered","_drawSceneToTarget","durationOverride","Math","computeSvg","userTarget","mountTarget","currentContainer","container","containerChanged","destroy","Ctor","mount","pixelRatio","_scenePixelRatio","_lastScenePick","on","event","_routeSceneEvent","resize","drawDuration","duration","_sceneRepaintRAF","cancelAnimationFrame","_transitionEndsAt","Date","now","_timelineSelection","brushing","sequence","Array","isArray","max","map","v","Number","trailCatchup","_trailSeq","drawScene","host","querySelector","tlGroup","appendChild","zoomBrush","lastElementChild","_interactionDatum","pick","_event","rawDatum","datum","sourceDatum","sourceIndex","i","index","d","fire","fn","call","nativeEvent","lastPick","isLegend","shapeType","_hoverDatum","nodeAny","isLegendNode","closest","suffix","handlerKey","_scheduleSceneRepaint","requestAnimationFrame","_resizeObserver","disconnect","_tooltipClass","_uuid","_visiblePoll","clearInterval","_resizePoll","clearTimeout","_scrollPoll","scrollContainer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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