@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
@@ -0,0 +1,241 @@
1
+ /**
2
+ Shortest-path measures of a network's nodes: betweenness (Brandes'
3
+ algorithm) and closeness, from one search per node. The graph is a list
4
+ of directed arcs; an undirected link is two arcs, one each way.
5
+ */ /** One way along a link: from `source` to `target`, `length` steps long (default 1). */ /**
6
+ The arcs between distinct nodes, keeping the shortest of parallel arcs.
7
+ Arcs from a node to itself, arcs to unknown nodes, and arcs without a
8
+ positive finite length are left out.
9
+ */ function adjacency(index, arcs) {
10
+ const n = index.size;
11
+ const out = Array.from({
12
+ length: n
13
+ }, ()=>new Map());
14
+ for (const arc of arcs){
15
+ const a = index.get(arc.source);
16
+ const b = index.get(arc.target);
17
+ const length = arc.length ?? 1;
18
+ if (a === undefined || b === undefined || a === b) continue;
19
+ if (!(length > 0) || !Number.isFinite(length)) continue;
20
+ const prev = out[a].get(b);
21
+ if (prev === undefined || length < prev) out[a].set(b, length);
22
+ }
23
+ const offsets = new Int32Array(n + 1);
24
+ for(let i = 0; i < n; i++)offsets[i + 1] = offsets[i] + out[i].size;
25
+ const targets = new Int32Array(offsets[n]);
26
+ const lengths = new Float64Array(offsets[n]);
27
+ let unit = true;
28
+ out.forEach((adj, i)=>{
29
+ let k = offsets[i];
30
+ for (const [b, length] of adj){
31
+ targets[k] = b;
32
+ lengths[k++] = length;
33
+ if (length !== 1) unit = false;
34
+ }
35
+ });
36
+ return {
37
+ offsets,
38
+ targets,
39
+ lengths,
40
+ unit
41
+ };
42
+ }
43
+ /** The slack allowed when comparing path lengths, for floating-point sums. */ const EPSILON = 1e-9;
44
+ /** Whether path length `a` equals `b` (a positive length), allowing for floating-point sums. */ const same = (a, b)=>Math.abs(a - b) <= EPSILON * b;
45
+ /** A binary min-heap of node indices by distance, with stale entries skipped on pop. */ class Heap {
46
+ nodes = [];
47
+ keys = [];
48
+ get size() {
49
+ return this.nodes.length;
50
+ }
51
+ push(node, key) {
52
+ const { nodes, keys } = this;
53
+ let i = nodes.length;
54
+ nodes.push(node);
55
+ keys.push(key);
56
+ while(i > 0){
57
+ const p = i - 1 >> 1;
58
+ if (keys[p] <= key) break;
59
+ nodes[i] = nodes[p];
60
+ keys[i] = keys[p];
61
+ i = p;
62
+ }
63
+ nodes[i] = node;
64
+ keys[i] = key;
65
+ }
66
+ /** The key of the node `pop` last returned. */ key = 0;
67
+ /** Removes and returns the node with the smallest key, setting `key` to it. */ pop() {
68
+ const { nodes, keys } = this;
69
+ const top = nodes[0];
70
+ this.key = keys[0];
71
+ const node = nodes.pop();
72
+ const key = keys.pop();
73
+ const n = nodes.length;
74
+ if (n) {
75
+ let i = 0;
76
+ for(;;){
77
+ let c = 2 * i + 1;
78
+ if (c >= n) break;
79
+ if (c + 1 < n && keys[c + 1] < keys[c]) c++;
80
+ if (keys[c] >= key) break;
81
+ nodes[i] = nodes[c];
82
+ keys[i] = keys[c];
83
+ i = c;
84
+ }
85
+ nodes[i] = node;
86
+ keys[i] = key;
87
+ }
88
+ return top;
89
+ }
90
+ }
91
+ /** Breadth-first search from `s`, counting shortest paths (every arc one step). */ function bfs(g, s, w) {
92
+ const { dist, sigma, order } = w;
93
+ const { offsets, targets } = g;
94
+ dist.fill(Infinity);
95
+ sigma.fill(0);
96
+ dist[s] = 0;
97
+ sigma[s] = 1;
98
+ order[0] = s;
99
+ let head = 0;
100
+ let tail = 1;
101
+ while(head < tail){
102
+ const v = order[head++];
103
+ const next = dist[v] + 1;
104
+ const end = offsets[v + 1];
105
+ for(let k = offsets[v]; k < end; k++){
106
+ const t = targets[k];
107
+ if (dist[t] === Infinity) {
108
+ dist[t] = next;
109
+ order[tail++] = t;
110
+ }
111
+ if (dist[t] === next) sigma[t] += sigma[v];
112
+ }
113
+ }
114
+ w.reached = tail;
115
+ }
116
+ /** Dijkstra's search from `s`, counting shortest paths. */ function dijkstra(g, s, w) {
117
+ const { dist, sigma, order } = w;
118
+ dist.fill(Infinity);
119
+ sigma.fill(0);
120
+ const { offsets, targets, lengths } = g;
121
+ const done = w.done;
122
+ done.fill(0);
123
+ dist[s] = 0;
124
+ sigma[s] = 1;
125
+ const heap = new Heap();
126
+ heap.push(s, 0);
127
+ let reached = 0;
128
+ while(heap.size){
129
+ const v = heap.pop();
130
+ const d = heap.key;
131
+ if (done[v] || d > dist[v]) continue;
132
+ done[v] = 1;
133
+ order[reached++] = v;
134
+ const end = offsets[v + 1];
135
+ for(let k = offsets[v]; k < end; k++){
136
+ const t = targets[k];
137
+ if (done[t]) continue;
138
+ const alt = d + lengths[k];
139
+ if (dist[t] !== Infinity && same(alt, dist[t])) sigma[t] += sigma[v];
140
+ else if (alt < dist[t]) {
141
+ dist[t] = alt;
142
+ sigma[t] = sigma[v];
143
+ heap.push(t, alt);
144
+ }
145
+ }
146
+ }
147
+ w.reached = reached;
148
+ }
149
+ /**
150
+ Adds each node's share of the shortest paths from the search's source
151
+ to `raw`, walking the reached nodes farthest first.
152
+ */ function accumulate(g, s, w, raw) {
153
+ const { dist, sigma, delta, order } = w;
154
+ const { offsets, targets, lengths, unit } = g;
155
+ for(let j = w.reached - 1; j >= 0; j--){
156
+ const v = order[j];
157
+ const dv = dist[v];
158
+ let sum = 0;
159
+ const end = offsets[v + 1];
160
+ for(let k = offsets[v]; k < end; k++){
161
+ const t = targets[k];
162
+ const dt = dist[t];
163
+ if (unit ? dt === dv + 1 : dt !== Infinity && same(dv + lengths[k], dt)) sum += (1 + delta[t]) / sigma[t];
164
+ }
165
+ delta[v] = sum * sigma[v];
166
+ if (v !== s) raw[v] += delta[v];
167
+ }
168
+ }
169
+ /** The current time in milliseconds, for task budgets. */ const now = ()=>typeof performance !== "undefined" ? performance.now() : Date.now();
170
+ /**
171
+ A task working out each node's betweenness and closeness (see
172
+ `networkMeasures`), one node's search per unit of work.
173
+ @param nodes The node ids; arcs naming other ids are ignored.
174
+ @param arcs The directed arcs between them.
175
+ */ export function measuresTask(nodes, arcs) {
176
+ const index = new Map();
177
+ for (const id of nodes)if (!index.has(id)) index.set(id, index.size);
178
+ const n = index.size;
179
+ const g = adjacency(index, arcs);
180
+ const w = {
181
+ dist: new Float64Array(n),
182
+ sigma: new Float64Array(n),
183
+ delta: new Float64Array(n),
184
+ order: new Int32Array(n),
185
+ reached: 0,
186
+ done: new Uint8Array(n)
187
+ };
188
+ const raw = new Float64Array(n);
189
+ const close = new Float64Array(n);
190
+ let s = 0;
191
+ return {
192
+ step (budget = Infinity) {
193
+ const start = now();
194
+ while(s < n){
195
+ if (g.unit) bfs(g, s, w);
196
+ else dijkstra(g, s, w);
197
+ let total = 0;
198
+ for(let j = 1; j < w.reached; j++)total += w.dist[w.order[j]];
199
+ const r = w.reached - 1;
200
+ close[s] = r > 0 && total > 0 ? r / total * (r / (n - 1)) : 0;
201
+ accumulate(g, s, w, raw);
202
+ s++;
203
+ if (now() - start >= budget) break;
204
+ }
205
+ return s >= n;
206
+ },
207
+ result () {
208
+ const scale = n > 2 ? 1 / ((n - 1) * (n - 2)) : 0;
209
+ const betweenness = new Map();
210
+ const closeness = new Map();
211
+ for (const [id, i] of index){
212
+ betweenness.set(id, raw[i] * scale);
213
+ closeness.set(id, close[i]);
214
+ }
215
+ return {
216
+ betweenness,
217
+ closeness
218
+ };
219
+ }
220
+ };
221
+ }
222
+ /**
223
+ Each node's betweenness and closeness.
224
+
225
+ Betweenness is the share of shortest paths between other pairs of nodes
226
+ that pass through the node, normalized by `(n - 1)(n - 2)` (the most a
227
+ node can have, as the center of a star), so it runs from 0 to 1.
228
+
229
+ Closeness is the inverse of the node's average distance to the nodes it
230
+ can reach, scaled by the share of the other nodes it can reach (Wasserman
231
+ and Faust's form, so a node in a small component isn't as close as one
232
+ linked to everything). It is 1 for a node one step from every other, and
233
+ 0 for a node that reaches none. In a directed graph it reads distances
234
+ from the node along its arcs.
235
+ @param nodes The node ids; arcs naming other ids are ignored.
236
+ @param arcs The directed arcs between them.
237
+ */ export function networkMeasures(nodes, arcs) {
238
+ const task = measuresTask(nodes, arcs);
239
+ task.step();
240
+ return task.result();
241
+ }
@@ -0,0 +1,309 @@
1
+ /**
2
+ Network measures in a node's tooltip (Network, Rings, ArcDiagram, and
3
+ Sankey): its degree (in and out when the chart draws arrows, and in
4
+ Sankey), its betweenness and closeness, and its cluster. In a browser,
5
+ betweenness and closeness are worked out in idle time after the chart
6
+ draws (see `scheduleNodeStats`); a tooltip shown before they are ready
7
+ reads "…" for them, and fills them in when they are. They are kept until the chart's nodes or
8
+ links change.
9
+ */ import { formatAbbreviate } from "@d3plus/format";
10
+ import { arrowEnds } from "./edgeArrows.js";
11
+ import { idleQueue } from "./idleQueue.js";
12
+ import { measuresTask, networkMeasures } from "./networkMeasures.js";
13
+ /** Every measure, in the order a node's tooltip lists them. */ export const NODE_STATS = [
14
+ "degree",
15
+ "betweenness",
16
+ "closeness",
17
+ "cluster"
18
+ ];
19
+ /** The `nodeTooltipStats` and `nodeTooltipStatsConfig` fields. */ export function nodeStatsFields() {
20
+ return [
21
+ /**
22
+ The network measures a node's tooltip lists: `true` for all of them,
23
+ `false` for none, or an Array of `"degree"`, `"betweenness"`,
24
+ `"closeness"`, and `"cluster"`, in the order to list them.
25
+ @type {boolean | string[]}
26
+ */ {
27
+ key: "nodeTooltipStats",
28
+ default: true
29
+ },
30
+ /**
31
+ Settings for the network measures: `weighted` counts a strong link
32
+ (by `linkSize`, or Sankey's `value`) as a shorter step than a weak
33
+ one for betweenness and closeness. Defaults to `{weighted: false}`,
34
+ every link one step.
35
+ @type {{weighted?: boolean}}
36
+ */ {
37
+ key: "nodeTooltipStatsConfig",
38
+ merge: true,
39
+ default: {}
40
+ }
41
+ ];
42
+ }
43
+ /**
44
+ The measures `nodeTooltipStats` asks for, in its order: every measure
45
+ for `true`, the known names of an Array (once each), and none otherwise.
46
+ */ export function nodeTooltipStatList(value) {
47
+ if (value === true) return [
48
+ ...NODE_STATS
49
+ ];
50
+ if (!Array.isArray(value)) return [];
51
+ return [
52
+ ...new Set(value)
53
+ ].filter((s)=>NODE_STATS.includes(s));
54
+ }
55
+ /** A link's weight: its value, or 1 when that isn't a positive number. */ const linkWeight = (value)=>value !== undefined && value > 0 && Number.isFinite(value) ? value : 1;
56
+ /**
57
+ The degrees and the arcs the measures walk. A link is one-way when
58
+ `arrows` puts a head on one end only (from source to target for
59
+ `"target"`, back for `"source"`), and two-way otherwise. When `weighted`,
60
+ a link's length is the strongest link's weight over its own, so the
61
+ strongest link is one step and a link half as strong is two.
62
+ */ export function nodeStatsGraph(nodes, links, arrows, weighted) {
63
+ const zero = ()=>new Map(nodes.map((id)=>[
64
+ id,
65
+ 0
66
+ ]));
67
+ const degree = zero();
68
+ const inDegree = zero();
69
+ const outDegree = zero();
70
+ const add = (map, id)=>map.set(id, (map.get(id) ?? 0) + 1);
71
+ const strongest = weighted ? links.reduce((m, l)=>Math.max(m, linkWeight(l.value)), 1e-300) : 1;
72
+ let directed = false;
73
+ const arcs = [];
74
+ for (const l of links){
75
+ const ends = arrows ? arrowEnds(arrows, l.datum, l.index) : {
76
+ source: false,
77
+ target: false
78
+ };
79
+ const forward = ends.target && !ends.source;
80
+ const back = ends.source && !ends.target;
81
+ if (forward || back) directed = true;
82
+ const length = weighted ? strongest / linkWeight(l.value) : 1;
83
+ add(degree, l.source);
84
+ if (l.target !== l.source) add(degree, l.target);
85
+ if (!back) {
86
+ arcs.push({
87
+ source: l.source,
88
+ target: l.target,
89
+ length
90
+ });
91
+ add(outDegree, l.source);
92
+ add(inDegree, l.target);
93
+ }
94
+ if (!forward) {
95
+ arcs.push({
96
+ source: l.target,
97
+ target: l.source,
98
+ length
99
+ });
100
+ add(outDegree, l.target);
101
+ add(inDegree, l.source);
102
+ }
103
+ }
104
+ return {
105
+ directed,
106
+ degree,
107
+ inDegree,
108
+ outDegree,
109
+ nodes,
110
+ arcs
111
+ };
112
+ }
113
+ const memos = new WeakMap();
114
+ /** A key naming the nodes and the arcs, so a redraw of the same network reuses its measures. */ function measuresKey(stats) {
115
+ return `${stats.nodes.join("\u0000")}|${stats.arcs.map((a)=>`${a.source}>${a.target}:${a.length}`).join("\u0000")}`;
116
+ }
117
+ /** The memo's `measuresKey`, worked out once. */ const memoKey = (memo)=>memo.key ??= measuresKey(memo.stats);
118
+ /**
119
+ The `arrows` the measures read: every link runs from source to target
120
+ in a chart whose links always do (Sankey sets `ctx.linksDirected`).
121
+ */ function statArrows(viz) {
122
+ return viz.ctx.linksDirected === true ? true : viz.schema.arrows;
123
+ }
124
+ /** Whether `nodeTooltipStatsConfig` weights the paths by `linkSize`. */ function statWeighted(viz) {
125
+ const config = viz.schema.nodeTooltipStatsConfig;
126
+ return config?.weighted === true;
127
+ }
128
+ /**
129
+ The chart graph's degrees and arcs, for the chart's current `arrows` and
130
+ `nodeTooltipStatsConfig.weighted`.
131
+ @param links The graph's links, read only when they haven't been for these settings.
132
+ */ function memoFor(viz, graph, links) {
133
+ const arrows = statArrows(viz);
134
+ const weighted = statWeighted(viz);
135
+ const memo = memos.get(graph);
136
+ if (memo && memo.arrows === arrows && memo.weighted === weighted) return memo;
137
+ const stats = nodeStatsGraph([
138
+ ...graph.byNode.keys()
139
+ ], links(), arrows, weighted);
140
+ const next = {
141
+ arrows,
142
+ weighted,
143
+ stats
144
+ };
145
+ memos.set(graph, next);
146
+ return next;
147
+ }
148
+ /** The measures worked out for the chart, by `measuresKey`. */ function measuresCache(viz) {
149
+ let cache = viz.ctx.nodeStatsCache;
150
+ if (!(cache instanceof Map)) viz.ctx.nodeStatsCache = cache = new Map();
151
+ return cache;
152
+ }
153
+ /**
154
+ Whether the measures are worked out in idle time: in a browser, but not
155
+ while `@d3plus/ssr` renders the chart (or anywhere without a window),
156
+ where they are worked out when first asked for.
157
+ */ export function nodeStatsInIdle(viz) {
158
+ return !viz._ssr && typeof window !== "undefined";
159
+ }
160
+ /** Whether `nodeTooltipStats` lists a measure that needs shortest paths. */ function needsPaths(viz) {
161
+ const list = nodeTooltipStatList(viz.schema.nodeTooltipStats);
162
+ return list.includes("betweenness") || list.includes("closeness");
163
+ }
164
+ /**
165
+ Queues the idle job working out a memo's measures, unless it is cached
166
+ or queued. `refresh` runs once they are ready.
167
+ */ function queueMeasures(viz, memo, refresh) {
168
+ const key = memoKey(memo);
169
+ const queue = idleQueue(viz);
170
+ if (measuresCache(viz).has(key) || queue.has(key)) return;
171
+ const task = measuresTask(memo.stats.nodes, memo.stats.arcs);
172
+ queue.add(key, {
173
+ step (budget) {
174
+ // A chart taken off the page stops; a tooltip queues it again.
175
+ if (viz._select?.node()?.isConnected === false) return true;
176
+ if (!task.step(budget)) return false;
177
+ measuresCache(viz).set(key, task.result());
178
+ refresh();
179
+ return true;
180
+ }
181
+ });
182
+ }
183
+ const drafts = new WeakMap();
184
+ /**
185
+ Queues the measures of the graphs one draw published, and cancels (and
186
+ forgets) any others: they belong to nodes and links the chart no longer
187
+ draws.
188
+ */ function settleDraw(viz, published) {
189
+ const keys = new Set();
190
+ if (needsPaths(viz)) for (const p of published){
191
+ const memo = memoFor(viz, p.graph, p.links);
192
+ keys.add(memoKey(memo));
193
+ queueMeasures(viz, memo, p.refresh);
194
+ }
195
+ idleQueue(viz).keep(keys);
196
+ const cache = measuresCache(viz);
197
+ for (const key of [
198
+ ...cache.keys()
199
+ ])if (!keys.has(key)) cache.delete(key);
200
+ }
201
+ /**
202
+ Works out a published graph's betweenness and closeness in the browser's
203
+ idle time after the chart draws (see `IdleQueue`), so a node's tooltip
204
+ rarely waits for them. The graphs one draw publishes (one per small
205
+ multiple) are settled together in the first idle turn after it: their
206
+ measures are queued, and a run for nodes and links the chart no longer
207
+ draws is cancelled. Nothing is queued while `@d3plus/ssr` renders.
208
+ @param refresh Runs when a graph's measures are ready, to update an open tooltip.
209
+ */ export function scheduleNodeStats(viz, graph, links, refresh) {
210
+ // A chart without node measures (Geomap's flows) has nothing to queue.
211
+ if (!nodeStatsInIdle(viz) || viz.schema.nodeTooltipStats === undefined) return;
212
+ let draft = drafts.get(viz);
213
+ if (!draft) {
214
+ drafts.set(viz, draft = []);
215
+ queueMicrotask(()=>{
216
+ const published = drafts.get(viz) ?? [];
217
+ drafts.delete(viz);
218
+ idleQueue(viz).beforeNext(()=>settleDraw(viz, published));
219
+ });
220
+ }
221
+ draft.push({
222
+ graph,
223
+ links,
224
+ refresh
225
+ });
226
+ }
227
+ /**
228
+ The memo's betweenness and closeness. In a browser they come from idle
229
+ time: until they are ready this queues them (if no draw has) and returns
230
+ undefined. Elsewhere they are worked out now. Either way they are kept by
231
+ their nodes and arcs, so a redraw that leaves those as they were reuses
232
+ them.
233
+ */ function measuresFor(viz, memo, refresh) {
234
+ const key = memoKey(memo);
235
+ const cache = measuresCache(viz);
236
+ const cached = cache.get(key);
237
+ if (cached) return cached;
238
+ if (nodeStatsInIdle(viz)) {
239
+ queueMeasures(viz, memo, refresh);
240
+ return undefined;
241
+ }
242
+ const measures = networkMeasures(memo.stats.nodes, memo.stats.arcs);
243
+ cache.set(key, measures);
244
+ return measures;
245
+ }
246
+ /** What a node's tooltip shows for a measure still being worked out: an ellipsis. */ export const STAT_PENDING = "\u2026";
247
+ /** The name of the cluster a node is in, when clusters color the chart. */ function nodeCluster(viz, id) {
248
+ const state = viz.ctx.clusterState;
249
+ if (!state?.active) return undefined;
250
+ const name = state.names.get(id);
251
+ return state.clusters.some((c)=>c.name === name) ? name : undefined;
252
+ }
253
+ /**
254
+ A node's measure rows, in `nodeTooltipStats` order: "Degree" (or
255
+ "In-degree" and "Out-degree" when the chart draws arrows, and in
256
+ Sankey), "Betweenness", "Closeness", and "Cluster" (when clusters color
257
+ the chart and the node is in one). Betweenness and closeness read
258
+ `STAT_PENDING` until they are ready (see `measuresFor`), so the tooltip
259
+ keeps its size when they fill in. `degree` says whether its
260
+ degree is listed, so the tooltip leaves out its count of connections.
261
+ @param links The graph's links, read once per graph, `arrows`, and
262
+ weighting when a measure other than the cluster needs them.
263
+ @param refresh Runs when measures this asked for become ready.
264
+ */ export function nodeStatRows(viz, graph, id, links, refresh = ()=>undefined) {
265
+ const list = nodeTooltipStatList(viz.schema.nodeTooltipStats);
266
+ if (!list.length) return {
267
+ rows: [],
268
+ degree: false
269
+ };
270
+ const t = (s)=>`${viz.schema.translate(s)}`;
271
+ const locale = viz.schema.locale;
272
+ let memo;
273
+ const read = ()=>memo ??= memoFor(viz, graph, links);
274
+ const rows = [];
275
+ for (const stat of list){
276
+ if (stat === "degree") {
277
+ const { stats } = read();
278
+ if (stats.directed) {
279
+ rows.push([
280
+ t("In-degree"),
281
+ `${stats.inDegree.get(id) ?? 0}`
282
+ ]);
283
+ rows.push([
284
+ t("Out-degree"),
285
+ `${stats.outDegree.get(id) ?? 0}`
286
+ ]);
287
+ } else rows.push([
288
+ t("Degree"),
289
+ `${stats.degree.get(id) ?? 0}`
290
+ ]);
291
+ } else if (stat === "cluster") {
292
+ const name = nodeCluster(viz, id);
293
+ if (name !== undefined) rows.push([
294
+ t("Cluster"),
295
+ name
296
+ ]);
297
+ } else {
298
+ const measures = measuresFor(viz, read(), refresh);
299
+ rows.push([
300
+ t(stat === "betweenness" ? "Betweenness" : "Closeness"),
301
+ measures ? formatAbbreviate(measures[stat].get(id) ?? 0, locale) : STAT_PENDING
302
+ ]);
303
+ }
304
+ }
305
+ return {
306
+ rows,
307
+ degree: list.includes("degree")
308
+ };
309
+ }
@@ -10,7 +10,9 @@
10
10
  @module
