@d3plus/core 3.1.6 → 4.1.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 (579) hide show
  1. package/README.md +9924 -78528
  2. package/es/index.js +8 -0
  3. package/es/index.js.map +1 -1
  4. package/es/internal.js +54 -0
  5. package/es/internal.js.map +1 -0
  6. package/es/src/charts/AreaPlot/index.js +36 -0
  7. package/es/src/charts/AreaPlot/index.js.map +1 -0
  8. package/es/src/charts/BarChart/index.js +48 -0
  9. package/es/src/charts/BarChart/index.js.map +1 -0
  10. package/es/src/charts/BoxWhisker/index.js +52 -0
  11. package/es/src/charts/BoxWhisker/index.js.map +1 -0
  12. package/es/src/charts/BumpChart/index.js +81 -0
  13. package/es/src/charts/BumpChart/index.js.map +1 -0
  14. package/es/src/charts/Donut/index.js +42 -0
  15. package/es/src/charts/Donut/index.js.map +1 -0
  16. package/es/src/charts/Geomap/applyLayout.js +208 -0
  17. package/es/src/charts/Geomap/applyLayout.js.map +1 -0
  18. package/es/src/charts/Geomap/emit.js +169 -0
  19. package/es/src/charts/Geomap/emit.js.map +1 -0
  20. package/es/src/charts/Geomap/index.js +521 -0
  21. package/es/src/charts/Geomap/index.js.map +1 -0
  22. package/es/src/charts/LinePlot/index.js +32 -0
  23. package/es/src/charts/LinePlot/index.js.map +1 -0
  24. package/es/src/charts/Matrix/applyLayout.js +92 -0
  25. package/es/src/charts/Matrix/applyLayout.js.map +1 -0
  26. package/es/src/charts/Matrix/emit.js +44 -0
  27. package/es/src/charts/Matrix/emit.js.map +1 -0
  28. package/es/src/charts/Matrix/index.js +154 -0
  29. package/es/src/charts/Matrix/index.js.map +1 -0
  30. package/es/src/charts/Network/applyLayout.js +322 -0
  31. package/es/src/charts/Network/applyLayout.js.map +1 -0
  32. package/es/src/charts/Network/emit.js +273 -0
  33. package/es/src/charts/Network/emit.js.map +1 -0
  34. package/es/src/charts/Network/index.js +422 -0
  35. package/es/src/charts/Network/index.js.map +1 -0
  36. package/es/src/charts/Pack/applyLayout.js +46 -0
  37. package/es/src/charts/Pack/applyLayout.js.map +1 -0
  38. package/es/src/charts/Pack/emit.js +116 -0
  39. package/es/src/charts/Pack/emit.js.map +1 -0
  40. package/es/src/charts/Pack/index.js +194 -0
  41. package/es/src/charts/Pack/index.js.map +1 -0
  42. package/es/src/charts/Pack/recursionCircles.js +18 -0
  43. package/es/src/charts/Pack/recursionCircles.js.map +1 -0
  44. package/es/src/charts/Pie/applyLayout.js +44 -0
  45. package/es/src/charts/Pie/applyLayout.js.map +1 -0
  46. package/es/src/charts/Pie/emit.js +111 -0
  47. package/es/src/charts/Pie/emit.js.map +1 -0
  48. package/es/src/charts/Pie/index.js +134 -0
  49. package/es/src/charts/Pie/index.js.map +1 -0
  50. package/es/src/charts/Plot/draw.js +424 -0
  51. package/es/src/charts/Plot/draw.js.map +1 -0
  52. package/es/src/charts/Plot/index.js +827 -0
  53. package/es/src/charts/Plot/index.js.map +1 -0
  54. package/es/src/charts/Plot/labelPlacement.js +36 -0
  55. package/es/src/charts/Plot/labelPlacement.js.map +1 -0
  56. package/es/src/charts/Plot/pipeline.js +594 -0
  57. package/es/src/charts/Plot/pipeline.js.map +1 -0
  58. package/es/src/charts/Plot/pipelineDomains.js +254 -0
  59. package/es/src/charts/Plot/pipelineDomains.js.map +1 -0
  60. package/es/src/charts/Plot/pipelineLineLabels.js +210 -0
  61. package/es/src/charts/Plot/pipelineLineLabels.js.map +1 -0
  62. package/es/src/charts/Plot/shapeDefaults.js +189 -0
  63. package/es/src/charts/Plot/shapeDefaults.js.map +1 -0
  64. package/es/src/charts/Plot/stackHelpers.js +52 -0
  65. package/es/src/charts/Plot/stackHelpers.js.map +1 -0
  66. package/es/src/charts/Priestley/applyLayout.js +121 -0
  67. package/es/src/charts/Priestley/applyLayout.js.map +1 -0
  68. package/es/src/charts/Priestley/emit.js +129 -0
  69. package/es/src/charts/Priestley/emit.js.map +1 -0
  70. package/es/src/charts/Priestley/index.js +97 -0
  71. package/es/src/charts/Priestley/index.js.map +1 -0
  72. package/es/src/charts/Radar/applyLayout.js +326 -0
  73. package/es/src/charts/Radar/applyLayout.js.map +1 -0
  74. package/es/src/charts/Radar/emit.js +28 -0
  75. package/es/src/charts/Radar/emit.js.map +1 -0
  76. package/es/src/charts/Radar/index.js +98 -0
  77. package/es/src/charts/Radar/index.js.map +1 -0
  78. package/es/src/charts/RadialMatrix/applyLayout.js +132 -0
  79. package/es/src/charts/RadialMatrix/applyLayout.js.map +1 -0
  80. package/es/src/charts/RadialMatrix/emit.js +33 -0
  81. package/es/src/charts/RadialMatrix/emit.js.map +1 -0
  82. package/es/src/charts/RadialMatrix/index.js +144 -0
  83. package/es/src/charts/RadialMatrix/index.js.map +1 -0
  84. package/es/src/charts/Rings/applyLayout.js +508 -0
  85. package/es/src/charts/Rings/applyLayout.js.map +1 -0
  86. package/es/src/charts/Rings/emit.js +222 -0
  87. package/es/src/charts/Rings/emit.js.map +1 -0
  88. package/es/src/charts/Rings/index.js +245 -0
  89. package/es/src/charts/Rings/index.js.map +1 -0
  90. package/es/src/charts/Sankey/applyLayout.js +107 -0
  91. package/es/src/charts/Sankey/applyLayout.js.map +1 -0
  92. package/es/src/charts/Sankey/emit.js +134 -0
  93. package/es/src/charts/Sankey/emit.js.map +1 -0
  94. package/es/src/charts/Sankey/index.js +219 -0
  95. package/es/src/charts/Sankey/index.js.map +1 -0
  96. package/es/src/charts/StackedArea/index.js +27 -0
  97. package/es/src/charts/StackedArea/index.js.map +1 -0
  98. package/es/src/charts/Tree/applyLayout.js +233 -0
  99. package/es/src/charts/Tree/applyLayout.js.map +1 -0
  100. package/es/src/charts/Tree/emit.js +257 -0
  101. package/es/src/charts/Tree/emit.js.map +1 -0
  102. package/es/src/charts/Tree/index.js +105 -0
  103. package/es/src/charts/Tree/index.js.map +1 -0
  104. package/es/src/charts/Treemap/applyLayout.js +85 -0
  105. package/es/src/charts/Treemap/applyLayout.js.map +1 -0
  106. package/es/src/charts/Treemap/emit.js +141 -0
  107. package/es/src/charts/Treemap/emit.js.map +1 -0
  108. package/es/src/charts/Treemap/index.js +177 -0
  109. package/es/src/charts/Treemap/index.js.map +1 -0
  110. package/es/src/charts/Treemap/thresholdFunction.js +112 -0
  111. package/es/src/charts/Treemap/thresholdFunction.js.map +1 -0
  112. package/es/src/charts/definition/ChartDefinition.js +12 -0
  113. package/es/src/charts/definition/ChartDefinition.js.map +1 -0
  114. package/es/src/charts/definition/applyDefinition.js +107 -0
  115. package/es/src/charts/definition/applyDefinition.js.map +1 -0
  116. package/es/src/charts/definition/makeChart.js +153 -0
  117. package/es/src/charts/definition/makeChart.js.map +1 -0
  118. package/es/src/charts/drawSteps/zoomControls.js +231 -96
  119. package/es/src/charts/drawSteps/zoomControls.js.map +1 -1
  120. package/es/src/charts/events/click.legend.js +2 -2
  121. package/es/src/charts/events/click.legend.js.map +1 -1
  122. package/es/src/charts/events/click.shape.js +5 -5
  123. package/es/src/charts/events/click.shape.js.map +1 -1
  124. package/es/src/charts/events/mouseenter.js +20 -1
  125. package/es/src/charts/events/mouseenter.js.map +1 -1
  126. package/es/src/charts/events/mouseleave.js +19 -4
  127. package/es/src/charts/events/mouseleave.js.map +1 -1
  128. package/es/src/charts/events/mousemove.legend.js +10 -10
  129. package/es/src/charts/events/mousemove.legend.js.map +1 -1
  130. package/es/src/charts/events/mousemove.shape.js +14 -8
  131. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  132. package/es/src/charts/events/touchstart.body.js.map +1 -1
  133. package/es/src/charts/features/axes.js +432 -0
  134. package/es/src/charts/features/axes.js.map +1 -0
  135. package/es/src/charts/features/chartGeometry.js +66 -0
  136. package/es/src/charts/features/chartGeometry.js.map +1 -0
  137. package/es/src/charts/features/colorScaleBucket.js +92 -0
  138. package/es/src/charts/features/colorScaleBucket.js.map +1 -0
  139. package/es/src/charts/features/emitHelpers.js +217 -0
  140. package/es/src/charts/features/emitHelpers.js.map +1 -0
  141. package/es/src/charts/features/ensureZoomDom.js +71 -0
  142. package/es/src/charts/features/ensureZoomDom.js.map +1 -0
  143. package/es/src/charts/features/features.js +650 -0
  144. package/es/src/charts/features/features.js.map +1 -0
  145. package/es/src/charts/features/featuresLegend.js +180 -0
  146. package/es/src/charts/features/featuresLegend.js.map +1 -0
  147. package/es/src/charts/features/legendLabel.js +12 -0
  148. package/es/src/charts/features/legendLabel.js.map +1 -0
  149. package/es/src/charts/features/lineLabels.js +154 -0
  150. package/es/src/charts/features/lineLabels.js.map +1 -0
  151. package/es/src/charts/features/plotPaint.js +512 -0
  152. package/es/src/charts/features/plotPaint.js.map +1 -0
  153. package/es/src/charts/features/shapeEmit.js +273 -0
  154. package/es/src/charts/features/shapeEmit.js.map +1 -0
  155. package/es/src/charts/helpers/matrixData.js +3 -3
  156. package/es/src/charts/helpers/matrixData.js.map +1 -1
  157. package/es/src/charts/index.js +21 -21
  158. package/es/src/charts/index.js.map +1 -1
  159. package/es/src/charts/pipeline/resolveSpec.js +44 -0
  160. package/es/src/charts/pipeline/resolveSpec.js.map +1 -0
  161. package/es/src/charts/pipeline/runChartDraw.js +109 -0
  162. package/es/src/charts/pipeline/runChartDraw.js.map +1 -0
  163. package/es/src/charts/pipeline/runVizPipeline.js +84 -0
  164. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -0
  165. package/es/src/charts/pipeline/stages.js +103 -0
  166. package/es/src/charts/pipeline/stages.js.map +1 -0
  167. package/es/src/charts/pipeline/vizContext.js +29 -0
  168. package/es/src/charts/pipeline/vizContext.js.map +1 -0
  169. package/es/src/charts/pipeline/vizDraw.js +37 -0
  170. package/es/src/charts/pipeline/vizDraw.js.map +1 -0
  171. package/es/src/charts/pipeline/vizDrawPure.js +174 -0
  172. package/es/src/charts/pipeline/vizDrawPure.js.map +1 -0
  173. package/es/src/charts/pipeline/vizPreDraw.js +145 -0
  174. package/es/src/charts/pipeline/vizPreDraw.js.map +1 -0
  175. package/es/src/charts/pipeline/vizPreDrawPure.js +279 -0
  176. package/es/src/charts/pipeline/vizPreDrawPure.js.map +1 -0
  177. package/es/src/charts/plotBuffers/Bar.js +4 -4
  178. package/es/src/charts/plotBuffers/Bar.js.map +1 -1
  179. package/es/src/charts/plotBuffers/Box.js +4 -4
  180. package/es/src/charts/plotBuffers/Box.js.map +1 -1
  181. package/es/src/charts/plotBuffers/Circle.js +2 -2
  182. package/es/src/charts/plotBuffers/Circle.js.map +1 -1
  183. package/es/src/charts/plotBuffers/Line.js +5 -5
  184. package/es/src/charts/plotBuffers/Line.js.map +1 -1
  185. package/es/src/charts/plotBuffers/Rect.js +2 -2
  186. package/es/src/charts/plotBuffers/Rect.js.map +1 -1
  187. package/es/src/charts/plotBuffers/discreteBuffer.js +1 -2
  188. package/es/src/charts/plotBuffers/discreteBuffer.js.map +1 -1
  189. package/es/src/charts/plotBuffers/numericBuffer.js +1 -2
  190. package/es/src/charts/plotBuffers/numericBuffer.js.map +1 -1
  191. package/es/src/charts/viz/Viz.js +985 -0
  192. package/es/src/charts/viz/Viz.js.map +1 -0
  193. package/es/src/charts/viz/VizBase.js +447 -0
  194. package/es/src/charts/viz/VizBase.js.map +1 -0
  195. package/es/src/charts/viz/VizBaseConfig.js +504 -0
  196. package/es/src/charts/viz/VizBaseConfig.js.map +1 -0
  197. package/es/src/charts/viz/interactionOpacity.js +247 -0
  198. package/es/src/charts/viz/interactionOpacity.js.map +1 -0
  199. package/es/src/charts/viz/ordinalColor.js +71 -0
  200. package/es/src/charts/viz/ordinalColor.js.map +1 -0
  201. package/es/src/charts/viz/trailCatchup.js +127 -0
  202. package/es/src/charts/viz/trailCatchup.js.map +1 -0
  203. package/es/src/charts/viz/vizDefaults.js +602 -0
  204. package/es/src/charts/viz/vizDefaults.js.map +1 -0
  205. package/es/src/charts/viz/vizRender.js +251 -0
  206. package/es/src/charts/viz/vizRender.js.map +1 -0
  207. package/es/src/charts/viz/vizTypes.js +28 -0
  208. package/es/src/charts/viz/vizTypes.js.map +1 -0
  209. package/es/src/components/Axis/Axis.js +691 -0
  210. package/es/src/components/Axis/Axis.js.map +1 -0
  211. package/es/src/components/Axis/AxisBottom.js.map +1 -0
  212. package/es/src/components/Axis/AxisLeft.js.map +1 -0
  213. package/es/src/components/Axis/AxisRight.js.map +1 -0
  214. package/es/src/components/Axis/AxisTop.js.map +1 -0
  215. package/es/src/components/Axis/axisLayout.js +208 -0
  216. package/es/src/components/Axis/axisLayout.js.map +1 -0
  217. package/es/src/components/Axis/axisLayoutLabels.js +177 -0
  218. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -0
  219. package/es/src/components/Axis/axisLayoutScale.js +374 -0
  220. package/es/src/components/Axis/axisLayoutScale.js.map +1 -0
  221. package/es/src/components/Axis/axisRender.js +535 -0
  222. package/es/src/components/Axis/axisRender.js.map +1 -0
  223. package/es/src/components/ColorScale/ColorScale.js +506 -0
  224. package/es/src/components/ColorScale/ColorScale.js.map +1 -0
  225. package/es/src/components/ColorScale/colorScaleRender.js +277 -0
  226. package/es/src/components/ColorScale/colorScaleRender.js.map +1 -0
  227. package/es/src/components/ColorScale/colorScaleScale.js +274 -0
  228. package/es/src/components/ColorScale/colorScaleScale.js.map +1 -0
  229. package/es/src/components/Legend/Legend.js +445 -0
  230. package/es/src/components/Legend/Legend.js.map +1 -0
  231. package/es/src/components/Legend/legendConfig.js +87 -0
  232. package/es/src/components/Legend/legendConfig.js.map +1 -0
  233. package/es/src/components/Legend/legendRender.js +245 -0
  234. package/es/src/components/Legend/legendRender.js.map +1 -0
  235. package/es/src/components/Message.js.map +1 -1
  236. package/es/src/components/TextBox.js +655 -453
  237. package/es/src/components/TextBox.js.map +1 -1
  238. package/es/src/components/Timeline/Timeline.js +674 -0
  239. package/es/src/components/Timeline/Timeline.js.map +1 -0
  240. package/es/src/components/Timeline/timelineConfig.js +115 -0
  241. package/es/src/components/Timeline/timelineConfig.js.map +1 -0
  242. package/es/src/components/Timeline/timelineRender.js +267 -0
  243. package/es/src/components/Timeline/timelineRender.js.map +1 -0
  244. package/es/src/components/Tooltip.js +288 -249
  245. package/es/src/components/Tooltip.js.map +1 -1
  246. package/es/src/components/index.js +8 -8
  247. package/es/src/components/index.js.map +1 -1
  248. package/es/src/fluent.js +265 -0
  249. package/es/src/fluent.js.map +1 -0
  250. package/es/src/shapes/Area.js +96 -114
  251. package/es/src/shapes/Area.js.map +1 -1
  252. package/es/src/shapes/Bar.js +71 -86
  253. package/es/src/shapes/Bar.js.map +1 -1
  254. package/es/src/shapes/Box.js +295 -190
  255. package/es/src/shapes/Box.js.map +1 -1
  256. package/es/src/shapes/Circle.js +84 -35
  257. package/es/src/shapes/Circle.js.map +1 -1
  258. package/es/src/shapes/Image.js +164 -85
  259. package/es/src/shapes/Image.js.map +1 -1
  260. package/es/src/shapes/Line.js +51 -94
  261. package/es/src/shapes/Line.js.map +1 -1
  262. package/es/src/shapes/Path.js +33 -41
  263. package/es/src/shapes/Path.js.map +1 -1
  264. package/es/src/shapes/Rect.js +86 -37
  265. package/es/src/shapes/Rect.js.map +1 -1
  266. package/es/src/shapes/Shape.js +655 -678
  267. package/es/src/shapes/Shape.js.map +1 -1
  268. package/es/src/shapes/Whisker.js +156 -61
  269. package/es/src/shapes/Whisker.js.map +1 -1
  270. package/es/src/shapes/buildLabelData.js +125 -0
  271. package/es/src/shapes/buildLabelData.js.map +1 -0
  272. package/es/src/shapes/emitLabels.js +84 -0
  273. package/es/src/shapes/emitLabels.js.map +1 -0
  274. package/es/src/shapes/hitAreaNode.js +37 -0
  275. package/es/src/shapes/hitAreaNode.js.map +1 -0
  276. package/es/src/shapes/sceneSort.js +57 -0
  277. package/es/src/shapes/sceneSort.js.map +1 -0
  278. package/es/src/shapes/shapeConfig.js +31 -0
  279. package/es/src/shapes/shapeConfig.js.map +1 -0
  280. package/es/src/utils/BaseClass.js +35 -19
  281. package/es/src/utils/BaseClass.js.map +1 -1
  282. package/es/src/utils/D3Scale.js +16 -0
  283. package/es/src/utils/D3Scale.js.map +1 -0
  284. package/es/src/utils/D3plusConfig.js.map +1 -1
  285. package/es/src/utils/configPrep.js +8 -3
  286. package/es/src/utils/configPrep.js.map +1 -1
  287. package/es/src/utils/getProp.js +1 -1
  288. package/es/src/utils/getProp.js.map +1 -1
  289. package/es/src/utils/index.js +1 -0
  290. package/es/src/utils/index.js.map +1 -1
  291. package/es/src/utils/paintComponentScene.js +59 -0
  292. package/es/src/utils/paintComponentScene.js.map +1 -0
  293. package/es/umd-entry.js +16 -0
  294. package/es/umd-entry.js.map +1 -0
  295. package/package.json +15 -10
  296. package/types/index.d.ts +3 -1
  297. package/types/internal.d.ts +54 -0
  298. package/types/src/charts/AreaPlot/index.d.ts +10 -0
  299. package/types/src/charts/BarChart/index.d.ts +10 -0
  300. package/types/src/charts/BoxWhisker/index.d.ts +11 -0
  301. package/types/src/charts/BumpChart/index.d.ts +11 -0
  302. package/types/src/charts/ChartDefinition.d.ts +75 -0
  303. package/types/src/charts/Donut/index.d.ts +13 -0
  304. package/types/src/charts/Geomap/applyLayout.d.ts +7 -0
  305. package/types/src/charts/Geomap/emit.d.ts +7 -0
  306. package/types/src/charts/Geomap/index.d.ts +14 -0
  307. package/types/src/charts/Geomap.d.ts +6 -0
  308. package/types/src/charts/LinePlot/index.d.ts +10 -0
  309. package/types/src/charts/Matrix/applyLayout.d.ts +9 -0
  310. package/types/src/charts/Matrix/emit.d.ts +6 -0
  311. package/types/src/charts/Matrix/index.d.ts +14 -0
  312. package/types/src/charts/Matrix.d.ts +0 -26
  313. package/types/src/charts/Network/applyLayout.d.ts +10 -0
  314. package/types/src/charts/Network/emit.d.ts +6 -0
  315. package/types/src/charts/Network/index.d.ts +7 -0
  316. package/types/src/charts/Network.d.ts +0 -24
  317. package/types/src/charts/Pack/applyLayout.d.ts +16 -0
  318. package/types/src/charts/Pack/emit.d.ts +6 -0
  319. package/types/src/charts/Pack/index.d.ts +15 -0
  320. package/types/src/charts/Pack/recursionCircles.d.ts +7 -0
  321. package/types/src/charts/Pack.d.ts +0 -13
  322. package/types/src/charts/Pie/applyLayout.d.ts +8 -0
  323. package/types/src/charts/Pie/emit.d.ts +5 -0
  324. package/types/src/charts/Pie/index.d.ts +14 -0
  325. package/types/src/charts/Pie.d.ts +0 -27
  326. package/types/src/charts/Plot/draw.d.ts +2 -0
  327. package/types/src/charts/Plot/index.d.ts +167 -0
  328. package/types/src/charts/Plot/labelPlacement.d.ts +15 -0
  329. package/types/src/charts/Plot/pipeline.d.ts +70 -0
  330. package/types/src/charts/Plot/pipelineDomains.d.ts +2 -0
  331. package/types/src/charts/Plot/pipelineLineLabels.d.ts +2 -0
  332. package/types/src/charts/Plot/shapeDefaults.d.ts +64 -0
  333. package/types/src/charts/Plot/stackHelpers.d.ts +24 -0
  334. package/types/src/charts/Plot.d.ts +23 -72
  335. package/types/src/charts/Priestley/applyLayout.d.ts +21 -0
  336. package/types/src/charts/Priestley/emit.d.ts +6 -0
  337. package/types/src/charts/Priestley/index.d.ts +14 -0
  338. package/types/src/charts/Radar/applyLayout.d.ts +10 -0
  339. package/types/src/charts/Radar/emit.d.ts +7 -0
  340. package/types/src/charts/Radar/index.d.ts +14 -0
  341. package/types/src/charts/RadialMatrix/applyLayout.d.ts +11 -0
  342. package/types/src/charts/RadialMatrix/emit.d.ts +6 -0
  343. package/types/src/charts/RadialMatrix/index.d.ts +14 -0
  344. package/types/src/charts/RadialMatrix.d.ts +0 -15
  345. package/types/src/charts/Rings/applyLayout.d.ts +2 -0
  346. package/types/src/charts/Rings/emit.d.ts +7 -0
  347. package/types/src/charts/Rings/index.d.ts +15 -0
  348. package/types/src/charts/Rings.d.ts +0 -13
  349. package/types/src/charts/Sankey/applyLayout.d.ts +7 -0
  350. package/types/src/charts/Sankey/emit.d.ts +6 -0
  351. package/types/src/charts/Sankey/index.d.ts +7 -0
  352. package/types/src/charts/Sankey.d.ts +0 -4
  353. package/types/src/charts/StackedArea/index.d.ts +10 -0
  354. package/types/src/charts/Tree/applyLayout.d.ts +2 -0
  355. package/types/src/charts/Tree/emit.d.ts +7 -0
  356. package/types/src/charts/Tree/index.d.ts +14 -0
  357. package/types/src/charts/Tree.d.ts +0 -16
  358. package/types/src/charts/Treemap/applyLayout.d.ts +16 -0
  359. package/types/src/charts/Treemap/emit.d.ts +6 -0
  360. package/types/src/charts/Treemap/index.d.ts +18 -0
  361. package/types/src/charts/Treemap/thresholdFunction.d.ts +25 -0
  362. package/types/src/charts/Treemap.d.ts +4 -13
  363. package/types/src/charts/Viz.d.ts +49 -361
  364. package/types/src/charts/VizBase.d.ts +158 -0
  365. package/types/src/charts/VizBaseConfig.d.ts +148 -0
  366. package/types/src/charts/applyDefinition.d.ts +13 -0
  367. package/types/src/charts/axes.d.ts +134 -0
  368. package/types/src/charts/chartGeometry.d.ts +58 -0
  369. package/types/src/charts/definition/ChartDefinition.d.ts +84 -0
  370. package/types/src/charts/definition/applyDefinition.d.ts +13 -0
  371. package/types/src/charts/definition/makeChart.d.ts +22 -0
  372. package/types/src/charts/drawSteps/zoomControls.d.ts +25 -5
  373. package/types/src/charts/emitHelpers.d.ts +122 -0
  374. package/types/src/charts/ensureZoomDom.d.ts +39 -0
  375. package/types/src/charts/events/click.legend.d.ts +1 -1
  376. package/types/src/charts/events/click.shape.d.ts +1 -1
  377. package/types/src/charts/events/mouseenter.d.ts +1 -1
  378. package/types/src/charts/events/mouseleave.d.ts +1 -1
  379. package/types/src/charts/events/mousemove.legend.d.ts +1 -1
  380. package/types/src/charts/events/mousemove.shape.d.ts +1 -1
  381. package/types/src/charts/events/touchstart.body.d.ts +1 -1
  382. package/types/src/charts/factories.d.ts +73 -0
  383. package/types/src/charts/features/axes.d.ts +134 -0
  384. package/types/src/charts/features/chartGeometry.d.ts +58 -0
  385. package/types/src/charts/features/colorScaleBucket.d.ts +43 -0
  386. package/types/src/charts/features/colorScaleBucketShare.d.ts +16 -0
  387. package/types/src/charts/features/emitHelpers.d.ts +123 -0
  388. package/types/src/charts/features/ensureZoomDom.d.ts +39 -0
  389. package/types/src/charts/features/features.d.ts +152 -0
  390. package/types/src/charts/features/featuresLegend.d.ts +12 -0
  391. package/types/src/charts/features/legendLabel.d.ts +11 -0
  392. package/types/src/charts/features/lineLabels.d.ts +40 -0
  393. package/types/src/charts/features/plotPaint.d.ts +233 -0
  394. package/types/src/charts/features/shapeEmit.d.ts +61 -0
  395. package/types/src/charts/features.d.ts +152 -0
  396. package/types/src/charts/featuresLegend.d.ts +12 -0
  397. package/types/src/charts/helpers/matrixData.d.ts +1 -1
  398. package/types/src/charts/index.d.ts +21 -21
  399. package/types/src/charts/legendLabel.d.ts +11 -0
  400. package/types/src/charts/lineLabels.d.ts +40 -0
  401. package/types/src/charts/makeChart.d.ts +22 -0
  402. package/types/src/charts/pipeline/resolveSpec.d.ts +51 -0
  403. package/types/src/charts/pipeline/runChartDraw.d.ts +38 -0
  404. package/types/src/charts/pipeline/runVizPipeline.d.ts +31 -0
  405. package/types/src/charts/pipeline/stages.d.ts +160 -0
  406. package/types/src/charts/pipeline/vizContext.d.ts +45 -0
  407. package/types/src/charts/pipeline/vizDraw.d.ts +25 -0
  408. package/types/src/charts/pipeline/vizDrawPure.d.ts +46 -0
  409. package/types/src/charts/pipeline/vizPreDraw.d.ts +22 -0
  410. package/types/src/charts/pipeline/vizPreDrawPure.d.ts +68 -0
  411. package/types/src/charts/plotBuffers/Bar.d.ts +6 -5
  412. package/types/src/charts/plotBuffers/Box.d.ts +6 -5
  413. package/types/src/charts/plotBuffers/Circle.d.ts +6 -5
  414. package/types/src/charts/plotBuffers/Line.d.ts +6 -5
  415. package/types/src/charts/plotBuffers/Rect.d.ts +6 -5
  416. package/types/src/charts/plotBuffers/discreteBuffer.d.ts +2 -1
  417. package/types/src/charts/plotBuffers/numericBuffer.d.ts +2 -1
  418. package/types/src/charts/plotPaint.d.ts +233 -0
  419. package/types/src/charts/resolveSpec.d.ts +50 -0
  420. package/types/src/charts/runChartDraw.d.ts +38 -0
  421. package/types/src/charts/runVizPipeline.d.ts +31 -0
  422. package/types/src/charts/shapeEmit.d.ts +61 -0
  423. package/types/src/charts/stages.d.ts +117 -0
  424. package/types/src/charts/viz/Viz.d.ts +111 -0
  425. package/types/src/charts/viz/VizBase.d.ts +160 -0
  426. package/types/src/charts/viz/VizBaseConfig.d.ts +157 -0
  427. package/types/src/charts/viz/interactionOpacity.d.ts +23 -0
  428. package/types/src/charts/viz/ordinalColor.d.ts +14 -0
  429. package/types/src/charts/viz/trailCatchup.d.ts +14 -0
  430. package/types/src/charts/viz/vizDefaults.d.ts +8 -0
  431. package/types/src/charts/viz/vizRender.d.ts +8 -0
  432. package/types/src/charts/viz/vizTypes.d.ts +250 -0
  433. package/types/src/charts/vizContext.d.ts +46 -0
  434. package/types/src/charts/vizDefaults.d.ts +8 -0
  435. package/types/src/charts/vizDraw.d.ts +25 -0
  436. package/types/src/charts/vizDrawPure.d.ts +17 -0
  437. package/types/src/charts/vizPreDraw.d.ts +22 -0
  438. package/types/src/charts/vizPreDrawPure.d.ts +40 -0
  439. package/types/src/charts/vizRender.d.ts +8 -0
  440. package/types/src/charts/vizTypes.d.ts +202 -0
  441. package/types/src/components/Axis/Axis.d.ts +182 -0
  442. package/types/src/components/Axis/AxisBottom.d.ts +11 -0
  443. package/types/src/components/Axis/AxisLeft.d.ts +11 -0
  444. package/types/src/components/Axis/AxisRight.d.ts +11 -0
  445. package/types/src/components/Axis/AxisTop.d.ts +11 -0
  446. package/types/src/components/Axis/axisLayout.d.ts +29 -0
  447. package/types/src/components/Axis/axisLayoutLabels.d.ts +70 -0
  448. package/types/src/components/Axis/axisLayoutScale.d.ts +14 -0
  449. package/types/src/components/Axis/axisRender.d.ts +68 -0
  450. package/types/src/components/Axis.d.ts +68 -194
  451. package/types/src/components/ColorScale/ColorScale.d.ts +100 -0
  452. package/types/src/components/ColorScale/colorScaleRender.d.ts +15 -0
  453. package/types/src/components/ColorScale/colorScaleScale.d.ts +19 -0
  454. package/types/src/components/ColorScale.d.ts +1 -129
  455. package/types/src/components/Legend/Legend.d.ts +95 -0
  456. package/types/src/components/Legend/legendConfig.d.ts +7 -0
  457. package/types/src/components/Legend/legendRender.d.ts +16 -0
  458. package/types/src/components/Legend.d.ts +9 -73
  459. package/types/src/components/TextBox.d.ts +25 -218
  460. package/types/src/components/Timeline/Timeline.d.ts +118 -0
  461. package/types/src/components/Timeline/timelineConfig.d.ts +6 -0
  462. package/types/src/components/Timeline/timelineRender.d.ts +24 -0
  463. package/types/src/components/Timeline.d.ts +7 -81
  464. package/types/src/components/Tooltip.d.ts +20 -200
  465. package/types/src/components/axisLayout.d.ts +27 -0
  466. package/types/src/components/axisLayoutLabels.d.ts +42 -0
  467. package/types/src/components/axisLayoutScale.d.ts +12 -0
  468. package/types/src/components/axisRender.d.ts +65 -0
  469. package/types/src/components/colorScaleRender.d.ts +15 -0
  470. package/types/src/components/colorScaleScale.d.ts +19 -0
  471. package/types/src/components/index.d.ts +8 -8
  472. package/types/src/components/legendConfig.d.ts +7 -0
  473. package/types/src/components/legendRender.d.ts +16 -0
  474. package/types/src/components/timelineConfig.d.ts +6 -0
  475. package/types/src/components/timelineRender.d.ts +14 -0
  476. package/types/src/fluent.d.ts +94 -0
  477. package/types/src/shapes/Area.d.ts +15 -27
  478. package/types/src/shapes/Bar.d.ts +13 -33
  479. package/types/src/shapes/Box.d.ts +17 -56
  480. package/types/src/shapes/Circle.d.ts +11 -17
  481. package/types/src/shapes/Image.d.ts +18 -84
  482. package/types/src/shapes/Line.d.ts +12 -22
  483. package/types/src/shapes/Path.d.ts +12 -19
  484. package/types/src/shapes/Rect.d.ts +11 -27
  485. package/types/src/shapes/Shape.d.ts +46 -257
  486. package/types/src/shapes/Whisker.d.ts +15 -42
  487. package/types/src/shapes/buildLabelData.d.ts +50 -0
  488. package/types/src/shapes/emitLabels.d.ts +16 -0
  489. package/types/src/shapes/hitAreaNode.d.ts +19 -0
  490. package/types/src/shapes/sceneSort.d.ts +20 -0
  491. package/types/src/shapes/shapeConfig.d.ts +226 -0
  492. package/types/src/utils/BaseClass.d.ts +13 -7
  493. package/types/src/utils/D3Scale.d.ts +48 -0
  494. package/types/src/utils/D3plusConfig.d.ts +270 -15
  495. package/types/src/utils/configPrep.d.ts +7 -4
  496. package/types/src/utils/getProp.d.ts +3 -1
  497. package/types/src/utils/index.d.ts +3 -1
  498. package/types/src/utils/paintComponentScene.d.ts +28 -0
  499. package/types/umd-entry.d.ts +15 -0
  500. package/umd/d3plus-core.full.js +30966 -19051
  501. package/umd/d3plus-core.full.js.map +1 -1
  502. package/umd/d3plus-core.full.min.js +5400 -2949
  503. package/umd/d3plus-core.js +17364 -10534
  504. package/umd/d3plus-core.js.map +1 -1
  505. package/umd/d3plus-core.min.js +3494 -1877
  506. package/es/src/charts/AreaPlot.js +0 -85
  507. package/es/src/charts/AreaPlot.js.map +0 -1
  508. package/es/src/charts/BarChart.js +0 -92
  509. package/es/src/charts/BarChart.js.map +0 -1
  510. package/es/src/charts/BoxWhisker.js +0 -92
  511. package/es/src/charts/BoxWhisker.js.map +0 -1
  512. package/es/src/charts/BumpChart.js +0 -147
  513. package/es/src/charts/BumpChart.js.map +0 -1
  514. package/es/src/charts/Donut.js +0 -84
  515. package/es/src/charts/Donut.js.map +0 -1
  516. package/es/src/charts/Geomap.js +0 -766
  517. package/es/src/charts/Geomap.js.map +0 -1
  518. package/es/src/charts/LinePlot.js +0 -83
  519. package/es/src/charts/LinePlot.js.map +0 -1
  520. package/es/src/charts/Matrix.js +0 -341
  521. package/es/src/charts/Matrix.js.map +0 -1
  522. package/es/src/charts/Network.js +0 -796
  523. package/es/src/charts/Network.js.map +0 -1
  524. package/es/src/charts/Pack.js +0 -308
  525. package/es/src/charts/Pack.js.map +0 -1
  526. package/es/src/charts/Pie.js +0 -232
  527. package/es/src/charts/Pie.js.map +0 -1
  528. package/es/src/charts/Plot.js +0 -2114
  529. package/es/src/charts/Plot.js.map +0 -1
  530. package/es/src/charts/Priestley.js +0 -296
  531. package/es/src/charts/Priestley.js.map +0 -1
  532. package/es/src/charts/Radar.js +0 -420
  533. package/es/src/charts/Radar.js.map +0 -1
  534. package/es/src/charts/RadialMatrix.js +0 -383
  535. package/es/src/charts/RadialMatrix.js.map +0 -1
  536. package/es/src/charts/Rings.js +0 -788
  537. package/es/src/charts/Rings.js.map +0 -1
  538. package/es/src/charts/Sankey.js +0 -461
  539. package/es/src/charts/Sankey.js.map +0 -1
  540. package/es/src/charts/StackedArea.js +0 -80
  541. package/es/src/charts/StackedArea.js.map +0 -1
  542. package/es/src/charts/Tree.js +0 -347
  543. package/es/src/charts/Tree.js.map +0 -1
  544. package/es/src/charts/Treemap.js +0 -454
  545. package/es/src/charts/Treemap.js.map +0 -1
  546. package/es/src/charts/Viz.js +0 -1832
  547. package/es/src/charts/Viz.js.map +0 -1
  548. package/es/src/charts/drawSteps/drawAttribution.js +0 -16
  549. package/es/src/charts/drawSteps/drawAttribution.js.map +0 -1
  550. package/es/src/charts/drawSteps/drawBack.js +0 -24
  551. package/es/src/charts/drawSteps/drawBack.js.map +0 -1
  552. package/es/src/charts/drawSteps/drawColorScale.js +0 -75
  553. package/es/src/charts/drawSteps/drawColorScale.js.map +0 -1
  554. package/es/src/charts/drawSteps/drawLegend.js +0 -122
  555. package/es/src/charts/drawSteps/drawLegend.js.map +0 -1
  556. package/es/src/charts/drawSteps/drawSubtitle.js +0 -31
  557. package/es/src/charts/drawSteps/drawSubtitle.js.map +0 -1
  558. package/es/src/charts/drawSteps/drawTimeline.js +0 -85
  559. package/es/src/charts/drawSteps/drawTimeline.js.map +0 -1
  560. package/es/src/charts/drawSteps/drawTitle.js +0 -31
  561. package/es/src/charts/drawSteps/drawTitle.js.map +0 -1
  562. package/es/src/charts/drawSteps/drawTotal.js +0 -32
  563. package/es/src/charts/drawSteps/drawTotal.js.map +0 -1
  564. package/es/src/components/Axis.js +0 -1457
  565. package/es/src/components/Axis.js.map +0 -1
  566. package/es/src/components/AxisBottom.js.map +0 -1
  567. package/es/src/components/AxisLeft.js.map +0 -1
  568. package/es/src/components/AxisRight.js.map +0 -1
  569. package/es/src/components/AxisTop.js.map +0 -1
  570. package/es/src/components/ColorScale.js +0 -843
  571. package/es/src/components/ColorScale.js.map +0 -1
  572. package/es/src/components/Legend.js +0 -622
  573. package/es/src/components/Legend.js.map +0 -1
  574. package/es/src/components/Timeline.js +0 -695
  575. package/es/src/components/Timeline.js.map +0 -1
  576. /package/es/src/components/{AxisBottom.js → Axis/AxisBottom.js} +0 -0
  577. /package/es/src/components/{AxisLeft.js → Axis/AxisLeft.js} +0 -0
  578. /package/es/src/components/{AxisRight.js → Axis/AxisRight.js} +0 -0
  579. /package/es/src/components/{AxisTop.js → Axis/AxisTop.js} +0 -0
