@d3plus/core 4.3.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 (335) hide show
  1. package/README.md +7406 -3676
  2. package/es/index.js +3 -3
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +13 -2
  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 +9 -3
  9. package/es/src/charts/BarChart/index.js.map +1 -1
  10. package/es/src/charts/BoxWhisker/index.js +6 -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 +220 -0
  17. package/es/src/charts/Chord/emit.js.map +1 -0
  18. package/es/src/charts/Chord/index.js +249 -0
  19. package/es/src/charts/Chord/index.js.map +1 -0
  20. package/es/src/charts/Geomap/applyLayout.js +17 -10
  21. package/es/src/charts/Geomap/applyLayout.js.map +1 -1
  22. package/es/src/charts/Geomap/basemapTheme.js +78 -0
  23. package/es/src/charts/Geomap/basemapTheme.js.map +1 -0
  24. package/es/src/charts/Geomap/emit.js +18 -9
  25. package/es/src/charts/Geomap/emit.js.map +1 -1
  26. package/es/src/charts/Geomap/index.js +74 -105
  27. package/es/src/charts/Geomap/index.js.map +1 -1
  28. package/es/src/charts/Histogram/binData.js +225 -0
  29. package/es/src/charts/Histogram/binData.js.map +1 -0
  30. package/es/src/charts/Histogram/index.js +271 -0
  31. package/es/src/charts/Histogram/index.js.map +1 -0
  32. package/es/src/charts/LinePlot/index.js +1 -2
  33. package/es/src/charts/LinePlot/index.js.map +1 -1
  34. package/es/src/charts/Matrix/emit.js +6 -0
  35. package/es/src/charts/Matrix/emit.js.map +1 -1
  36. package/es/src/charts/Matrix/index.js +1 -2
  37. package/es/src/charts/Matrix/index.js.map +1 -1
  38. package/es/src/charts/Network/applyLayout.js +52 -4
  39. package/es/src/charts/Network/applyLayout.js.map +1 -1
  40. package/es/src/charts/Network/emit.js +61 -27
  41. package/es/src/charts/Network/emit.js.map +1 -1
  42. package/es/src/charts/Network/index.js +40 -55
  43. package/es/src/charts/Network/index.js.map +1 -1
  44. package/es/src/charts/Pack/emit.js +40 -2
  45. package/es/src/charts/Pack/emit.js.map +1 -1
  46. package/es/src/charts/Pack/index.js +14 -2
  47. package/es/src/charts/Pack/index.js.map +1 -1
  48. package/es/src/charts/Pie/applyLayout.js +20 -2
  49. package/es/src/charts/Pie/applyLayout.js.map +1 -1
  50. package/es/src/charts/Pie/emit.js +277 -32
  51. package/es/src/charts/Pie/emit.js.map +1 -1
  52. package/es/src/charts/Pie/index.js +47 -3
  53. package/es/src/charts/Pie/index.js.map +1 -1
  54. package/es/src/charts/Plot/discreteSpan.js +42 -0
  55. package/es/src/charts/Plot/discreteSpan.js.map +1 -0
  56. package/es/src/charts/Plot/draw.js +3 -1
  57. package/es/src/charts/Plot/draw.js.map +1 -1
  58. package/es/src/charts/Plot/index.js +152 -17
  59. package/es/src/charts/Plot/index.js.map +1 -1
  60. package/es/src/charts/Plot/pipeline.js +48 -22
  61. package/es/src/charts/Plot/pipeline.js.map +1 -1
  62. package/es/src/charts/Plot/pipelineDomains.js +84 -8
  63. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  64. package/es/src/charts/Plot/plotZoom.js +278 -0
  65. package/es/src/charts/Plot/plotZoom.js.map +1 -0
  66. package/es/src/charts/Plot/shapeDefaults.js +3 -3
  67. package/es/src/charts/Plot/shapeDefaults.js.map +1 -1
  68. package/es/src/charts/Plot/sharedHover.js +431 -0
  69. package/es/src/charts/Plot/sharedHover.js.map +1 -0
  70. package/es/src/charts/Plot/sharedHoverScene.js +230 -0
  71. package/es/src/charts/Plot/sharedHoverScene.js.map +1 -0
  72. package/es/src/charts/Plot/sharedTooltip.js +163 -0
  73. package/es/src/charts/Plot/sharedTooltip.js.map +1 -0
  74. package/es/src/charts/Plot/stackShareLabels.js +137 -0
  75. package/es/src/charts/Plot/stackShareLabels.js.map +1 -0
  76. package/es/src/charts/Plot/stackShareTooltip.js +31 -0
  77. package/es/src/charts/Plot/stackShareTooltip.js.map +1 -0
  78. package/es/src/charts/Plot/trendLines.js +367 -0
  79. package/es/src/charts/Plot/trendLines.js.map +1 -0
  80. package/es/src/charts/Plot/trendScene.js +220 -0
  81. package/es/src/charts/Plot/trendScene.js.map +1 -0
  82. package/es/src/charts/Plot/trendTooltip.js +160 -0
  83. package/es/src/charts/Plot/trendTooltip.js.map +1 -0
  84. package/es/src/charts/Priestley/emit.js +36 -3
  85. package/es/src/charts/Priestley/emit.js.map +1 -1
  86. package/es/src/charts/Priestley/index.js +1 -2
  87. package/es/src/charts/Priestley/index.js.map +1 -1
  88. package/es/src/charts/Radar/emit.js +4 -1
  89. package/es/src/charts/Radar/emit.js.map +1 -1
  90. package/es/src/charts/Radar/index.js +16 -4
  91. package/es/src/charts/Radar/index.js.map +1 -1
  92. package/es/src/charts/RadialMatrix/emit.js +6 -0
  93. package/es/src/charts/RadialMatrix/emit.js.map +1 -1
  94. package/es/src/charts/RadialMatrix/index.js +18 -3
  95. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  96. package/es/src/charts/Rings/applyLayout.js +72 -116
  97. package/es/src/charts/Rings/applyLayout.js.map +1 -1
  98. package/es/src/charts/Rings/emit.js +75 -10
  99. package/es/src/charts/Rings/emit.js.map +1 -1
  100. package/es/src/charts/Rings/index.js +24 -5
  101. package/es/src/charts/Rings/index.js.map +1 -1
  102. package/es/src/charts/Rings/ringsSizing.js +189 -0
  103. package/es/src/charts/Rings/ringsSizing.js.map +1 -0
  104. package/es/src/charts/Sankey/emit.js +55 -11
  105. package/es/src/charts/Sankey/emit.js.map +1 -1
  106. package/es/src/charts/Sankey/index.js +8 -2
  107. package/es/src/charts/Sankey/index.js.map +1 -1
  108. package/es/src/charts/StackedArea/index.js +9 -3
  109. package/es/src/charts/StackedArea/index.js.map +1 -1
  110. package/es/src/charts/Tree/emit.js +10 -4
  111. package/es/src/charts/Tree/emit.js.map +1 -1
  112. package/es/src/charts/Tree/index.js +6 -5
  113. package/es/src/charts/Tree/index.js.map +1 -1
  114. package/es/src/charts/Treemap/emit.js +56 -3
  115. package/es/src/charts/Treemap/emit.js.map +1 -1
  116. package/es/src/charts/Treemap/index.js +1 -2
  117. package/es/src/charts/Treemap/index.js.map +1 -1
  118. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  119. package/es/src/charts/definition/makeChart.js +8 -1
  120. package/es/src/charts/definition/makeChart.js.map +1 -1
  121. package/es/src/charts/drawSteps/backControl.js +85 -0
  122. package/es/src/charts/drawSteps/backControl.js.map +1 -0
  123. package/es/src/charts/drawSteps/bottomRightControls.js +193 -0
  124. package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
  125. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +161 -0
  126. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -0
  127. package/es/src/charts/drawSteps/controlButtonStyle.js +108 -0
  128. package/es/src/charts/drawSteps/controlButtonStyle.js.map +1 -0
  129. package/es/src/charts/drawSteps/minimap.js +395 -0
  130. package/es/src/charts/drawSteps/minimap.js.map +1 -0
  131. package/es/src/charts/drawSteps/minimapMarkup.js +147 -0
  132. package/es/src/charts/drawSteps/minimapMarkup.js.map +1 -0
  133. package/es/src/charts/drawSteps/searchControls.js +358 -0
  134. package/es/src/charts/drawSteps/searchControls.js.map +1 -0
  135. package/es/src/charts/drawSteps/searchControlsMarkup.js +430 -0
  136. package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -0
  137. package/es/src/charts/drawSteps/tableView.js +173 -0
  138. package/es/src/charts/drawSteps/tableView.js.map +1 -0
  139. package/es/src/charts/drawSteps/tableViewControl.js +39 -0
  140. package/es/src/charts/drawSteps/tableViewControl.js.map +1 -0
  141. package/es/src/charts/drawSteps/tableViewMarkup.js +647 -0
  142. package/es/src/charts/drawSteps/tableViewMarkup.js.map +1 -0
  143. package/es/src/charts/drawSteps/topLeftControls.js +73 -0
  144. package/es/src/charts/drawSteps/topLeftControls.js.map +1 -0
  145. package/es/src/charts/drawSteps/topLeftControlsMarkup.js +227 -0
  146. package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +1 -0
  147. package/es/src/charts/drawSteps/zoomControls.js +317 -175
  148. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  149. package/es/src/charts/drawSteps/zoomControlsMarkup.js +280 -0
  150. package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +1 -0
  151. package/es/src/charts/events/click.shape.js +24 -1
  152. package/es/src/charts/events/click.shape.js.map +1 -1
  153. package/es/src/charts/events/mouseenter.js +3 -0
  154. package/es/src/charts/events/mouseenter.js.map +1 -1
  155. package/es/src/charts/events/mouseleave.js +3 -0
  156. package/es/src/charts/events/mouseleave.js.map +1 -1
  157. package/es/src/charts/events/mousemove.shape.js +2 -0
  158. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  159. package/es/src/charts/features/attributionFeature.js +137 -0
  160. package/es/src/charts/features/attributionFeature.js.map +1 -0
  161. package/es/src/charts/features/axes.js +24 -9
  162. package/es/src/charts/features/axes.js.map +1 -1
  163. package/es/src/charts/features/chartGeometry.js +16 -2
  164. package/es/src/charts/features/chartGeometry.js.map +1 -1
  165. package/es/src/charts/features/edgeArrows.js +155 -0
  166. package/es/src/charts/features/edgeArrows.js.map +1 -0
  167. package/es/src/charts/features/emitHelpers.js +32 -0
  168. package/es/src/charts/features/emitHelpers.js.map +1 -1
  169. package/es/src/charts/features/ensureZoomDom.js +63 -12
  170. package/es/src/charts/features/ensureZoomDom.js.map +1 -1
  171. package/es/src/charts/features/features.js +89 -112
  172. package/es/src/charts/features/features.js.map +1 -1
  173. package/es/src/charts/features/featuresLegend.js +53 -17
  174. package/es/src/charts/features/featuresLegend.js.map +1 -1
  175. package/es/src/charts/features/plotPaint.js +81 -29
  176. package/es/src/charts/features/plotPaint.js.map +1 -1
  177. package/es/src/charts/features/shapeEmit.js +20 -2
  178. package/es/src/charts/features/shapeEmit.js.map +1 -1
  179. package/es/src/charts/features/zoomExtent.js +185 -0
  180. package/es/src/charts/features/zoomExtent.js.map +1 -0
  181. package/es/src/charts/helpers/tileAttributions.js +26 -0
  182. package/es/src/charts/helpers/tileAttributions.js.map +1 -1
  183. package/es/src/charts/index.js +2 -0
  184. package/es/src/charts/index.js.map +1 -1
  185. package/es/src/charts/pipeline/drillMorph.js +159 -0
  186. package/es/src/charts/pipeline/drillMorph.js.map +1 -0
  187. package/es/src/charts/pipeline/runChartDraw.js +35 -1
  188. package/es/src/charts/pipeline/runChartDraw.js.map +1 -1
  189. package/es/src/charts/pipeline/runVizPipeline.js +49 -15
  190. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  191. package/es/src/charts/pipeline/vizDrawPure.js +52 -6
  192. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  193. package/es/src/charts/viz/Viz.js +103 -59
  194. package/es/src/charts/viz/Viz.js.map +1 -1
  195. package/es/src/charts/viz/VizBase.js +186 -5
  196. package/es/src/charts/viz/VizBase.js.map +1 -1
  197. package/es/src/charts/viz/VizBaseConfig.js +41 -3
  198. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  199. package/es/src/charts/viz/ordinalColor.js +2 -2
  200. package/es/src/charts/viz/ordinalColor.js.map +1 -1
  201. package/es/src/charts/viz/vizDefaults.js +270 -58
  202. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  203. package/es/src/charts/viz/vizRender.js +54 -4
  204. package/es/src/charts/viz/vizRender.js.map +1 -1
  205. package/es/src/charts/viz/vizTypes.js.map +1 -1
  206. package/es/src/charts/viz/vizVisibility.js +145 -0
  207. package/es/src/charts/viz/vizVisibility.js.map +1 -0
  208. package/es/src/components/Axis/Axis.js +18 -9
  209. package/es/src/components/Axis/Axis.js.map +1 -1
  210. package/es/src/components/Axis/axisLayoutLabels.js +2 -1
  211. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  212. package/es/src/components/Axis/axisRender.js +5 -1
  213. package/es/src/components/Axis/axisRender.js.map +1 -1
  214. package/es/src/components/ColorScale/ColorScale.js +11 -11
  215. package/es/src/components/ColorScale/ColorScale.js.map +1 -1
  216. package/es/src/components/ColorScale/colorScaleScale.js +22 -10
  217. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -1
  218. package/es/src/components/Legend/Legend.js +8 -5
  219. package/es/src/components/Legend/Legend.js.map +1 -1
  220. package/es/src/components/Legend/legendConfig.js +87 -21
  221. package/es/src/components/Legend/legendConfig.js.map +1 -1
  222. package/es/src/components/Legend/legendRender.js +29 -22
  223. package/es/src/components/Legend/legendRender.js.map +1 -1
  224. package/es/src/components/SizeLegend/SizeLegend.js +411 -0
  225. package/es/src/components/SizeLegend/SizeLegend.js.map +1 -0
  226. package/es/src/components/SizeLegend/sizeLegendLayout.js +285 -0
  227. package/es/src/components/SizeLegend/sizeLegendLayout.js.map +1 -0
  228. package/es/src/components/Timeline/timelineConfig.js +8 -4
  229. package/es/src/components/Timeline/timelineConfig.js.map +1 -1
  230. package/es/src/components/Timeline/timelineRender.js +1 -2
  231. package/es/src/components/Timeline/timelineRender.js.map +1 -1
  232. package/es/src/components/Tooltip.js +27 -7
  233. package/es/src/components/Tooltip.js.map +1 -1
  234. package/es/src/components/index.js +1 -0
  235. package/es/src/components/index.js.map +1 -1
  236. package/es/src/shapes/Box.js +4 -2
  237. package/es/src/shapes/Box.js.map +1 -1
  238. package/es/src/shapes/Shape.js +1 -1
  239. package/es/src/shapes/Shape.js.map +1 -1
  240. package/es/src/shapes/Whisker.js +3 -2
  241. package/es/src/shapes/Whisker.js.map +1 -1
  242. package/es/src/shapes/validateShapeConfig.js +141 -0
  243. package/es/src/shapes/validateShapeConfig.js.map +1 -0
  244. package/es/src/utils/BaseClass.js +134 -4
  245. package/es/src/utils/BaseClass.js.map +1 -1
  246. package/es/src/utils/D3plusConfig.js.map +1 -1
  247. package/es/src/utils/configDefault.js +17 -0
  248. package/es/src/utils/configDefault.js.map +1 -0
  249. package/es/src/utils/configPrep.js +2 -1
  250. package/es/src/utils/configPrep.js.map +1 -1
  251. package/es/src/utils/configWarnings.js +37 -0
  252. package/es/src/utils/configWarnings.js.map +1 -0
  253. package/es/src/utils/index.js +1 -0
  254. package/es/src/utils/index.js.map +1 -1
  255. package/package.json +13 -11
  256. package/types/index.d.ts +4 -4
  257. package/types/internal.d.ts +16 -2
  258. package/types/src/charts/BarChart/index.d.ts +2 -1
  259. package/types/src/charts/Chord/applyLayout.d.ts +43 -0
  260. package/types/src/charts/Chord/emit.d.ts +10 -0
  261. package/types/src/charts/Chord/index.d.ts +19 -0
  262. package/types/src/charts/Geomap/applyLayout.d.ts +9 -1
  263. package/types/src/charts/Geomap/basemapTheme.d.ts +35 -0
  264. package/types/src/charts/Histogram/binData.d.ts +37 -0
  265. package/types/src/charts/Histogram/index.d.ts +14 -0
  266. package/types/src/charts/Network/applyLayout.d.ts +8 -0
  267. package/types/src/charts/Plot/discreteSpan.d.ts +9 -0
  268. package/types/src/charts/Plot/index.d.ts +51 -3
  269. package/types/src/charts/Plot/pipeline.d.ts +14 -0
  270. package/types/src/charts/Plot/plotZoom.d.ts +65 -0
  271. package/types/src/charts/Plot/sharedHover.d.ts +79 -0
  272. package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
  273. package/types/src/charts/Plot/sharedTooltip.d.ts +26 -0
  274. package/types/src/charts/Plot/stackShareLabels.d.ts +21 -0
  275. package/types/src/charts/Plot/stackShareTooltip.d.ts +9 -0
  276. package/types/src/charts/Plot/trendLines.d.ts +70 -0
  277. package/types/src/charts/Plot/trendScene.d.ts +18 -0
  278. package/types/src/charts/Plot/trendTooltip.d.ts +19 -0
  279. package/types/src/charts/Rings/applyLayout.d.ts +9 -0
  280. package/types/src/charts/Rings/ringsSizing.d.ts +49 -0
  281. package/types/src/charts/StackedArea/index.d.ts +2 -1
  282. package/types/src/charts/definition/ChartDefinition.d.ts +33 -1
  283. package/types/src/charts/definition/makeChart.d.ts +2 -1
  284. package/types/src/charts/drawSteps/backControl.d.ts +29 -0
  285. package/types/src/charts/drawSteps/bottomRightControls.d.ts +26 -0
  286. package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +108 -0
  287. package/types/src/charts/drawSteps/controlButtonStyle.d.ts +45 -0
  288. package/types/src/charts/drawSteps/minimap.d.ts +19 -0
  289. package/types/src/charts/drawSteps/minimapMarkup.d.ts +45 -0
  290. package/types/src/charts/drawSteps/searchControls.d.ts +3 -0
  291. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +111 -0
  292. package/types/src/charts/drawSteps/tableView.d.ts +23 -0
  293. package/types/src/charts/drawSteps/tableViewControl.d.ts +21 -0
  294. package/types/src/charts/drawSteps/tableViewMarkup.d.ts +119 -0
  295. package/types/src/charts/drawSteps/topLeftControls.d.ts +32 -0
  296. package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +72 -0
  297. package/types/src/charts/drawSteps/zoomControls.d.ts +48 -8
  298. package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +138 -0
  299. package/types/src/charts/features/attributionFeature.d.ts +21 -0
  300. package/types/src/charts/features/axes.d.ts +1 -1
  301. package/types/src/charts/features/chartGeometry.d.ts +9 -3
  302. package/types/src/charts/features/edgeArrows.d.ts +92 -0
  303. package/types/src/charts/features/emitHelpers.d.ts +19 -0
  304. package/types/src/charts/features/ensureZoomDom.d.ts +6 -2
  305. package/types/src/charts/features/features.d.ts +32 -17
  306. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  307. package/types/src/charts/features/plotPaint.d.ts +40 -2
  308. package/types/src/charts/features/zoomExtent.d.ts +25 -0
  309. package/types/src/charts/index.d.ts +2 -0
  310. package/types/src/charts/pipeline/drillMorph.d.ts +29 -0
  311. package/types/src/charts/pipeline/runVizPipeline.d.ts +14 -3
  312. package/types/src/charts/viz/Viz.d.ts +18 -1
  313. package/types/src/charts/viz/VizBase.d.ts +99 -4
  314. package/types/src/charts/viz/VizBaseConfig.d.ts +25 -3
  315. package/types/src/charts/viz/vizDefaults.d.ts +155 -0
  316. package/types/src/charts/viz/vizTypes.d.ts +204 -4
  317. package/types/src/charts/viz/vizVisibility.d.ts +34 -0
  318. package/types/src/components/Axis/Axis.d.ts +2 -0
  319. package/types/src/components/Legend/legendRender.d.ts +8 -2
  320. package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
  321. package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
  322. package/types/src/components/Tooltip.d.ts +18 -3
  323. package/types/src/components/index.d.ts +1 -0
  324. package/types/src/shapes/validateShapeConfig.d.ts +10 -0
  325. package/types/src/utils/BaseClass.d.ts +15 -1
  326. package/types/src/utils/D3plusConfig.d.ts +200 -8
  327. package/types/src/utils/configDefault.d.ts +11 -0
  328. package/types/src/utils/configWarnings.d.ts +28 -0
  329. package/types/src/utils/index.d.ts +2 -1
  330. package/umd/d3plus-core.full.js +44507 -35766
  331. package/umd/d3plus-core.full.js.map +1 -1
  332. package/umd/d3plus-core.full.min.js +7073 -4410
  333. package/umd/d3plus-core.js +16718 -9634
  334. package/umd/d3plus-core.js.map +1 -1
  335. package/umd/d3plus-core.min.js +4615 -2322
