@d3plus/core 4.11.0 → 4.12.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 (287) hide show
  1. package/es/internal.js +15 -5
  2. package/es/src/charts/Alluvial/emit.js +2 -2
  3. package/es/src/charts/Alluvial/index.js +7 -1
  4. package/es/src/charts/Alluvial/titles.js +24 -4
  5. package/es/src/charts/ArcDiagram/emit.js +27 -13
  6. package/es/src/charts/ArcDiagram/events.js +6 -2
  7. package/es/src/charts/ArcDiagram/index.js +2 -0
  8. package/es/src/charts/BarChart/index.js +3 -10
  9. package/es/src/charts/Calendar/index.js +2 -0
  10. package/es/src/charts/Candlestick/index.js +4 -10
  11. package/es/src/charts/Gantt/applyLayout.js +2 -4
  12. package/es/src/charts/Geomap/flowEmit.js +11 -6
  13. package/es/src/charts/Hexbin/index.js +2 -0
  14. package/es/src/charts/Icicle/index.js +3 -1
  15. package/es/src/charts/Matrix/applyLayout.js +20 -9
  16. package/es/src/charts/Matrix/index.js +19 -1
  17. package/es/src/charts/Network/applyLayout.js +36 -5
  18. package/es/src/charts/Network/bundle.js +5 -4
  19. package/es/src/charts/Network/emit.js +39 -40
  20. package/es/src/charts/Network/graph.js +34 -5
  21. package/es/src/charts/Network/graphFluent.js +5 -3
  22. package/es/src/charts/Network/index.js +6 -1
  23. package/es/src/charts/Pack/applyLayout.js +16 -5
  24. package/es/src/charts/Pack/emit.js +15 -8
  25. package/es/src/charts/Pack/groupRows.js +61 -0
  26. package/es/src/charts/Pack/index.js +3 -0
  27. package/es/src/charts/Pack/neutralPaint.js +20 -0
  28. package/es/src/charts/Pack/nodeNames.js +35 -0
  29. package/es/src/charts/ParallelCoordinates/axes.js +22 -22
  30. package/es/src/charts/ParallelCoordinates/chrome.js +18 -0
  31. package/es/src/charts/ParallelCoordinates/index.js +3 -1
  32. package/es/src/charts/ParallelCoordinates/titles.js +17 -9
  33. package/es/src/charts/Pie/emit.js +9 -1
  34. package/es/src/charts/Pie/index.js +10 -0
  35. package/es/src/charts/Plot/areaEnter.js +68 -0
  36. package/es/src/charts/Plot/draw.js +26 -12
  37. package/es/src/charts/Plot/index.js +4 -10
  38. package/es/src/charts/Plot/lineMarkerKeys.js +19 -0
  39. package/es/src/charts/Plot/plotInit.js +6 -0
  40. package/es/src/charts/Plot/shapeLabelLegend.js +67 -0
  41. package/es/src/charts/Plot/sharedHover.js +2 -1
  42. package/es/src/charts/Plot/sharedTooltip.js +13 -3
  43. package/es/src/charts/PolarArea/index.js +2 -1
  44. package/es/src/charts/Priestley/applyLayout.js +11 -7
  45. package/es/src/charts/Priestley/index.js +0 -2
  46. package/es/src/charts/Priestley/timeAxis.js +11 -8
  47. package/es/src/charts/Pyramid/gutter.js +52 -16
  48. package/es/src/charts/Pyramid/index.js +55 -7
  49. package/es/src/charts/Pyramid/scene.js +4 -4
  50. package/es/src/charts/Radar/applyLayout.js +31 -33
  51. package/es/src/charts/Radar/axisDecorations.js +29 -17
  52. package/es/src/charts/Radar/curvedLabels.js +43 -2
  53. package/es/src/charts/Radar/emit.js +30 -15
  54. package/es/src/charts/Radar/index.js +41 -2
  55. package/es/src/charts/Radar/points.js +85 -0
  56. package/es/src/charts/RadialBar/emit.js +6 -1
  57. package/es/src/charts/RadialBar/index.js +10 -0
  58. package/es/src/charts/RadialMatrix/applyLayout.js +115 -31
  59. package/es/src/charts/RadialMatrix/index.js +15 -2
  60. package/es/src/charts/Rings/applyLayout.js +11 -150
  61. package/es/src/charts/Rings/emit.js +80 -40
  62. package/es/src/charts/Rings/index.js +27 -4
  63. package/es/src/charts/Rings/ringsCurves.js +156 -0
  64. package/es/src/charts/Rings/ringsParallel.js +20 -3
  65. package/es/src/charts/Rings/ringsPlacement.js +152 -0
  66. package/es/src/charts/Rings/ringsSizing.js +61 -38
  67. package/es/src/charts/Sankey/applyLayout.js +18 -4
  68. package/es/src/charts/Sankey/index.js +7 -1
  69. package/es/src/charts/Sunburst/emit.js +9 -1
  70. package/es/src/charts/Sunburst/index.js +13 -1
  71. package/es/src/charts/Tree/applyLayout.js +44 -14
  72. package/es/src/charts/Tree/emit.js +5 -5
  73. package/es/src/charts/Tree/index.js +10 -12
  74. package/es/src/charts/Tree/keys.js +33 -0
  75. package/es/src/charts/Tree/nodeLabel.js +15 -0
  76. package/es/src/charts/Treemap/emitGroupHeaders.js +3 -5
  77. package/es/src/charts/definition/makeChart.js +6 -2
  78. package/es/src/charts/drawSteps/minimap.js +4 -20
  79. package/es/src/charts/drawSteps/zoomActions.js +36 -0
  80. package/es/src/charts/drawSteps/zoomControls.js +31 -18
  81. package/es/src/charts/drawSteps/zoomControlsMarkup.js +23 -4
  82. package/es/src/charts/drawSteps/zoomDrag.js +188 -0
  83. package/es/src/charts/drawSteps/zoomFit.js +69 -0
  84. package/es/src/charts/events/click.legend.js +4 -2
  85. package/es/src/charts/events/click.shape.js +5 -3
  86. package/es/src/charts/events/mouseenter.js +6 -16
  87. package/es/src/charts/events/mouseleave.js +9 -2
  88. package/es/src/charts/events/mousemove.legend.js +28 -32
  89. package/es/src/charts/events/mousemove.shape.js +44 -44
  90. package/es/src/charts/features/axes.js +15 -4
  91. package/es/src/charts/features/axesFinal.js +7 -2
  92. package/es/src/charts/features/axesMeasure.js +26 -8
  93. package/es/src/charts/features/axisTooltip.js +138 -0
  94. package/es/src/charts/features/centerLabel.js +177 -0
  95. package/es/src/charts/features/colorScaleBivariate.js +83 -0
  96. package/es/src/charts/features/colorScaleBucket.js +18 -0
  97. package/es/src/charts/features/colorScaleHover.js +30 -5
  98. package/es/src/charts/features/colorScaleLimit.js +73 -0
  99. package/es/src/charts/features/colorScaleTooltip.js +77 -0
  100. package/es/src/charts/features/colorScaleTop.js +61 -0
  101. package/es/src/charts/features/curvedArrows.js +33 -0
  102. package/es/src/charts/features/depthKey.js +26 -0
  103. package/es/src/charts/features/edgeArrows.js +61 -2
  104. package/es/src/charts/features/featuresColorScale.js +57 -16
  105. package/es/src/charts/features/hoverTicks.js +41 -0
  106. package/es/src/charts/features/idleQueue.js +72 -0
  107. package/es/src/charts/features/linkInteraction.js +59 -7
  108. package/es/src/charts/features/networkMeasures.js +241 -0
  109. package/es/src/charts/features/nodeStats.js +309 -0
  110. package/es/src/charts/features/plotEndLabels.js +28 -7
  111. package/es/src/charts/features/plotPaint.js +9 -2
  112. package/es/src/charts/features/shapeEmit.js +7 -1
  113. package/es/src/charts/features/textHalo.js +3 -2
  114. package/es/src/charts/partition/chartFields.js +12 -3
  115. package/es/src/charts/partition/interaction.js +10 -5
  116. package/es/src/charts/pipeline/insetPlacement.js +8 -3
  117. package/es/src/charts/polar/chrome.js +81 -9
  118. package/es/src/charts/polar/config.js +4 -0
  119. package/es/src/charts/polar/wedgeLayout.js +2 -1
  120. package/es/src/charts/viz/Viz.js +24 -15
  121. package/es/src/charts/viz/VizBase.js +39 -4
  122. package/es/src/charts/viz/backgroundInk.js +10 -0
  123. package/es/src/charts/viz/emphasis.js +14 -0
  124. package/es/src/charts/viz/fillStroke.js +10 -0
  125. package/es/src/charts/viz/interactionOpacity.js +115 -32
  126. package/es/src/charts/viz/reportDrawError.js +15 -0
  127. package/es/src/charts/viz/setCursor.js +29 -0
  128. package/es/src/charts/viz/tooltipEnabled.js +38 -0
  129. package/es/src/charts/viz/userClick.js +34 -0
  130. package/es/src/charts/viz/vizDataPolling.js +0 -1
  131. package/es/src/charts/viz/vizDefaults.js +13 -34
  132. package/es/src/charts/viz/vizFields.js +6 -1
  133. package/es/src/charts/viz/vizRender.js +35 -5
  134. package/es/src/charts/viz/vizVisibility.js +12 -2
  135. package/es/src/components/Axis/Axis.js +29 -2
  136. package/es/src/components/Axis/axisBreak.js +29 -7
  137. package/es/src/components/Axis/axisDefaults.js +11 -0
  138. package/es/src/components/Axis/axisLabelKinds.js +36 -0
  139. package/es/src/components/Axis/axisLabelLineHeight.js +19 -0
  140. package/es/src/components/Axis/axisLabelRoom.js +37 -0
  141. package/es/src/components/Axis/axisLabelSize.js +171 -0
  142. package/es/src/components/Axis/axisLabelThinning.js +98 -4
  143. package/es/src/components/Axis/axisLayout.js +71 -46
  144. package/es/src/components/Axis/axisLayoutLabels.js +82 -140
  145. package/es/src/components/Axis/axisLayoutScale.js +9 -10
  146. package/es/src/components/Axis/axisLimit.js +27 -0
  147. package/es/src/components/Axis/axisMaxSize.js +39 -0
  148. package/es/src/components/Axis/axisRender.js +20 -8
  149. package/es/src/components/Axis/axisRounding.js +16 -1
  150. package/es/src/components/Axis/axisScene.js +11 -2
  151. package/es/src/components/Axis/axisTitle.js +53 -0
  152. package/es/src/components/Axis/axisTooltipTargets.js +128 -0
  153. package/es/src/components/ColorScale/ColorScale.js +62 -18
  154. package/es/src/components/ColorScale/bivariateRender.js +353 -0
  155. package/es/src/components/ColorScale/bivariateScale.js +150 -0
  156. package/es/src/components/ColorScale/colorScaleRender.js +32 -2
  157. package/es/src/components/ColorScale/colorScaleSwatchTooltips.js +77 -0
  158. package/es/src/components/Legend/Legend.js +10 -2
  159. package/es/src/components/Legend/legendCut.js +108 -0
  160. package/es/src/components/Legend/legendRender.js +38 -13
  161. package/es/src/components/TextBox.js +5 -2
  162. package/es/src/components/Timeline/timelineRender.js +2 -1
  163. package/es/src/components/textBoxScene.js +3 -0
  164. package/es/src/components/textEllipsis.js +7 -0
  165. package/es/src/components/tooltipDom.js +8 -5
  166. package/es/src/fluent.js +48 -0
  167. package/es/src/utils/BaseClass.js +7 -2
  168. package/es/src/utils/configValue.js +9 -0
  169. package/package.json +10 -10
  170. package/types/index.d.ts +1 -1
  171. package/types/internal.d.ts +22 -5
  172. package/types/src/charts/Alluvial/titles.d.ts +16 -3
  173. package/types/src/charts/ArcDiagram/emit.d.ts +3 -2
  174. package/types/src/charts/ArcDiagram/events.d.ts +2 -1
  175. package/types/src/charts/Geomap/flowEmit.d.ts +3 -2
  176. package/types/src/charts/Matrix/applyLayout.d.ts +4 -2
  177. package/types/src/charts/Network/applyLayout.d.ts +11 -0
  178. package/types/src/charts/Network/bundle.d.ts +3 -1
  179. package/types/src/charts/Network/graph.d.ts +12 -4
  180. package/types/src/charts/Pack/applyLayout.d.ts +2 -0
  181. package/types/src/charts/Pack/groupRows.d.ts +46 -0
  182. package/types/src/charts/Pack/index.d.ts +3 -0
  183. package/types/src/charts/Pack/neutralPaint.d.ts +14 -0
  184. package/types/src/charts/Pack/nodeNames.d.ts +23 -0
  185. package/types/src/charts/ParallelCoordinates/chrome.d.ts +12 -0
  186. package/types/src/charts/ParallelCoordinates/index.d.ts +1 -0
  187. package/types/src/charts/ParallelCoordinates/titles.d.ts +7 -2
  188. package/types/src/charts/Plot/areaEnter.d.ts +34 -0
  189. package/types/src/charts/Plot/index.d.ts +4 -10
  190. package/types/src/charts/Plot/lineMarkerKeys.d.ts +11 -0
  191. package/types/src/charts/Plot/shapeLabelLegend.d.ts +19 -0
  192. package/types/src/charts/Plot/sharedTooltip.d.ts +7 -1
  193. package/types/src/charts/Priestley/timeAxis.d.ts +7 -4
  194. package/types/src/charts/Pyramid/gutter.d.ts +28 -6
  195. package/types/src/charts/Pyramid/scene.d.ts +1 -1
  196. package/types/src/charts/Radar/applyLayout.d.ts +2 -3
  197. package/types/src/charts/Radar/axisDecorations.d.ts +5 -2
  198. package/types/src/charts/Radar/curvedLabels.d.ts +35 -0
  199. package/types/src/charts/Radar/emit.d.ts +5 -2
  200. package/types/src/charts/Radar/index.d.ts +7 -2
  201. package/types/src/charts/Radar/points.d.ts +50 -0
  202. package/types/src/charts/RadialMatrix/applyLayout.d.ts +6 -4
  203. package/types/src/charts/Rings/emit.d.ts +24 -2
  204. package/types/src/charts/Rings/index.d.ts +4 -2
  205. package/types/src/charts/Rings/ringsCurves.d.ts +50 -0
  206. package/types/src/charts/Rings/ringsGraph.d.ts +29 -5
  207. package/types/src/charts/Rings/ringsParallel.d.ts +4 -2
  208. package/types/src/charts/Rings/ringsPlacement.d.ts +47 -0
  209. package/types/src/charts/Rings/ringsSizing.d.ts +36 -9
  210. package/types/src/charts/Tree/applyLayout.d.ts +20 -0
  211. package/types/src/charts/Tree/keys.d.ts +25 -0
  212. package/types/src/charts/Tree/nodeLabel.d.ts +11 -0
  213. package/types/src/charts/definition/ChartDefinition.d.ts +13 -0
  214. package/types/src/charts/definition/makeChart.d.ts +2 -2
  215. package/types/src/charts/drawSteps/zoomActions.d.ts +30 -0
  216. package/types/src/charts/drawSteps/zoomControls.d.ts +15 -0
  217. package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +16 -1
  218. package/types/src/charts/drawSteps/zoomDrag.d.ts +71 -0
  219. package/types/src/charts/drawSteps/zoomFit.d.ts +30 -0
  220. package/types/src/charts/features/axisTooltip.d.ts +49 -0
  221. package/types/src/charts/features/centerLabel.d.ts +75 -0
  222. package/types/src/charts/features/colorScaleBivariate.d.ts +50 -0
  223. package/types/src/charts/features/colorScaleBucket.d.ts +10 -0
  224. package/types/src/charts/features/colorScaleHover.d.ts +13 -3
  225. package/types/src/charts/features/colorScaleLimit.d.ts +60 -0
  226. package/types/src/charts/features/colorScaleTooltip.d.ts +43 -0
  227. package/types/src/charts/features/colorScaleTop.d.ts +30 -0
  228. package/types/src/charts/features/curvedArrows.d.ts +14 -0
  229. package/types/src/charts/features/depthKey.d.ts +19 -0
  230. package/types/src/charts/features/edgeArrows.d.ts +29 -2
  231. package/types/src/charts/features/hoverTicks.d.ts +30 -0
  232. package/types/src/charts/features/idleQueue.d.ts +46 -0
  233. package/types/src/charts/features/linkInteraction.d.ts +13 -4
  234. package/types/src/charts/features/networkMeasures.d.ts +53 -0
  235. package/types/src/charts/features/nodeStats.d.ts +93 -0
  236. package/types/src/charts/features/plotEndLabels.d.ts +14 -1
  237. package/types/src/charts/features/textHalo.d.ts +4 -3
  238. package/types/src/charts/partition/chartFields.d.ts +6 -1
  239. package/types/src/charts/pipeline/insetPlacement.d.ts +6 -0
  240. package/types/src/charts/polar/chrome.d.ts +19 -6
  241. package/types/src/charts/viz/Viz.d.ts +10 -3
  242. package/types/src/charts/viz/VizBase.d.ts +31 -2
  243. package/types/src/charts/viz/backgroundInk.d.ts +8 -0
  244. package/types/src/charts/viz/emphasis.d.ts +17 -0
  245. package/types/src/charts/viz/fillStroke.d.ts +7 -0
  246. package/types/src/charts/viz/reportDrawError.d.ts +12 -0
  247. package/types/src/charts/viz/setCursor.d.ts +26 -0
  248. package/types/src/charts/viz/tooltipEnabled.d.ts +31 -0
  249. package/types/src/charts/viz/userClick.d.ts +35 -0
  250. package/types/src/charts/viz/vizFields.d.ts +5 -0
  251. package/types/src/charts/viz/vizTypes.d.ts +16 -0
  252. package/types/src/charts/viz/vizVisibility.d.ts +7 -0
  253. package/types/src/components/Axis/Axis.d.ts +33 -3
  254. package/types/src/components/Axis/axisBreak.d.ts +19 -3
  255. package/types/src/components/Axis/axisDefaults.d.ts +12 -0
  256. package/types/src/components/Axis/axisLabelKinds.d.ts +22 -0
  257. package/types/src/components/Axis/axisLabelLineHeight.d.ts +27 -0
  258. package/types/src/components/Axis/axisLabelRoom.d.ts +17 -0
  259. package/types/src/components/Axis/axisLabelSize.d.ts +82 -0
  260. package/types/src/components/Axis/axisLabelThinning.d.ts +38 -2
  261. package/types/src/components/Axis/axisLayout.d.ts +9 -2
  262. package/types/src/components/Axis/axisLayoutLabels.d.ts +28 -33
  263. package/types/src/components/Axis/axisLayoutScale.d.ts +3 -1
  264. package/types/src/components/Axis/axisLimit.d.ts +18 -0
  265. package/types/src/components/Axis/axisMaxSize.d.ts +48 -0
  266. package/types/src/components/Axis/axisRounding.d.ts +8 -0
  267. package/types/src/components/Axis/axisTitle.d.ts +30 -0
  268. package/types/src/components/Axis/axisTooltipTargets.d.ts +82 -0
  269. package/types/src/components/ColorScale/ColorScale.d.ts +21 -11
  270. package/types/src/components/ColorScale/bivariateRender.d.ts +53 -0
  271. package/types/src/components/ColorScale/bivariateScale.d.ts +92 -0
  272. package/types/src/components/ColorScale/colorScaleSwatchTooltips.d.ts +48 -0
  273. package/types/src/components/Legend/Legend.d.ts +5 -0
  274. package/types/src/components/Legend/legendCut.d.ts +31 -0
  275. package/types/src/components/Legend/legendRender.d.ts +6 -1
  276. package/types/src/components/TextBox.d.ts +4 -0
  277. package/types/src/components/textEllipsis.d.ts +6 -0
  278. package/types/src/fluent.d.ts +18 -0
  279. package/types/src/shapes/emitLabels.d.ts +1 -1
  280. package/types/src/utils/D3plusConfig.d.ts +485 -609
  281. package/types/src/utils/configValue.d.ts +8 -0
  282. package/types/src/utils/index.d.ts +1 -1
  283. package/types/umd-entry.d.ts +4 -0
  284. package/umd/d3plus-core.full.js +22930 -17936
  285. package/umd/d3plus-core.full.min.js +2 -2
  286. package/umd/d3plus-core.js +21240 -16404
  287. package/umd/d3plus-core.min.js +2 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- Rings' ring geometry and node sizing: where the two rings sit for a chart
