@d3plus/core 4.5.0 → 4.7.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 (312) hide show
  1. package/README.md +3930 -2032
  2. package/es/index.js +3 -3
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +11 -1
  5. package/es/internal.js.map +1 -1
  6. package/es/src/charts/BarChart/index.js +8 -1
  7. package/es/src/charts/BarChart/index.js.map +1 -1
  8. package/es/src/charts/BoxWhisker/index.js +5 -0
  9. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  10. package/es/src/charts/Chord/emit.js +55 -3
  11. package/es/src/charts/Chord/emit.js.map +1 -1
  12. package/es/src/charts/Chord/index.js +17 -0
  13. package/es/src/charts/Chord/index.js.map +1 -1
  14. package/es/src/charts/Geomap/applyLayout.js +20 -11
  15. package/es/src/charts/Geomap/applyLayout.js.map +1 -1
  16. package/es/src/charts/Geomap/index.js +8 -2
  17. package/es/src/charts/Geomap/index.js.map +1 -1
  18. package/es/src/charts/Histogram/binData.js +225 -0
  19. package/es/src/charts/Histogram/binData.js.map +1 -0
  20. package/es/src/charts/Histogram/index.js +271 -0
  21. package/es/src/charts/Histogram/index.js.map +1 -0
  22. package/es/src/charts/Matrix/emit.js +5 -4
  23. package/es/src/charts/Matrix/emit.js.map +1 -1
  24. package/es/src/charts/Network/applyLayout.js +52 -4
  25. package/es/src/charts/Network/applyLayout.js.map +1 -1
  26. package/es/src/charts/Network/emit.js +4 -4
  27. package/es/src/charts/Network/emit.js.map +1 -1
  28. package/es/src/charts/Network/index.js +10 -1
  29. package/es/src/charts/Network/index.js.map +1 -1
  30. package/es/src/charts/Pack/emit.js +42 -7
  31. package/es/src/charts/Pack/emit.js.map +1 -1
  32. package/es/src/charts/Pack/index.js +15 -0
  33. package/es/src/charts/Pack/index.js.map +1 -1
  34. package/es/src/charts/Pie/applyLayout.js +20 -2
  35. package/es/src/charts/Pie/applyLayout.js.map +1 -1
  36. package/es/src/charts/Pie/emit.js +275 -35
  37. package/es/src/charts/Pie/emit.js.map +1 -1
  38. package/es/src/charts/Pie/index.js +48 -1
  39. package/es/src/charts/Pie/index.js.map +1 -1
  40. package/es/src/charts/Plot/discreteSpan.js +42 -0
  41. package/es/src/charts/Plot/discreteSpan.js.map +1 -0
  42. package/es/src/charts/Plot/draw.js +3 -1
  43. package/es/src/charts/Plot/draw.js.map +1 -1
  44. package/es/src/charts/Plot/index.js +143 -14
  45. package/es/src/charts/Plot/index.js.map +1 -1
  46. package/es/src/charts/Plot/insetRegion.js +21 -0
  47. package/es/src/charts/Plot/insetRegion.js.map +1 -0
  48. package/es/src/charts/Plot/pipeline.js +47 -20
  49. package/es/src/charts/Plot/pipeline.js.map +1 -1
  50. package/es/src/charts/Plot/pipelineDomains.js +84 -8
  51. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  52. package/es/src/charts/Plot/shapeDefaults.js +3 -3
  53. package/es/src/charts/Plot/shapeDefaults.js.map +1 -1
  54. package/es/src/charts/Plot/sharedHover.js +532 -0
  55. package/es/src/charts/Plot/sharedHover.js.map +1 -0
  56. package/es/src/charts/Plot/sharedHoverScene.js +230 -0
  57. package/es/src/charts/Plot/sharedHoverScene.js.map +1 -0
  58. package/es/src/charts/Plot/sharedTooltip.js +183 -0
  59. package/es/src/charts/Plot/sharedTooltip.js.map +1 -0
  60. package/es/src/charts/Plot/stackShareLabels.js +137 -0
  61. package/es/src/charts/Plot/stackShareLabels.js.map +1 -0
  62. package/es/src/charts/Plot/stackShareTooltip.js +31 -0
  63. package/es/src/charts/Plot/stackShareTooltip.js.map +1 -0
  64. package/es/src/charts/Plot/trendLines.js +469 -0
  65. package/es/src/charts/Plot/trendLines.js.map +1 -0
  66. package/es/src/charts/Plot/trendProjection.js +120 -0
  67. package/es/src/charts/Plot/trendProjection.js.map +1 -0
  68. package/es/src/charts/Plot/trendScene.js +234 -0
  69. package/es/src/charts/Plot/trendScene.js.map +1 -0
  70. package/es/src/charts/Plot/trendTooltip.js +222 -0
  71. package/es/src/charts/Plot/trendTooltip.js.map +1 -0
  72. package/es/src/charts/Priestley/emit.js +34 -6
  73. package/es/src/charts/Priestley/emit.js.map +1 -1
  74. package/es/src/charts/Radar/index.js +15 -2
  75. package/es/src/charts/Radar/index.js.map +1 -1
  76. package/es/src/charts/RadialMatrix/emit.js +4 -4
  77. package/es/src/charts/RadialMatrix/emit.js.map +1 -1
  78. package/es/src/charts/RadialMatrix/index.js +17 -1
  79. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  80. package/es/src/charts/Rings/applyLayout.js +72 -116
  81. package/es/src/charts/Rings/applyLayout.js.map +1 -1
  82. package/es/src/charts/Rings/emit.js +2 -3
  83. package/es/src/charts/Rings/emit.js.map +1 -1
  84. package/es/src/charts/Rings/index.js +18 -3
  85. package/es/src/charts/Rings/index.js.map +1 -1
  86. package/es/src/charts/Rings/ringsSizing.js +189 -0
  87. package/es/src/charts/Rings/ringsSizing.js.map +1 -0
  88. package/es/src/charts/Sankey/index.js +2 -0
  89. package/es/src/charts/Sankey/index.js.map +1 -1
  90. package/es/src/charts/StackedArea/index.js +8 -1
  91. package/es/src/charts/StackedArea/index.js.map +1 -1
  92. package/es/src/charts/Tree/emit.js +2 -2
  93. package/es/src/charts/Tree/emit.js.map +1 -1
  94. package/es/src/charts/Tree/index.js +7 -3
  95. package/es/src/charts/Tree/index.js.map +1 -1
  96. package/es/src/charts/Treemap/emit.js +58 -6
  97. package/es/src/charts/Treemap/emit.js.map +1 -1
  98. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  99. package/es/src/charts/definition/makeChart.js +14 -1
  100. package/es/src/charts/definition/makeChart.js.map +1 -1
  101. package/es/src/charts/drawSteps/backControl.js +17 -2
  102. package/es/src/charts/drawSteps/backControl.js.map +1 -1
  103. package/es/src/charts/drawSteps/bottomRightControls.js +196 -0
  104. package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -0
  105. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +292 -0
  106. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -0
  107. package/es/src/charts/drawSteps/minimap.js +34 -9
  108. package/es/src/charts/drawSteps/minimap.js.map +1 -1
  109. package/es/src/charts/drawSteps/searchControlsMarkup.js +15 -38
  110. package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -1
  111. package/es/src/charts/drawSteps/zoomControls.js +3 -0
  112. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  113. package/es/src/charts/events/click.legend.js +10 -5
  114. package/es/src/charts/events/click.legend.js.map +1 -1
  115. package/es/src/charts/events/click.shape.js +24 -1
  116. package/es/src/charts/events/click.shape.js.map +1 -1
  117. package/es/src/charts/events/mouseenter.js +3 -0
  118. package/es/src/charts/events/mouseenter.js.map +1 -1
  119. package/es/src/charts/events/mouseleave.js +3 -0
  120. package/es/src/charts/events/mouseleave.js.map +1 -1
  121. package/es/src/charts/events/mousemove.shape.js +10 -1
  122. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  123. package/es/src/charts/features/axes.js +4 -1
  124. package/es/src/charts/features/axes.js.map +1 -1
  125. package/es/src/charts/features/emitHelpers.js +43 -5
  126. package/es/src/charts/features/emitHelpers.js.map +1 -1
  127. package/es/src/charts/features/features.js +3 -104
  128. package/es/src/charts/features/features.js.map +1 -1
  129. package/es/src/charts/features/featuresColorScale.js +161 -0
  130. package/es/src/charts/features/featuresColorScale.js.map +1 -0
  131. package/es/src/charts/features/featuresLegend.js +155 -34
  132. package/es/src/charts/features/featuresLegend.js.map +1 -1
  133. package/es/src/charts/features/insetState.js +174 -0
  134. package/es/src/charts/features/insetState.js.map +1 -0
  135. package/es/src/charts/features/plotPaint.js +51 -24
  136. package/es/src/charts/features/plotPaint.js.map +1 -1
  137. package/es/src/charts/features/sceneBounds.js +271 -0
  138. package/es/src/charts/features/sceneBounds.js.map +1 -0
  139. package/es/src/charts/features/shapeEmit.js +20 -2
  140. package/es/src/charts/features/shapeEmit.js.map +1 -1
  141. package/es/src/charts/features/tooltipSwatch.js +73 -0
  142. package/es/src/charts/features/tooltipSwatch.js.map +1 -0
  143. package/es/src/charts/index.js +1 -0
  144. package/es/src/charts/index.js.map +1 -1
  145. package/es/src/charts/pipeline/drillMorph.js +159 -0
  146. package/es/src/charts/pipeline/drillMorph.js.map +1 -0
  147. package/es/src/charts/pipeline/insetPlacement.js +406 -0
  148. package/es/src/charts/pipeline/insetPlacement.js.map +1 -0
  149. package/es/src/charts/pipeline/runChartDraw.js +35 -1
  150. package/es/src/charts/pipeline/runChartDraw.js.map +1 -1
  151. package/es/src/charts/pipeline/runVizPipeline.js +22 -3
  152. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  153. package/es/src/charts/pipeline/vizDrawPure.js +20 -0
  154. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -1
  155. package/es/src/charts/viz/Viz.js +82 -11
  156. package/es/src/charts/viz/Viz.js.map +1 -1
  157. package/es/src/charts/viz/VizBase.js +29 -1
  158. package/es/src/charts/viz/VizBase.js.map +1 -1
  159. package/es/src/charts/viz/VizBaseConfig.js +25 -21
  160. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  161. package/es/src/charts/viz/interactionOpacity.js +21 -13
  162. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  163. package/es/src/charts/viz/linkGroup.js +386 -0
  164. package/es/src/charts/viz/linkGroup.js.map +1 -0
  165. package/es/src/charts/viz/ordinalColor.js +2 -2
  166. package/es/src/charts/viz/ordinalColor.js.map +1 -1
  167. package/es/src/charts/viz/sceneRows.js +33 -0
  168. package/es/src/charts/viz/sceneRows.js.map +1 -0
  169. package/es/src/charts/viz/vizDefaults.js +39 -15
  170. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  171. package/es/src/charts/viz/vizRender.js +54 -4
  172. package/es/src/charts/viz/vizRender.js.map +1 -1
  173. package/es/src/charts/viz/vizTypes.js.map +1 -1
  174. package/es/src/charts/viz/vizVisibility.js +145 -0
  175. package/es/src/charts/viz/vizVisibility.js.map +1 -0
  176. package/es/src/components/Axis/Axis.js +8 -8
  177. package/es/src/components/Axis/Axis.js.map +1 -1
  178. package/es/src/components/Axis/AxisBottom.js +1 -1
  179. package/es/src/components/Axis/AxisBottom.js.map +1 -1
  180. package/es/src/components/Axis/AxisLeft.js +1 -1
  181. package/es/src/components/Axis/AxisLeft.js.map +1 -1
  182. package/es/src/components/Axis/AxisRight.js +1 -1
  183. package/es/src/components/Axis/AxisRight.js.map +1 -1
  184. package/es/src/components/Axis/AxisTop.js +1 -1
  185. package/es/src/components/Axis/AxisTop.js.map +1 -1
  186. package/es/src/components/Axis/axisLayoutLabels.js +13 -1
  187. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  188. package/es/src/components/ColorScale/ColorScale.js +11 -11
  189. package/es/src/components/ColorScale/ColorScale.js.map +1 -1
  190. package/es/src/components/ColorScale/colorScaleScale.js +22 -10
  191. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -1
  192. package/es/src/components/Legend/Legend.js +8 -5
  193. package/es/src/components/Legend/Legend.js.map +1 -1
  194. package/es/src/components/Legend/legendConfig.js +3 -2
  195. package/es/src/components/Legend/legendConfig.js.map +1 -1
  196. package/es/src/components/Legend/legendRender.js +70 -26
  197. package/es/src/components/Legend/legendRender.js.map +1 -1
  198. package/es/src/components/SizeLegend/SizeLegend.js +411 -0
  199. package/es/src/components/SizeLegend/SizeLegend.js.map +1 -0
  200. package/es/src/components/SizeLegend/sizeLegendLayout.js +285 -0
  201. package/es/src/components/SizeLegend/sizeLegendLayout.js.map +1 -0
  202. package/es/src/components/TextBox.js +1 -1
  203. package/es/src/components/TextBox.js.map +1 -1
  204. package/es/src/components/Timeline/timelineConfig.js +8 -4
  205. package/es/src/components/Timeline/timelineConfig.js.map +1 -1
  206. package/es/src/components/Timeline/timelineRender.js +1 -2
  207. package/es/src/components/Timeline/timelineRender.js.map +1 -1
  208. package/es/src/components/Tooltip.js +27 -7
  209. package/es/src/components/Tooltip.js.map +1 -1
  210. package/es/src/components/index.js +1 -0
  211. package/es/src/components/index.js.map +1 -1
  212. package/es/src/shapes/Bar.js +1 -1
  213. package/es/src/shapes/Bar.js.map +1 -1
  214. package/es/src/shapes/Box.js +5 -3
  215. package/es/src/shapes/Box.js.map +1 -1
  216. package/es/src/shapes/Rect.js +1 -1
  217. package/es/src/shapes/Rect.js.map +1 -1
  218. package/es/src/shapes/Shape.js +10 -37
  219. package/es/src/shapes/Shape.js.map +1 -1
  220. package/es/src/shapes/Whisker.js +4 -3
  221. package/es/src/shapes/Whisker.js.map +1 -1
  222. package/es/src/shapes/textureKey.js +104 -0
  223. package/es/src/shapes/textureKey.js.map +1 -0
  224. package/es/src/shapes/validateShapeConfig.js +141 -0
  225. package/es/src/shapes/validateShapeConfig.js.map +1 -0
  226. package/es/src/utils/BaseClass.js +134 -4
  227. package/es/src/utils/BaseClass.js.map +1 -1
  228. package/es/src/utils/D3plusConfig.js.map +1 -1
  229. package/es/src/utils/configDefault.js +17 -0
  230. package/es/src/utils/configDefault.js.map +1 -0
  231. package/es/src/utils/configPrep.js +2 -1
  232. package/es/src/utils/configPrep.js.map +1 -1
  233. package/es/src/utils/configWarnings.js +37 -0
  234. package/es/src/utils/configWarnings.js.map +1 -0
  235. package/es/src/utils/index.js +1 -0
  236. package/es/src/utils/index.js.map +1 -1
  237. package/package.json +12 -10
  238. package/types/index.d.ts +5 -4
  239. package/types/internal.d.ts +15 -1
  240. package/types/src/charts/BarChart/index.d.ts +2 -1
  241. package/types/src/charts/Geomap/applyLayout.d.ts +9 -1
  242. package/types/src/charts/Histogram/binData.d.ts +37 -0
  243. package/types/src/charts/Histogram/index.d.ts +14 -0
  244. package/types/src/charts/Network/applyLayout.d.ts +8 -0
  245. package/types/src/charts/Plot/discreteSpan.d.ts +9 -0
  246. package/types/src/charts/Plot/index.d.ts +47 -0
  247. package/types/src/charts/Plot/insetRegion.d.ts +4 -0
  248. package/types/src/charts/Plot/pipeline.d.ts +14 -0
  249. package/types/src/charts/Plot/sharedHover.d.ts +84 -0
  250. package/types/src/charts/Plot/sharedHoverScene.d.ts +11 -0
  251. package/types/src/charts/Plot/sharedTooltip.d.ts +36 -0
  252. package/types/src/charts/Plot/stackShareLabels.d.ts +21 -0
  253. package/types/src/charts/Plot/stackShareTooltip.d.ts +9 -0
  254. package/types/src/charts/Plot/trendLines.d.ts +90 -0
  255. package/types/src/charts/Plot/trendProjection.d.ts +28 -0
  256. package/types/src/charts/Plot/trendScene.d.ts +19 -0
  257. package/types/src/charts/Plot/trendTooltip.d.ts +30 -0
  258. package/types/src/charts/Rings/applyLayout.d.ts +9 -0
  259. package/types/src/charts/Rings/ringsSizing.d.ts +49 -0
  260. package/types/src/charts/StackedArea/index.d.ts +2 -1
  261. package/types/src/charts/definition/ChartDefinition.d.ts +39 -0
  262. package/types/src/charts/definition/makeChart.d.ts +2 -1
  263. package/types/src/charts/drawSteps/bottomRightControls.d.ts +26 -0
  264. package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +110 -0
  265. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +7 -5
  266. package/types/src/charts/features/emitHelpers.d.ts +18 -4
  267. package/types/src/charts/features/features.d.ts +1 -8
  268. package/types/src/charts/features/featuresColorScale.d.ts +24 -0
  269. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  270. package/types/src/charts/features/insetState.d.ts +95 -0
  271. package/types/src/charts/features/plotPaint.d.ts +25 -0
  272. package/types/src/charts/features/sceneBounds.d.ts +18 -0
  273. package/types/src/charts/features/tooltipSwatch.d.ts +31 -0
  274. package/types/src/charts/index.d.ts +1 -0
  275. package/types/src/charts/pipeline/drillMorph.d.ts +29 -0
  276. package/types/src/charts/pipeline/insetPlacement.d.ts +45 -0
  277. package/types/src/charts/pipeline/runVizPipeline.d.ts +10 -1
  278. package/types/src/charts/viz/Viz.d.ts +27 -2
  279. package/types/src/charts/viz/VizBase.d.ts +13 -0
  280. package/types/src/charts/viz/VizBaseConfig.d.ts +11 -11
  281. package/types/src/charts/viz/linkGroup.d.ts +96 -0
  282. package/types/src/charts/viz/sceneRows.d.ts +13 -0
  283. package/types/src/charts/viz/vizTypes.d.ts +164 -3
  284. package/types/src/charts/viz/vizVisibility.d.ts +34 -0
  285. package/types/src/components/Axis/AxisBottom.d.ts +1 -1
  286. package/types/src/components/Axis/AxisLeft.d.ts +1 -1
  287. package/types/src/components/Axis/AxisRight.d.ts +1 -1
  288. package/types/src/components/Axis/AxisTop.d.ts +1 -1
  289. package/types/src/components/ColorScale/ColorScale.d.ts +4 -4
  290. package/types/src/components/Legend/legendRender.d.ts +9 -3
  291. package/types/src/components/SizeLegend/SizeLegend.d.ts +107 -0
  292. package/types/src/components/SizeLegend/sizeLegendLayout.d.ts +101 -0
  293. package/types/src/components/TextBox.d.ts +1 -1
  294. package/types/src/components/Tooltip.d.ts +18 -3
  295. package/types/src/components/index.d.ts +1 -0
  296. package/types/src/shapes/Bar.d.ts +1 -1
  297. package/types/src/shapes/Box.d.ts +1 -1
  298. package/types/src/shapes/Rect.d.ts +1 -1
  299. package/types/src/shapes/Whisker.d.ts +1 -1
  300. package/types/src/shapes/textureKey.d.ts +9 -0
  301. package/types/src/shapes/validateShapeConfig.d.ts +10 -0
  302. package/types/src/utils/BaseClass.d.ts +15 -1
  303. package/types/src/utils/D3plusConfig.d.ts +139 -0
  304. package/types/src/utils/configDefault.d.ts +11 -0
  305. package/types/src/utils/configWarnings.d.ts +28 -0
  306. package/types/src/utils/index.d.ts +2 -1
  307. package/umd/d3plus-core.full.js +9325 -3024
  308. package/umd/d3plus-core.full.js.map +1 -1
  309. package/umd/d3plus-core.full.min.js +3348 -1727
  310. package/umd/d3plus-core.js +5412 -831
  311. package/umd/d3plus-core.js.map +1 -1
  312. package/umd/d3plus-core.min.js +2199 -948