@@ -0,0 +1,141 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function _iterable_to_array(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _non_iterable_spread() {
13
+ 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
+ }
15
+ function _to_consumable_array(arr) {
16
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
+ }
18
+ function _unsupported_iterable_to_array(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
+ }
26
+ /**
27
+ `treemapEmit` — scene nodes for a laid-out Treemap: one rect per cell
28
+ plus the title + share-% text labels for each cell, both as flat data.
29
+ */ import { colorContrast } from "@d3plus/color";
30
+ import { formatAbbreviate } from "@d3plus/format";
31
+ import constant from "../../utils/constant.js";
32
+ import { emitLabels } from "../../shapes/emitLabels.js";
33
+ function resolveAccessor(val, d, i) {
34
+ if (typeof val === "function") {
35
+ return val(d, i);
36
+ }
37
+ return val;
38
+ }
39
+ export var treemapEmit = function treemapEmit(param) {
40
+ var viz = param.viz, shapeData = param.shapeData;
41
+ var _viz_schema_shapeConfig;
42
+ var nodes = shapeData !== null && shapeData !== void 0 ? shapeData : [];
43
+ if (!nodes.length) return [];
44
+ var locale = viz.schema.locale;
45
+ var drawLabel = viz._drawLabel;
46
+ var sc = (_viz_schema_shapeConfig = viz.schema.shapeConfig) !== null && _viz_schema_shapeConfig !== void 0 ? _viz_schema_shapeConfig : {};
47
+ var rectNodes = nodes.map(function(d) {
48
+ var _d_i;
49
+ var fill = resolveAccessor(sc.fill, d.data, d.i);
50
+ var stroke = resolveAccessor(sc.stroke, d.data, d.i);
51
+ var opacity = resolveAccessor(sc.opacity, d.data, d.i);
52
+ var strokeWidth = resolveAccessor(sc.strokeWidth, d.data, d.i);
53
+ return {
54
+ type: "rect",
55
+ key: "treemap-".concat(d.id),
56
+ x: d.x0,
57
+ y: d.y0,
58
+ width: d.x1 - d.x0,
59
+ height: d.y1 - d.y0,
60
+ datum: d.data,
61
+ paint: {
62
+ fill: typeof fill === "string" ? fill : undefined,
63
+ stroke: typeof stroke === "string" || stroke == null ? stroke : String(stroke),
64
+ opacity: opacity,
65
+ strokeWidth: strokeWidth
66
+ },
67
+ aria: {
68
+ label: "".concat(drawLabel(d.data, (_d_i = d.i) !== null && _d_i !== void 0 ? _d_i : 0), ", ").concat(viz.schema.sum(d.data), ", ").concat(formatAbbreviate(d.share * 100, locale), "%")
69
+ }
70
+ };
71
+ });
72
+ var labelNodes = emitLabels({
73
+ data: nodes,
74
+ label: function label(d) {
75
+ var _node_i;
76
+ var node = d;
77
+ return [
78
+ drawLabel(node.data, (_node_i = node.i) !== null && _node_i !== void 0 ? _node_i : 0),
79
+ "".concat(formatAbbreviate(node.share * 100, locale), "%")
80
+ ];
81
+ },
82
+ x: function x(d) {
83
+ var node = d;
84
+ return node.x0 + (node.x1 - node.x0) / 2;
85
+ },
86
+ y: function y(d) {
87
+ var node = d;
88
+ return node.y0 + (node.y1 - node.y0) / 2;
89
+ },
90
+ aes: function aes(d) {
91
+ var node = d;
92
+ return {
93
+ width: node.x1 - node.x0,
94
+ height: node.y1 - node.y0
95
+ };
96
+ },
97
+ rotate: constant(0),
98
+ id: function id(d) {
99
+ return d.id;
100
+ },
101
+ labelBounds: function labelBounds(_d, _i, aes) {
102
+ var fontMax = 32;
103
+ var fontMin = 8;
104
+ var padding = 5;
105
+ var w = aes.width, h = aes.height;
106
+ var sh = Math.min(fontMax, (h - padding * 2) * 0.5);
107
+ if (sh < fontMin) sh = 0;
108
+ return [
109
+ {
110
+ width: w,
111
+ height: h - sh,
112
+ x: -w / 2,
113
+ y: -h / 2
114
+ },
115
+ {
116
+ width: w,
117
+ height: sh + padding * 2,
118
+ x: -w / 2,
119
+ y: h / 2 - sh - padding * 2
120
+ }
121
+ ];
122
+ },
123
+ labelConfig: {
124
+ fontMax: 32,
125
+ textAnchor: function textAnchor(d) {
126
+ return d && d.l === 0 ? "start" : "middle";
127
+ },
128
+ verticalAlign: function verticalAlign(d) {
129
+ return d && d.l === 0 ? "top" : "bottom";
130
+ },
131
+ fontColor: function fontColor(d) {
132
+ var src = d && d.data ? d.data : d;
133
+ var fillVal = resolveAccessor(sc.fill, src, src.i);
134
+ return typeof fillVal === "string" ? colorContrast(fillVal) : undefined;
135
+ }
136
+ }
137
+ });
138
+ return _to_consumable_array(rectNodes).concat(_to_consumable_array(labelNodes));
139
+ };
140
+
141
+ //# sourceMappingURL=emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/Treemap/emit.ts"],"sourcesContent":["/**\n `treemapEmit` — scene nodes for a laid-out Treemap: one rect per cell\n plus the title + share-% text labels for each cell, both as flat data.\n*/\n\nimport {colorContrast} from \"@d3plus/color\";\nimport {formatAbbreviate} from \"@d3plus/format\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport constant from \"../../utils/constant.js\";\nimport {emitLabels} from \"../../shapes/emitLabels.js\";\nimport type {ChartEmit} from \"../definition/ChartDefinition.js\";\nimport type {TreemapShapeNode} from \"./applyLayout.js\";\n\nfunction 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\nexport const treemapEmit: ChartEmit = ({viz, shapeData}) => {\n const nodes = (shapeData ?? []) as TreemapShapeNode[];\n if (!nodes.length) return [];\n\n const locale = viz.schema.locale;\n const drawLabel = viz._drawLabel;\n const sc = (viz.schema.shapeConfig ?? {}) as Record<string, unknown>;\n\n const rectNodes: SceneNode[] = nodes.map(d => {\n const fill = resolveAccessor<string>(sc.fill, d.data, d.i);\n const stroke = resolveAccessor<string | undefined>(sc.stroke, d.data, d.i);\n const opacity = resolveAccessor<number>(sc.opacity, d.data, d.i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d.data, d.i);\n return {\n type: \"rect\",\n key: `treemap-${d.id}`,\n x: d.x0,\n y: d.y0,\n width: d.x1 - d.x0,\n height: d.y1 - d.y0,\n datum: d.data,\n paint: {\n fill: typeof fill === \"string\" ? fill : undefined,\n stroke:\n typeof stroke === \"string\" || stroke == null\n ? stroke\n : String(stroke),\n opacity,\n strokeWidth,\n },\n aria: {\n label: `${drawLabel(d.data, d.i ?? 0)}, ${(viz.schema.sum as (d: DataPoint) => number)(d.data)}, ${formatAbbreviate(d.share * 100, locale)}%`,\n },\n } as SceneNode;\n });\n\n const labelNodes = emitLabels({\n data: nodes as unknown as DataPoint[],\n label: d => {\n const node = d as unknown as TreemapShapeNode;\n return [\n drawLabel(node.data, node.i ?? 0),\n `${formatAbbreviate(node.share * 100, locale)}%`,\n ];\n },\n x: d => {\n const node = d as unknown as TreemapShapeNode;\n return node.x0 + (node.x1 - node.x0) / 2;\n },\n y: d => {\n const node = d as unknown as TreemapShapeNode;\n return node.y0 + (node.y1 - node.y0) / 2;\n },\n aes: d => {\n const node = d as unknown as TreemapShapeNode;\n return {width: node.x1 - node.x0, height: node.y1 - node.y0};\n },\n rotate: constant(0),\n id: d => (d as unknown as TreemapShapeNode).id,\n labelBounds: (_d, _i, aes) => {\n const fontMax = 32;\n const fontMin = 8;\n const padding = 5;\n const {width: w, height: h} = aes as {width: number; height: number};\n let sh = Math.min(fontMax, (h - padding * 2) * 0.5);\n if (sh < fontMin) sh = 0;\n return [\n {width: w, height: h - sh, x: -w / 2, y: -h / 2},\n {width: w, height: sh + padding * 2, x: -w / 2, y: h / 2 - sh - padding * 2},\n ];\n },\n labelConfig: {\n fontMax: 32,\n textAnchor: (d: DataPoint & {l?: number}) =>\n d && d.l === 0 ? \"start\" : \"middle\",\n verticalAlign: (d: DataPoint & {l?: number}) =>\n d && d.l === 0 ? \"top\" : \"bottom\",\n fontColor: (d: DataPoint & {data?: DataPoint; i?: number}) => {\n const src = (d && d.data ? d.data : d) as DataPoint & {i?: number};\n const fillVal = resolveAccessor<string>(sc.fill, src, src.i);\n return typeof fillVal === \"string\" ? colorContrast(fillVal) : undefined;\n },\n },\n });\n\n return [...rectNodes, ...labelNodes];\n};\n"],"names":["colorContrast","formatAbbreviate","constant","emitLabels","resolveAccessor","val","d","i","treemapEmit","viz","shapeData","nodes","length","locale","schema","drawLabel","_drawLabel","sc","shapeConfig","rectNodes","map","fill","data","stroke","opacity","strokeWidth","type","key","id","x","x0","y","y0","width","x1","height","y1","datum","paint","undefined","String","aria","label","sum","share","labelNodes","node","aes","rotate","labelBounds","_d","_i","fontMax","fontMin","padding","w","h","sh","Math","min","labelConfig","textAnchor","l","verticalAlign","fontColor","src","fill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AE"}
@@ -0,0 +1,177 @@
1
+ /**
2
+ Treemap — d3-hierarchy treemap layout, one cell per leaf.
3
+
4
+ Implementation files in this folder:
5
+ - `applyLayout.ts` — chart-specific `TransformStage`.
6
+ - `emit.ts` — rect + label scene nodes from the laid-out data.
7
+ - `thresholdFunction.ts` — pure threshold-merge algorithm.
8
+
9
+ The default export is the chart class via `makeChart(def)`; the named
10
+ export is the def itself.
11
+ */ import { treemap, treemapBinary, treemapDice, treemapResquarify, treemapSlice, treemapSliceDice, treemapSquarify } from "d3-hierarchy";
12
+ import { formatAbbreviate } from "@d3plus/format";
13
+ import accessor from "../../utils/accessor.js";
14
+ import { backFeature, subtitleFeature, titleFeature, totalFeature } from "../features/features.js";
15
+ import { colorScaleBucketShare } from "../features/colorScaleBucket.js";
16
+ import { makeChart } from "../definition/makeChart.js";
17
+ import { applyTreemapLayout } from "./applyLayout.js";
18
+ import { treemapEmit } from "./emit.js";
19
+ import { thresholdFunction } from "./thresholdFunction.js";
20
+ var tileMethods = {
21
+ treemapBinary: treemapBinary,
22
+ treemapDice: treemapDice,
23
+ treemapResquarify: treemapResquarify,
24
+ treemapSlice: treemapSlice,
25
+ treemapSliceDice: treemapSliceDice,
26
+ treemapSquarify: treemapSquarify
27
+ };
28
+ var isAggregated = function isAggregated(leaf) {
29
+ return !!leaf.children && leaf.children.length === 1 && leaf.children[0].data._isAggregation === true;
30
+ };
31
+ export var treemapDef = {
32
+ name: "Treemap",
33
+ features: [
34
+ backFeature,
35
+ titleFeature,
36
+ subtitleFeature,
37
+ totalFeature
38
+ ],
39
+ layoutStage: applyTreemapLayout,
40
+ emit: treemapEmit,
41
+ thresholdFunction: function thresholdFunction1(viz, data) {
42
+ return thresholdFunction(data, {
43
+ aggs: viz.schema.aggs,
44
+ drawDepth: viz._drawDepth,
45
+ groupBy: viz.schema.groupBy,
46
+ threshold: viz.schema.threshold,
47
+ thresholdKey: viz.schema.thresholdKey
48
+ });
49
+ },
50
+ ctx: {
51
+ treemap: treemap().round(true)
52
+ },
53
+ fields: [
54
+ {
55
+ key: "layoutPadding",
56
+ default: 1
57
+ },
58
+ {
59
+ key: "sort",
60
+ default: function _default(a, b) {
61
+ var _b_value, _a_value;
62
+ return ((_b_value = b.value) !== null && _b_value !== void 0 ? _b_value : 0) - ((_a_value = a.value) !== null && _a_value !== void 0 ? _a_value : 0);
63
+ },
64
+ decorate: function decorate(_viz, base) {
65
+ var baseSort = base;
66
+ return function(a, b) {
67
+ var aggA = isAggregated(a);
68
+ var aggB = isAggregated(b);
69
+ return aggA && !aggB ? 1 : !aggA && aggB ? -1 : baseSort(a, b);
70
+ };
71
+ }
72
+ },
73
+ {
74
+ key: "sum",
75
+ default: accessor("value"),
76
+ coerce: function coerce(v) {
77
+ return typeof v === "function" ? v : accessor(v);
78
+ },
79
+ onSet: function onSet(viz, v) {
80
+ viz.schema.thresholdKey = v;
81
+ }
82
+ },
83
+ {
84
+ key: "tile",
85
+ default: treemapSquarify,
86
+ coerce: function coerce(v) {
87
+ var _tileMethods_key;
88
+ if (typeof v !== "string") return v;
89
+ var key = "treemap".concat(v.charAt(0).toUpperCase()).concat(v.slice(1));
90
+ return (_tileMethods_key = tileMethods[key]) !== null && _tileMethods_key !== void 0 ? _tileMethods_key : treemapSquarify;
91
+ }
92
+ },
93
+ {
94
+ key: "shapeConfig",
95
+ merge: true,
96
+ factory: function factory(viz) {
97
+ return {
98
+ ariaLabel: function ariaLabel(d, i) {
99
+ var rank = typeof d.rank === "number" ? "".concat(d.rank + 1, ". ") : "";
100
+ var sumFn = viz.schema.sum;
101
+ return "".concat(rank).concat(viz._drawLabel(d, i), ", ").concat(sumFn(d, i), ".");
102
+ },
103
+ labelConfig: {
104
+ fontMax: 32,
105
+ fontMin: 8,
106
+ fontResize: true,
107
+ padding: 5
108
+ }
109
+ };
110
+ }
111
+ },
112
+ {
113
+ key: "tooltipConfig",
114
+ merge: true,
115
+ factory: function factory(viz) {
116
+ return {
117
+ tbody: [
118
+ [
119
+ function() {
120
+ return viz.schema.translate("Share");
121
+ },
122
+ function(_d, _i, x) {
123
+ // A ColorScale range swatch carries no per-row share, so sum the
124
+ // share of every datum that falls in its color range.
125
+ if (x._isColorScaleBucket) {
126
+ var s = colorScaleBucketShare(viz, x.color, viz.schema.sum);
127
+ return s == null ? "" : "".concat(formatAbbreviate(s * 100, viz.schema.locale), "%");
128
+ }
129
+ // A Legend bucket aggregates multiple rows, so `share` arrives
130
+ // as an array of the members' shares — sum it; a single cell's
131
+ // share is a plain number.
132
+ var share = Array.isArray(x.share) ? x.share.reduce(function(a, b) {
133
+ return a + b;
134
+ }, 0) : x.share;
135
+ if (!Number.isFinite(share)) return "";
136
+ return "".concat(formatAbbreviate(share * 100, viz.schema.locale), "%");
137
+ }
138
+ ]
139
+ ]
140
+ };
141
+ }
142
+ },
143
+ {
144
+ key: "legendTooltip",
145
+ merge: true,
146
+ factory: function factory() {
147
+ return {
148
+ tbody: []
149
+ };
150
+ }
151
+ },
152
+ {
153
+ key: "legendSort",
154
+ factory: function factory(viz) {
155
+ var sumFn = viz.schema.sum;
156
+ return function(a, b) {
157
+ return sumFn(b) - sumFn(a);
158
+ };
159
+ }
160
+ },
161
+ {
162
+ key: "legend",
163
+ factory: function factory(viz) {
164
+ var base = viz.schema.legend;
165
+ return function(config, arr) {
166
+ if (arr.length === viz._filteredData.length) return false;
167
+ return base.call(viz, config, arr);
168
+ };
169
+ }
170
+ }
171
+ ]
172
+ };
173
+ /**
174
+ Uses the d3 treemap layout to create SVG rectangles based on an array of data.
175
+ */ export default makeChart(treemapDef);
176
+
177
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/Treemap/index.ts"],"sourcesContent":["/**\n Treemap — d3-hierarchy treemap layout, one cell per leaf.\n\n Implementation files in this folder:\n - `applyLayout.ts` — chart-specific `TransformStage`.\n - `emit.ts` — rect + label scene nodes from the laid-out data.\n - `thresholdFunction.ts` — pure threshold-merge algorithm.\n\n The default export is the chart class via `makeChart(def)`; the named\n export is the def itself.\n*/\n\nimport {\n treemap,\n treemapBinary,\n treemapDice,\n treemapResquarify,\n treemapSlice,\n treemapSliceDice,\n treemapSquarify,\n} from \"d3-hierarchy\";\nimport type {HierarchyNode} from \"d3-hierarchy\";\n\nimport {formatAbbreviate} from \"@d3plus/format\";\nimport type {DataPoint} from \"@d3plus/data\";\n\nimport accessor from \"../../utils/accessor.js\";\nimport {backFeature, subtitleFeature, titleFeature, totalFeature} from \"../features/features.js\";\nimport {colorScaleBucketShare} from \"../features/colorScaleBucket.js\";\nimport type {ChartDefinition} from \"../definition/ChartDefinition.js\";\nimport type {D3plusConfig} from \"../../utils/D3plusConfig.js\";\nimport {makeChart} from \"../definition/makeChart.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\nimport {applyTreemapLayout} from \"./applyLayout.js\";\nimport {treemapEmit} from \"./emit.js\";\nimport {thresholdFunction} from \"./thresholdFunction.js\";\n\nconst tileMethods: Record<string, unknown> = {\n treemapBinary,\n treemapDice,\n treemapResquarify,\n treemapSlice,\n treemapSliceDice,\n treemapSquarify,\n};\n\ntype AggregatedLeaf = Omit<HierarchyNode<DataPoint>, \"children\"> & {\n children?: AggregatedLeaf[];\n data: DataPoint & {_isAggregation?: boolean};\n};\n\nconst isAggregated = (leaf: AggregatedLeaf): boolean =>\n !!leaf.children &&\n leaf.children.length === 1 &&\n leaf.children[0].data._isAggregation === true;\n\ntype SortFn = (a: HierarchyNode<DataPoint>, b: HierarchyNode<DataPoint>) => number;\n\nexport const treemapDef: ChartDefinition = {\n name: \"Treemap\",\n\n features: [backFeature, titleFeature, subtitleFeature, totalFeature],\n layoutStage: applyTreemapLayout,\n emit: treemapEmit,\n\n thresholdFunction: (viz: VizInstance, data: unknown[]) =>\n thresholdFunction(data as DataPoint[], {\n aggs: viz.schema.aggs,\n drawDepth: viz._drawDepth,\n groupBy: viz.schema.groupBy as ((d: DataPoint) => DataPoint[keyof DataPoint])[],\n threshold: viz.schema.threshold as (branchData: DataPoint[]) => number,\n thresholdKey: viz.schema.thresholdKey as (d: DataPoint) => number,\n }),\n\n ctx: {\n treemap: treemap().round(true),\n },\n\n fields: [\n {key: \"layoutPadding\", default: 1},\n {\n key: \"sort\",\n default: ((a, b) => (b.value ?? 0) - (a.value ?? 0)) as SortFn,\n decorate: (_viz, base) => {\n const baseSort = base as SortFn;\n return ((a, b) => {\n const aggA = isAggregated(a as AggregatedLeaf);\n const aggB = isAggregated(b as AggregatedLeaf);\n return aggA && !aggB ? 1 : !aggA && aggB ? -1 : baseSort(a, b);\n }) as SortFn;\n },\n },\n {\n key: \"sum\",\n default: accessor(\"value\"),\n coerce: v => (typeof v === \"function\" ? v : accessor(v as string)),\n onSet: (viz, v) => { viz.schema.thresholdKey = v; },\n },\n {\n key: \"tile\",\n default: treemapSquarify,\n coerce: v => {\n if (typeof v !== \"string\") return v;\n const key = `treemap${v.charAt(0).toUpperCase()}${v.slice(1)}`;\n return tileMethods[key] ?? treemapSquarify;\n },\n },\n {\n key: \"shapeConfig\",\n merge: true,\n factory: (viz: VizInstance) => ({\n ariaLabel: (d: DataPoint & {rank?: number}, i: number) => {\n const rank = typeof d.rank === \"number\" ? `${d.rank + 1}. ` : \"\";\n const sumFn = viz.schema.sum as (d: DataPoint, i: number) => number;\n return `${rank}${viz._drawLabel(d, i)}, ${sumFn(d, i)}.`;\n },\n labelConfig: {fontMax: 32, fontMin: 8, fontResize: true, padding: 5},\n }),\n },\n {\n key: \"tooltipConfig\",\n merge: true,\n factory: (viz: VizInstance) => ({\n tbody: [\n [\n () => viz.schema.translate(\"Share\"),\n (_d: DataPoint, _i: number, x: Record<string, unknown>) => {\n // A ColorScale range swatch carries no per-row share, so sum the\n // share of every datum that falls in its color range.\n if (x._isColorScaleBucket) {\n const s = colorScaleBucketShare(\n viz,\n x.color,\n viz.schema.sum as (d: DataPoint, i: number) => number,\n );\n return s == null\n ? \"\"\n : `${formatAbbreviate(s * 100, viz.schema.locale)}%`;\n }\n // A Legend bucket aggregates multiple rows, so `share` arrives\n // as an array of the members' shares — sum it; a single cell's\n // share is a plain number.\n const share = Array.isArray(x.share)\n ? (x.share as number[]).reduce((a, b) => a + b, 0)\n : (x.share as number);\n if (!Number.isFinite(share)) return \"\";\n return `${formatAbbreviate(share * 100, viz.schema.locale)}%`;\n },\n ],\n ],\n }),\n },\n {\n key: \"legendTooltip\",\n merge: true,\n factory: () => ({tbody: []}),\n },\n {\n key: \"legendSort\",\n factory: (viz: VizInstance) => {\n const sumFn = viz.schema.sum as (d: DataPoint) => number;\n return (a: DataPoint, b: DataPoint) => sumFn(b) - sumFn(a);\n },\n },\n {\n key: \"legend\",\n factory: (viz: VizInstance) => {\n const base = viz.schema.legend as (config: D3plusConfig, arr: DataPoint[]) => unknown;\n return (config: D3plusConfig, arr: DataPoint[]) => {\n if (arr.length === viz._filteredData.length) return false;\n return base.call(viz, config, arr);\n };\n },\n },\n ],\n};\n\n/**\n Uses the d3 treemap layout to create SVG rectangles based on an array of data.\n*/\nexport default makeChart(treemapDef);\n"],"names":["treemap","treemapBinary","treemapDice","treemapResquarify","treemapSlice","treemapSliceDice","treemapSquarify","formatAbbreviate","accessor","backFeature","subtitleFeature","titleFeature","totalFeature","colorScaleBucketShare","makeChart","applyTreemapLayout","treemapEmit","thresholdFunction","tileMethods","isAggregated","leaf","children","length","data","_isAggregation","treemapDef","name","features","layoutStage","emit","viz","aggs","schema","drawDepth","_drawDepth","groupBy","threshold","thresholdKey","ctx","round","fields","key","default","a","b","value","decorate","_viz","base","baseSort","aggA","aggB","coerce","v","onSet","charAt","toUpperCase","slice","merge","factory","ariaLabel","d","i","rank","sumFn","sum","_drawLabel","labelConfig","fontMax","fontMin","fontResize","padding","tbody","translate","_d","_i","x","_isColorScaleBucket","s","color","locale","share","Array","isArray","reduce","Number","isFinite","legend","config","arr","_filteredData","call"],"mappings":"AAAA;;;;;;;;;;AAUA,GAEA,SACEA,OAAO,EACPC,aAAa,EACbC,WAAW,EACXC,iBAAiB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OAAOlB,IAAIE,MAAM,CAACuD,MAAM;gBAC9B,OAAO,SAACC,QAAsBC;oBAC5B,IAAIA,IAAInE,MAAM,KAAKQ,IAAI4D,aAAa,CAACpE,MAAM,EAAE,OAAO;oBACpD,OAAO0B,KAAK2C,IAAI,CAAC7D,KAAK0D,QAAQC;gBAChC;YACF;QACF;KACD;AACH,EAAE;AAEF;;AAEA,GACA,eAAe3E,UAAUW,YAAY"}
@@ -0,0 +1,112 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _iterable_to_array(iter) {
13
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
14
+ }
15
+ function _iterable_to_array_limit(arr, i) {
16
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
17
+ if (_i == null) return;
18
+ var _arr = [];
19
+ var _n = true;
20
+ var _d = false;
21
+ var _s, _e;
22
+ try {
23
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
24
+ _arr.push(_s.value);
25
+ if (i && _arr.length === i) break;
26
+ }
27
+ } catch (err) {
28
+ _d = true;
29
+ _e = err;
30
+ } finally{
31
+ try {
32
+ if (!_n && _i["return"] != null) _i["return"]();
33
+ } finally{
34
+ if (_d) throw _e;
35
+ }
36
+ }
37
+ return _arr;
38
+ }
39
+ function _non_iterable_rest() {
40
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ function _non_iterable_spread() {
43
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ function _sliced_to_array(arr, i) {
46
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
47
+ }
48
+ function _to_consumable_array(arr) {
49
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
50
+ }
51
+ function _unsupported_iterable_to_array(o, minLen) {
52
+ if (!o) return;
53
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
54
+ var n = Object.prototype.toString.call(o).slice(8, -1);
55
+ if (n === "Object" && o.constructor) n = o.constructor.name;
56
+ if (n === "Map" || n === "Set") return Array.from(n);
57
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
58
+ }
59
+ /**
60
+ Treemap threshold-merge algorithm — pure: takes its inputs explicitly,
61
+ returns a new array. `treemapDef.thresholdFunction` binds the inputs
62
+ from the viz.
63
+ */ import { group, sum } from "d3-array";
64
+ import { merge } from "@d3plus/data";
65
+ /**
66
+ Walks `data` to `drawDepth` and merges entries whose `thresholdKey`
67
+ value falls below `threshold(branchData) * totalSum` into a single
68
+ aggregated row at that depth. Returns the kept set; original `data`
69
+ is not mutated.
70
+ */ export function thresholdFunction(data, inputs) {
71
+ var _thresholdByDepth;
72
+ var aggs = inputs.aggs, drawDepth = inputs.drawDepth, groupBy = inputs.groupBy, threshold = inputs.threshold, thresholdKey = inputs.thresholdKey;
73
+ var totalSum = sum(data, thresholdKey);
74
+ if (!threshold || !thresholdKey) return data;
75
+ /**
76
+ Explores the data tree recursively and merges elements under
77
+ the indicated threshold.
78
+ */ function thresholdByDepth(branchData, depth) {
79
+ if (depth < drawDepth) {
80
+ return _to_consumable_array(group(branchData, groupBy[depth])).reduce(function(bulk, param) {
81
+ var _param = _sliced_to_array(param, 2), values = _param[1];
82
+ var _thresholdByDepth;
83
+ var subBranchData = (_thresholdByDepth = thresholdByDepth(values, depth + 1)) !== null && _thresholdByDepth !== void 0 ? _thresholdByDepth : [];
84
+ return bulk.concat(subBranchData);
85
+ }, []);
86
+ }
87
+ if (depth === drawDepth) {
88
+ var thresholdPercent = Math.min(1, Math.max(0, threshold(branchData)));
89
+ if (!isFinite(thresholdPercent) || isNaN(thresholdPercent)) return null;
90
+ // Single-pass O(N) partition into kept + removed bucket.
91
+ var removedItems = [];
92
+ var kept = [];
93
+ var thresholdValue = thresholdPercent * totalSum;
94
+ for(var i = 0; i < branchData.length; i++){
95
+ var datum = branchData[i];
96
+ if (thresholdKey(datum) < thresholdValue) removedItems.push(datum);
97
+ else kept.push(datum);
98
+ }
99
+ if (removedItems.length > 0) {
100
+ var mergedItem = merge(removedItems, aggs);
101
+ mergedItem._isAggregation = true;
102
+ mergedItem._threshold = thresholdPercent;
103
+ kept.push(mergedItem);
104
+ }
105
+ return kept;
106
+ }
107
+ throw new Error("Depth is higher than the amount of grouping levels.");
108
+ }
109
+ return (_thresholdByDepth = thresholdByDepth(data, 0)) !== null && _thresholdByDepth !== void 0 ? _thresholdByDepth : data;
110
+ }
111
+
112
+ //# sourceMappingURL=thresholdFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/Treemap/thresholdFunction.ts"],"sourcesContent":["/**\n Treemap threshold-merge algorithm — pure: takes its inputs explicitly,\n returns a new array. `treemapDef.thresholdFunction` binds the inputs\n from the viz.\n*/\n\nimport {group, sum} from \"d3-array\";\nimport {merge} from \"@d3plus/data\";\nimport type {DataPoint} from \"@d3plus/data\";\n\nexport interface ThresholdInputs {\n /** Per-key aggregation overrides used by `merge` to bucket removed items. */\n aggs: Record<string, (leaves: DataPoint[]) => unknown>;\n /** The drill-down depth at which the threshold filter applies. */\n drawDepth: number;\n /** GroupBy accessors used to walk down the tree to `drawDepth`. */\n groupBy: ((d: DataPoint) => DataPoint[keyof DataPoint])[];\n /** Threshold accessor — returns a 0..1 percentage given the branch data. */\n threshold: (branchData: DataPoint[]) => number;\n /** Per-datum value accessor compared against `threshold * totalSum`. */\n thresholdKey: (d: DataPoint) => number;\n}\n\n/**\n Walks `data` to `drawDepth` and merges entries whose `thresholdKey`\n value falls below `threshold(branchData) * totalSum` into a single\n aggregated row at that depth. Returns the kept set; original `data`\n is not mutated.\n*/\nexport function thresholdFunction(\n data: DataPoint[],\n inputs: ThresholdInputs,\n): DataPoint[] {\n const {aggs, drawDepth, groupBy, threshold, thresholdKey} = inputs;\n const totalSum = sum(data, thresholdKey);\n\n if (!threshold || !thresholdKey) return data;\n\n /**\n Explores the data tree recursively and merges elements under\n the indicated threshold.\n */\n function thresholdByDepth(\n branchData: DataPoint[],\n depth: number,\n ): DataPoint[] | null {\n if (depth < drawDepth) {\n return [...group(branchData, groupBy[depth])].reduce(\n (bulk: DataPoint[], [, values]): DataPoint[] => {\n const subBranchData: DataPoint[] =\n thresholdByDepth(values, depth + 1) ?? [];\n return bulk.concat(subBranchData);\n },\n [],\n );\n }\n\n if (depth === drawDepth) {\n const thresholdPercent = Math.min(\n 1,\n Math.max(0, threshold(branchData)),\n );\n\n if (!isFinite(thresholdPercent) || isNaN(thresholdPercent)) return null;\n\n // Single-pass O(N) partition into kept + removed bucket.\n const removedItems: DataPoint[] = [];\n const kept: DataPoint[] = [];\n const thresholdValue = thresholdPercent * totalSum;\n for (let i = 0; i < branchData.length; i++) {\n const datum = branchData[i];\n if (thresholdKey(datum) < thresholdValue) removedItems.push(datum);\n else kept.push(datum);\n }\n\n if (removedItems.length > 0) {\n const mergedItem = merge(\n removedItems,\n aggs as unknown as Parameters<typeof merge>[1],\n );\n mergedItem._isAggregation = true;\n mergedItem._threshold = thresholdPercent;\n kept.push(mergedItem as unknown as DataPoint);\n }\n\n return kept;\n }\n\n throw new Error(\"Depth is higher than the amount of grouping levels.\");\n }\n\n return thresholdByDepth(data, 0) ?? data;\n}\n"],"names":["group","sum","merge","thresholdFunction","data","inputs","thresholdByDepth","aggs","drawDepth","groupBy","threshold","thresholdKey","totalSum","branchData","depth","reduce","bulk","values","subBranchData","concat","thresholdPercent","Math","min","max","isFinite","isNaN","removedItems","kept","thresholdValue","i","length","datum","push","mergedItem","_isAggregation","_threshold","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AAIA,GAEA,SAAQA,KAAK,EAAEC,GAAG,QAAO,WAAW;AACpC,SAAQC,KAAK,QAAO,eAAe;AAgBnC;;;;;AAKA,GACA,OAAO,SAASC,kBACdC,IAAiB,EACjBC,MAAuB;QA4DhBC;IA1DP,IAAOC,OAAqDF,OAArDE,MAAMC,YAA+CH,OAA/CG,WAAWC,UAAoCJ,OAApCI,SAASC,YAA2BL,OAA3BK,WAAWC,eAAgBN,OAAhBM;IAC5C,IAAMC,WAAWX,IAAIG,MAAMO;IAE3B,IAAI,CAACD,aAAa,CAACC,cAAc,OAAOP;IAExC;;;EAGA,GACA,SAASE,iBACPO,UAAuB,EACvBC,KAAa;QAEb,IAAIA,QAAQN,WAAW;YACrB,OAAO,AAAC,qBAAGR,MAAMa,YAAYJ,OAAO,CAACK,MAAM,GAAGC,MAAM,CAClD,SAACC;yDAAsBC;oBAEnBX;gBADF,IAAMY,iBACJZ,oBAAAA,iBAAiBW,QAAQH,QAAQ,gBAAjCR,+BAAAA,oBAAuC,EAAE;gBAC3C,OAAOU,KAAKG,MAAM,CAACD;YACrB,GACA,EAAE;QAEN;QAEA,IAAIJ,UAAUN,WAAW;YACvB,IAAMY,mBAAmBC,KAAKC,GAAG,CAC/B,GACAD,KAAKE,GAAG,CAAC,GAAGb,UAAUG;YAGxB,IAAI,CAACW,SAASJ,qBAAqBK,MAAML,mBAAmB,OAAO;YAEnE,yDAAyD;YACzD,IAAMM,eAA4B,EAAE;YACpC,IAAMC,OAAoB,EAAE;YAC5B,IAAMC,iBAAiBR,mBAAmBR;YAC1C,IAAK,IAAIiB,IAAI,GAAGA,IAAIhB,WAAWiB,MAAM,EAAED,IAAK;gBAC1C,IAAME,QAAQlB,UAAU,CAACgB,EAAE;gBAC3B,IAAIlB,aAAaoB,SAASH,gBAAgBF,aAAaM,IAAI,CAACD;qBACvDJ,KAAKK,IAAI,CAACD;YACjB;YAEA,IAAIL,aAAaI,MAAM,GAAG,GAAG;gBAC3B,IAAMG,aAAa/B,MACjBwB,cACAnB;gBAEF0B,WAAWC,cAAc,GAAG;gBAC5BD,WAAWE,UAAU,GAAGf;gBACxBO,KAAKK,IAAI,CAACC;YACZ;YAEA,OAAON;QACT;QAEA,MAAM,IAAIS,MAAM;IAClB;IAEA,QAAO9B,oBAAAA,iBAAiBF,MAAM,gBAAvBE,+BAAAA,oBAA6BF;AACtC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ `ChartDefinition` — charts as *values*, not classes.
3
+
4
+ A chart in v4 is the def value `{name, fields?, ctx?, features, stages,
5
+ layoutStage?, emit, chartTransform?, setup?, thresholdFunction?}`. Each
6
+ chart's def lives next to its applyLayout + emit in `./<ChartName>/`;
7
+ `makeChart(def, Base?)` produces the chart class from the def.
8
+ */ /** Type guard for the paint-driven variant. */ export function isPaintDriven(def) {
9
+ return def.paintDriven === true;
10
+ }
11
+
12
+ //# sourceMappingURL=ChartDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/definition/ChartDefinition.ts"],"sourcesContent":["/**\n `ChartDefinition` — charts as *values*, not classes.\n\n A chart in v4 is the def value `{name, fields?, ctx?, features, stages,\n layoutStage?, emit, chartTransform?, setup?, thresholdFunction?}`. Each\n chart's def lives next to its applyLayout + emit in `./<ChartName>/`;\n `makeChart(def, Base?)` produces the chart class from the def.\n*/\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {FeatureModule} from \"../features/features.js\";\nimport type {TransformStage, VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\ninterface ChartDefinitionBase {\n /** Stable name for tagging and class generation. */\n name: string;\n /** Chart-internal scratch seeded onto `viz.ctx.<key>` at construction. */\n ctx?: Record<string, unknown>;\n /**\n Scalar defaults seeded onto `viz._<key>` at construction. Defs that\n need instance slots keep them here; user-facing values otherwise go\n in `fields[].default` and chart-internal scratch in `ctx`.\n */\n defaults?: Record<string, unknown>;\n /** Fluent accessor declarations; `makeChart` installs each as `viz.<key>()`. */\n fields?: import(\"../../fluent.js\").ConfigField[];\n /** Chart-level features composed in; order is layout order. */\n features: FeatureModule[];\n /**\n Chart-specific layout stage run in `_draw` after the shared chart-shell\n prep (`vizPreDrawPure`). If absent, `makeChart` doesn't invoke\n `runChartDraw` — the chart relies on its parent's `_draw` only.\n */\n layoutStage?: TransformStage;\n /** Optional pure threshold algorithm (replaces `Viz._thresholdFunction`). */\n thresholdFunction?: (viz: VizInstance, data: unknown[]) => unknown[];\n /**\n Optional chart-specific `_chartTransform` builder. Receives the viz\n after the layout stage runs; returns the transform applied to the\n chart scene. Default: margin-origin translation.\n */\n chartTransform?: (viz: VizInstance) => import(\"@d3plus/render\").Transform | undefined;\n /**\n Optional fixed clip region for the chart-cells group (a window in absolute\n scene coordinates that the chart content is clipped to). Geomap uses this to\n contain projected geography within the map rectangle so it can't spill under\n the legend/timeline; the clip stays put while pan/zoom moves content beneath\n it. Only meaningful for charts whose `chartTransform` is undefined.\n */\n chartClip?: (viz: VizInstance) => import(\"@d3plus/render\").ClipShape | undefined;\n /**\n Imperative per-instance setup hook — runs once after `applyDefinition`\n seeds the chart. Use for event handler overrides and shadowed methods\n that don't fit the declarative `fields`/`ctx` surface.\n */\n setup?: (viz: VizInstance) => void;\n}\n\n/**\n A data-driven chart's emit: a pure function from a chart context (with\n optional laid-out `shapeData`) to the scene nodes for one frame.\n*/\nexport type ChartEmit = (ctx: VizContext & {shapeData?: DataPoint[]}) => SceneNode[];\n\n/** Data-driven chart: `emit(ctx)` produces the scene nodes. */\nexport interface DataDrivenChartDefinition extends ChartDefinitionBase {\n paintDriven?: false;\n emit: ChartEmit;\n}\n\n/**\n Paint-driven chart: `Plot._paint` populates `viz._chartScene` by calling\n `plotPaint`, which builds the scene from the paint context assembled in\n `drawPlot`. There is no `emit` step — `runChartDraw` refuses to drive\n paint-driven defs (see runChartDraw.ts), so the scene is produced entirely\n inside the Plot draw flow.\n*/\nexport interface PaintDrivenChartDefinition extends ChartDefinitionBase {\n paintDriven: true;\n}\n\n/** Discriminated union; use `isPaintDriven` to narrow. */\nexport type ChartDefinition =\n | DataDrivenChartDefinition\n | PaintDrivenChartDefinition;\n\n/** Type guard for the paint-driven variant. */\nexport function isPaintDriven(\n def: ChartDefinition,\n): def is PaintDrivenChartDefinition {\n return def.paintDriven === true;\n}\n"],"names":["isPaintDriven","def","paintDriven"],"mappings":"AAAA;;;;;;;AAOA,GAkFA,6CAA6C,GAC7C,OAAO,SAASA,cACdC,GAAoB;IAEpB,OAAOA,IAAIC,WAAW,KAAK;AAC7B"}
@@ -0,0 +1,107 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _iterable_to_array_limit(arr, i) {
10
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
11
+ if (_i == null) return;
12
+ var _arr = [];
13
+ var _n = true;
14
+ var _d = false;
15
+ var _s, _e;
16
+ try {
17
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
18
+ _arr.push(_s.value);
19
+ if (i && _arr.length === i) break;
20
+ }
21
+ } catch (err) {
22
+ _d = true;
23
+ _e = err;
24
+ } finally{
25
+ try {
26
+ if (!_n && _i["return"] != null) _i["return"]();
27
+ } finally{
28
+ if (_d) throw _e;
29
+ }
30
+ }
31
+ return _arr;
32
+ }
33
+ function _non_iterable_rest() {
34
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _sliced_to_array(arr, i) {
37
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
38
+ }
39
+ function _unsupported_iterable_to_array(o, minLen) {
40
+ if (!o) return;
41
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
42
+ var n = Object.prototype.toString.call(o).slice(8, -1);
43
+ if (n === "Object" && o.constructor) n = o.constructor.name;
44
+ if (n === "Map" || n === "Set") return Array.from(n);
45
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
46
+ }
47
+ /**
48
+ `applyDefinition(viz, def)` — wire a ChartDefinition into a Viz instance.
49
+
50
+ Seeds `viz.ctx` from `def.ctx`, seeds `_<key>` slots from
51
+ `def.defaults` (charts that declare scalar defaults there), and installs
52
+ fluent accessors from `def.fields` (which write into `viz.schema`). All config defaults
53
+ — `shapeConfig`, `tooltipConfig`, `legendSort`, `legend`, etc. — live
54
+ in `fields` and use `factory` / `merge` for viz-bound and merge
55
+ semantics.
56
+ */ import { installFluent } from "../../fluent.js";
57
+ export function applyDefinition(viz, def) {
58
+ if (def.ctx) {
59
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
60
+ try {
61
+ for(var _iterator = Object.entries(def.ctx)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
62
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
63
+ viz.ctx[key] = value;
64
+ }
65
+ } catch (err) {
66
+ _didIteratorError = true;
67
+ _iteratorError = err;
68
+ } finally{
69
+ try {
70
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
71
+ _iterator.return();
72
+ }
73
+ } finally{
74
+ if (_didIteratorError) {
75
+ throw _iteratorError;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ if (def.defaults) {
81
+ var scratch = viz;
82
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
83
+ try {
84
+ for(var _iterator1 = Object.entries(def.defaults)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
85
+ var _step_value1 = _sliced_to_array(_step1.value, 2), key1 = _step_value1[0], value1 = _step_value1[1];
86
+ scratch["_".concat(key1)] = value1;
87
+ }
88
+ } catch (err) {
89
+ _didIteratorError1 = true;
90
+ _iteratorError1 = err;
91
+ } finally{
92
+ try {
93
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
94
+ _iterator1.return();
95
+ }
96
+ } finally{
97
+ if (_didIteratorError1) {
98
+ throw _iteratorError1;
99
+ }
100
+ }
101
+ }
102
+ }
103
+ if (def.fields) installFluent(viz, def.fields);
104
+ if (def.setup) def.setup(viz);
105
+ }
106
+
107
+ //# sourceMappingURL=applyDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/charts/definition/applyDefinition.ts"],"sourcesContent":["/**\n `applyDefinition(viz, def)` — wire a ChartDefinition into a Viz instance.\n\n Seeds `viz.ctx` from `def.ctx`, seeds `_<key>` slots from\n `def.defaults` (charts that declare scalar defaults there), and installs\n fluent accessors from `def.fields` (which write into `viz.schema`). All config defaults\n — `shapeConfig`, `tooltipConfig`, `legendSort`, `legend`, etc. — live\n in `fields` and use `factory` / `merge` for viz-bound and merge\n semantics.\n*/\n\nimport {installFluent} from \"../../fluent.js\";\nimport type {ChartDefinition} from \"./ChartDefinition.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\nexport function applyDefinition(viz: VizInstance, def: ChartDefinition): void {\n if (def.ctx) {\n for (const [key, value] of Object.entries(def.ctx)) viz.ctx[key] = value;\n }\n if (def.defaults) {\n const scratch = viz as unknown as Record<string, unknown>;\n for (const [key, value] of Object.entries(def.defaults)) {\n scratch[`_${key}`] = value;\n }\n }\n if (def.fields) installFluent(viz, def.fields);\n if (def.setup) def.setup(viz);\n}\n"],"names":["installFluent","applyDefinition","viz","def","ctx","Object","entries","key","value","defaults","scratch","fields","setup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;AASA,GAEA,SAAQA,aAAa,QAAO,kBAAkB;AAI9C,OAAO,SAASC,gBAAgBC,GAAgB,EAAEC,GAAoB;IACpE,IAAIA,IAAIC,GAAG,EAAE;YACN,kCAAA,2BAAA;;YAAL,QAAK,YAAsBC,OAAOC,OAAO,CAACH,IAAIC,GAAG,sBAA5C,SAAA,6BAAA,QAAA,yBAAA;gBAAA,mCAAA,iBAAOG,sBAAKC;gBAAmCN,IAAIE,GAAG,CAACG,IAAI,GAAGC;;;YAA9D;YAAA;;;qBAAA,6BAAA;oBAAA;;;oBAAA;0BAAA;;;;IACP;IACA,IAAIL,IAAIM,QAAQ,EAAE;QAChB,IAAMC,UAAUR;YACX,mCAAA,4BAAA;;YAAL,QAAK,aAAsBG,OAAOC,OAAO,CAACH,IAAIM,QAAQ,sBAAjD,UAAA,8BAAA,SAAA,0BAAA,kCAAoD;gBAApD,oCAAA,kBAAOF,wBAAKC;gBACfE,OAAO,CAAC,AAAC,IAAO,OAAJH,MAAM,GAAGC;YACvB;;YAFK;YAAA;;;qBAAA,8BAAA;oBAAA;;;oBAAA;0BAAA;;;;IAGP;IACA,IAAIL,IAAIQ,MAAM,EAAEX,cAAcE,KAAKC,IAAIQ,MAAM;IAC7C,IAAIR,IAAIS,KAAK,EAAET,IAAIS,KAAK,CAACV;AAC3B"}