2
+ Rings' ring geometry and node sizing: where the rings sit for a chart
3
3
  area, each node's radius — fixed per ring, or from a `size` scale shared
4
4
  by every node (center included) that the size legend reads back — and
5
5
  whether the center's label still fits inside it.
@@ -9,20 +9,62 @@
9
9
  import * as scales from "d3-scale";
10
10
  import { textWidth } from "@d3plus/dom";
11
11
  import { fontFamilyStringify } from "@d3plus/text";
12
- /** Ring geometry for a chart area: the center plus two rings, each a third of the radius apart. */ export function ringsGeometry(width, height) {
12
+ /** The number of rings a `hops` value asks for: a whole number, at least 1 (2 when unset or not a number). */ export function ringsHops(hops) {
13
+ const n = Number(hops);
14
+ return hops != null && Number.isFinite(n) ? Math.max(1, Math.floor(n)) : 2;
15
+ }
16
+ /**
17
+ Ring geometry for a chart area: the center plus `hops` rings, evenly
18
+ spaced so the last leaves one more spacing of room for its labels.
19
+ */ export function ringsGeometry(width, height, hops = 2) {
13
20
  const radius = (min([
14
21
  height,
15
22
  width
16
23
  ]) || 0) / 2;
17
- const ringWidth = radius / 3;
24
+ const ringWidth = radius / (hops + 1);
25
+ const baseRing = hops === 1 ? radius / 3 : ringWidth;
26
+ const rings = Array.from({
27
+ length: hops
28
+ }, (_, k)=>ringWidth + ringWidth * k);
18
29
  return {
19
30
  width,
20
31
  height,
21
32
  ringWidth,
22
33
  primaryRing: ringWidth,
23
- secondaryRing: ringWidth * 2
34
+ baseRing,
35
+ rings
24
36
  };
25
37
  }
38
+ /**
39
+ The largest radius an unsized node may take on each of `count` rings
40
+ `ringWidth` apart, innermost first. Each ring's room halves the one
41
+ inside it, so outer nodes are smaller, and an inner ring's nodes stay
42
+ within half again the size of the ring outside it.
43
+ */ export function ringNodeRadii(ringWidth, count) {
44
+ const radii = [];
45
+ for(let k = 1; k <= count; k++){
46
+ const room = ringWidth / 2 ** k;
47
+ const floor = k === 1 ? 8 : 4;
48
+ let r = room / 2 - 4;
49
+ if (r < floor) r = min([
50
+ room / 2,
51
+ floor
52
+ ]) || 0;
53
+ if (k > 1 && r > ringWidth / 10) r = ringWidth / 10;
54
+ radii.push(r);
55
+ }
56
+ for(let k = 1; k < count; k++)if (radii[k] > radii[k - 1] && radii[k] > 10) radii[k] = radii[k - 1] * 0.75;
57
+ for(let k = count - 2; k >= 0; k--)if (radii[k] > radii[k + 1] * 1.5) radii[k] = radii[k + 1] * 1.5;
58
+ return radii.map((r)=>Math.floor(r));
59
+ }
60
+ /**
61
+ Each ring's unsized node radius, innermost first: the first ring's
62
+ nodes take the two-ring chart's first-ring size for the `baseRing`
63
+ spacing, and every ring past it the second ring's.
64
+ */ export function ringsNodeRadii(geom) {
65
+ const [first, outer] = ringNodeRadii(geom.baseRing, 2);
66
+ return geom.rings.map((_, k)=>k ? outer : first);
67
+ }
26
68
  /** Clamps a radius into `[sizeMin, sizeMax]` (either bound optional). */ function clampRadius(v, r) {
27
69
  const lo = v.schema.sizeMin;
28
70
  const hi = v.schema.sizeMax;
@@ -31,17 +73,16 @@ import { fontFamilyStringify } from "@d3plus/text";
31
73
  /**
32
74
  The radius scale for sized Rings: `sizeScale` over every placed node's
33
75
  `size` value. Its top radius is capped so neighbors can't overlap — a
34
- quarter of the ring width radially, and half the gap between adjacent
76
+ quarter of the `baseRing` spacing radially, and half the gap between adjacent
35
77
  slots around each ring (`slots` is how many evenly spaced positions the
36
- outer ring is divided into) — then by `sizeMax`; its bottom is `sizeMin`,
78
+ rings are divided into) — then by `sizeMax`; its bottom is `sizeMin`,
37
79
  held to at most half the top so small values still read smaller.
38
80
  */ function ringsSizeScale(v, geom, slots, values) {
39
- const { ringWidth, primaryRing, secondaryRing } = geom;
81
+ const { baseRing, rings } = geom;
40
82
  const half = Math.sin(Math.PI / Math.max(slots, 2));
41
83
  const cap = Math.max(1, Math.floor(min([
42
- ringWidth / 4,
43
- primaryRing * half - 1,
44
- secondaryRing * half - 1
84
+ baseRing / 4,
85
+ ...rings.map((ring)=>ring * half - 1)
45
86
  ])));
46
87
  const rMax = Math.min(v.schema.sizeMax ?? Infinity, cap);
47
88
  const rMin = Math.min(rMax / 2, v.schema.sizeMin ?? 3);
@@ -53,18 +94,16 @@ import { fontFamilyStringify } from "@d3plus/text";
53
94
  ]);
54
95
  }