@@ -0,0 +1,155 @@
1
+ /**
2
+ Shared arrowhead geometry for edge charts (Network, Rings, Sankey).
3
+
4
+ Arrowheads are drawn as filled-triangle `path` scene nodes rather than SVG
5
+ `marker-end`, because d3plus renders to both SVG and Canvas and Canvas has no
6
+ marker support. Each chart computes the tip point + tangent angle from its own
7
+ edge geometry (edges terminate differently per chart) and calls `arrowNode`.
8
+ The triangle lives in the same content coordinate space as its edge, so it
9
+ pans/zooms and hover-dims in lockstep with the edge.
10
+
11
+ Chord doesn't use this module — its ribbons carry arrowheads via d3-chord's
12
+ `ribbonArrow`.
13
+
14
+ @module
15
+ */ function _define_property(obj, key, value) {
16
+ if (key in obj) {
17
+ Object.defineProperty(obj, key, {
18
+ value: value,
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true
22
+ });
23
+ } else {
24
+ obj[key] = value;
25
+ }
26
+ return obj;
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
+ }
43
+ /** Normalize an `arrows` config value for one edge into `{source, target}` flags. */ export function arrowEnds(arrows, d, i) {
44
+ var v = typeof arrows === "function" ? arrows(d, i) : arrows;
45
+ if (v === true || v === "target") return {
46
+ source: false,
47
+ target: true
48
+ };
49
+ if (v === "source") return {
50
+ source: true,
51
+ target: false
52
+ };
53
+ if (v === "both") return {
54
+ source: true,
55
+ target: true
56
+ };
57
+ return {
58
+ source: false,
59
+ target: false
60
+ };
61
+ }
62
+ var round = function round(n) {
63
+ return Math.round(n * 100) / 100;
64
+ };
65
+ /**
66
+ SVG path `d` for a filled isosceles triangle whose tip is at `(x, y)`, pointing
67
+ along `angle` (radians), with `size` the tip-to-base length.
68
+ */ export function arrowPathD(x, y, angle, size) {
69
+ var halfBase = size * 0.6;
70
+ var bx = x - Math.cos(angle) * size;
71
+ var by = y - Math.sin(angle) * size;
72
+ var nx = Math.cos(angle + Math.PI / 2);
73
+ var ny = Math.sin(angle + Math.PI / 2);
74
+ return "M".concat(round(x), ",").concat(round(y), "L").concat(round(bx + nx * halfBase), ",").concat(round(by + ny * halfBase), "L").concat(round(bx - nx * halfBase), ",").concat(round(by - ny * halfBase), "Z");
75
+ }
76
+ /**
77
+ Tip point + direction for a straight-edge arrowhead sitting at the boundary of
78
+ an endpoint node (radius `r`), pointing from `(fromX, fromY)` toward
79
+ `(toX, toY)`. `gap` insets the tip slightly off the node edge. Used by Network
80
+ (center-to-center links) and Rings' straight center-links.
81
+ */ export function straightArrowTip(fromX, fromY, toX, toY, r) {
82
+ var gap = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
83
+ var angle = Math.atan2(toY - fromY, toX - fromX);
84
+ return {
85
+ x: toX - Math.cos(angle) * (r + gap),
86
+ y: toY - Math.sin(angle) * (r + gap),
87
+ angle: angle
88
+ };
89
+ }
90
+ /**
91
+ Resolve the arrowhead size from the `arrowSize` config (a number or per-edge
92
+ accessor), falling back to a size derived from the edge's stroke width.
93
+ */ export function arrowSizeFor(arrowSize, d, i, strokeWidth) {
94
+ var cfg = typeof arrowSize === "function" ? arrowSize(d, i) : arrowSize;
95
+ return typeof cfg === "number" ? cfg : Math.max(6, strokeWidth * 3);
96
+ }
97
+ /**
98
+ Emit arrowhead nodes for a straight, center-to-center edge between two nodes
99
+ (radii `source.r`/`target.r`), insetting each tip to the node boundary.
100
+ Returns `[]` when `arrows` selects neither end. Used by Network and Rings'
101
+ straight center-links.
102
+ */ export function straightEdgeArrows(opts) {
103
+ var ends = arrowEnds(opts.arrows, opts.datum, opts.i);
104
+ if (!ends.source && !ends.target) return [];
105
+ var size = arrowSizeFor(opts.arrowSize, opts.datum, opts.i, typeof opts.strokeWidth === "number" ? opts.strokeWidth : 1);
106
+ var s = opts.source, t = opts.target, datum = opts.datum, fill = opts.fill, keyPrefix = opts.keyPrefix;
107
+ var out = [];
108
+ if (ends.target) {
109
+ var _t_r;
110
+ var tip = straightArrowTip(s.x, s.y, t.x, t.y, (_t_r = t.r) !== null && _t_r !== void 0 ? _t_r : 0, 1);
111
+ out.push(arrowNode({
112
+ key: "".concat(keyPrefix, "-t"),
113
+ datum: datum,
114
+ x: tip.x,
115
+ y: tip.y,
116
+ angle: tip.angle,
117
+ size: size,
118
+ fill: fill
119
+ }));
120
+ }
121
+ if (ends.source) {
122
+ var _s_r;
123
+ var tip1 = straightArrowTip(t.x, t.y, s.x, s.y, (_s_r = s.r) !== null && _s_r !== void 0 ? _s_r : 0, 1);
124
+ out.push(arrowNode({
125
+ key: "".concat(keyPrefix, "-s"),
126
+ datum: datum,
127
+ x: tip1.x,
128
+ y: tip1.y,
129
+ angle: tip1.angle,
130
+ size: size,
131
+ fill: fill
132
+ }));
133
+ }
134
+ return out;
135
+ }
136
+ /**
137
+ Build one arrowhead scene node. `interactive: false` so the edge path owns
138
+ hit-testing, and the same `datum` as its edge so the hover-dim pass keeps the
139
+ arrow paired with its edge.
140
+ */ export function arrowNode(opts) {
141
+ return {
142
+ type: "path",
143
+ key: opts.key,
144
+ d: arrowPathD(opts.x, opts.y, opts.angle, opts.size),
145
+ datum: opts.datum,
146
+ interactive: false,
147
+ paint: _object_spread({
148
+ fill: opts.fill
149
+ }, opts.opacity !== undefined ? {
150
+ opacity: opts.opacity
151
+ } : {})
152
+ };
153
+ }
154
+
155
+ //# sourceMappingURL=edgeArrows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/features/edgeArrows.ts"],"sourcesContent":["/**\n Shared arrowhead geometry for edge charts (Network, Rings, Sankey).\n\n Arrowheads are drawn as filled-triangle `path` scene nodes rather than SVG\n `marker-end`, because d3plus renders to both SVG and Canvas and Canvas has no\n marker support. Each chart computes the tip point + tangent angle from its own\n edge geometry (edges terminate differently per chart) and calls `arrowNode`.\n The triangle lives in the same content coordinate space as its edge, so it\n pans/zooms and hover-dims in lockstep with the edge.\n\n Chord doesn't use this module — its ribbons carry arrowheads via d3-chord's\n `ribbonArrow`.\n\n @module\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\n/** Which end(s) of an edge carry an arrowhead. `true` is equivalent to `\"target\"`. */\nexport type ArrowEndValue = boolean | \"target\" | \"source\" | \"both\";\n\n/** The `arrows` config: a fixed value or a per-edge accessor. */\nexport type ArrowValue =\n | ArrowEndValue\n | ((d: DataPoint, i: number) => ArrowEndValue);\n\n/** Resolved per-edge arrow ends. */\nexport interface ArrowEnds {\n source: boolean;\n target: boolean;\n}\n\n/** Normalize an `arrows` config value for one edge into `{source, target}` flags. */\nexport function arrowEnds(arrows: ArrowValue, d: DataPoint, i: number): ArrowEnds {\n const v = typeof arrows === \"function\" ? arrows(d, i) : arrows;\n if (v === true || v === \"target\") return {source: false, target: true};\n if (v === \"source\") return {source: true, target: false};\n if (v === \"both\") return {source: true, target: true};\n return {source: false, target: false};\n}\n\nconst round = (n: number): number => Math.round(n * 100) / 100;\n\n/**\n SVG path `d` for a filled isosceles triangle whose tip is at `(x, y)`, pointing\n along `angle` (radians), with `size` the tip-to-base length.\n*/\nexport function arrowPathD(\n x: number,\n y: number,\n angle: number,\n size: number,\n): string {\n const halfBase = size * 0.6;\n const bx = x - Math.cos(angle) * size;\n const by = y - Math.sin(angle) * size;\n const nx = Math.cos(angle + Math.PI / 2);\n const ny = Math.sin(angle + Math.PI / 2);\n return `M${round(x)},${round(y)}L${round(bx + nx * halfBase)},${round(by + ny * halfBase)}L${round(bx - nx * halfBase)},${round(by - ny * halfBase)}Z`;\n}\n\n/**\n Tip point + direction for a straight-edge arrowhead sitting at the boundary of\n an endpoint node (radius `r`), pointing from `(fromX, fromY)` toward\n `(toX, toY)`. `gap` insets the tip slightly off the node edge. Used by Network\n (center-to-center links) and Rings' straight center-links.\n*/\nexport function straightArrowTip(\n fromX: number,\n fromY: number,\n toX: number,\n toY: number,\n r: number,\n gap = 1,\n): {x: number; y: number; angle: number} {\n const angle = Math.atan2(toY - fromY, toX - fromX);\n return {\n x: toX - Math.cos(angle) * (r + gap),\n y: toY - Math.sin(angle) * (r + gap),\n angle,\n };\n}\n\n/**\n Resolve the arrowhead size from the `arrowSize` config (a number or per-edge\n accessor), falling back to a size derived from the edge's stroke width.\n*/\nexport function arrowSizeFor(\n arrowSize: unknown,\n d: DataPoint,\n i: number,\n strokeWidth: number,\n): number {\n const cfg =\n typeof arrowSize === \"function\"\n ? (arrowSize as (d: DataPoint, i: number) => unknown)(d, i)\n : arrowSize;\n return typeof cfg === \"number\" ? cfg : Math.max(6, strokeWidth * 3);\n}\n\n/**\n Emit arrowhead nodes for a straight, center-to-center edge between two nodes\n (radii `source.r`/`target.r`), insetting each tip to the node boundary.\n Returns `[]` when `arrows` selects neither end. Used by Network and Rings'\n straight center-links.\n*/\nexport function straightEdgeArrows(opts: {\n arrows: ArrowValue;\n arrowSize: unknown;\n strokeWidth?: number;\n datum: DataPoint;\n i: number;\n keyPrefix: string;\n fill?: string;\n source: {x: number; y: number; r?: number};\n target: {x: number; y: number; r?: number};\n}): SceneNode[] {\n const ends = arrowEnds(opts.arrows, opts.datum, opts.i);\n if (!ends.source && !ends.target) return [];\n const size = arrowSizeFor(\n opts.arrowSize,\n opts.datum,\n opts.i,\n typeof opts.strokeWidth === \"number\" ? opts.strokeWidth : 1,\n );\n const {source: s, target: t, datum, fill, keyPrefix} = opts;\n const out: SceneNode[] = [];\n if (ends.target) {\n const tip = straightArrowTip(s.x, s.y, t.x, t.y, t.r ?? 0, 1);\n out.push(arrowNode({key: `${keyPrefix}-t`, datum, x: tip.x, y: tip.y, angle: tip.angle, size, fill}));\n }\n if (ends.source) {\n const tip = straightArrowTip(t.x, t.y, s.x, s.y, s.r ?? 0, 1);\n out.push(arrowNode({key: `${keyPrefix}-s`, datum, x: tip.x, y: tip.y, angle: tip.angle, size, fill}));\n }\n return out;\n}\n\n/** Inputs for a single arrowhead scene node. */\nexport interface ArrowNodeOpts {\n key: string | number;\n datum: DataPoint;\n x: number;\n y: number;\n /** Direction the arrow points, in radians. */\n angle: number;\n size: number;\n fill?: string;\n opacity?: number;\n}\n\n/**\n Build one arrowhead scene node. `interactive: false` so the edge path owns\n hit-testing, and the same `datum` as its edge so the hover-dim pass keeps the\n arrow paired with its edge.\n*/\nexport function arrowNode(opts: ArrowNodeOpts): SceneNode {\n return {\n type: \"path\",\n key: opts.key,\n d: arrowPathD(opts.x, opts.y, opts.angle, opts.size),\n datum: opts.datum,\n interactive: false,\n paint: {\n fill: opts.fill,\n ...(opts.opacity !== undefined ? {opacity: opts.opacity} : {}),\n },\n } as SceneNode;\n}\n"],"names":["arrowEnds","arrows","d","i","v","source","target","round","n","Math","arrowPathD","x","y","angle","size","halfBase","bx","cos","by","sin","nx","PI","ny","straightArrowTip","fromX","fromY","toX","toY","r","gap","atan2","arrowSizeFor","arrowSize","strokeWidth","cfg","max","straightEdgeArrows","opts","ends","datum","s","t","fill","keyPrefix","out","tip","push","arrowNode","key","type","interactive","paint","opacity","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,mFAAmF,GACnF,OAAO,SAASA,UAAUC,MAAkB,EAAEC,CAAY,EAAEC,CAAS;IACnE,IAAMC,IAAI,OAAOH,WAAW,aAAaA,OAAOC,GAAGC,KAAKF;IACxD,IAAIG,MAAM,QAAQA,MAAM,UAAU,OAAO;QAACC,QAAQ;QAAOC,QAAQ;IAAI;IACrE,IAAIF,MAAM,UAAU,OAAO;QAACC,QAAQ;QAAMC,QAAQ;IAAK;IACvD,IAAIF,MAAM,QAAQ,OAAO;QAACC,QAAQ;QAAMC,QAAQ;IAAI;IACpD,OAAO;QAACD,QAAQ;QAAOC,QAAQ;IAAK;AACtC;AAEA,IAAMC,QAAQ,eAACC;WAAsBC,KAAKF,KAAK,CAACC,IAAI,OAAO;;AAE3D;;;AAGA,GACA,OAAO,SAASE,WACdC,CAAS,EACTC,CAAS,EACTC,KAAa,EACbC,IAAY;IAEZ,IAAMC,WAAWD,OAAO;IACxB,IAAME,KAAKL,IAAIF,KAAKQ,GAAG,CAACJ,SAASC;IACjC,IAAMI,KAAKN,IAAIH,KAAKU,GAAG,CAACN,SAASC;IACjC,IAAMM,KAAKX,KAAKQ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;QACND,KAAKX,KAAKW,GAAG;QACb9C,GAAGQ,WAAW2B,KAAK1B,CAAC,EAAE0B,KAAKzB,CAAC,EAAEyB,KAAKxB,KAAK,EAAEwB,KAAKvB,IAAI;QACnDyB,OAAOF,KAAKE,KAAK;QACjBW,aAAa;QACbC,OAAO;YACLT,MAAML,KAAKK,IAAI;WACXL,KAAKe,OAAO,KAAKC,YAAY;YAACD,SAASf,KAAKe,OAAO;QAAA,IAAI,CAAC;IAEhE;AACF"}
@@ -67,6 +67,10 @@ function _object_spread_props(target, source) {
67
67
  function _to_consumable_array(arr) {
68
68
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
69
69
  }
70
+ function _type_of(obj) {
71
+ "@swc/helpers - typeof";
72
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
73
+ }
70
74
  function _unsupported_iterable_to_array(o, minLen) {
71
75
  if (!o) return;
72
76
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -96,6 +100,7 @@ function _unsupported_iterable_to_array(o, minLen) {
96
100
 
97
101
  @module
98
102
  */ import configPrep from "../../utils/configPrep.js";
103
+ import { isDefault } from "../../utils/configDefault.js";
99
104
  import * as shapes from "../../shapes/index.js";
100
105
  /** The shape registry indexed by key, typed as constructable classes. */ var shapeCtors = shapes;
101
106
  /** Construct a shape instance by its registry key (e.g. "Bar", "Line"). */ export var makeShape = function makeShape(key) {
@@ -132,6 +137,14 @@ import * as shapes from "../../shapes/index.js";
132
137
  vectorEffect: ve === "none" || ve === "non-scaling-stroke" ? ve : undefined
133
138
  };
134
139
  }
140
+ /**
141
+ Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`
142
+ wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree
143
+ convention — same unwrap `paintFromShapeConfig` callers already do).
144
+ */ export function drawNodeLabel(viz, d, i) {
145
+ var _d_data, _d_i;
146
+ return viz._drawLabel((_d_data = d.data) !== null && _d_data !== void 0 ? _d_data : d, (_d_i = d.i) !== null && _d_i !== void 0 ? _d_i : i);
147
+ }
135
148
  /**
136
149
  Apply a shape-config object to a chart-specific shape key, returning the
137
150
  configPrep-massaged object suitable for `.config(...)`. Equivalent to
@@ -149,6 +162,25 @@ import * as shapes from "../../shapes/index.js";
149
162
  // satisfies that contract at runtime.
150
163
  return configPrep.bind(viz)(config !== null && config !== void 0 ? config : viz.schema.shapeConfig, kind, shapeKey);
151
164
  }
165
+ /**
166
+ The user's label config for one shape kind — `shapeConfig.labelConfig`
167
+ overlaid with `shapeConfig[shapeKey].labelConfig`, data-wrapped the same
168
+ way the Shape path wraps it. Spread it over a chart's own label defaults so
169
+ user settings (including `fontFamily()`) win. Library-seeded defaults are
170
+ left out so they don't override the chart's.
171
+ */ export function userLabelConfig(viz, shapeKey) {
172
+ var _viz_schema_shapeConfig;
173
+ var sc = (_viz_schema_shapeConfig = viz.schema.shapeConfig) !== null && _viz_schema_shapeConfig !== void 0 ? _viz_schema_shapeConfig : {};
174
+ var labelConfigOf = function labelConfigOf(cfg) {
175
+ return cfg && (typeof cfg === "undefined" ? "undefined" : _type_of(cfg)) === "object" ? cfg.labelConfig : undefined;
176
+ };
177
+ var raw = _object_spread({}, labelConfigOf(sc), labelConfigOf(sc[shapeKey]));
178
+ for(var key in raw)if (isDefault(raw[key])) delete raw[key];
179
+ var labelConfig = shapeConfigFor(viz, shapeKey, {
180
+ labelConfig: raw
181
+ }).labelConfig;
182
+ return labelConfig !== null && labelConfig !== void 0 ? labelConfig : {};
183
+ }
152
184
  /**
153
185
  Run `shape.render()` in compute mode and collect the resulting scene
154
186
  nodes — shape children and/or label children — in a single flat array.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/emitHelpers.ts"],"sourcesContent":["/**\n Helpers for `ChartDefinition.emit` functions.\n\n Most chart-as-data emits follow the same shape-compute pattern:\n instantiate a Shape (Rect/Circle/Path/…) in `renderMode(\"compute\")`,\n feed it the laid-out data + per-emit config + viz-level shapeConfig,\n call `render()` (which short-circuits before DOM mutation in compute\n mode but populates internal state), then extract:\n\n - the shape's own scene via `shape.toScene().children`\n - its labels via `shape._labelClass.toScene().children`\n\n These two helpers reduce that boilerplate to a single call and\n centralize the `configPrep.bind(viz)(viz.schema.shapeConfig, \"shape\", key)`\n incantation. The helpers swallow exceptions (returning `[]`) to\n preserve the existing pure-Node fallback: tests that run without\n loading the shape registry continue to see an empty emit instead\n of crashing.\n\n @module\n*/\n\nimport configPrep from \"../../utils/configPrep.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport * as shapes from \"../../shapes/index.js\";\n\n/** The shape registry indexed by key, typed as constructable classes. */\nconst shapeCtors = shapes as unknown as Record<string, new () => shapes.Shape>;\n\n/** Construct a shape instance by its registry key (e.g. \"Bar\", \"Line\"). */\nexport const makeShape = (key: string): shapes.Shape => new shapeCtors[key]();\n\n/**\n Structural minimum a Shape (or shape-like component: TextBox, Axis)\n must satisfy for the helpers below to work with it. Captures only the\n members the helpers touch — `render()`, optional `toScene()`, and an\n optional inner `_labelClass` with its own `toScene()`.\n\n Replaces the previous `shape: any` parameter on `collectComputed` and\n `absorbShapeIntoChartScene` — both helpers consume the same surface\n regardless of whether the actual instance is a `Shape` subclass, a\n `TextBox`, an `Axis`, or anything else that exposes these members.\n*/\nexport interface ShapeLike {\n render(): unknown;\n toScene?: () => GroupNode | null | undefined;\n _labelClass?: {\n toScene?: () => GroupNode | null | undefined;\n };\n}\n\n/**\n Structural minimum a Viz instance must satisfy for these helpers to\n work. Each chart subclass has many more fields; the helpers only need\n `_chartScene` (mutated by `absorbShapeIntoChartScene`) and\n `schema.shapeConfig` (read by `shapeConfigFor`'s default-config branch).\n*/\nexport interface VizLike {\n _chartScene?: SceneNode[];\n schema: Record<string, unknown>;\n}\n\n/**\n Resolve a per-datum accessor — either a function `(d, i) => T` or a bare\n value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,\n Priestley, …). Centralized here so each emit doesn't need its own copy.\n*/\nexport function resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\n/**\n Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,\n `opacity`) from a shape-config record for a single datum. Returns a\n `Paint`-shaped object compatible with `SceneNode.paint`. `fill` is\n forced to `string | undefined` to match `Paint.fill` (texture/object\n fills fall through to `undefined`; the existing flat-data emits already\n do this same coercion).\n*/\nexport function paintFromShapeConfig(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n): {\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n opacity?: number;\n vectorEffect?: \"none\" | \"non-scaling-stroke\";\n} {\n const fill = resolveAccessor<unknown>(sc.fill, d, i);\n const stroke = resolveAccessor<string>(sc.stroke, d, i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d, i);\n const opacity = resolveAccessor<number>(sc.opacity, d, i);\n const ve = resolveAccessor<string>(sc.vectorEffect, d, i);\n return {\n fill: typeof fill === \"string\" ? fill : undefined,\n stroke,\n strokeWidth,\n opacity,\n vectorEffect: ve === \"none\" || ve === \"non-scaling-stroke\" ? ve : undefined,\n };\n}\n\n/**\n Apply a shape-config object to a chart-specific shape key, returning the\n configPrep-massaged object suitable for `.config(...)`. Equivalent to\n `(configPrep as any).bind(viz)(config, \"shape\", key)`. When `config` is\n omitted it defaults to `viz.schema.shapeConfig` (the common case — 11 sites);\n callers that compose a transient config object (e.g. Plot's confidence\n bands) pass it explicitly.\n\n `kind` is the second `configPrep` argument (the property to filter by).\n Defaults to `\"shape\"` — the standard call shape. Network's link config\n uses `\"edge\"` instead.\n*/\nexport function shapeConfigFor(\n viz: VizLike,\n shapeKey: string,\n config?: Record<string, unknown>,\n kind: string = \"shape\",\n): Record<string, unknown> {\n // configPrep binds its `this` to a VizContext-shaped object; VizLike\n // satisfies that contract at runtime.\n return configPrep.bind(viz as unknown as VizContext)(\n (config ?? viz.schema.shapeConfig) as Parameters<typeof configPrep>[0],\n kind,\n shapeKey,\n );\n}\n\n/**\n Run `shape.render()` in compute mode and collect the resulting scene\n nodes — shape children and/or label children — in a single flat array.\n Returns `[]` if `shape` is missing or rendering throws (pure-Node\n fallback for tests that don't load the shape registry).\n\n @param shape A shape instance already configured (data, accessors,\n config) and set to `renderMode(\"compute\")`.\n @param opts.shape Include `shape.toScene().children` (default true).\n @param opts.labels Include `shape._labelClass.toScene().children`\n (default true).\n*/\nexport function collectComputed(\n shape: ShapeLike | null | undefined,\n opts: {shape?: boolean; labels?: boolean} = {},\n): SceneNode[] {\n if (!shape) return [];\n const includeShape = opts.shape !== false;\n const includeLabels = opts.labels !== false;\n try {\n shape.render();\n const out: SceneNode[] = [];\n if (includeShape && typeof shape.toScene === \"function\") {\n const s = shape.toScene();\n if (s && Array.isArray(s.children)) out.push(...s.children);\n }\n if (includeLabels) {\n const lbl = shape._labelClass;\n if (lbl && typeof lbl.toScene === \"function\") {\n const ls = lbl.toScene();\n if (ls && Array.isArray(ls.children)) out.push(...ls.children);\n }\n }\n return out;\n } catch {\n return [];\n }\n}\n\n/**\n Push a compute-mode shape's scene nodes onto `viz._chartScene`. Used\n inside chart-specific layout stages that need to mount axis decorations,\n background rects, or other helper geometry alongside the main shape\n emit. The shape MUST already be in `renderMode(\"compute\")`; this helper\n calls `shape.render()` and then absorbs both the shape and label scenes.\n\n Lives here (not in Plot.ts) so any chart stage can call it. Optionally\n wraps the absorbed nodes in a group with the given key + transform,\n useful when the decoration needs its own coordinate system that's\n distinct from the chart-wide `_chartTransform`.\n*/\nexport function absorbShapeIntoChartScene(\n viz: VizLike,\n shape: ShapeLike | null | undefined,\n wrap?: {key: string; transform?: {x: number; y: number}},\n): void {\n if (!shape || typeof shape.toScene !== \"function\") return;\n if (!Array.isArray(viz._chartScene)) viz._chartScene = [];\n const children = collectComputed(shape);\n if (!children.length) return;\n if (wrap) {\n viz._chartScene!.push({type: \"group\", ...wrap, children});\n } else {\n viz._chartScene!.push(...children);\n }\n}\n"],"names":["configPrep","shapes","shapeCtors","makeShape","key","resolveAccessor","val","d","i","paintFromShapeConfig","sc","fill","stroke","strokeWidth","opacity","ve","vectorEffect","undefined","shapeConfigFor","viz","shapeKey","config","kind","bind","schema","shapeConfig","collectComputed","shape","opts","includeShape","includeLabels","labels","render","out","toScene","s","Array","isArray","children","push","lbl","_labelClass","ls","absorbShapeIntoChartScene","wrap","_chartScene","length","type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,GAEA,OAAOA,gBAAgB,4BAA4B;AAMnD,YAAYC,YAAY,wBAAwB;AAEhD,uEAAuE,GACvE,IAAMC,aAAaD;AAEnB,yEAAyE,GACzE,OAAO,IAAME,YAAY,mBAACC;WAA8B,IAAIF,UAAU,CAACE,IAAI;EAAG;AAgC9E;;;;AAIA,GACA,OAAO,SAASC,gBACdC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OAAOF,QAAQ,YAAY;QAC7B,OAAO,AAACA,IAAmDC,GAAGC;IAChE;IACA,OAAOF;AACT;AAEA;;;;;;;AAOA,GACA,OAAO,SAASG,qBACdC,EAA2B,EAC3BH,CAAY,EACZC,CAAqB;IAQrB,IAAMG,OAAON,gBAAyBK,GAAGC,IAAI,EAAEJ,GAAGC;IAClD,IAAMI,SAASP,gBAAwBK,GAAGE,MAAM,EAAEL,GAAGC;IACrD,IAAMK,cAAcR,gBAAwBK,GAAGG,WAAW,EAAEN,GAAGC;IAC/D,IAAMM,UAAUT,gBAAwBK,GAAGI,OAAO,EAAEP,GAAGC;IACvD,IAAMO,KAAKV,gBAAwBK,GAAGM,YAAY,EAAET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;AACF;AAEA;;;;;;;;;;;AAWA,GACA,OAAO,SAASU,0BACdxB,GAAY,EACZQ,KAAmC,EACnCiB,IAAwD;IAExD,IAAI,CAACjB,SAAS,OAAOA,MAAMO,OAAO,KAAK,YAAY;IACnD,IAAI,CAACE,MAAMC,OAAO,CAAClB,IAAI0B,WAAW,GAAG1B,IAAI0B,WAAW,GAAG,EAAE;IACzD,IAAMP,WAAWZ,gBAAgBC;IACjC,IAAI,CAACW,SAASQ,MAAM,EAAE;IACtB,IAAIF,MAAM;QACRzB,IAAI0B,WAAW,CAAEN,IAAI,CAAC;YAACQ,MAAM;WAAYH;YAAMN,UAAAA;;IACjD,OAAO;YACLnB;QAAAA,CAAAA,mBAAAA,IAAI0B,WAAW,EAAEN,IAAI,OAArBpB,kBAAsB,qBAAGmB;IAC3B;AACF"}
1
+ {"version":3,"sources":["../../../../src/charts/features/emitHelpers.ts"],"sourcesContent":["/**\n Helpers for `ChartDefinition.emit` functions.\n\n Most chart-as-data emits follow the same shape-compute pattern:\n instantiate a Shape (Rect/Circle/Path/…) in `renderMode(\"compute\")`,\n feed it the laid-out data + per-emit config + viz-level shapeConfig,\n call `render()` (which short-circuits before DOM mutation in compute\n mode but populates internal state), then extract:\n\n - the shape's own scene via `shape.toScene().children`\n - its labels via `shape._labelClass.toScene().children`\n\n These two helpers reduce that boilerplate to a single call and\n centralize the `configPrep.bind(viz)(viz.schema.shapeConfig, \"shape\", key)`\n incantation. The helpers swallow exceptions (returning `[]`) to\n preserve the existing pure-Node fallback: tests that run without\n loading the shape registry continue to see an empty emit instead\n of crashing.\n\n @module\n*/\n\nimport configPrep from \"../../utils/configPrep.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\nimport {isDefault} from \"../../utils/configDefault.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport * as shapes from \"../../shapes/index.js\";\n\n/** The shape registry indexed by key, typed as constructable classes. */\nconst shapeCtors = shapes as unknown as Record<string, new () => shapes.Shape>;\n\n/** Construct a shape instance by its registry key (e.g. \"Bar\", \"Line\"). */\nexport const makeShape = (key: string): shapes.Shape => new shapeCtors[key]();\n\n/**\n Structural minimum a Shape (or shape-like component: TextBox, Axis)\n must satisfy for the helpers below to work with it. Captures only the\n members the helpers touch — `render()`, optional `toScene()`, and an\n optional inner `_labelClass` with its own `toScene()`.\n\n Replaces the previous `shape: any` parameter on `collectComputed` and\n `absorbShapeIntoChartScene` — both helpers consume the same surface\n regardless of whether the actual instance is a `Shape` subclass, a\n `TextBox`, an `Axis`, or anything else that exposes these members.\n*/\nexport interface ShapeLike {\n render(): unknown;\n toScene?: () => GroupNode | null | undefined;\n _labelClass?: {\n toScene?: () => GroupNode | null | undefined;\n };\n}\n\n/**\n Structural minimum a Viz instance must satisfy for these helpers to\n work. Each chart subclass has many more fields; the helpers only need\n `_chartScene` (mutated by `absorbShapeIntoChartScene`) and\n `schema.shapeConfig` (read by `shapeConfigFor`'s default-config branch).\n*/\nexport interface VizLike {\n _chartScene?: SceneNode[];\n schema: Record<string, unknown>;\n}\n\n/**\n Resolve a per-datum accessor — either a function `(d, i) => T` or a bare\n value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,\n Priestley, …). Centralized here so each emit doesn't need its own copy.\n*/\nexport function resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\n/**\n Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,\n `opacity`) from a shape-config record for a single datum. Returns a\n `Paint`-shaped object compatible with `SceneNode.paint`. `fill` is\n forced to `string | undefined` to match `Paint.fill` (texture/object\n fills fall through to `undefined`; the existing flat-data emits already\n do this same coercion).\n*/\nexport function paintFromShapeConfig(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n): {\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n opacity?: number;\n vectorEffect?: \"none\" | \"non-scaling-stroke\";\n} {\n const fill = resolveAccessor<unknown>(sc.fill, d, i);\n const stroke = resolveAccessor<string>(sc.stroke, d, i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d, i);\n const opacity = resolveAccessor<number>(sc.opacity, d, i);\n const ve = resolveAccessor<string>(sc.vectorEffect, d, i);\n return {\n fill: typeof fill === \"string\" ? fill : undefined,\n stroke,\n strokeWidth,\n opacity,\n vectorEffect: ve === \"none\" || ve === \"non-scaling-stroke\" ? ve : undefined,\n };\n}\n\n/**\n Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`\n wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree\n convention — same unwrap `paintFromShapeConfig` callers already do).\n*/\nexport function drawNodeLabel(\n viz: {_drawLabel: (d: DataPoint, i: number) => string},\n d: DataPoint & {data?: DataPoint; i?: number},\n i: number,\n): string {\n return viz._drawLabel((d.data ?? d) as DataPoint, (d.i ?? i) as number);\n}\n\n/**\n Apply a shape-config object to a chart-specific shape key, returning the\n configPrep-massaged object suitable for `.config(...)`. Equivalent to\n `(configPrep as any).bind(viz)(config, \"shape\", key)`. When `config` is\n omitted it defaults to `viz.schema.shapeConfig` (the common case — 11 sites);\n callers that compose a transient config object (e.g. Plot's confidence\n bands) pass it explicitly.\n\n `kind` is the second `configPrep` argument (the property to filter by).\n Defaults to `\"shape\"` — the standard call shape. Network's link config\n uses `\"edge\"` instead.\n*/\nexport function shapeConfigFor(\n viz: VizLike,\n shapeKey: string,\n config?: Record<string, unknown>,\n kind: string = \"shape\",\n): Record<string, unknown> {\n // configPrep binds its `this` to a VizContext-shaped object; VizLike\n // satisfies that contract at runtime.\n return configPrep.bind(viz as unknown as VizContext)(\n (config ?? viz.schema.shapeConfig) as Parameters<typeof configPrep>[0],\n kind,\n shapeKey,\n );\n}\n\n/**\n The user's label config for one shape kind — `shapeConfig.labelConfig`\n overlaid with `shapeConfig[shapeKey].labelConfig`, data-wrapped the same\n way the Shape path wraps it. Spread it over a chart's own label defaults so\n user settings (including `fontFamily()`) win. Library-seeded defaults are\n left out so they don't override the chart's.\n*/\nexport function userLabelConfig(\n viz: VizLike,\n shapeKey: string,\n): Record<string, unknown> {\n const sc = (viz.schema.shapeConfig ?? {}) as Record<string, unknown>;\n const labelConfigOf = (cfg: unknown): Record<string, unknown> | undefined =>\n cfg && typeof cfg === \"object\"\n ? ((cfg as Record<string, unknown>).labelConfig as Record<string, unknown>)\n : undefined;\n const raw: Record<string, unknown> = {\n ...labelConfigOf(sc),\n ...labelConfigOf(sc[shapeKey]),\n };\n for (const key in raw) if (isDefault(raw[key])) delete raw[key];\n const {labelConfig} = shapeConfigFor(viz, shapeKey, {labelConfig: raw});\n return (labelConfig ?? {}) as Record<string, unknown>;\n}\n\n/**\n Run `shape.render()` in compute mode and collect the resulting scene\n nodes — shape children and/or label children — in a single flat array.\n Returns `[]` if `shape` is missing or rendering throws (pure-Node\n fallback for tests that don't load the shape registry).\n\n @param shape A shape instance already configured (data, accessors,\n config) and set to `renderMode(\"compute\")`.\n @param opts.shape Include `shape.toScene().children` (default true).\n @param opts.labels Include `shape._labelClass.toScene().children`\n (default true).\n*/\nexport function collectComputed(\n shape: ShapeLike | null | undefined,\n opts: {shape?: boolean; labels?: boolean} = {},\n): SceneNode[] {\n if (!shape) return [];\n const includeShape = opts.shape !== false;\n const includeLabels = opts.labels !== false;\n try {\n shape.render();\n const out: SceneNode[] = [];\n if (includeShape && typeof shape.toScene === \"function\") {\n const s = shape.toScene();\n if (s && Array.isArray(s.children)) out.push(...s.children);\n }\n if (includeLabels) {\n const lbl = shape._labelClass;\n if (lbl && typeof lbl.toScene === \"function\") {\n const ls = lbl.toScene();\n if (ls && Array.isArray(ls.children)) out.push(...ls.children);\n }\n }\n return out;\n } catch {\n return [];\n }\n}\n\n/**\n Push a compute-mode shape's scene nodes onto `viz._chartScene`. Used\n inside chart-specific layout stages that need to mount axis decorations,\n background rects, or other helper geometry alongside the main shape\n emit. The shape MUST already be in `renderMode(\"compute\")`; this helper\n calls `shape.render()` and then absorbs both the shape and label scenes.\n\n Lives here (not in Plot.ts) so any chart stage can call it. Optionally\n wraps the absorbed nodes in a group with the given key + transform,\n useful when the decoration needs its own coordinate system that's\n distinct from the chart-wide `_chartTransform`.\n*/\nexport function absorbShapeIntoChartScene(\n viz: VizLike,\n shape: ShapeLike | null | undefined,\n wrap?: {key: string; transform?: {x: number; y: number}},\n): void {\n if (!shape || typeof shape.toScene !== \"function\") return;\n if (!Array.isArray(viz._chartScene)) viz._chartScene = [];\n const children = collectComputed(shape);\n if (!children.length) return;\n if (wrap) {\n viz._chartScene!.push({type: \"group\", ...wrap, children});\n } else {\n viz._chartScene!.push(...children);\n }\n}\n"],"names":["configPrep","isDefault","shapes","shapeCtors","makeShape","key","resolveAccessor","val","d","i","paintFromShapeConfig","sc","fill","stroke","strokeWidth","opacity","ve","vectorEffect","undefined","drawNodeLabel","viz","_drawLabel","data","shapeConfigFor","shapeKey","config","kind","bind","schema","shapeConfig","userLabelConfig","labelConfigOf","cfg","labelConfig","raw","collectComputed","shape","opts","includeShape","includeLabels","labels","render","out","toScene","s","Array","isArray","children","push","lbl","_labelClass","ls","absorbShapeIntoChartScene","wrap","_chartScene","length","type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,GAEA,OAAOA,gBAAgB,4BAA4B;AAEnD,SAAQC,SAAS,QAAO,+BAA+B;AAKvD,YAAYC,YAAY,wBAAwB;AAEhD,uEAAuE,GACvE,IAAMC,aAAaD;AAEnB,yEAAyE,GACzE,OAAO,IAAME,YAAY,mBAACC;WAA8B,IAAIF,UAAU,CAACE,IAAI;EAAG;AAgC9E;;;;AAIA,GACA,OAAO,SAASC,gBACdC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OA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,EAAE;IACX;AACF;AAEA;;;;;;;;;;;AAWA,GACA,OAAO,SAASU,0BACdhC,GAAY,EACZgB,KAAmC,EACnCiB,IAAwD;IAExD,IAAI,CAACjB,SAAS,OAAOA,MAAMO,OAAO,KAAK,YAAY;IACnD,IAAI,CAACE,MAAMC,OAAO,CAAC1B,IAAIkC,WAAW,GAAGlC,IAAIkC,WAAW,GAAG,EAAE;IACzD,IAAMP,WAAWZ,gBAAgBC;IACjC,IAAI,CAACW,SAASQ,MAAM,EAAE;IACtB,IAAIF,MAAM;QACRjC,IAAIkC,WAAW,CAAEN,IAAI,CAAC;YAACQ,MAAM;WAAYH;YAAMN,UAAAA;;IACjD,OAAO;YACL3B;QAAAA,CAAAA,mBAAAA,IAAIkC,WAAW,EAAEN,IAAI,OAArB5B,kBAAsB,qBAAG2B;IAC3B;AACF"}
@@ -1,3 +1,11 @@
1
+ function _instanceof(left, right) {
2
+ "@swc/helpers - instanceof";
3
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
4
+ return !!right[Symbol.hasInstance](left);
5
+ } else {
6
+ return left instanceof right;
7
+ }
8
+ }
1
9
  /**
2
10
  `ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +
3
11
  hitArea that d3-zoom and tile-loading need.
@@ -20,18 +28,61 @@
20
28
  scene-graph-native interaction path (renderer.on(...) dispatch +
21
29
  tile-data → image scene nodes) would let this go away; until then,
22
30
  it's the documented home for the imperative half of v4 zoom.
23
- */ export function ensureZoomDom(viz, opts) {
31
+ */ import { select } from "d3-selection";
32
+ /** The HTML element the chart's <svg> (and, on canvas, its <canvas>) mount in. */ function hostElement(viz) {
33
+ var _ref;
34
+ var _viz__select_node, _viz__select;
35
+ var host = (_ref = (_viz__select = viz._select) === null || _viz__select === void 0 ? void 0 : (_viz__select_node = _viz__select.node()) === null || _viz__select_node === void 0 ? void 0 : _viz__select_node.parentNode) !== null && _ref !== void 0 ? _ref : null;
36
+ while(host && !_instanceof(host, HTMLElement))host = host.parentNode;
37
+ return _instanceof(host, HTMLElement) ? host : null;
38
+ }
39
+ /**
40
+ Where the zoom DOM mounts. Normally the chart's own <svg>, beneath the
41
+ painted scene. On the Canvas backend that <svg> overlays the <canvas>, so
42
+ Geomap's opaque ocean and basemap tiles would hide the geography painted
43
+ on it; they mount instead in an underlay <svg> stacked beneath the canvas
44
+ (the canvas is transparent wherever there is no geography).
45
+ */ function zoomDomParent(viz, kind) {
46
+ var host = kind === "geomap" && viz._renderer === "canvas" && !viz._ssr ? hostElement(viz) : null;
47
+ if (!host) return viz._select;
48
+ // `isolation` makes the host a stacking context, so the underlay's
49
+ // negative z-index puts it beneath the (in-flow) canvas but not beneath
50
+ // the host's own background.
51
+ host.style.isolation = "isolate";
52
+ var underlay = select(host).selectAll(":scope > svg.d3plus-geomap-underlay").data([
53
+ 0
54
+ ]);
55
+ return underlay.enter().insert("svg", ":first-child").attr("class", "d3plus-geomap-underlay").style("position", "absolute").style("top", "0").style("left", "0").style("z-index", "-1").style("overflow", "hidden").style("pointer-events", "none").merge(underlay).attr("width", viz.schema.width).attr("height", viz.schema.height);
56
+ }
57
+ /** Drops a canvas-mode tile underlay once the chart renders to SVG again. */ function removeTileUnderlay(viz) {
58
+ var _host_querySelector;
59
+ var host = hostElement(viz);
60
+ if (host) (_host_querySelector = host.querySelector(":scope > svg.d3plus-geomap-underlay")) === null || _host_querySelector === void 0 ? void 0 : _host_querySelector.remove();
61
+ }
62
+ export function ensureZoomDom(viz, opts) {
24
63
  var kind = opts.kind, width = opts.width, height = opts.height, duration = opts.duration, ocean = opts.ocean;
25
- var cls = kind === "network" ? "d3plus-network" : "d3plus-geomap";
64
+ var cls = "d3plus-".concat(kind === "generic" ? "zoom" : kind);
26
65
  var bg = kind === "geomap" ? ocean || "transparent" : "transparent";
27
- var select = viz._select;
28
- var container = select.selectAll("svg.".concat(cls)).data([
66
+ var parent = zoomDomParent(viz, kind);
67
+ // Adopt a container mounted under the other parent (the renderer changed).
68
+ var existing = viz._container && viz._container.classed(cls) ? viz._container.node() : null;
69
+ if (existing && existing.parentNode !== parent.node()) parent.node().insertBefore(existing, parent.node().firstChild);
70
+ if (parent !== viz._select) viz._select.selectAll(":scope > svg.d3plus-geomap").remove();
71
+ else removeTileUnderlay(viz);
72
+ var container = parent.selectAll(":scope > svg.".concat(cls)).data([
29
73
  0
30
74
  ]);
31
- container = container.enter().append("svg").attr("class", cls).attr("opacity", 0).attr("width", width).attr("height", height).attr("x", viz._margin.left).attr("y", viz._margin.top).style("background-color", bg).merge(container);
75
+ container = container.enter()// First child: beneath the scene, which the renderer paints after it.
76
+ .insert("svg", ":first-child").attr("class", cls).attr("opacity", 0).attr("width", width).attr("height", height).attr("x", viz._margin.left).attr("y", viz._margin.top).style("background-color", bg).merge(container);
32
77
  viz._container = container;
33
78
  container.transition().duration(duration).attr("opacity", 1).attr("width", width).attr("height", height).attr("x", viz._margin.left).attr("y", viz._margin.top);
34
- if (kind === "network") {
79
+ if (kind === "generic") {
80
+ var zoomGroup = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
81
+ 0
82
+ ]);
83
+ zoomGroup = zoomGroup.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup);
84
+ viz._zoomGroup = zoomGroup;
85
+ } else if (kind === "network") {
35
86
  // Hit-area for "click outside any node" → reset focus + zoom.
36
87
  var hitArea = container.selectAll("rect.".concat(cls, "-hitArea")).data([
37
88
  0
@@ -43,11 +94,11 @@
43
94
  viz._zoomToBounds(null);
44
95
  }
45
96
  });
46
- var zoomGroup = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
97
+ var zoomGroup1 = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
47
98
  0
48
99
  ]);
49
- zoomGroup = zoomGroup.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup);
50
- viz._zoomGroup = zoomGroup;
100
+ zoomGroup1 = zoomGroup1.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup1);
101
+ viz._zoomGroup = zoomGroup1;
51
102
  } else {
52
103
  // Geomap also needs an ocean rect (under tiles + paths) and the tile
53
104
  // group that `_renderTiles` mutates with map imagery.
@@ -60,11 +111,11 @@
60
111
  ]);