@@ -0,0 +1,406 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ function _type_of(obj) {
30
+ "@swc/helpers - typeof";
31
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
32
+ }
33
+ /**
34
+ Draws one piece of chart chrome — the size legend, else the legend, else
35
+ the colorScale — inside the chart's negative space instead of in a
36
+ margin, when the chart offers a region (`ChartDefinition.insetRegion`)
37
+ and `legendInset` is on.
38
+
39
+ Placement needs the chart's laid-out marks, but chrome normally claims
40
+ its margin before the chart lays out, so the draw runs optimistically:
41
+ 1. Every candidate skips its margin claim, and the chart lays out in
42
+ the full area.
43
+ 2. The open space around the marks (`negativeSpace`) is searched for
44
+ the first candidate, in priority order, that fits.
45
+ 3. If one fits and nothing else is waiting on a margin, that draw
46
+ stands. If other candidates are showing, the chart lays out again
47
+ with them back in their margins, and the winner is fitted again in
48
+ the (smaller) chart. When nothing fits, the chart lays out normally.
49
+
50
+ @module
51
+ */ import { negativeSpace } from "@d3plus/math";
52
+ import { chartBounds } from "../features/chartGeometry.js";
53
+ import { paintColorScaleInset } from "../features/featuresColorScale.js";
54
+ import { buildLegendData, paintLegendInset } from "../features/featuresLegend.js";
55
+ import { sanitizePosition } from "../features/features.js";
56
+ import { markBoxes } from "../features/sceneBounds.js";
57
+ import { INSET_PRIORITY, insetFrame, insetStyle } from "../features/insetState.js";
58
+ import { bottomRightControlsBox } from "../drawSteps/bottomRightControlsMarkup.js";
59
+ import { MINIMAP_RIGHT_INSET } from "../drawSteps/minimapMarkup.js";
60
+ import { getTopLeftContributions } from "../drawSteps/topLeftControls.js";
61
+ import { topLeftControlsBox } from "../drawSteps/topLeftControlsMarkup.js";
62
+ import { zoomControlsBox } from "../drawSteps/zoomControlsMarkup.js";
63
+ import { resolveSpec } from "./resolveSpec.js";
64
+ /**
65
+ The default inset region: the chart area (or `bounds`, in surface
66
+ coordinates), with the boxes of every data mark in the chart's scene as
67
+ obstacles (less any subtree `skip` excludes). Charts opt in by returning
68
+ this from their `insetRegion`.
69
+ */ export function sceneInsetRegion(viz, bounds, skip) {
70
+ var _chartBounds = chartBounds(viz), width = _chartBounds.width, height = _chartBounds.height;
71
+ return {
72
+ bounds: bounds !== null && bounds !== void 0 ? bounds : {
73
+ x: viz._margin.left,
74
+ y: viz._margin.top,
75
+ width: width,
76
+ height: height
77
+ },
78
+ obstacles: markBoxes(viz._chartScene || [], viz._chartTransform, skip)
79
+ };
80
+ }
81
+ /** Whether `legendInset` is on for this draw. */ function insetEnabled(viz) {
82
+ var flag = viz.schema.legendInset;
83
+ return typeof flag === "function" ? Boolean(flag.bind(viz)(resolveSpec(viz))) : Boolean(flag);
84
+ }
85
+ /** The smallest a legend entry can be: a swatch (1.4× the 12px label font) plus its padding. */ var MIN_LEGEND_ENTRY = 12 * 1.4 + 5;
86
+ /**
87
+ Whether the legend could possibly lay out inside the chart: its entries,
88
+ even with their labels dropped, must fit the largest frame an inset
89
+ legend may take (see `insetFrame`). Rules out laying out a legend of
90
+ hundreds of entries just to find it doesn't fit.
91
+ */ function legendCouldFit(viz) {
92
+ var frame = insetFrame("column", {
93
+ width: viz.schema.width || 0,
94
+ height: viz.schema.height || 0
95
+ });
96
+ var entries = buildLegendData(viz).legendData.length;
97
+ return entries * MIN_LEGEND_ENTRY * MIN_LEGEND_ENTRY <= frame.width * frame.height;
98
+ }
99
+ /**
100
+ The candidates this draw may place inside the chart, in priority order.
101
+ A legend or colorScale whose position the user set explicitly stays
102
+ where they put it.
103
+ */ function insetCandidates(viz) {
104
+ var auto = viz._insetAutoPositions;
105
+ return INSET_PRIORITY.filter(function(key) {
106
+ if (key === "legend") return (!auto || viz.schema.legendPosition === auto.legend) && legendCouldFit(viz);
107
+ if (key === "colorScale") return !auto || viz.schema.colorScalePosition === auto.colorScale;
108
+ return true;
109
+ });
110
+ }
111
+ /** The orientations a candidate may take inside the chart. */ var ORIENTS = {
112
+ sizeLegend: [
113
+ "column"
114
+ ],
115
+ legend: [
116
+ "column",
117
+ "row"
118
+ ],
119
+ colorScale: [
120
+ "column",
121
+ "row"
122
+ ]
123
+ };
124
+ /** Whether a candidate laid out for the chart's interior this pass is showing at all. */ function isShowing(viz, key) {
125
+ var _bottomRightControlsBox, _viz__legendClass__data, _viz__legendClass;
126
+ if (key === "sizeLegend") return Boolean((_bottomRightControlsBox = bottomRightControlsBox(viz)) === null || _bottomRightControlsBox === void 0 ? void 0 : _bottomRightControlsBox.inset);
127
+ if (key === "legend") return Boolean((_viz__legendClass = viz._legendClass) === null || _viz__legendClass === void 0 ? void 0 : (_viz__legendClass__data = _viz__legendClass._data) === null || _viz__legendClass__data === void 0 ? void 0 : _viz__legendClass__data.length);
128
+ return Boolean(viz.schema.colorScale) && sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz))) !== false && !viz.schema.colorScaleConfig.select;
129
+ }
130
+ /**
131
+ Lays a showing candidate out for the chart's interior in `orient` and
132
+ returns its content size, or null when it can't lay out that way.
133
+ */ function measure(viz, key, orient, area) {
134
+ if (key === "sizeLegend") {
135
+ var box = bottomRightControlsBox(viz);
136
+ return box ? {
137
+ width: box.width,
138
+ height: box.height
139
+ } : null;
140
+ }
141
+ return key === "legend" ? paintLegendInset(viz, orient, area) : paintColorScaleInset(viz, orient, area);
142
+ }
143
+ /** The chart corners an inset box is tried in, most preferred first. */ var CORNERS = [
144
+ {
145
+ alignX: "right",
146
+ alignY: "bottom"
147
+ },
148
+ {
149
+ alignX: "right",
150
+ alignY: "top"
151
+ },
152
+ {
153
+ alignX: "left",
154
+ alignY: "bottom"
155
+ },
156
+ {
157
+ alignX: "left",
158
+ alignY: "top"
159
+ }
160
+ ];
161
+ /**
162
+ Where a box of `width` × `height` sits in the open rects (sorted largest
163
+ first): in the first chart corner, in `CORNERS` order, that some rect
164
+ reaching that corner has room for. When it fits in no corner, it goes in
165
+ the first rect it fits, against whichever of the rect's sides lie on the
166
+ region's edges (bottom-right when it touches both), centered along an
167
+ axis otherwise.
168
+ */ export function fitInset(rects, bounds, width, height) {
169
+ var eps = 0.5;
170
+ var fits = rects.filter(function(r) {
171
+ return r.width >= width && r.height >= height;
172
+ });
173
+ if (!fits.length) return null;
174
+ var edges = function edges(r) {
175
+ return {
176
+ right: Math.abs(r.x + r.width - (bounds.x + bounds.width)) < eps,
177
+ left: Math.abs(r.x - bounds.x) < eps,
178
+ bottom: Math.abs(r.y + r.height - (bounds.y + bounds.height)) < eps,
179
+ top: Math.abs(r.y - bounds.y) < eps
180
+ };
181
+ };
182
+ var place = function place(r, alignX, alignY) {
183
+ return {
184
+ x: alignX === "right" ? r.x + r.width - width : alignX === "left" ? r.x : r.x + (r.width - width) / 2,
185
+ y: alignY === "bottom" ? r.y + r.height - height : alignY === "top" ? r.y : r.y + (r.height - height) / 2,
186
+ width: width,
187
+ height: height,
188
+ alignX: alignX,
189
+ alignY: alignY
190
+ };
191
+ };
192
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
193
+ try {
194
+ var _loop = function() {
195
+ var _step_value = _step.value, alignX = _step_value.alignX, alignY = _step_value.alignY;
196
+ var rect = fits.find(function(r) {
197
+ var e = edges(r);
198
+ return e[alignX] && e[alignY];
199
+ });
200
+ if (rect) return {
201
+ v: place(rect, alignX, alignY)
202
+ };
203
+ };
204
+ for(var _iterator = CORNERS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
205
+ var _ret = _loop();
206
+ if (_type_of(_ret) === "object") return _ret.v;
207
+ }
208
+ } catch (err) {
209
+ _didIteratorError = true;
210
+ _iteratorError = err;
211
+ } finally{
212
+ try {
213
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
214
+ _iterator.return();
215
+ }
216
+ } finally{
217
+ if (_didIteratorError) {
218
+ throw _iteratorError;
219
+ }
220
+ }
221
+ }
222
+ var rect = fits[0], e = edges(rect);
223
+ return place(rect, e.right ? "right" : e.left ? "left" : "center", e.bottom ? "bottom" : e.top ? "top" : "middle");
224
+ }
225
+ /** Rough height of the attribution credit, a single line of small text. */ var ATTRIBUTION_HEIGHT = 22;
226
+ /**
227
+ Boxes of the chrome overlaid on the chart that inset chrome must also
228
+ stay clear of: the zoom buttons (and the minimap that opens beneath
229
+ them once zoomed), the top-left controls, and the attribution credit in
230
+ the chart area's bottom-right corner (sized from its rendered node when
231
+ there is one, otherwise from its text, up to the half of the chart it
232
+ may span before collapsing to a badge).
233
+ */ function chromeBoxes(viz) {
234
+ var boxes = [];
235
+ var _chartBounds = chartBounds(viz), width = _chartBounds.width, height = _chartBounds.height;
236
+ var zoom = zoomControlsBox(viz);
237
+ if (zoom) {
238
+ var minimap = viz.schema.minimap ? (zoom.width - MINIMAP_RIGHT_INSET) * (height / Math.max(1, width)) : 0;
239
+ boxes.push({
240
+ x: viz.schema.width - zoom.width,
241
+ y: 0,
242
+ width: zoom.width,
243
+ height: zoom.height + minimap
244
+ });
245
+ }
246
+ var topLeft = topLeftControlsBox(viz, getTopLeftContributions(viz));
247
+ if (topLeft) boxes.push({
248
+ x: 0,
249
+ y: 0,
250
+ width: topLeft.width,
251
+ height: topLeft.height
252
+ });
253
+ if (viz.schema.attribution) {
254
+ var _viz__select_node, _viz__select_node1, _viz__select, _parent_querySelector;
255
+ var parent = (_viz__select = viz._select) === null || _viz__select === void 0 ? void 0 : (_viz__select_node1 = _viz__select.node) === null || _viz__select_node1 === void 0 ? void 0 : (_viz__select_node = _viz__select_node1.call(_viz__select)) === null || _viz__select_node === void 0 ? void 0 : _viz__select_node.parentNode;
256
+ var node = parent === null || parent === void 0 ? void 0 : (_parent_querySelector = parent.querySelector) === null || _parent_querySelector === void 0 ? void 0 : _parent_querySelector.call(parent, "div.d3plus-attribution");
257
+ var text = String(viz.schema.attribution).replace(/<[^>]*>/g, "");
258
+ var w = Math.min((node === null || node === void 0 ? void 0 : node.offsetWidth) || text.length * 6 + 30, width / 2);
259
+ var h = (node === null || node === void 0 ? void 0 : node.offsetHeight) || ATTRIBUTION_HEIGHT;
260
+ var right = viz.schema.width - viz._margin.right, bottom = viz.schema.height - viz._margin.bottom;
261
+ boxes.push({
262
+ x: right - w,
263
+ y: bottom - h,
264
+ width: w,
265
+ height: h
266
+ });
267
+ }
268
+ return boxes;
269
+ }
270
+ /** The open rects in the chart's region, kept `padding` clear of the marks and the region's edges. */ function openSpace(viz) {
271
+ var _viz__insetRegion;
272
+ var region = (_viz__insetRegion = viz._insetRegion) === null || _viz__insetRegion === void 0 ? void 0 : _viz__insetRegion.call(viz);
273
+ if (!region) return null;
274
+ var padding = insetStyle(viz).padding;
275
+ var b = region.bounds;
276
+ var bounds = {
277
+ x: b.x + padding,
278
+ y: b.y + padding,
279
+ width: b.width - padding * 2,
280
+ height: b.height - padding * 2
281
+ };
282
+ if (bounds.width <= 0 || bounds.height <= 0) return null;
283
+ var exclude = chromeBoxes(viz);
284
+ return {
285
+ rects: negativeSpace(bounds, region.obstacles, {
286
+ padding: padding,
287
+ exclude: exclude
288
+ }),
289
+ bounds: bounds,
290
+ area: b
291
+ };
292
+ }
293
+ /**
294
+ Fits the first of `keys` that has room inside the chart. Returns the
295
+ placement (or null) and which candidates are showing at all.
296
+ */ function choose(viz, keys) {
297
+ var showing = keys.filter(function(key) {
298
+ return isShowing(viz, key);
299
+ });
300
+ var space = showing.length ? openSpace(viz) : null;
301
+ if (!space || !space.rects.length) return {
302
+ placement: null,
303
+ showing: showing
304
+ };
305
+ var margin = insetStyle(viz).margin;
306
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
307
+ try {
308
+ for(var _iterator = showing[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
309
+ var key = _step.value;
310
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
311
+ try {
312
+ for(var _iterator1 = ORIENTS[key][Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
313
+ var orient = _step1.value;
314
+ var size = measure(viz, key, orient, space.area);
315
+ var spot = size && fitInset(space.rects, space.bounds, size.width + margin * 2, size.height + margin * 2);
316
+ if (spot) {
317
+ return {
318
+ placement: _object_spread({
319
+ key: key,
320
+ orient: orient
321
+ }, spot),
322
+ showing: showing
323
+ };
324
+ }
325
+ }
326
+ } catch (err) {
327
+ _didIteratorError1 = true;
328
+ _iteratorError1 = err;
329
+ } finally{
330
+ try {
331
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
332
+ _iterator1.return();
333
+ }
334
+ } finally{
335
+ if (_didIteratorError1) {
336
+ throw _iteratorError1;
337
+ }
338
+ }
339
+ }
340
+ }
341
+ } catch (err) {
342
+ _didIteratorError = true;
343
+ _iteratorError = err;
344
+ } finally{
345
+ try {
346
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
347
+ _iterator.return();
348
+ }
349
+ } finally{
350
+ if (_didIteratorError) {
351
+ throw _iteratorError;
352
+ }
353
+ }
354
+ }
355
+ return {
356
+ placement: null,
357
+ showing: showing
358
+ };
359
+ }
360
+ /** Runs `_draw()` again from the margins the render started with. */ function redraw(viz, start) {
361
+ viz._margin = _object_spread({}, start.margin);
362
+ viz._padding = _object_spread({}, start.padding);
363
+ viz._draw();
364
+ }
365
+ /**
366
+ `viz._draw()`, placing chrome inside the chart's negative space when it
367
+ fits (see the module docs). Leaves `viz._insetPlacement` set to what was
368
+ placed, or null.
369
+ */ export function drawWithInset(viz) {
370
+ viz._insetPlacement = null;
371
+ var keys = typeof viz._insetRegion === "function" && insetEnabled(viz) ? insetCandidates(viz) : [];
372
+ if (!keys.length) {
373
+ viz._insetPending = null;
374
+ viz._draw();
375
+ return;
376
+ }
377
+ var start = {
378
+ margin: _object_spread({}, viz._margin),
379
+ padding: _object_spread({}, viz._padding)
380
+ };
381
+ viz._insetPending = new Set(keys);
382
+ viz._draw();
383
+ var first = choose(viz, keys);
384
+ var showing = first.showing;
385
+ var placement = first.placement;
386
+ if (!showing.length) return;
387
+ if (placement && showing.some(function(k) {
388
+ return k !== placement.key;
389
+ })) {
390
+ viz._insetPending = new Set([
391
+ placement.key
392
+ ]);
393
+ redraw(viz, start);
394
+ placement = choose(viz, [
395
+ placement.key
396
+ ]).placement;
397
+ }
398
+ if (!placement) {
399
+ viz._insetPending = new Set();
400
+ redraw(viz, start);
401
+ return;
402
+ }
403
+ viz._insetPlacement = placement;
404
+ }
405
+
406
+ //# sourceMappingURL=insetPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/pipeline/insetPlacement.ts"],"sourcesContent":["/**\n Draws one piece of chart chrome — the size legend, else the legend, else\n the colorScale — inside the chart's negative space instead of in a\n margin, when the chart offers a region (`ChartDefinition.insetRegion`)\n and `legendInset` is on.\n\n Placement needs the chart's laid-out marks, but chrome normally claims\n its margin before the chart lays out, so the draw runs optimistically:\n 1. Every candidate skips its margin claim, and the chart lays out in\n the full area.\n 2. The open space around the marks (`negativeSpace`) is searched for\n the first candidate, in priority order, that fits.\n 3. If one fits and nothing else is waiting on a margin, that draw\n stands. If other candidates are showing, the chart lays out again\n with them back in their margins, and the winner is fitted again in\n the (smaller) chart. When nothing fits, the chart lays out normally.\n\n @module\n*/\n\nimport {negativeSpace} from \"@d3plus/math\";\nimport type {Bounds} from \"@d3plus/math\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {chartBounds} from \"../features/chartGeometry.js\";\nimport {paintColorScaleInset} from \"../features/featuresColorScale.js\";\nimport {buildLegendData, paintLegendInset} from \"../features/featuresLegend.js\";\nimport {sanitizePosition} from \"../features/features.js\";\nimport {markBoxes} from \"../features/sceneBounds.js\";\nimport {INSET_PRIORITY, insetFrame, insetStyle} from \"../features/insetState.js\";\nimport type {InsetKey, InsetOrient, InsetPlacement, InsetRegion} from \"../features/insetState.js\";\nimport {bottomRightControlsBox} from \"../drawSteps/bottomRightControlsMarkup.js\";\nimport {MINIMAP_RIGHT_INSET} from \"../drawSteps/minimapMarkup.js\";\nimport {getTopLeftContributions} from \"../drawSteps/topLeftControls.js\";\nimport {topLeftControlsBox} from \"../drawSteps/topLeftControlsMarkup.js\";\nimport {zoomControlsBox} from \"../drawSteps/zoomControlsMarkup.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {resolveSpec} from \"./resolveSpec.js\";\n\n/**\n The default inset region: the chart area (or `bounds`, in surface\n coordinates), with the boxes of every data mark in the chart's scene as\n obstacles (less any subtree `skip` excludes). Charts opt in by returning\n this from their `insetRegion`.\n*/\nexport function sceneInsetRegion(\n viz: VizInstance,\n bounds?: Bounds,\n skip?: (node: SceneNode) => boolean,\n): InsetRegion {\n const {width, height} = chartBounds(viz);\n return {\n bounds: bounds ?? {x: viz._margin.left, y: viz._margin.top, width, height},\n obstacles: markBoxes(viz._chartScene || [], viz._chartTransform, skip),\n };\n}\n\n/** Whether `legendInset` is on for this draw. */\nfunction insetEnabled(viz: VizInstance): boolean {\n const flag = viz.schema.legendInset;\n return typeof flag === \"function\" ? Boolean(flag.bind(viz)(resolveSpec(viz))) : Boolean(flag);\n}\n\n/** The smallest a legend entry can be: a swatch (1.4× the 12px label font) plus its padding. */\nconst MIN_LEGEND_ENTRY = 12 * 1.4 + 5;\n\n/**\n Whether the legend could possibly lay out inside the chart: its entries,\n even with their labels dropped, must fit the largest frame an inset\n legend may take (see `insetFrame`). Rules out laying out a legend of\n hundreds of entries just to find it doesn't fit.\n*/\nfunction legendCouldFit(viz: VizInstance): boolean {\n const frame = insetFrame(\"column\", {width: viz.schema.width || 0, height: viz.schema.height || 0});\n const entries = buildLegendData(viz).legendData.length;\n return entries * MIN_LEGEND_ENTRY * MIN_LEGEND_ENTRY <= frame.width * frame.height;\n}\n\n/**\n The candidates this draw may place inside the chart, in priority order.\n A legend or colorScale whose position the user set explicitly stays\n where they put it.\n*/\nfunction insetCandidates(viz: VizInstance): InsetKey[] {\n const auto = viz._insetAutoPositions;\n return INSET_PRIORITY.filter(key => {\n if (key === \"legend\")\n return (!auto || viz.schema.legendPosition === auto.legend) && legendCouldFit(viz);\n if (key === \"colorScale\") return !auto || viz.schema.colorScalePosition === auto.colorScale;\n return true;\n });\n}\n\n/** The orientations a candidate may take inside the chart. */\nconst ORIENTS: Record<InsetKey, InsetOrient[]> = {\n sizeLegend: [\"column\"],\n legend: [\"column\", \"row\"],\n colorScale: [\"column\", \"row\"],\n};\n\n/** Whether a candidate laid out for the chart's interior this pass is showing at all. */\nfunction isShowing(viz: VizInstance, key: InsetKey): boolean {\n if (key === \"sizeLegend\") return Boolean(bottomRightControlsBox(viz)?.inset);\n if (key === \"legend\") return Boolean(viz._legendClass?._data?.length);\n return Boolean(viz.schema.colorScale) &&\n sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz))) !== false &&\n !viz.schema.colorScaleConfig.select;\n}\n\n/**\n Lays a showing candidate out for the chart's interior in `orient` and\n returns its content size, or null when it can't lay out that way.\n*/\nfunction measure(\n viz: VizInstance,\n key: InsetKey,\n orient: InsetOrient,\n area: {width: number; height: number},\n): {width: number; height: number} | null {\n if (key === \"sizeLegend\") {\n const box = bottomRightControlsBox(viz);\n return box ? {width: box.width, height: box.height} : null;\n }\n return key === \"legend\"\n ? paintLegendInset(viz, orient, area)\n : paintColorScaleInset(viz, orient, area);\n}\n\n/** The chart corners an inset box is tried in, most preferred first. */\nconst CORNERS: Array<Pick<InsetPlacement, \"alignX\" | \"alignY\">> = [\n {alignX: \"right\", alignY: \"bottom\"},\n {alignX: \"right\", alignY: \"top\"},\n {alignX: \"left\", alignY: \"bottom\"},\n {alignX: \"left\", alignY: \"top\"},\n];\n\n/**\n Where a box of `width` × `height` sits in the open rects (sorted largest\n first): in the first chart corner, in `CORNERS` order, that some rect\n reaching that corner has room for. When it fits in no corner, it goes in\n the first rect it fits, against whichever of the rect's sides lie on the\n region's edges (bottom-right when it touches both), centered along an\n axis otherwise.\n*/\nexport function fitInset(\n rects: Bounds[],\n bounds: Bounds,\n width: number,\n height: number,\n): (Bounds & Pick<InsetPlacement, \"alignX\" | \"alignY\">) | null {\n const eps = 0.5;\n const fits = rects.filter(r => r.width >= width && r.height >= height);\n if (!fits.length) return null;\n const edges = (r: Bounds) => ({\n right: Math.abs(r.x + r.width - (bounds.x + bounds.width)) < eps,\n left: Math.abs(r.x - bounds.x) < eps,\n bottom: Math.abs(r.y + r.height - (bounds.y + bounds.height)) < eps,\n top: Math.abs(r.y - bounds.y) < eps,\n });\n const place = (r: Bounds, alignX: InsetPlacement[\"alignX\"], alignY: InsetPlacement[\"alignY\"]) => ({\n x: alignX === \"right\" ? r.x + r.width - width : alignX === \"left\" ? r.x : r.x + (r.width - width) / 2,\n y: alignY === \"bottom\" ? r.y + r.height - height : alignY === \"top\" ? r.y : r.y + (r.height - height) / 2,\n width,\n height,\n alignX,\n alignY,\n });\n for (const {alignX, alignY} of CORNERS) {\n const rect = fits.find(r => {\n const e = edges(r);\n return e[alignX as \"left\" | \"right\"] && e[alignY as \"top\" | \"bottom\"];\n });\n if (rect) return place(rect, alignX, alignY);\n }\n const rect = fits[0], e = edges(rect);\n return place(\n rect,\n e.right ? \"right\" : e.left ? \"left\" : \"center\",\n e.bottom ? \"bottom\" : e.top ? \"top\" : \"middle\",\n );\n}\n\n/** Rough height of the attribution credit, a single line of small text. */\nconst ATTRIBUTION_HEIGHT = 22;\n\n/**\n Boxes of the chrome overlaid on the chart that inset chrome must also\n stay clear of: the zoom buttons (and the minimap that opens beneath\n them once zoomed), the top-left controls, and the attribution credit in\n the chart area's bottom-right corner (sized from its rendered node when\n there is one, otherwise from its text, up to the half of the chart it\n may span before collapsing to a badge).\n*/\nfunction chromeBoxes(viz: VizInstance): Bounds[] {\n const boxes: Bounds[] = [];\n const {width, height} = chartBounds(viz);\n const zoom = zoomControlsBox(viz as never);\n if (zoom) {\n const minimap = viz.schema.minimap ? (zoom.width - MINIMAP_RIGHT_INSET) * (height / Math.max(1, width)) : 0;\n boxes.push({x: viz.schema.width - zoom.width, y: 0, width: zoom.width, height: zoom.height + minimap});\n }\n const topLeft = topLeftControlsBox(viz as never, getTopLeftContributions(viz as never));\n if (topLeft) boxes.push({x: 0, y: 0, width: topLeft.width, height: topLeft.height});\n if (viz.schema.attribution) {\n const parent = viz._select?.node?.()?.parentNode as Element | null | undefined;\n const node = parent?.querySelector?.(\"div.d3plus-attribution\") as HTMLElement | null | undefined;\n const text = String(viz.schema.attribution).replace(/<[^>]*>/g, \"\");\n const w = Math.min(node?.offsetWidth || text.length * 6 + 30, width / 2);\n const h = node?.offsetHeight || ATTRIBUTION_HEIGHT;\n const right = viz.schema.width - viz._margin.right, bottom = viz.schema.height - viz._margin.bottom;\n boxes.push({x: right - w, y: bottom - h, width: w, height: h});\n }\n return boxes;\n}\n\n/** The open rects in the chart's region, kept `padding` clear of the marks and the region's edges. */\nfunction openSpace(viz: VizInstance): {rects: Bounds[]; bounds: Bounds; area: {width: number; height: number}} | null {\n const region = viz._insetRegion?.();\n if (!region) return null;\n const {padding} = insetStyle(viz);\n const b = region.bounds;\n const bounds = {\n x: b.x + padding,\n y: b.y + padding,\n width: b.width - padding * 2,\n height: b.height - padding * 2,\n };\n if (bounds.width <= 0 || bounds.height <= 0) return null;\n const exclude = chromeBoxes(viz);\n return {rects: negativeSpace(bounds, region.obstacles, {padding, exclude}), bounds, area: b};\n}\n\n/**\n Fits the first of `keys` that has room inside the chart. Returns the\n placement (or null) and which candidates are showing at all.\n*/\nfunction choose(viz: VizInstance, keys: InsetKey[]): {placement: InsetPlacement | null; showing: InsetKey[]} {\n const showing = keys.filter(key => isShowing(viz, key));\n const space = showing.length ? openSpace(viz) : null;\n if (!space || !space.rects.length) return {placement: null, showing};\n const {margin} = insetStyle(viz);\n for (const key of showing) {\n for (const orient of ORIENTS[key]) {\n const size = measure(viz, key, orient, space.area);\n const spot = size && fitInset(space.rects, space.bounds, size.width + margin * 2, size.height + margin * 2);\n if (spot) {\n return {placement: {key, orient, ...spot}, showing};\n }\n }\n }\n return {placement: null, showing};\n}\n\n/** Runs `_draw()` again from the margins the render started with. */\nfunction redraw(viz: VizInstance, start: {margin: VizInstance[\"_margin\"]; padding: VizInstance[\"_padding\"]}): void {\n viz._margin = {...start.margin};\n viz._padding = {...start.padding};\n viz._draw();\n}\n\n/**\n `viz._draw()`, placing chrome inside the chart's negative space when it\n fits (see the module docs). Leaves `viz._insetPlacement` set to what was\n placed, or null.\n*/\nexport function drawWithInset(viz: VizInstance): void {\n viz._insetPlacement = null;\n const keys = typeof viz._insetRegion === \"function\" && insetEnabled(viz) ? insetCandidates(viz) : [];\n if (!keys.length) {\n viz._insetPending = null;\n viz._draw();\n return;\n }\n const start = {margin: {...viz._margin}, padding: {...viz._padding}};\n viz._insetPending = new Set(keys);\n viz._draw();\n\n const first = choose(viz, keys);\n const {showing} = first;\n let {placement} = first;\n if (!showing.length) return;\n if (placement && showing.some(k => k !== placement!.key)) {\n viz._insetPending = new Set([placement.key]);\n redraw(viz, start);\n placement = choose(viz, [placement.key]).placement;\n }\n if (!placement) {\n viz._insetPending = new Set();\n redraw(viz, start);\n return;\n }\n viz._insetPlacement = placement;\n}\n"],"names":["negativeSpace","chartBounds","paintColorScaleInset","buildLegendData","paintLegendInset","sanitizePosition","markBoxes","INSET_PRIORITY","insetFrame","insetStyle","bottomRightControlsBox","MINIMAP_RIGHT_INSET","getTopLeftContributions","topLeftControlsBox","zoomControlsBox","resolveSpec","sceneInsetRegion","viz","bounds","skip","width","height","x","_margin","left","y","top","obstacles","_chartScene","_chartTransform","insetEnabled","flag","schema","legendInset","Boolean","bind","MIN_LEGEND_ENTRY","legendCouldFit","frame","entries","legendData","length","insetCandidates","auto","_insetAutoPositions","filter","key","legendPosition","legend","colorScalePosition","colorScale","ORIENTS","sizeLegend","isShowing","inset","_legendClass","_data","colorScaleConfig","select","measure","orient","area","box","CORNERS","alignX","alignY","fitInset","rects","eps","fits","r","edges","right","Math","abs","bottom","place","rect","find","e","ATTRIBUTION_HEIGHT","chromeBoxes","boxes","zoom","minimap","max","push","topLeft","attribution","parent","_select","node","parentNode","querySelector","text","String","replace","w","min","offsetWidth","h","offsetHeight","openSpace","region","_insetRegion","padding","b","exclude","choose","keys","showing","space","placement","margin","size","spot","redraw","start","_padding","_draw","drawWithInset","_insetPlacement","_insetPending","Set","first","some","k"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;AAkBA,GAEA,SAAQA,aAAa,QAAO,eAAe;AAI3C,SAAQC,WAAW,QAAO,+BAA+B;AACzD,SAAQC,oBAAoB,QAAO,oCAAoC;AACvE,SAAQC,eAAe,EAAEC,gBAAgB,QAAO,gCAAgC;AAChF,SAAQC,gBAAgB,QAAO,0BAA0B;AACzD,SAAQC,SAAS,QAAO,6BAA6B;AACrD,SAAQC,cAAc,EAAEC,UAAU,EAAEC,UAAU,QAAO,4BAA4B;AAEjF,SAAQC,sBAAsB,QAAO,4CAA4C;AACjF,SAAQC,mBAAmB,QAAO,gCAAgC;AAClE,SAAQC,uBAAuB,QAAO,kCAAkC;AACxE,SAAQC,kBAAkB,QAAO,wCAAwC;AACzE,SAAQC,eAAe,QAAO,qCAAqC;AAEnE,SAAQC,WAAW,QAAO,mBAAmB;AAE7C;;;;;AAKA,GACA,OAAO,SAASC,iBACdC,GAAgB,EAChBC,MAAe,EACfC,IAAmC;IAEnC,IAAwBlB,eAAAA,YAAYgB,MAA7BG,QAAiBnB,aAAjBmB,OAAOC,SAAUpB,aAAVoB;I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SAAS;IACpD;IACA,IAAI,CAACA,WAAW;QACd/F,IAAIyG,aAAa,GAAG,IAAIC;QACxBP,OAAOnG,KAAKoG;QACZ;IACF;IACApG,IAAIwG,eAAe,GAAGT;AACxB"}
@@ -6,12 +6,40 @@ function _array_like_to_array(arr, len) {
6
6
  function _array_without_holes(arr) {
7
7
  if (Array.isArray(arr)) return _array_like_to_array(arr);
8
8
  }
9
+ function _define_property(obj, key, value) {
10
+ if (key in obj) {
11
+ Object.defineProperty(obj, key, {
12
+ value: value,
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true
16
+ });
17
+ } else {
18
+ obj[key] = value;
19
+ }
20
+ return obj;
21
+ }
9
22
  function _iterable_to_array(iter) {
10
23
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
24
  }
12
25
  function _non_iterable_spread() {
13
26
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
27
  }
28
+ function _object_spread(target) {
29
+ for(var i = 1; i < arguments.length; i++){
30
+ var source = arguments[i] != null ? arguments[i] : {};
31
+ var ownKeys = Object.keys(source);
32
+ if (typeof Object.getOwnPropertySymbols === "function") {
33
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
34
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
35
+ }));
36
+ }
37
+ ownKeys.forEach(function(key) {
38
+ _define_property(target, key, source[key]);
39
+ });
40
+ }
41
+ return target;
42
+ }
15
43
  function _to_consumable_array(arr) {
16
44
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
45
  }