55
96
  /**
56
- Assigns each ring node its `ring` + `r`, and `center.r`. Sized charts
57
- (`size` set) run every node, center included, through one
58
- `ringsSizeScale`, and return it; unsized charts use the fixed ring radii
59
- and return null.
60
- */ export function sizeRingsNodes(v, center, geom, slots, primaries, secondaries) {
61
- primaries.forEach((p)=>p.ring = 1);
62
- secondaries.forEach((s)=>s.ring = 2);
97
+ Assigns each ring node its `ring` (1 innermost) + `r`, and `center.r`.
98
+ Sized charts (`size` set) run every node, center included, through one
99
+ `ringsSizeScale`, and return it; unsized charts give each ring its
100
+ `ringsNodeRadii` radius and return null.
101
+ */ export function sizeRingsNodes(v, center, geom, slots, rings) {
102
+ rings.forEach((ring, k)=>ring.forEach((n)=>n.ring = k + 1));
63
103
  if (v._size) {
64
104
  const all = [
65
105
  center,
66
- ...primaries,
67
- ...secondaries
106
+ ...rings.flat()
68
107
  ];
69
108
  all.forEach((n)=>n.size = Number(v._size(n.data, n.i)));
70
109
  const values = all.map((n)=>n.size).filter((n)=>Number.isFinite(n));
@@ -74,24 +113,8 @@ import { fontFamilyStringify } from "@d3plus/text";
74
113
  return radius;
75
114
  }
76
115
  }
77
- const { ringWidth } = geom;
78
- const primaryDistance = ringWidth / 2;
79
- const secondaryDistance = ringWidth / 4;
80
- let primaryMax = primaryDistance / 2 - 4;
81
- if (primaryDistance / 2 - 4 < 8) primaryMax = min([
82
- primaryDistance / 2,
83
- 8
84
- ]) || 0;
85
- let secondaryMax = secondaryDistance / 2 - 4;
86
- if (secondaryDistance / 2 - 4 < 4) secondaryMax = min([
87
- secondaryDistance / 2,
88
- 4
89
- ]) || 0;
90
- if (secondaryMax > ringWidth / 10) secondaryMax = ringWidth / 10;
91
- if (secondaryMax > primaryMax && secondaryMax > 10) secondaryMax = primaryMax * 0.75;
92
- if (primaryMax > secondaryMax * 1.5) primaryMax = secondaryMax * 1.5;
93
- primaries.forEach((p)=>p.r = clampRadius(v, Math.floor(primaryMax)));
94
- secondaries.forEach((s)=>s.r = clampRadius(v, Math.floor(secondaryMax)));
116
+ const radii = ringsNodeRadii(geom);
117
+ rings.forEach((ring, k)=>ring.forEach((n)=>n.r = clampRadius(v, radii[k])));
95
118
  return null;
96
119
  }