11
11
  */ import { fontExists, rtl as detectRTL } from "@d3plus/dom";
12
12
  import { fontFamily as d3plusFontFamily, textWrap } from "@d3plus/text";
13
+ import { labelLineHeight } from "../../components/Axis/axisLabelLineHeight.js";
13
14
  import TextBox from "../../components/TextBox.js";
15
+ import configValue from "../../utils/configValue.js";
14
16
  import { swarmHidesAxis } from "../Plot/swarm.js";
15
17
  /**
16
18
  Layered over the user's config on the x test axis that measures the plot's
@@ -19,7 +21,6 @@ import { swarmHidesAxis } from "../Plot/swarm.js";
19
21
  */ export const END_LABEL_AXIS_CONFIG = {
20
22
  labels: []
21
23
  };
22
- const resolve = (value, d, i)=>typeof value === "function" ? value(d, i) : value;
23
24
  /**
24
25
  Whether a Plot labels its x axis with its two ends: the x axis shows, the
25
26
  y axis is hidden (the chart is no taller than `yCutoff`), and the user
@@ -52,7 +53,7 @@ const resolve = (value, d, i)=>typeof value === "function" ? value(d, i) : value
52
53
  }
53
54
  /**
54
55
  Formats an axis's domain ends with its tick format and measures them with
55
- its label font (`shapeConfig.labelConfig` and `shapeConfig.lineHeight`).
56
+ its label font and line height (see `labelLineHeight`).
56
57
  Read after the axis has been measured or rendered.
57
58
  */ export function measureEndLabels(axis) {
58
59
  const shapeConfig = axis.schema.shapeConfig;
@@ -60,13 +61,15 @@ const resolve = (value, d, i)=>typeof value === "function" ? value(d, i) : value
60
61
  const format = axis._labelFormat || ((d)=>`${d}`);
61
62
  let height = 0, padding = 0;
62
63
  const labels = domainEnds(axis).map((value, i)=>{
63
- const fontSize = resolve(labelConfig.fontSize ?? 12, value, i);
64
- const lineHeight = shapeConfig.lineHeight ? shapeConfig.lineHeight(value, i) : fontSize * 1.4;
64
+ const fontSize = configValue(labelConfig.fontSize ?? 12, value, i);
65
+ const lineHeight = labelLineHeight(shapeConfig, value, i, fontSize);
65
66
  const text = `${format(value) ?? ""}`;
66
- const wrap = textWrap().fontFamily(fontExists(resolve(labelConfig.fontFamily ?? d3plusFontFamily, value, i))).fontSize(fontSize).fontWeight(resolve(labelConfig.fontWeight ?? 400, value, i)).lineHeight(lineHeight).width(Number.MAX_SAFE_INTEGER).height(lineHeight)(text);
67
+ const wrap = textWrap().fontFamily(fontExists(configValue(labelConfig.fontFamily ?? d3plusFontFamily, value, i))).fontSize(fontSize).fontWeight(configValue(labelConfig.fontWeight ?? 400, value, i)).lineHeight(lineHeight).width(Number.MAX_SAFE_INTEGER).height(lineHeight)(text);
67
68
  const lines = wrap.lines.filter((l)=>l !== "");
68
- height = Math.max(height, Math.ceil(lines.length * lineHeight));
69
- padding = Math.max(padding, resolve(labelConfig.padding ?? 0, value, i));
69
+ // The whole pixel above the text: TextBox draws a line only in a box
70
+ // taller than the line.
71
+ if (lines.length) height = Math.max(height, Math.floor(lines.length * lineHeight) + 1);
72
+ padding = Math.max(padding, configValue(labelConfig.padding ?? 0, value, i));
70
73
  return {
71
74
  value,
72
75
  text,
@@ -87,6 +90,22 @@ const resolve = (value, d, i)=>typeof value === "function" ? value(d, i) : value
87
90
  const space = measure.height ? measure.padding + measure.height : 0;
88
91
  return available - space >= space ? space : 0;
89
92
  }
93
+ /**
94
+ The x labels a Plot keeps once its chrome (title, legend, the corner
95
+ controls' reach, …) has claimed its margins. End labels claim their room
96
+ against the chart area as it stood before; when `room`, the height left
97
+ for the plot and its x labels, no longer holds both (see
98
+ `endLabelSpace`), they are dropped and the plot takes their height.
99
+ */ export function endLabelsInRoom(claim, measure, room) {
100
+ const { xLabelMode, xHeight } = claim;
101
+ return xLabelMode === "ends" && !endLabelSpace(measure(), room) ? {
102
+ xLabelMode: "none",
103
+ xHeight: 0
104
+ } : {
105
+ xLabelMode,
106
+ xHeight
107
+ };
108
+ }
90
109
  /**
91
110
  Splits `span` between a start and an end label of natural widths `start`
92
111
  and `end`, at least `gap` apart. Labels that fit keep room to their
@@ -187,6 +206,8 @@ const resolve = (value, d, i)=>typeof value === "function" ? value(d, i) : value
187
206
  const labelConfig = axis.schema.shapeConfig.labelConfig || {};
188
207
  const textBox = new TextBox().renderMode("compute").config(labelConfig).config({
189
208
  fontResize: false,
209
+ // Painted with the line height they were measured with.
210
+ lineHeight: (d)=>labelLineHeight(axis.schema.shapeConfig, d.value, d.i),
190
211
  padding: 0,
191
212
  rotate: 0,
192
213
  textAnchor: (d)=>d.textAnchor,
@@ -15,6 +15,7 @@ import { valueAxisExtent } from "../Plot/baselineBreak.js";
15
15
  import { breakLineNodes, maskBreaks } from "../Plot/plotBreaks.js";
16
16
  import { clipToPlotArea } from "../Plot/domainClip.js";
17
17
  import { collectComputed, makeShape } from "./emitHelpers.js";
18
+ import { discreteAxis, tagHoverTicks } from "./hoverTicks.js";
18
19
  import { emitLineLabelConnectors } from "./lineLabels.js";
19
20
  import { emitAnnotations } from "./plotAnnotations.js";
20
21
  import { plotAnnotationFrame } from "./annotationFrame.js";
@@ -25,7 +26,9 @@ import { barHitsFirst } from "../Plot/barHitArea.js";
25
26
  import { emitTrendLines } from "../Plot/trendScene.js";
26
27
  import { emitTrendLabels } from "../Plot/trendLabels.js";
27
28
  import { emitAlongLabels } from "../Plot/lineLabelsAlong.js";
29
+ import { countShapeLabels } from "../Plot/shapeLabelLegend.js";
28
30
  import { emitAreaLabels } from "../Plot/areaLabelsAlong.js";
31
+ import { holdAreaLabels } from "../Plot/areaEnter.js";
29
32
  import { plotEdges } from "./pathLabelGeometry.js";
30
33
  import { emitForecast, forecastRows } from "../Plot/forecastScene.js";
31
34
  import { markSharedConfig } from "../../utils/configWarnings.js";
@@ -165,7 +168,8 @@ const isGridNode = (node)=>typeof node.key === "string" && node.key.startsWith("
165
168
  — ticks, tick labels, domain bar, title — which stays on top. Each axis
166
169
  is wrapped in a group with its axis-relative transform; the chart-cells
167
170
  group's `_chartTransform` composes with this to land at the right
168
- absolute position.
171
+ absolute position. A discrete axis's tick labels follow the hover (see
172
+ `tagHoverTicks`), matched on the marks' value for that axis.
169
173
  */ function collectAxisScenes(axisSceneQueue) {
170
174
  const grid = [];
171
175
  const rest = [];
@@ -173,6 +177,7 @@ const isGridNode = (node)=>typeof node.key === "string" && node.key.startsWith("
173
177
  if (!axis || typeof axis.toScene !== "function") return;
174
178
  const scene = axis.toScene();
175
179
  if (!scene) return;
180
+ if (discreteAxis(axis)) tagHoverTicks(scene, key.replace(/^plot-|-axis$/g, ""));
176
181
  const children = scene.children || [];
177
182
  const gridChildren = children.filter(isGridNode);
178
183
  const restChildren = children.filter((c)=>!isGridNode(c));
@@ -263,11 +268,13 @@ const isGridNode = (node)=>typeof node.key === "string" && node.key.startsWith("
263
268
  // plot's axes, clear of the plot's clips and masks.
264
269
  const shapeAxes = takeAxisNodes(marks, shapesStart);
265
270
  if (viz._plotUnderlay) marks.splice(shapesStart, 0, ...viz._plotUnderlay(marks.slice(shapesStart), x, y));
271
+ // Shapes that each show their legend entry's name hide the default legend.
272
+ countShapeLabels(viz, marks.slice(shapesStart));
266
273
  // Labels along the lines and the stacked bands sit above the marks.
267
274
  const edges = plotEdges(xRange, yRange, pCtx.x2Height);
268
275
  // Trend labels go last, to clear the line labels.
269
276
  marks.push(...emitAlongLabels(viz, marks, edges));
270
- marks.push(...emitAreaLabels(viz, marks, edges));
277
+ marks.push(...holdAreaLabels(emitAreaLabels(viz, marks, edges)));
271
278
  marks.push(...emitTrendLabels(viz, x, y, edges, marks));
272
279
  // The plot area reaches down through any room reserved under the value
273
280
  // axis's range (see `_plotInsetBottom`), so marks drawn there stay.