@@ -60,7 +88,7 @@ function _unsupported_iterable_to_array(o, minLen) {
60
88
  @param transformFn Optional builder for `_chartTransform`. Default:
61
89
  margin-origin (`{x: margin.left, y: margin.top}`).
62
90
  */ import { runStages } from "./stages.js";
63
- import { marginOriginTransform } from "../features/chartGeometry.js";
91
+ import { chartBounds, marginOriginTransform } from "../features/chartGeometry.js";
64
92
  import { isPaintDriven } from "../definition/ChartDefinition.js";
65
93
  export function runChartDraw(viz, def, stage, transformFn) {
66
94
  // Invariant: this helper OWNS `_chartScene` for the current draw — it
@@ -104,6 +132,12 @@ export function runChartDraw(viz, def, stage, transformFn) {
104
132
  viz._chartScene = _to_consumable_array(stagePushed).concat(_to_consumable_array(emitted));
105
133
  viz._chartTransform = transformFn ? transformFn(viz) : marginOriginTransform(viz);
106
134
  viz._chartClip = def.chartClip ? def.chartClip(viz) : undefined;
135
+ // The box the drill-down morph transition (enterFrom/exitTo) measures its
136
+ // fractions against — see ChartDefinition.chartBodyRect.
137
+ viz._bodyRect = def.chartBodyRect ? def.chartBodyRect(viz) : _object_spread({
138
+ x: 0,
139
+ y: 0
140
+ }, chartBounds(viz));
107
141
  }
108
142
 
109
143
  //# sourceMappingURL=runChartDraw.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/pipeline/runChartDraw.ts"],"sourcesContent":["/**\n `runChartDraw(viz, def, stage, transform?)` — collapses the canonical\n chart-subclass `_draw` body into a single call.\n\n Every Viz-extending chart subclass (Tree, Pie, Pack, Treemap, Matrix,\n RadialMatrix, Priestley, Network, Rings, Geomap, Radar) has the same\n three-line sequence after `super._draw(callback)`:\n\n const {shapeData} = runStages({viz: this}, [layoutStage]);\n this._chartScene = def.emit({viz: this, shapeData});\n this._chartTransform = { ... };\n\n This helper inlines that. The chart's `_draw` becomes:\n\n _draw(callback) {\n super._draw(callback);\n runChartDraw(this, myDef, applyMyLayout);\n return this;\n }\n\n For charts that compute a non-default `_chartTransform` (Pie centers,\n Radar centers, etc.), pass a third arg that returns the transform.\n\n Doesn't reach into chart-specific stash patterns (e.g. Pack writes\n `_packOffsetX`/`_packOffsetY` from its stage; the transform fn can\n read those off `viz` if needed).\n\n @param viz The chart instance (`this` from `_draw`).\n @param def The chart's `ChartDefinition` (e.g. `treeDef`, `pieDef`).\n @param stage The chart-specific layout `TransformStage`.\n @param transformFn Optional builder for `_chartTransform`. Default:\n margin-origin (`{x: margin.left, y: margin.top}`).\n*/\n\nimport {runStages} from \"./stages.js\";\nimport {marginOriginTransform} from \"../features/chartGeometry.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {Transform} from \"@d3plus/render\";\nimport type {ChartDefinition} from \"../definition/ChartDefinition.js\";\nimport {isPaintDriven} from \"../definition/ChartDefinition.js\";\nimport type {TransformStage, VizContext} from \"./stages.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runChartDraw(\n viz: Viz,\n def: ChartDefinition,\n stage: TransformStage,\n transformFn?: (viz: Viz) => Transform | undefined,\n): void {\n // Invariant: this helper OWNS `_chartScene` for the current draw — it\n // overwrites with `def.emit(ctx)`. The Plot family takes a different\n // flow: `Plot._paint` populates `_chartScene` directly from `plotPaint`\n // (which builds the scene from its paint context), and paint-driven defs\n // carry no `emit`. Calling `runChartDraw` on a paint-driven chart would\n // clobber that scene. The ChartDefinition.paintDriven discriminant is the\n // structural signal — failing loud so future contributors who try to\n // \"unify\" Plot with runChartDraw can't silently clobber the chart scene.\n if (isPaintDriven(def)) {\n throw new Error(\n `runChartDraw cannot drive ${def.name} — it's a paint-driven chart ` +\n \"(ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, \" +\n \"AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely \" +\n \"on Plot._paint to populate _chartScene imperatively; their _draw \" +\n \"should NOT call runChartDraw.\",\n );\n }\n // Reset _chartScene BEFORE the stage so its body has a known starting\n // point for any decoration nodes it pushes (axes, grids, spokes).\n viz._chartScene = [];\n const ctx = runStages({viz}, [stage]);\n if (!Array.isArray(viz._chartScene)) {\n // A stage reassigned `viz._chartScene` to a non-array (or replaced\n // it with undefined). Without this guard, the silent `[]` fallback\n // would discard the stage's intent — and the comment at the\n // concat below promises \"decorations are preserved\". Fail loud so\n // accidental reassignment surfaces instead of stealth-dropping\n // axis/grid nodes.\n throw new Error(\n `runChartDraw: stage for ${def.name} replaced viz._chartScene with ` +\n `a non-array value (got ${typeof viz._chartScene}). Stages should ` +\n \"use `(v._chartScene ||= []).push(...)` rather than reassigning.\",\n );\n }\n const stagePushed = viz._chartScene.slice();\n // ctx.shapeData is the generic layout bag (`unknown[]`); ChartEmit reads it\n // as DataPoint[] — each chart's layout stage produced rows it understands.\n const emitted = def.emit(ctx as VizContext & {shapeData?: DataPoint[]});\n // Preserve decorations the stage pushed (Matrix/Priestley/Radar/\n // RadialMatrix push axis/grid groups via `(v._chartScene ||= []).push`)\n // by concatenating them with the emit output. Without this, the\n // overwrite at the line below would silently discard every\n // decoration — Matrix renders bare cells with no row/column axes.\n // Stage decorations come FIRST so emit shapes paint on top.\n viz._chartScene = [...stagePushed, ...emitted];\n viz._chartTransform = transformFn\n ? transformFn(viz)\n : marginOriginTransform(viz);\n viz._chartClip = def.chartClip ? def.chartClip(viz) : undefined;\n}\n"],"names":["runStages","marginOriginTransform","isPaintDriven","runChartDraw","viz","def","stage","transformFn","Error","name","_chartScene","ctx","Array","isArray","stagePushed","slice","emitted","emit","_chartTransform","_chartClip","chartClip","undefined"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,GAEA,SAAQA,SAAS,QAAO,cAAc;AACtC,SAAQC,qBAAqB,QAAO,+BAA+B;AAKnE,SAAQC,aAAa,QAAO,mCAAmC;AAI/D,OAAO,SAASC,aACdC,GAAQ,EACRC,GAAoB,EACpBC,KAAqB,EACrBC,WAAiD;IAEjD,sEAAsE;IACtE,qEAAqE;IACrE,wEAAwE;IACxE,yEAAyE;IACzE,wEAAwE;IACxE,0EAA0E;IAC1E,qEAAqE;IACrE,yEAAyE;IACzE,IAAIL,cAAcG,MAAM;QACtB,MAAM,IAAIG,MACR,AAAC,6BAAqC,OAATH,IAAII,IAAI,EAAC,mCACtC,wEACA,wEACA,sEACA;IAEJ;IACA,sEAAsE;IACtE,kEAAkE;IAClEL,IAAIM,WAAW,GAAG,EAAE;IACpB,IAAMC,MAAMX,UAAU;QAACI,KAAAA;IAAG,GAAG;QAACE;KAAM;IACpC,IAAI,CAACM,MAAMC,OAAO,CAACT,IAAIM,WAAW,GAAG;QACnC,mEAAmE;QACnE,mEAAmE;QACnE,4DAA4D;QAC5D,kEAAkE;QAClE,+DAA+D;QAC/D,mBAAmB;QACnB,MAAM,IAAIF,MACR,AAAC,2BAAmC,OAATH,IAAII,IAAI,EAAC,qCACpC,AAAC,0BAAgD,OAAvB,SAAOL,IAAIM,WAAW,GAAC,uBACjD;IAEJ;IACA,IAAMI,cAAcV,IAAIM,WAAW,CAACK,KAAK;IACzC,4EAA4E;IAC5E,2EAA2E;IAC3E,IAAMC,UAAUX,IAAIY,IAAI,CAACN;IACzB,iEAAiE;IACjE,wEAAwE;IACxE,gEAAgE;IAChE,2DAA2D;IAC3D,kEAAkE;IAClE,4DAA4D;IAC5DP,IAAIM,WAAW,GAAG,AAAC,qBAAGI,oBAAa,qBAAGE;IACtCZ,IAAIc,eAAe,GAAGX,cAClBA,YAAYH,OACZH,sBAAsBG;IAC1BA,IAAIe,UAAU,GAAGd,IAAIe,SAAS,GAAGf,IAAIe,SAAS,CAAChB,OAAOiB;AACxD"}
1
+ {"version":3,"sources":["../../../../src/charts/pipeline/runChartDraw.ts"],"sourcesContent":["/**\n `runChartDraw(viz, def, stage, transform?)` — collapses the canonical\n chart-subclass `_draw` body into a single call.\n\n Every Viz-extending chart subclass (Tree, Pie, Pack, Treemap, Matrix,\n RadialMatrix, Priestley, Network, Rings, Geomap, Radar) has the same\n three-line sequence after `super._draw(callback)`:\n\n const {shapeData} = runStages({viz: this}, [layoutStage]);\n this._chartScene = def.emit({viz: this, shapeData});\n this._chartTransform = { ... };\n\n This helper inlines that. The chart's `_draw` becomes:\n\n _draw(callback) {\n super._draw(callback);\n runChartDraw(this, myDef, applyMyLayout);\n return this;\n }\n\n For charts that compute a non-default `_chartTransform` (Pie centers,\n Radar centers, etc.), pass a third arg that returns the transform.\n\n Doesn't reach into chart-specific stash patterns (e.g. Pack writes\n `_packOffsetX`/`_packOffsetY` from its stage; the transform fn can\n read those off `viz` if needed).\n\n @param viz The chart instance (`this` from `_draw`).\n @param def The chart's `ChartDefinition` (e.g. `treeDef`, `pieDef`).\n @param stage The chart-specific layout `TransformStage`.\n @param transformFn Optional builder for `_chartTransform`. Default:\n margin-origin (`{x: margin.left, y: margin.top}`).\n*/\n\nimport {runStages} from \"./stages.js\";\nimport {chartBounds, marginOriginTransform} from \"../features/chartGeometry.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {Transform} from \"@d3plus/render\";\nimport type {ChartDefinition} from \"../definition/ChartDefinition.js\";\nimport {isPaintDriven} from \"../definition/ChartDefinition.js\";\nimport type {TransformStage, VizContext} from \"./stages.js\";\nimport type {VizInstance as Viz} from \"../viz/vizTypes.js\";\n\nexport function runChartDraw(\n viz: Viz,\n def: ChartDefinition,\n stage: TransformStage,\n transformFn?: (viz: Viz) => Transform | undefined,\n): void {\n // Invariant: this helper OWNS `_chartScene` for the current draw — it\n // overwrites with `def.emit(ctx)`. The Plot family takes a different\n // flow: `Plot._paint` populates `_chartScene` directly from `plotPaint`\n // (which builds the scene from its paint context), and paint-driven defs\n // carry no `emit`. Calling `runChartDraw` on a paint-driven chart would\n // clobber that scene. The ChartDefinition.paintDriven discriminant is the\n // structural signal — failing loud so future contributors who try to\n // \"unify\" Plot with runChartDraw can't silently clobber the chart scene.\n if (isPaintDriven(def)) {\n throw new Error(\n `runChartDraw cannot drive ${def.name} — it's a paint-driven chart ` +\n \"(ChartDefinition.paintDriven=true). Paint-driven charts (BarChart, \" +\n \"AreaPlot, LinePlot, BumpChart, StackedArea, BoxWhisker, Plot) rely \" +\n \"on Plot._paint to populate _chartScene imperatively; their _draw \" +\n \"should NOT call runChartDraw.\",\n );\n }\n // Reset _chartScene BEFORE the stage so its body has a known starting\n // point for any decoration nodes it pushes (axes, grids, spokes).\n viz._chartScene = [];\n const ctx = runStages({viz}, [stage]);\n if (!Array.isArray(viz._chartScene)) {\n // A stage reassigned `viz._chartScene` to a non-array (or replaced\n // it with undefined). Without this guard, the silent `[]` fallback\n // would discard the stage's intent — and the comment at the\n // concat below promises \"decorations are preserved\". Fail loud so\n // accidental reassignment surfaces instead of stealth-dropping\n // axis/grid nodes.\n throw new Error(\n `runChartDraw: stage for ${def.name} replaced viz._chartScene with ` +\n `a non-array value (got ${typeof viz._chartScene}). Stages should ` +\n \"use `(v._chartScene ||= []).push(...)` rather than reassigning.\",\n );\n }\n const stagePushed = viz._chartScene.slice();\n // ctx.shapeData is the generic layout bag (`unknown[]`); ChartEmit reads it\n // as DataPoint[] — each chart's layout stage produced rows it understands.\n const emitted = def.emit(ctx as VizContext & {shapeData?: DataPoint[]});\n // Preserve decorations the stage pushed (Matrix/Priestley/Radar/\n // RadialMatrix push axis/grid groups via `(v._chartScene ||= []).push`)\n // by concatenating them with the emit output. Without this, the\n // overwrite at the line below would silently discard every\n // decoration — Matrix renders bare cells with no row/column axes.\n // Stage decorations come FIRST so emit shapes paint on top.\n viz._chartScene = [...stagePushed, ...emitted];\n viz._chartTransform = transformFn\n ? transformFn(viz)\n : marginOriginTransform(viz);\n viz._chartClip = def.chartClip ? def.chartClip(viz) : undefined;\n // The box the drill-down morph transition (enterFrom/exitTo) measures its\n // fractions against — see ChartDefinition.chartBodyRect.\n viz._bodyRect = def.chartBodyRect\n ? def.chartBodyRect(viz)\n : {x: 0, y: 0, ...chartBounds(viz)};\n}\n"],"names":["runStages","chartBounds","marginOriginTransform","isPaintDriven","runChartDraw","viz","def","stage","transformFn","Error","name","_chartScene","ctx","Array","isArray","stagePushed","slice","emitted","emit","_chartTransform","_chartClip","chartClip","undefined","_bodyRect","chartBodyRect","x","y"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Gd,IAAIe,SAAS,GAAGf,IAAIe,SAAS,CAAChB,OAAOiB;IACtD,0EAA0E;IAC1E,yDAAyD;IACzDjB,IAAIkB,SAAS,GAAGjB,IAAIkB,aAAa,GAC7BlB,IAAIkB,aAAa,CAACnB,OAClB;QAACoB,GAAG;QAAGC,GAAG;OAAMzB,YAAYI;AAClC"}
@@ -38,10 +38,12 @@ function _unsupported_iterable_to_array(o, minLen) {
38
38
  callback:
39
39
 
40
40
  1. `viz._preDraw()` — data filtering + legend-data + drawDepth
41
- 2. `viz._draw()` — chart-specific layout + scene absorption
41
+ 2. `viz._draw()` — chart-specific layout + scene absorption, re-run
42
+ when chrome is placed inside the chart (`drawWithInset`)
42
43
  3. `zoomControls(viz)` — zoom HTML overlay (architectural carve-out)
43
44
  4. `minimapFeature.layout(viz)` — zoomed-chart viewport indicator
44
45
  5. `topLeftControlsFeature.layout(viz)` — back/table-view/search panel
46
+ 5b. `bottomRightControlsFeature.layout(viz)` — size-legend corner panel
45
47
  6. `attributionFeature.layout(viz)` — bottom-right attribution panel
46
48
  7. `tableViewFeature.layout(viz)` — chart-sized data-table overlay
47
49
  8. `viz._drawSceneToTarget()` — paint scene via SvgRenderer/CanvasRenderer
@@ -57,7 +59,10 @@ function _unsupported_iterable_to_array(o, minLen) {
57
59
  */ import { attributionFeature, runLayout } from "../features/features.js";
58
60
  import { minimapFeature } from "../drawSteps/minimap.js";
59
61
  import { zoomFeature } from "../drawSteps/zoomControls.js";
62
+ import { resolveDrillMorph } from "./drillMorph.js";
63
+ import { drawWithInset } from "./insetPlacement.js";
60
64
  import { topLeftControlsFeature } from "../drawSteps/topLeftControls.js";
65
+ import { bottomRightControlsFeature } from "../drawSteps/bottomRightControls.js";
61
66
  import { tableViewFeature } from "../drawSteps/tableView.js";
62
67
  export function runVizPipeline(viz) {
63
68
  // Goes through `viz._preDraw()` / `viz._draw()` (not the free functions
@@ -66,7 +71,9 @@ export function runVizPipeline(viz) {
66
71
  // hold the BASE Viz behavior; subclasses' `super._preDraw()`/`super._draw()`
67
72
  // calls hit the shim which delegates to the free functions.
68
73
  viz._preDraw();
69
- viz._draw();
74
+ // `_draw()`, possibly more than once: chrome that fits inside the chart's
75
+ // negative space is placed there after layout (see insetPlacement.ts).
76
+ drawWithInset(viz);
70
77
  // Post-draw features: zoom + brush event wiring, the minimap, the shared
71
78
  // top-left controls panel (back / table-view button / search), the
72
79
  // attribution overlay, and the table-view data-table overlay. All run
@@ -87,17 +94,29 @@ export function runVizPipeline(viz) {
87
94
  // buffer that `toScene()` reads — including on later repaints (a zoom
88
95
  // event, a table-view toggle), which re-walk `toScene()` outside this
89
96
  // pipeline pass.
97
+ runPostDrawFeatures(viz);
98
+ // Resolve the drill-down morph's enter/exit boxes (if a drill click armed
99
+ // one) now that this draw's _bodyRect/_chartScene are final.
100
+ resolveDrillMorph(viz);
101
+ viz._drawSceneToTarget();
102
+ }
103
+ /**
104
+ Runs the post-draw features (see above) and appends their panels. Anything
105
+ that re-runs `viz._draw()` outside this pipeline — Rings re-centering on a
106
+ click, say — must call this after it: `_draw()` resets the feature panels,
107
+ so skipping it drops the corner controls, size legend, and attribution.
108
+ */ export function runPostDrawFeatures(viz) {
90
109
  var post = runLayout({
91
110
  viz: viz
92
111
  }, [
93
112
  zoomFeature,
94
113
  minimapFeature,
95
114
  topLeftControlsFeature,
115
+ bottomRightControlsFeature,
96
116
  attributionFeature,
97
117
  tableViewFeature
98
118
  ]);
99
119
  if (post.panels.length) viz._featurePanels = _to_consumable_array(viz._featurePanels || []).concat(_to_consumable_array(post.panels));
100
- viz._drawSceneToTarget();
101
120
  }
102
121
 
103
122
  //# sourceMappingURL=runVizPipeline.js.map