97
120
  /** Smallest font size, in pixels, a center label may shrink to and still sit inside its circle. */ const CENTER_LABEL_MIN_FONT = 9;
@@ -103,7 +126,7 @@ import { fontFamilyStringify } from "@d3plus/text";
103
126
  the circle (`inside: false`), where it reads against the background
104
127
  rather than the circle's fill.
105
128
  */ export function ringsCenterLabel(v, center, geom, text, fontFamily) {
106
- const { primaryRing } = geom;
129
+ const { baseRing: primaryRing } = geom;
107
130
  if (!v._size) return {
108
131
  bounds: {
109
132
  x: -primaryRing / 2,
@@ -22,6 +22,23 @@ import { sankeyDrawableLinks, sankeyLoopWarning, unlinkedNodeValue } from "./san
22
22
  id
23
23
  }));
24
24
  }
25
+ /**
26
+ The nodes a Sankey without `nodes` draws: one per link end, then each
27
+ data row with an id no link uses, so a node without links still draws.
28
+ */ function nodesFromLinksAndData(v) {
29
+ const nodes = nodesFromLinks(v.schema.links ?? [], [
30
+ v.schema.linksSource,
31
+ v.schema.linksTarget
32
+ ]);
33
+ const ids = new Set(nodes.map((n, i)=>String(v.schema.nodeId(n, i))));
34
+ (v._filteredData ?? []).forEach((d, i)=>{
35
+ const id = v.schema.nodeId(d, i);
36
+ if (id === undefined || id === null || ids.has(String(id))) return;
37
+ ids.add(String(id));
38
+ nodes.push(d);
39
+ });
40
+ return nodes;
41
+ }
25
42
  /**
26
43
  Gives each node no drawn link touches a `fixedValue` (see
27
44
  `unlinkedNodeValue`), so it draws with a height like the rest.
@@ -93,10 +110,7 @@ export const applySankeyLayout = ({ viz })=>{
93
110
  viz
94
111
  };
95
112
  }
96
- const _nodes = hasNodes ? v.schema.nodes : nodesFromLinks(v.schema.links, [
97
- v.schema.linksSource,
98
- v.schema.linksTarget
99
- ]);
113
+ const _nodes = hasNodes ? v.schema.nodes : nodesFromLinksAndData(v);
100
114
  const nodes = _nodes.map((n, i)=>({
101
115
  __d3plus__: true,
102
116
  data: n,
@@ -14,6 +14,7 @@ import { makeChart } from "../definition/makeChart.js";
14
14
  import { loaderFormatFields, setLoaderValue } from "../viz/loaderFormat.js";
15
15
  import { focusLink, installFocusBackgroundClick } from "../features/linkFocus.js";
16
16
  import { isLinkDatum, linkHighlight, linkTooltipConfig, nodeHighlight } from "../features/linkInteraction.js";
17
+ import { nodeStatsFields } from "../features/nodeStats.js";
17
18
  import { applySankeyLayout } from "./applyLayout.js";
18
19
  import { sankeyEmit } from "./emit.js";
19
20
  import { simpleHover } from "../viz/simpleHover.js";
@@ -94,7 +95,8 @@ export const sankeyDef = {
94
95
  /**
95
96
  The nodes to draw, including any that no link touches (see
96
97
  `value`). When empty, the nodes are the unique source and target
97
- values in `links`. Accepts an array of node objects, or a
98
+ values in `links`, plus each data row with an id no link uses.
99
+ Accepts an array of node objects, or a
98
100
  URL/filepath string to load them from. `nodesFormat` transforms them;
99
101
  a function passed as a second argument sets it.
100
102
  @type {object[] | string}
@@ -140,6 +142,9 @@ export const sankeyDef = {
140
142
  v.hover = simpleHover;
141
143
  },
142
144
  ctx: {
145
+ // Flows run from source to target: node tooltips split the degree in
146
+ // and out, and shortest paths follow the flows.
147
+ linksDirected: true,
143
148
  sankey: sankey()
144
149
  },
145
150
  fields: [
@@ -212,6 +217,7 @@ export const sankeyDef = {
212
217
  */ {
213
218
  key: "nodeTooltipLinks"
214
219
  },