61
112
  tileGroup = tileGroup.enter().append("g").attr("class", "".concat(cls, "-tileGroup")).merge(tileGroup);
62
113
  viz._tileGroup = tileGroup;
63
- var zoomGroup1 = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
114
+ var zoomGroup2 = container.selectAll("g.".concat(cls, "-zoomGroup")).data([
64
115
  0
65
116
  ]);
66
- zoomGroup1 = zoomGroup1.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup1);
67
- viz._zoomGroup = zoomGroup1;
117
+ zoomGroup2 = zoomGroup2.enter().append("g").attr("class", "".concat(cls, "-zoomGroup")).merge(zoomGroup2);
118
+ viz._zoomGroup = zoomGroup2;
68
119
  }
69
120
  }
70
121
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/ensureZoomDom.ts"],"sourcesContent":["/**\n `ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +\n hitArea that d3-zoom and tile-loading need.\n\n This is the lifecycle half of v4 zoom support. The CONTROLS (zoom-in/\n zoom-out/etc.) ride the scene graph as an HtmlOverlay (see\n `drawSteps/zoomControls.ts`). The zoom-transform application also\n rides the scene graph (`viz._zoomTransform` composed into\n `Viz.toScene()`). But d3-zoom's *event binding* needs a real DOM\n element to bind to, and Geomap's tile-loading mutates the inner\n `<g>` directly — so this helper exists as the documented home for\n that imperative setup.\n\n Idempotent: calling it again returns the existing nodes. Mutates the\n viz instance with `_container` / `_zoomGroup` (and the Network\n variant also wires the hitArea click handler).\n\n The helper stays as long as d3-zoom owns event binding and Geomap's\n tile-loading mounts `<g>` elements directly. An eventual fully\n scene-graph-native interaction path (renderer.on(...) dispatch +\n tile-data → image scene nodes) would let this go away; until then,\n it's the documented home for the imperative half of v4 zoom.\n*/\n\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport type ZoomDomKind = \"network\" | \"geomap\";\n\ninterface SetupOpts {\n /** \"network\" or \"geomap\" — picks the css class + behavior tweaks. */\n kind: ZoomDomKind;\n /** Chart-area width (margin-adjusted). */\n width: number;\n /** Chart-area height (margin-adjusted). */\n height: number;\n /** Transition duration for fade-in. */\n duration: number;\n /** Geomap-only: ocean fill color (also used as the svg background). */\n ocean?: string;\n}\n\nexport function ensureZoomDom(viz: Viz, opts: SetupOpts): void {\n const {kind, width, height, duration, ocean} = opts;\n const cls = kind === \"network\" ? \"d3plus-network\" : \"d3plus-geomap\";\n const bg = kind === \"geomap\" ? ocean || \"transparent\" : \"transparent\";\n\n const select = viz._select!;\n let container = select.selectAll(`svg.${cls}`).data([0]);\n container = container\n .enter()\n .append(\"svg\")\n .attr(\"class\", cls)\n .attr(\"opacity\", 0)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top)\n .style(\"background-color\", bg)\n .merge(container);\n viz._container = container;\n\n container\n .transition()\n .duration(duration)\n .attr(\"opacity\", 1)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top);\n\n if (kind === \"network\") {\n // Hit-area for \"click outside any node\" → reset focus + zoom.\n const hitArea = container.selectAll(`rect.${cls}-hitArea`).data([0]);\n hitArea\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-hitArea`)\n .merge(hitArea)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", \"transparent\")\n .on(\"click\", () => {\n if (viz._focus) {\n viz.active!(false);\n viz._focus = undefined;\n viz._zoomToBounds!(null);\n }\n });\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n } else {\n // Geomap also needs an ocean rect (under tiles + paths) and the tile\n // group that `_renderTiles` mutates with map imagery.\n const oceanRect = container.selectAll(`rect.${cls}-ocean`).data([0]);\n oceanRect\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-ocean`)\n .merge(oceanRect)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", ocean || \"transparent\");\n\n let tileGroup = container.selectAll(`g.${cls}-tileGroup`).data([0]);\n tileGroup = tileGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-tileGroup`)\n .merge(tileGroup);\n viz._tileGroup = tileGroup;\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n }\n}\n"],"names":["ensureZoomDom","viz","opts","kind","width","height","duration","ocean","cls","bg","select","_select","container","selectAll","data","enter","append","attr","_margin","left","top","style","merge","_container","transition","hitArea","on","_focus","active","undefined","_zoomToBounds","zoomGroup","_zoomGroup","oceanRect","tileGroup","_tileGroup"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,GAmBA,OAAO,SAASA,cAAcC,GAAQ,EAAEC,IAAe;IACrD,IAAOC,OAAwCD,KAAxCC,MAAMC,QAAkCF,KAAlCE,OAAOC,SAA2BH,KAA3BG,QAAQC,WAAmBJ,KAAnBI,UAAUC,QAASL,KAATK;IACtC,IAAMC,MAAML,SAAS,YAAY,mBAAmB;IACpD,IAAMM,KAAKN,SAAS,WAAWI,SAAS,gBAAgB;IAExD,IAAMG,SAAST,IAAIU,OAAO;IAC1B,IAAIC,YAAYF,OAAOG,SAAS,CAAC,AAAC,OAAU,OAAJL,MAAOM,IAAI,CAAC;QAAC;KAAE;IACvDF,YAAYA,UACTG,KAAK,GACLC,MAAM,CAAC,OACPC,IAAI,CAAC,SAAST,KACdS,IAAI,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D;QACtD,IAAME,YAAYrB,UAAUC,SAAS,CAAC,AAAC,QAAW,OAAJL,KAAI,WAASM,IAAI,CAAC;YAAC;SAAE;QACnEmB,UACGlB,KAAK,GACLC,MAAM,CAAC,QACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,WACrBc,KAAK,CAACW,WACNhB,IAAI,CAAC,SAASb,OACda,IAAI,CAAC,UAAUZ,QACfY,IAAI,CAAC,QAAQV,SAAS;QAEzB,IAAI2B,YAAYtB,UAAUC,SAAS,CAAC,AAAC,KAAQ,OAAJL,KAAI,eAAaM,IAAI,CAAC;YAAC;SAAE;QAClEoB,YAAYA,UACTnB,KAAK,GACLC,MAAM,CAAC,KACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,eACrBc,KAAK,CAACY;QACTjC,IAAIkC,UAAU,GAAGD;QAEjB,IAAIH,aAAYnB,UAAUC,SAAS,CAAC,AAAC,KAAQ,OAAJL,KAAI,eAAaM,IAAI,CAAC;YAAC;SAAE;QAClEiB,aAAYA,WACThB,KAAK,GACLC,MAAM,CAAC,KACPC,IAAI,CAAC,SAAS,AAAC,GAAM,OAAJT,KAAI,eACrBc,KAAK,CAACS;QACT9B,IAAI+B,UAAU,GAAGD;IACnB;AACF"}
1
+ {"version":3,"sources":["../../../../src/charts/features/ensureZoomDom.ts"],"sourcesContent":["/**\n `ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +\n hitArea that d3-zoom and tile-loading need.\n\n This is the lifecycle half of v4 zoom support. The CONTROLS (zoom-in/\n zoom-out/etc.) ride the scene graph as an HtmlOverlay (see\n `drawSteps/zoomControls.ts`). The zoom-transform application also\n rides the scene graph (`viz._zoomTransform` composed into\n `Viz.toScene()`). But d3-zoom's *event binding* needs a real DOM\n element to bind to, and Geomap's tile-loading mutates the inner\n `<g>` directly — so this helper exists as the documented home for\n that imperative setup.\n\n Idempotent: calling it again returns the existing nodes. Mutates the\n viz instance with `_container` / `_zoomGroup` (and the Network\n variant also wires the hitArea click handler).\n\n The helper stays as long as d3-zoom owns event binding and Geomap's\n tile-loading mounts `<g>` elements directly. An eventual fully\n scene-graph-native interaction path (renderer.on(...) dispatch +\n tile-data → image scene nodes) would let this go away; until then,\n it's the documented home for the imperative half of v4 zoom.\n*/\n\nimport {select} from \"d3-selection\";\n\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport type ZoomDomKind = \"network\" | \"geomap\" | \"generic\";\n\ninterface SetupOpts {\n /**\n \"network\" or \"geomap\" — picks the css class + behavior tweaks. \"generic\"\n is the bare surface (zoom group + brush host) every other chart gets\n when `zoom` is enabled.\n */\n kind: ZoomDomKind;\n /** Chart-area width (margin-adjusted). */\n width: number;\n /** Chart-area height (margin-adjusted). */\n height: number;\n /** Transition duration for fade-in. */\n duration: number;\n /** Geomap-only: ocean fill color (also used as the svg background). */\n ocean?: string;\n}\n\n/** The HTML element the chart's <svg> (and, on canvas, its <canvas>) mount in. */\nfunction hostElement(viz: Viz): HTMLElement | null {\n let host = viz._select?.node()?.parentNode ?? null;\n while (host && !(host instanceof HTMLElement)) host = host.parentNode;\n return host instanceof HTMLElement ? host : null;\n}\n\n/**\n Where the zoom DOM mounts. Normally the chart's own <svg>, beneath the\n painted scene. On the Canvas backend that <svg> overlays the <canvas>, so\n Geomap's opaque ocean and basemap tiles would hide the geography painted\n on it; they mount instead in an underlay <svg> stacked beneath the canvas\n (the canvas is transparent wherever there is no geography).\n*/\nfunction zoomDomParent(viz: Viz, kind: ZoomDomKind): NonNullable<Viz[\"_select\"]> {\n const host = kind === \"geomap\" && viz._renderer === \"canvas\" && !viz._ssr ? hostElement(viz) : null;\n if (!host) return viz._select!;\n // `isolation` makes the host a stacking context, so the underlay's\n // negative z-index puts it beneath the (in-flow) canvas but not beneath\n // the host's own background.\n host.style.isolation = \"isolate\";\n const underlay = select(host).selectAll<SVGSVGElement, number>(\":scope > svg.d3plus-geomap-underlay\").data([0]);\n return underlay\n .enter()\n .insert(\"svg\", \":first-child\")\n .attr(\"class\", \"d3plus-geomap-underlay\")\n .style(\"position\", \"absolute\")\n .style(\"top\", \"0\")\n .style(\"left\", \"0\")\n .style(\"z-index\", \"-1\")\n .style(\"overflow\", \"hidden\")\n .style(\"pointer-events\", \"none\")\n .merge(underlay)\n .attr(\"width\", viz.schema.width)\n .attr(\"height\", viz.schema.height) as unknown as NonNullable<Viz[\"_select\"]>;\n}\n\n/** Drops a canvas-mode tile underlay once the chart renders to SVG again. */\nfunction removeTileUnderlay(viz: Viz): void {\n const host = hostElement(viz);\n if (host) host.querySelector(\":scope > svg.d3plus-geomap-underlay\")?.remove();\n}\n\nexport function ensureZoomDom(viz: Viz, opts: SetupOpts): void {\n const {kind, width, height, duration, ocean} = opts;\n const cls = `d3plus-${kind === \"generic\" ? \"zoom\" : kind}`;\n const bg = kind === \"geomap\" ? ocean || \"transparent\" : \"transparent\";\n\n const parent = zoomDomParent(viz, kind);\n // Adopt a container mounted under the other parent (the renderer changed).\n const existing = viz._container && viz._container.classed(cls) ? viz._container.node() : null;\n if (existing && existing.parentNode !== parent.node())\n parent.node().insertBefore(existing, parent.node().firstChild);\n if (parent !== viz._select) viz._select!.selectAll(\":scope > svg.d3plus-geomap\").remove();\n else removeTileUnderlay(viz);\n\n let container = parent.selectAll(`:scope > svg.${cls}`).data([0]);\n container = container\n .enter()\n // First child: beneath the scene, which the renderer paints after it.\n .insert(\"svg\", \":first-child\")\n .attr(\"class\", cls)\n .attr(\"opacity\", 0)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top)\n .style(\"background-color\", bg)\n .merge(container);\n viz._container = container;\n\n container\n .transition()\n .duration(duration)\n .attr(\"opacity\", 1)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"x\", viz._margin.left)\n .attr(\"y\", viz._margin.top);\n\n if (kind === \"generic\") {\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n } else if (kind === \"network\") {\n // Hit-area for \"click outside any node\" → reset focus + zoom.\n const hitArea = container.selectAll(`rect.${cls}-hitArea`).data([0]);\n hitArea\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-hitArea`)\n .merge(hitArea)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", \"transparent\")\n .on(\"click\", () => {\n if (viz._focus) {\n viz.active!(false);\n viz._focus = undefined;\n viz._zoomToBounds!(null);\n }\n });\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n } else {\n // Geomap also needs an ocean rect (under tiles + paths) and the tile\n // group that `_renderTiles` mutates with map imagery.\n const oceanRect = container.selectAll(`rect.${cls}-ocean`).data([0]);\n oceanRect\n .enter()\n .append(\"rect\")\n .attr(\"class\", `${cls}-ocean`)\n .merge(oceanRect)\n .attr(\"width\", width)\n .attr(\"height\", height)\n .attr(\"fill\", ocean || \"transparent\");\n\n let tileGroup = container.selectAll(`g.${cls}-tileGroup`).data([0]);\n tileGroup = tileGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-tileGroup`)\n .merge(tileGroup);\n viz._tileGroup = tileGroup;\n\n let zoomGroup = container.selectAll(`g.${cls}-zoomGroup`).data([0]);\n zoomGroup = zoomGroup\n .enter()\n .append(\"g\")\n .attr(\"class\", `${cls}-zoomGroup`)\n .merge(zoomGroup);\n viz._zoomGroup = zoomGroup;\n }\n}\n"],"names":["select","hostElement","viz","host","_select","node","parentNode","HTMLElement","zoomDomParent","kind","_renderer","_ssr","style","isolation","underlay","selectAll","data","enter","insert","attr","merge","schema","width","height","removeTileUnderlay","querySelector","remove","ensureZoomDom","opts","duration","ocean","cls","bg","parent","existing","_container","classed","insertBefore","firstChild","container","_margin","left","top","transition","zoomGroup","append","_zoomGroup","hitArea","on","_focus","active","undefined","_zoomToBounds","oceanRect","tileGroup","_tileGroup"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,GAEA,SAAQA,MAAM,QAAO,eAAe;AAuBpC,gFAAgF,GAChF,SAASC,YAAYC,GAAQ;;QAChBA,mBAAAA;IAAX,IAAIC,gBAAOD,eAAAA,IAAIE,OAAO,cAAXF,oCAAAA,oBAAAA,aAAaG,IAAI,gBAAjBH,wCAAAA,kBAAqBI,UAAU,uCAAI;IAC9C,MAAOH,QAAQ,CAAEA,AAAI,YAAJA,MAAgBI,aAAcJ,OAAOA,KAAKG,UAAU;IACrE,OAAOH,AAAI,YAAJA,MAAgBI,eAAcJ,OAAO;AAC9C;AAEA;;;;;;AAMA,GACA,SAASK,cAAcN,GAAQ,EAAEO,IAAiB;IAChD,IAAMN,OAAOM,SAAS,YAAYP,IAAIQ,SAAS,KAAK,YAAY,CAACR,IAAIS,IAAI,GAAGV,YAAYC,OAAO;IAC/F,IAAI,CAACC,MAAM,OAAOD,IAAIE,OAAO;IAC7B,mEAAmE;IACnE,wEAAwE;IACxE,6BAA6B;IAC7BD,KAAKS,KAAK,CAACC,SAAS,GAAG;IACvB,IAAMC,WAAWd,OAAOG,MAAMY,SAAS,CAAwB,uCAAuCC,IAAI,CAAC;QAAC;KAAE;IAC9G,OAAOF,SACJG,KAAK,GACLC,MAAM,CAAC,OAAO,gBACdC,IAAI,CAAC,SAAS,0BACdP,KAAK,CAAC,YAAY,YAClBA,KAAK,CAAC,OAAO,KACbA,KAAK,CAAC,QAAQ,KACdA,KAAK,CAAC,WAAW,MACjBA,KAAK,CAAC,YAAY,UAClBA,KAAK,CAAC,kBAAkB,QACxBQ,KAAK,CAACN,UACNK,IAAI,CAAC,SAASjB,IAAImB,MAAM,CAACC,KAAK,EAC9BH,IAAI,CA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