220
+ ...nodeStatsFields(),
215
221
  /** The width of each node, in pixels. */ {
216
222
  key: "nodeWidth",
217
223
  default: 30
@@ -8,6 +8,7 @@ import { arcPath } from "@d3plus/render";
8
8
  import { emitLabels } from "../../shapes/emitLabels.js";
9
9
  import { resolveAccessor, shapeConfigFor, textureFill, userLabelConfig } from "../features/emitHelpers.js";
10
10
  import { backgroundImageNodes } from "../features/backgroundImageEmit.js";
11
+ import { centerLabelNodes } from "../features/centerLabel.js";
11
12
  import { sunburstPadAngle } from "./geometry.js";
12
13
  import { sunburstSplit } from "./labelFit.js";
13
14
  import { labelMetrics } from "../partition/labelWords.js";
@@ -183,10 +184,17 @@ export const sunburstEmit = ({ viz, shapeData })=>{
183
184
  padAngle,
184
185
  padPixel
185
186
  });
187
+ // The center slot is hollow until a drill-down fills it with the focused node.
188
+ const radii = viz.ctx.sunburstRadii;
189
+ const hollow = radii && !nodes.some((n)=>n.depth === 0);
190
+ const center = hollow ? centerLabelNodes(viz, {
191
+ radius: radii[0][1]
192
+ }, sumFn) : [];
186
193
  return [
187
194
  ...ghosts,
188
195
  ...pathNodes,
189
196
  ...imageNodes,
190
- ...labelNodes
197
+ ...labelNodes,
198
+ ...center
191
199
  ];
192
200
  };
@@ -11,10 +11,11 @@
11
11
  - `interaction.ts` — hover lineage, tooltip rows, and click-to-zoom.
12
12
  */ import accessor from "../../utils/accessor.js";
13
13
  import { centerChartTransform } from "../features/chartGeometry.js";
14
+ import { centerLabelDefaults } from "../features/centerLabel.js";
14
15
  import { makeChart } from "../definition/makeChart.js";
15
16
  import { rowLegend, shareRow } from "../features/sharedFields.js";
16
17
  import { sceneInsetRegion } from "../pipeline/insetPlacement.js";
17
- import { partitionDefaultSort, partitionLegendSort, partitionSetup, partitionSortDecorate, partitionSumCoerce, partitionSumOnSet, partitionThreshold } from "../partition/chartFields.js";
18
+ import { partitionDefaultSort, partitionLegendSort, partitionSetup, partitionShapeDepth, partitionSortDecorate, partitionSumCoerce, partitionSumOnSet, partitionThreshold } from "../partition/chartFields.js";
18
19
  import { partitionShadeDefaults } from "../partition/shade.js";
19
20
  import { applySunburstLayout } from "./applyLayout.js";
20
21
  import { sunburstEmit } from "./emit.js";
@@ -39,12 +40,23 @@ export const sunburstDef = {
39
40
  },
40
41
  // Shading applies only while the default colors stay in place.
41
42
  setup: (viz)=>partitionSetup(viz, sunburstInteraction),
43
+ // Each node reports its own `groupBy` level to the `tooltip` accessor.
44
+ shapeDepth: partitionShapeDepth(sunburstInteraction),
42
45
  // Small-multiple panels as close to square as the grid allows.
43
46
  facet: {
44
47
  aspect: 1
45
48
  },
46
49
  ctx: {},
47
50
  fields: [
51
+ {
52
+ key: "centerLabel",
53
+ default: false
54
+ },
55
+ {
56
+ key: "centerLabelConfig",
57
+ merge: true,
58
+ factory: centerLabelDefaults
59
+ },
48
60
  /**
49
61
  The radius of the center slot, in pixels, or a function that receives
50
62
  the outer radius and returns one. The center is hollow until a click
@@ -11,8 +11,33 @@ import { hierarchy } from "d3-hierarchy";
11
11
  import { scaleLinear } from "d3-scale";
12
12
  import { assign } from "@d3plus/dom";
13
13
  import { merge, nest } from "@d3plus/data";
14
+ import { stampDepth } from "../features/depthKey.js";
15
+ import { nameLevel, noKey, nodeId } from "./keys.js";
16
+ import { nodeLabel } from "./nodeLabel.js";
17
+ /**
18
+ Whether a nest entry is a group rather than a data row: it has a key, `0`
19
+ or `false` included, and a list of values. `undefined`, `null` and `""`
20
+ are no key.
21
+ */ export function isBranch(d) {
22
+ return !noKey(d.key) && Array.isArray(d.values);
23
+ }
24
+ /**
25
+ The first level of a Tree's nest, with each entry that has no key (one
26
+ `nest` groups the rows without a first-level key under) replaced by the
27
+ rows under it, so each of those rows is a leaf under the root.
28
+ @param entries The first level of the nest.
29
+ @param levels The number of key levels the nest has.
30
+ */ export function rootEntries(entries, levels) {
31
+ return entries.flatMap((e)=>noKey(e.key) && Array.isArray(e.values) ? rowsUnder(e, levels - 1) : [
32
+ e
33
+ ]);
34
+ }
35
+ /** Every row under a nest entry with `levels` entry levels inside it. */ function rowsUnder(entry, levels) {
36
+ const values = entry.values;
37
+ return levels < 1 ? values : values.flatMap((e)=>rowsUnder(e, levels - 1));
38
+ }
14
39
  /** Merge a branch's leaf values (recursively) through the schema aggs. */ function flattenBranchData(viz, branch) {
15
- return merge(branch.values.map((l)=>l.key && l.values ? flattenBranchData(viz, l) : l), viz.schema.aggs);
40
+ return merge(branch.values.map((l)=>isBranch(l) ? flattenBranchData(viz, l) : l), viz.schema.aggs);
16
41
  }
17
42
  /** Run the d3-hierarchy tree layout, flatten branch aggregations, and tag nodes. */ function buildTreeData(viz, width, height) {
18
43
  const treeLayout = viz.ctx.tree;
@@ -21,20 +46,23 @@ import { merge, nest } from "@d3plus/data";
21
46
  height
22
47
  ])(hierarchy({
23
48
  key: "root",
24
- values: nest(viz._filteredData, viz.schema.groupBy.slice(0, viz._drawDepth + 1))
25
- }, (d)=>d.key && d.values ? d.values : null).sort(viz.schema.sort));
26
- const treeData = root.descendants().filter((d)=>(d.depth ?? 0) <= viz.schema.groupBy.length && !!d.parent);
49
+ values: rootEntries(nest(viz._filteredData, viz.schema.groupBy.slice(0, viz._drawDepth + 1)), viz._drawDepth + 1)
50
+ }, (d)=>isBranch(d) ? d.values : null).sort(viz.schema.sort));
51
+ const treeData = root.descendants().filter((d)=>(d.depth ?? 0) <= viz._drawDepth + 1 && !!d.parent);
27
52
  treeData.forEach((d, i)=>{
28
53
  const dd = d.data;
29
- if (dd.key && dd.values) {
30
- d.data = flattenBranchData(viz, dd);
31
- }
54
+ // Each node gets a row of its own: a branch's merged leaves, or a copy of
55
+ // the row it wraps, so the rows the legend and `data()` hold are never
56
+ // written to.
57
+ const row = isBranch(dd) ? flattenBranchData(viz, dd) : {
58
+ ...dd
59
+ };
60
+ d.data = row;
32
61
  d.__d3plus__ = true;
33
62
  d.i = i;
34
63
  // The tooltip binds the unwrapped row, so the per-node hierarchy depth
35
64
  // (needed to label the node at its own level) must live on the row.
36
- // Mirrors Treemap stamping `share`/`rank` onto `d.data`.
37
- d.data.depth = d.depth;
65
+ stampDepth(row, d.depth ?? 1);
38
66
  });
39
67
  return treeData;
40
68
  }
@@ -53,7 +81,7 @@ import { merge, nest } from "@d3plus/data";
53
81
  const yExtent = extent(treeData, (d)=>d.y);
54
82
  const labelHeight = min([
55
83
  isVertical ? 50 : 100,
56
- (yExtent[1] - rBufferRoot - rBufferEnd) / (viz.schema.groupBy.length + 1)
84
+ (yExtent[1] - rBufferRoot - rBufferEnd) / (viz._drawDepth + 2)
57
85
  ]);
58
86
  viz.ctx.labelHeight = labelHeight;
59
87
  const labelWidths = nest(treeData, (d)=>d.depth).map((d)=>{
@@ -88,9 +116,11 @@ import { merge, nest } from "@d3plus/data";
88
116
  /** Build the per-shape config object consumed by the Tree's shape emit. */ function buildTreeShapeConfig(viz, labelHeight, labelWidths, isVertical, isHorizontal) {
89
117
  const labelFn = viz.schema.label;
90
118
  return {
91
- id: (d, i)=>viz._ids(d.data, i)[(d.depth ?? 1) - 1],
119
+ id: (d, i)=>nodeId(viz, d, i),
92
120
  label: (d, i)=>{
93
121
  if (labelFn) return labelFn(d.data, i);
122
+ const level = (d.depth ?? 1) - 1;
123
+ if (nameLevel(viz, d.data, i, level) !== level) return nodeLabel(viz, d.data, i);
94
124
  const ids = viz._ids(d.data, i).slice(0, d.depth ?? 1);
95
125
  return ids[ids.length - 1];
96
126
  },
@@ -112,8 +142,8 @@ import { merge, nest } from "@d3plus/data";
112
142
  return {
113
143
  width: isVertical ? w : offset * 2 + w,
114
144
  height: isHorizontal ? h : offset * 2 + h,
115
- x: isVertical ? -w / 2 : d.children && d.depth !== viz.schema.groupBy.length ? -(offset + w) : -offset,
116
- y: isHorizontal ? -h / 2 : d.children && d.depth !== viz.schema.groupBy.length ? -(offset + labelHeight) : -offset
145
+ x: isVertical ? -w / 2 : d.children && d.depth !== viz._drawDepth + 1 ? -(offset + w) : -offset,
146
+ y: isHorizontal ? -h / 2 : d.children && d.depth !== viz._drawDepth + 1 ? -(offset + labelHeight) : -offset
117
147
  };
118
148
  },
119
149
  labelBounds: (d, _i, s)=>{
@@ -128,7 +158,7 @@ import { merge, nest } from "@d3plus/data";
128
158
  [widthKey]: w,
129
159
  [heightKey]: h,
130
160
  [xKey]: -w / 2,
131
- [yKey]: d.children && d.depth !== viz.schema.groupBy.length ? -(offset + h) : offset
161
+ [yKey]: d.children && d.depth !== viz._drawDepth + 1 ? -(offset + h) : offset
132
162
  };
133
163
  }
134
164
  };
@@ -6,6 +6,7 @@
6
6
  import { emitLabels } from "../../shapes/emitLabels.js";
7
7
  import { paintFromShapeConfig, resolveAccessor, shapeConfigFor, userLabelConfig } from "../features/emitHelpers.js";
8
8
  import { backgroundImageNode } from "../features/backgroundImageEmit.js";
9
+ import { nodeLabel } from "./nodeLabel.js";
9
10
  /**
10
11
  Geometry per shape kind: returns the SceneNode fields that vary by
11
12
  kind (`type`, geometry coords) plus an `aes` record used by
@@ -79,9 +80,8 @@ export const treeEmit = ({ viz })=>{
79
80
  const d = linksData[i];
80
81
  const datum = d.data ?? d;
81
82
  const paint = paintFromShapeConfig(pathConfig, datum, i);
82
- // Link id: id at the source's depth (d.depth-1), matching the
83
- // layout's `id` config in `shapeConfig`.
84
- const id = viz._ids(datum, i)[(d.depth ?? 1) - 1];
83
+ // The link is keyed by the node it leads to.
84
+ const id = chartShapeConfig.id(d, d.i ?? i);
85
85
  // Translate the path's local coords (relative to the source's
86
86
  // position) by the node's x/y.
87
87
  const tx = d.x ?? 0;
@@ -97,7 +97,7 @@ export const treeEmit = ({ viz })=>{
97
97
  y: ty
98
98
  },
99
99
  aria: {
100
- label: `${viz._drawLabel(datum, d.i ?? i)}.`
100
+ label: `${nodeLabel(viz, datum, d.i ?? i)}.`
101
101
  }
102
102
  });
103
103
  }
@@ -126,7 +126,7 @@ export const treeEmit = ({ viz })=>{
126
126
  datum,
127
127
  paint,
128
128
  aria: {
129
- label: `${viz._drawLabel(datum, i)}.`
129
+ label: `${nodeLabel(viz, datum, i)}.`
130
130
  }
131
131
  };
132
132
  out.push(node);
@@ -6,10 +6,12 @@
6
6
  - `emit.ts` — Path (links) + per-shape-type scene nodes.
7
7
  */ import { tree } from "d3-hierarchy";
8
8
  import constant from "../../utils/constant.js";
9
+ import { depthOf } from "../features/depthKey.js";
9
10
  import { legendLabel } from "../features/legendLabel.js";
10
11
  import { makeChart } from "../definition/makeChart.js";
11
12
  import { applyTreeLayout } from "./applyLayout.js";
12
13
  import { treeEmit } from "./emit.js";
14
+ import { nodeLabel } from "./nodeLabel.js";
13
15
  import { sceneInsetRegion } from "../pipeline/insetPlacement.js";
14
16
  import { backgroundInk } from "../viz/backgroundInk.js";
15
17
  export const treeDef = {
@@ -17,6 +19,12 @@ export const treeDef = {
17
19
  layoutStage: applyTreeLayout,
18
20
  emit: treeEmit,
19
21
  insetRegion: sceneInsetRegion,
22
+ // A node's `groupBy` level, from the hierarchy depth applyTreeLayout stamps
23
+ // onto its row.
24
+ shapeDepth: (_viz, d)=>{
25
+ const depth = depthOf(d);
26
+ return depth === undefined ? undefined : depth - 1;
27
+ },
20
28
  ctx: {
21
29
  tree: tree(),
22
30
  previousShapes: []
@@ -49,14 +57,7 @@ export const treeDef = {
49
57
  key: "shapeConfig",
50
58
  merge: true,
51
59
  factory: (viz)=>({
52
- ariaLabel: (d, i)=>{
53
- const treeData = viz.ctx.linksData ? viz._chartScene : undefined;
54
- // The original ariaLabel used `_treeData[i].depth`; under the new
55
- // model the depth is on the source node so the accessor needs to
56
- // walk shapeData differently. Keep the simpler form: drawLabel only.
57
- void treeData;
58
- return viz._drawLabel(d, i);
59
- },
60
+ ariaLabel: (d, i)=>nodeLabel(viz, d, i),
60
61
  labelConfig: {
61
62
  fontColor: ()=>backgroundInk(viz)
62
63
  },
@@ -74,10 +75,7 @@ export const treeDef = {
74
75
  key: "tooltipConfig",
75
76
  merge: true,
76
77
  factory: (viz)=>({
77
- // The Tooltip calls `title(d, i)` with the bound row; the node's
78
- // hierarchy depth is stamped onto that row in applyTreeLayout, so the
79
- // label resolves at the node's own level rather than the leaf level.
80
- title: (d, i)=>viz._drawLabel(d, i, (d.depth ?? 1) - 1)
78
+ title: (d, i)=>nodeLabel(viz, d, i)
81
79
  })
82
80
  },
83
81
  {
@@ -0,0 +1,33 @@
1
+ /**
2
+ How a Tree reads a node's `groupBy` keys. A row that has no key at some
3
+ level (`undefined`, `null` or `""`) is drawn as a leaf of the group above
4
+ it, so it is named and keyed by the keys it does have.
5
+ */ import { unwrapRow } from "../features/shareKey.js";
6
+ /** Whether a `groupBy` value is no key: `undefined`, `null` or `""`. */ export function noKey(value) {
7
+ return value === undefined || value === null || value === "";
8
+ }
9
+ /** The `groupBy` accessors of the levels a Tree draws. */ function drawnKeys(viz) {
10
+ return viz.schema.groupBy.slice(0, viz._drawDepth + 1);
11
+ }
12
+ /**
13
+ The `groupBy` level a Tree node is named at: its own `level` when its row
14
+ has a key there, or else the deepest drawn level it has one at. Undefined
15
+ when the row has no key at any drawn level.
16
+ */ export function nameLevel(viz, d, i, level) {
17
+ const row = unwrapRow(d);
18
+ const keys = drawnKeys(viz);
19
+ if (level < keys.length && !noKey(keys[level](row, i))) return level;
20
+ for(let l = keys.length - 1; l >= 0; l--)if (!noKey(keys[l](row, i))) return l;
21
+ return undefined;
22
+ }
23
+ /**
24
+ The id a Tree node's scene keys are built from: its `groupBy` value at its
25
+ own level, or, for a row without a key there, every drawn key it has,
26
+ missing ones included, joined with `/`, so it never matches the group it
27
+ is drawn under.
28
+ */ export function nodeId(viz, d, i) {
29
+ const row = d.data;
30
+ const level = (d.depth ?? 1) - 1;
31
+ if (nameLevel(viz, row, i, level) === level) return viz._ids(row, i)[level];
32
+ return drawnKeys(viz).map((key)=>`${key(row, i)}`).join("/");
33
+ }
@@ -0,0 +1,15 @@
1
+ import { depthOf } from "../features/depthKey.js";
2
+ import { nameLevel } from "./keys.js";
3
+ /**
4
+ A Tree node's label at its own `groupBy` level, from the hierarchy depth
5
+ the layout stamps on the node's row: a branch node is named after its
6
+ group, not after the leaves under it. A row without a key at its own
7
+ level is a leaf there, named by the `label` accessor when there is one,
8
+ or else at the deepest level it has a key. The tooltip's title and the
9
+ node's accessible name both read it.
10
+ */ export function nodeLabel(viz, d, i) {
11
+ const own = (depthOf(d) ?? 1) - 1;
12
+ const level = nameLevel(viz, d, i, own);
13
+ if (level === own) return viz._drawLabel(d, i, own);
14
+ return viz.schema.label || level === undefined ? viz._drawLabel(d, i) : viz._drawLabel(d, i, level);
15
+ }
@@ -2,24 +2,22 @@
2
2
  Scene nodes for the Treemap's group headers: a strip rect per header and
3
3
  its left-aligned, single-line name.
4
4
  */ import { color } from "d3-color";
5
- import { interpolateRgb } from "d3-interpolate";
6
5
  import { colorContrast } from "@d3plus/color";
7
6
  import { formatAbbreviate } from "@d3plus/format";
8
7
  import constant from "../../utils/constant.js";
9
8
  import { emitLabels } from "../../shapes/emitLabels.js";
10
9
  import { resolveAccessor, shapeConfigFor } from "../features/emitHelpers.js";
11
10
  import { summedShare } from "../features/shareKey.js";
12
- import { backgroundInk, chartBackground } from "../viz/backgroundInk.js";
11
+ import { neutralFill } from "../viz/backgroundInk.js";
13
12
  /**
14
13
  A header strip's default fill: a darker shade of its group's color, or,
15
14
  when a colorScale colors the tiles by value, a neutral tone between the
16
15
  chart's background and its ink.
17
16
  */ export function defaultGroupFill(viz, row, i) {
18
- const neutral = ()=>interpolateRgb(chartBackground(viz), backgroundInk(viz))(0.7);
19
- if (viz.schema.colorScale) return neutral();
17
+ if (viz.schema.colorScale) return neutralFill(viz);
20
18
  const sc = shapeConfigFor(viz, "Rect");
21
19
  const base = color(`${resolveAccessor(sc.fill, row, i)}`);
22
- return base ? base.darker(0.8).formatHex() : neutral();
20
+ return base ? base.darker(0.8).formatHex() : neutralFill(viz);
23
21
  }
24
22
  /** The strip rects and name labels for `headers`. */ export function groupHeaderNodes(viz, headers, style) {
25
23
  if (!headers.length) return [];
@@ -6,9 +6,9 @@
6
6
  `applyDefinition(this, def)`, its `_draw` runs the shared Viz pipeline
7
7
  then the chart's own layout stage via `runChartDraw`, and its
8
8
  `_thresholdFunction` / `_thresholdLegend` / `_sizeLegendScale` / `_insetRegion` /
9
- `_tableData` / `_colorScaleShape` / `_pointMark` delegate to `def.thresholdFunction` /
9
+ `_tableData` / `_colorScaleShape` / `_pointMark` / `_shapeDepth` delegate to `def.thresholdFunction` /
10
10
  `def.sizeLegendScale` / `def.insetRegion` / `def.tableData` / `def.colorScaleShape` /
11
- `def.pointMark` if
11
+ `def.pointMark` / `def.shapeDepth` if
12
12
  present (else to the base chart's), `_facetHooks` layers `def.facet` over the base chart's, and
13
13
  `toScene` passes the base chart's scene through `def.decorateScene`.
14
14
 
@@ -27,6 +27,7 @@ import Viz from "../viz/Viz.js";
27
27
  constructor(){
28
28
  super();
29
29
  applyDefinition(this, def);
30
+ if (def.colorScaleTooltip === false) this._colorScaleTooltip = false;
30
31
  }
31
32
  _draw(callback) {
32
33
  super._draw(callback);
@@ -55,6 +56,9 @@ import Viz from "../viz/Viz.js";
55
56
  _pointMark(node) {
56
57
  return def.pointMark ? def.pointMark(this, node) : super._pointMark(node);
57
58
  }
59
+ _shapeDepth(d) {
60
+ return def.shapeDepth ? def.shapeDepth(this, d) : super._shapeDepth(d);
61
+ }
58
62
  _facetHooks() {
59
63
  return def.facet ? {
60
64
  ...super._facetHooks(),
@@ -1,8 +1,9 @@
1
1
  import { zoomIdentity, zoomTransform } from "d3-zoom";
2
2
  import { chartBounds } from "../features/chartGeometry.js";
3
3
  import { zoomTo } from "./zoomControls.js";
4
+ import { zoomedDims } from "./zoomFit.js";
4
5
  import { MINIMAP_GAP, MINIMAP_RIGHT_INSET, formatZoomLabel, minimapHtml, minimapStyles, paintMinimapStyle } from "./minimapMarkup.js";
5
- import { showsZoomControls, zoomControlsBox } from "./zoomControlsMarkup.js";
6
+ import { minimapAnchor } from "./zoomControlsMarkup.js";
6
7
  import { effectiveDuration } from "../viz/reducedMotion.js";
7
8
  /**
8
9
  The element d3-zoom's transform is read from — the same fallback
@@ -16,23 +17,6 @@ import { effectiveDuration } from "../viz/reducedMotion.js";
16
17
  const node = zoomTarget(viz)?.node();
17
18
  return node ? zoomTransform(node) : zoomIdentity;
18
19
  }
19
- /**
20
- Which screen dimensions the zoom actually scales. Every chart zooms its
21
- picture uniformly, except a Plot, which rescales only its linear and time
22
- axes — a bar chart with a discrete x axis zooms vertically alone, so the
23
- viewport box keeps the minimap's full width.
24
- @private
25
- */ function zoomedDims(viz) {
26
- const scales = viz._plotZoomBase?.scales;
27
- if (!scales) return {
28
- x: true,
29
- y: true
30
- };
31
- return {
32
- x: Boolean(scales.x || scales.x2),
33
- y: Boolean(scales.y || scales.y2)
34
- };
35
- }
36
20
  /** A keyboard nudge step, in minimap pixels — Shift takes a bigger step. */ const KEY_STEP = 10;
37
21
  const KEY_STEP_SHIFT = 40;
38
22
  const ARROW_KEYS = {
@@ -304,11 +288,11 @@ const ARROW_KEYS = {
304
288
  */ export const minimapFeature = {
305
289
  name: "minimap",
306
290
  layout: ({ viz })=>{
307
- if (!viz.schema.zoom || !viz.schema.minimap || !viz._container || !viz._zoomBehavior || !showsZoomControls(viz)) return {
291
+ if (!viz.schema.zoom || !viz.schema.minimap || !viz._container || !viz._zoomBehavior) return {
308
292
  panel: null,
309
293
  margin: {}
310
294
  };
311
- const box = zoomControlsBox(viz);
295
+ const box = minimapAnchor(viz);
312
296
  if (!box) return {
313
297
  panel: null,
314
298
  margin: {}