@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
@@ -3,6 +3,7 @@
3
3
  */ import { FULL_TURN } from "@d3plus/render";
4
4
  import { textureFill, shapeConfigFor, resolveAccessor } from "../features/emitHelpers.js";
5
5
  import { backgroundImageNodes } from "../features/backgroundImageEmit.js";
6
+ import { centerLabelNodes } from "../features/centerLabel.js";
6
7
  import { sweepFraction } from "./arcFit.js";
7
8
  import { pieOutsideLabels } from "./outsideNodes.js";
8
9
  import { pieLabelPlan, pieSharePct } from "./pieLabels.js";
@@ -182,11 +183,18 @@ export const pieEmit = ({ viz, shapeData })=>{
182
183
  slices[k].data,
183
184
  slices[k].i ?? 0
184
185
  ]);
186
+ // The hole is as wide as the narrowest slice's inner radius leaves it.
187
+ const hole = slices.reduce((m, d)=>Math.min(m, Number(resolveInnerRadius(d, d.i ?? 0)) || 0), Infinity);
185
188
  return [
186
189
  ...pathNodes,
187
190
  ...imageNodes,
188
191
  ...straight,
189
192
  ...curved,
190
- ...outside.nodes
193
+ ...outside.nodes,
194
+ ...centerLabelNodes(viz, {
195
+ radius: hole,
196
+ startAngle: sweep.start,
197
+ endAngle: sweep.end
198
+ }, value)
191
199
  ];
192
200
  };
@@ -8,6 +8,7 @@
8
8
  import accessor from "../../utils/accessor.js";
9
9
  import { fieldAccessor } from "../../utils/fieldAccessor.js";
10
10
  import { chartBounds, centerChartTransform } from "../features/chartGeometry.js";
11
+ import { centerLabelDefaults } from "../features/centerLabel.js";
11
12
  import { legendLargestFirst, rowLegend, shareRow } from "../features/sharedFields.js";
12
13
  import { makeChart } from "../definition/makeChart.js";
13
14
  import { applyPieLayout, pieAspect } from "./applyLayout.js";
@@ -77,6 +78,15 @@ export const pieDef = {
77
78
  key: "innerRadius",
78
79
  default: 0
79
80
  },
81
+ {
82
+ key: "centerLabel",
83
+ default: false
84
+ },
85
+ {
86
+ key: "centerLabelConfig",
87
+ merge: true,
88
+ factory: centerLabelDefaults
89
+ },
80
90
  /**
81
91
  Where the slices start, in degrees clockwise from 12 o'clock, the same
82
92
  convention Gauge, PolarArea and RadialBar use. With `endAngle`, draws a
@@ -0,0 +1,68 @@
1
+ /**
2
+ How areas grow in: every band starts flat on the value axis's baseline
3
+ and rises into place. An unstacked area starts on its own baseline; a
4
+ stack starts on the zero line (or the `baseline`, kept inside the
5
+ domain), so its bands rise together, each riding on the one beneath it.
6
+ Their labels fade in as the bands finish growing, where the bands land.
7
+ */ import { growFromLine } from "../helpers/densityEnter.js";
8
+ /**
9
+ The pixel line, along the value axis, that areas grow out of.
10
+ @param ctx The Plot shape-emit context the areas were drawn with.
11
+ */ export function areaBaseline(ctx) {
12
+ const { viz } = ctx;
13
+ const axis = viz.schema.discrete === "y" ? "x" : "y";
14
+ const own = ctx.shapeConfig[`${axis}0`];
15
+ if (!viz.schema.stacked && typeof own === "number" && Number.isFinite(own)) return own;
16
+ const domain = (axis === "x" ? ctx.xDomain : ctx.yDomain).map(Number);
17
+ const baseline = viz.schema.baseline;
18
+ const value = typeof baseline === "number" ? baseline : 0;
19
+ const lo = Math.min(...domain);
20
+ const hi = Math.max(...domain);
21
+ if (!Number.isFinite(lo) || !Number.isFinite(hi)) return null;
22
+ const at = (axis === "x" ? ctx.x : ctx.y)(Math.max(lo, Math.min(hi, value)));
23
+ return Number.isFinite(at) ? at : null;
24
+ }
25
+ /**
26
+ The share of an area's enter its labels wait out: they fade in over the
27
+ last part, once the bands have nearly reached the places they name.
28
+ */ export const AREA_LABEL_ENTER = {
29
+ start: 0.7,
30
+ end: 1
31
+ };
32
+ /**
33
+ Holds every text node under `nodes` back until late in its enter (see
34
+ `AREA_LABEL_ENTER`), so a label doesn't show where its band has yet to
35
+ grow.
36
+ @param nodes The label nodes, or the groups holding them.
37
+ */ export function holdAreaLabels(nodes) {
38
+ for (const node of nodes){
39
+ if (node.type === "text") node.enterWindow = AREA_LABEL_ENTER;
40
+ else if (node.type === "group") holdAreaLabels(node.children);
41
+ }
42
+ return nodes;
43
+ }
44
+ /** Every Area path's key under `nodes`. */ function areaKeys(nodes, out = []) {
45
+ for (const node of nodes){
46
+ if (node.type === "group") areaKeys(node.children, out);
47
+ else if (node.type === "path" && node.shapeType === "Area") out.push(`${node.key}`);
48
+ }
49
+ return out;
50
+ }
51
+ /**
52
+ Sets each Area path's `enterD`: its outline flattened onto the baseline
53
+ (see `areaBaseline`), so it grows out of the axis and, on exit, sinks
54
+ back into it. The areas' own labels fade in late (see `holdAreaLabels`).
55
+ @param ctx The Plot shape-emit context the areas were drawn with.
56
+ @param nodes The areas' scene nodes.
57
+ */ export function growAreasFromBaseline(ctx, nodes) {
58
+ const line = areaBaseline(ctx);
59
+ if (line === null) return;
60
+ const axis = ctx.viz.schema.discrete === "y" ? "x" : "y";
61
+ const keys = areaKeys(nodes);
62
+ if (!keys.length) return;
63
+ growFromLine(nodes, axis, new Map(keys.map((key)=>[
64
+ key,
65
+ line
66
+ ])));
67
+ holdAreaLabels(nodes);
68
+ }
@@ -8,6 +8,7 @@
8
8
  import { AxisBottom, AxisLeft, AxisTop, TextBox } from "../../components/index.js";
9
9
  import * as shapes from "../../shapes/index.js";
10
10
  import { measureAxes } from "../features/axesMeasure.js";
11
+ import { endLabelsInRoom, measureEndLabels } from "../features/plotEndLabels.js";
11
12
  import Viz from "../viz/Viz.js";
12
13
  import { runStages } from "../pipeline/stages.js";
13
14
  import { computePlotAxisValues, computePlotInitialDomains, computePlotScales, extendPlotOppScales, formatPlotData, measurePlotLineLabels, preparePlotAxisLayout } from "./pipeline.js";
@@ -197,6 +198,29 @@ const superDraw = (viz, callback)=>Viz.prototype._draw.call(viz, callback);
197
198
  };
198
199
  };
199
200
  }
201
+ /**
202
+ Draws the chart's chrome (title, legend, …) through the base Viz draw,
203
+ then settles the axes measured against the chart area as it stood before,
204
+ `height` tall: the margins the chrome claimed (the paint phase shrinks
205
+ the axes' ranges by them; a small-multiples panel arrives with its
206
+ margins set and claims nothing more), and the x labels the plot keeps in
207
+ the room left (see `endLabelsInRoom`).
208
+ */ function drawChrome(viz, callback, measured, xTest, height) {
209
+ const pre = {
210
+ ...viz._margin
211
+ };
212
+ superDraw(viz, callback);
213
+ const horizontalMargin = viz._margin.left + viz._margin.right - pre.left - pre.right;
214
+ const verticalMargin = viz._margin.top + viz._margin.bottom - pre.top - pre.bottom;
215
+ const { topOffset, x2Height } = measured;
216
+ const xLabels = endLabelsInRoom(measured, ()=>measureEndLabels(xTest), height - verticalMargin - topOffset - x2Height);
217
+ viz._padding.bottom += xLabels.xHeight - measured.xHeight;
218
+ return {
219
+ horizontalMargin,
220
+ verticalMargin,
221
+ ...xLabels
222
+ };
223
+ }
200
224
  export function drawPlot(viz, callback) {
201
225
  // The axis hover's positions belong to the previous layout.
202
226
  viz._axisHoverState = null;
@@ -267,16 +291,7 @@ export function drawPlot(viz, callback) {
267
291
  xData,
268
292
  x: scales.x
269
293
  }), measureLineLabels);
270
- // The axes measured against the chart area as it stood before the chrome
271
- // claimed its margins; the paint phase shrinks their ranges by what the
272
- // chrome claimed. (A small-multiples panel arrives with its margins set
273
- // and claims nothing more.)
274
- const pre = {
275
- ...viz._margin
276
- };
277
- superDraw(viz, callback);
278
- const horizontalMargin = viz._margin.left + viz._margin.right - pre.left - pre.right;
279
- const verticalMargin = viz._margin.top + viz._margin.bottom - pre.top - pre.bottom;
294
+ const chrome = drawChrome(viz, callback, measured, testAxes.xTest, height);
280
295
  // The local layout types (DomainValue domains, D3Scale scales, dynamically-
281
296
  // keyed rows) are broader than PlotPaintContext's; the emit reads each field
282
297
  // as the concrete type its producer guaranteed, so bridge at this boundary.
@@ -298,8 +313,7 @@ export function drawPlot(viz, callback) {
298
313
  width,
299
314
  opp,
300
315
  showLineLabels,
301
- horizontalMargin,
302
- verticalMargin
316
+ ...chrome
303
317
  };
304
318
  return viz._paint(pCtx);
305
319
  }
@@ -273,11 +273,7 @@ import { displayName } from "../../utils/displayName.js";
273
273
  return true;
274
274
  }
275
275
  /**
276
- Allows drawing custom shapes to be used as annotations in the provided x/y plot. This method accepts custom config objects for the [Shape](http://d3plus.org/docs/#Shape) class, either a single config object or an array of config objects. Each config object requires an additional parameter, the "shape", which denotes which [Shape](http://d3plus.org/docs/#Shape) sub-class to use ([Rect](http://d3plus.org/docs/#Rect), [Line](http://d3plus.org/docs/#Line), etc).
277
-
278
- Additionally, each config object can also contain an optional "layer" key, which defines whether the annotations will be displayed in "front" or in "back" of the primary visualization shapes. This value defaults to "back" if not present ("front" for callouts).
279
-
280
- Three more kinds draw chart notes: `"Callout"` anchors wrapped text in a box at each data row's `x`/`y` (in data units, or plot-area fractions with `xRef`/`yRef: "plot"`), offset by `dx`/`dy` pixels and joined to its anchor by a connector ending in an arrowhead or dot (see `CalloutAnnotation`); `"ReferenceLine"` and `"ReferenceBand"` draw what `referenceLines` and `referenceBands` entries expand into. All annotations follow zoom and never respond to the pointer or keyboard.
276
+ Custom shapes drawn as annotations on the plot: a [Shape](http://d3plus.org/docs/#Shape) config object, or an array of them, each with a `shape` key naming the Shape class to use (`"Rect"`, `"Line"`, …) and an optional `layer`, `"back"` (the default) or `"front"`. Three more kinds draw chart notes: `"Callout"` (wrapped text joined to a data point by a connector; see `CalloutAnnotation`), and `"ReferenceLine"` and `"ReferenceBand"` (what `referenceLines` and `referenceBands` expand into).
281
277
  */ annotations(_) {
282
278
  return arguments.length ? (this._annotations = _ instanceof Array ? _ : [
283
279
  _
@@ -289,7 +285,7 @@ Three more kinds draw chart notes: `"Callout"` anchors wrapped text in a box at
289
285
  return arguments.length ? (this._axisPersist = _, this) : this._axisPersist;
290
286
  }
291
287
  /**
292
- Starts the value axis (the x axis for horizontal charts) at a value: `baseline(n)` renders exactly like `yDomain([n])` (or `xDomain([n])`). Bars, areas, and stems still grow from the chart's own `0` in the Plots that draw from one (such as BarChart, AreaPlot, Histogram, and Lollipop), so with `baselineBreak` on (their default) the axis breaks back to a `0` tick and bars run through the break, with its gap cut across them, and with it off the axis stretches down to `0`. As with `yDomain([n])`, only `n` is pinned: the far end comes from the data and is rounded where the axis would round it with no domain set (left at the data when the axis config's `rounding` is "none"), and marks for values past `n` stop at the axis's edge. When every value sits at or below `n`, it ends the axis instead, like `yDomain([undefined, n])`. A bound given in `yDomain`/`xDomain` wins. Returns the chart's own baseline when none is set.
288
+ Starts the value axis at a value, like `yDomain([n])` (or `xDomain([n])` for horizontal charts); the far end comes from the data. Bars, areas, and stems still grow from `0`, so with `baselineBreak` on the axis breaks back to a `0` tick. A bound in `yDomain`/`xDomain` wins. Returns the chart's own baseline when none is set.
293
289
  */ baseline(_) {
294
290
  return arguments.length ? (setBaseline(this, _), this) : baselineValue(this);
295
291
  }
@@ -316,9 +312,7 @@ Three more kinds draw chart notes: `"Callout"` anchors wrapped text in a box at
316
312
  return this._buffer;
317
313
  }
318
314
  /**
319
- The confidence interval as an array of [lower, upper] bounds. Lines draw it as a shaded band; bars draw an error bar per bar, from the lower to the upper bound with a cap at each end (a stacked bar's bounds keep their distance from its value, measured from the bar's stacked end). Either bound may be `false` for a one-sided interval, and a row without a bound pinches the band onto its line. The value axis widens to fit the bounds, and tooltips list them (see `confidenceConfig.tooltip`). Pass `false` to turn the interval off.
320
-
321
- Pass an array of bands, outermost first, to draw nested bands around each line (a fan): each band is a `[lower, upper]` pair or `[lower, upper, label]`, or a `{lower, upper, label}` object, and `confidenceConfig.bandOpacity` shades them from the widest (lightest) to the narrowest (darkest). Tooltips list each band's range under its label ("Band 1", "Band 2", … when unlabeled), and bars draw the first band's error bar.
315
+ The confidence interval as `[lower, upper]` bounds (keys or accessors): lines draw a shaded band, bars an error bar. Either bound may be `false` for a one-sided interval, and the value axis widens to fit. Pass an array of bands, outermost first (`[lower, upper, label]` or `{lower, upper, label}`), to draw nested bands (a fan). `false` turns it off.
322
316
 
323
317
  @example <caption>Can be called with accessor functions or static keys:</caption>
324
318
  var data = {id: "alpha", value: 10, lci: 9, hci: 11};
@@ -341,7 +335,7 @@ Three more kinds draw chart notes: `"Callout"` anchors wrapped text in a box at
341
335
  return this;
342
336
  }
343
337
  /**
344
- Configuration object for shapes rendered as confidence intervals. A line's band is an Area, filled with the line's color at half opacity. A bar's error bar is a Path styled by `stroke` (default a shade darker than the bar), `strokeWidth` (default `2`), `strokeDasharray`, `strokeOpacity`, and `capWidth`: the length of each end cap, in pixels or as a percentage string of the bar's thickness (default `"50%"`). Keys nested under `Area` or `Bar` apply only to that shape's interval. With several bands, `bandOpacity` sets how each band looks where it is the innermost band drawn: an array ramps from the outermost band to the innermost (default `[0.15, 0.6]`), a number gives every band that opacity, and either replaces `fillOpacity`. `tooltip` (default `true`) lists the bounds in tooltips: a "Lower Bound" and "Upper Bound" row for a single mark, and a range after each series' value in a shared tooltip; set it to `false` to leave them out. Accepted keys: any key the Area or Path shape takes at the top level, plus `bandOpacity`, `capWidth`, `tooltip`, `Area` (Area keys), and `Bar` (Path keys and `capWidth`); any other key logs a warning.
338
+ Styles the confidence intervals: a line's band takes Area keys (filled with the line's color), and a bar's error bar takes Path keys (`stroke`, `strokeWidth`, …) plus `capWidth`, in pixels or a percentage of the bar (default `"50%"`). Keys under `Area` or `Bar` apply to that shape only. `bandOpacity` ramps nested bands' opacity (default `[0.15, 0.6]`), and `tooltip: false` leaves the bounds out of tooltips.
345
339
 
346
340
  @example
347
341
  .confidenceConfig({Bar: {stroke: "#333", capWidth: 8}, tooltip: false})
@@ -0,0 +1,19 @@
1
+ /**
2
+ A unique scene key for each line marker. A marker is its series and its
3
+ discrete value, or its x/y position when the chart has no discrete axis;
4
+ a series that repeats one of those numbers its repeats, so no two markers
5
+ share a key (the renderer keeps one node per key, which would give every
6
+ marker that shares one the last one's datum).
7
+ @param values The markers' points.
8
+ @param discrete The chart's discrete axis, if any.
9
+ */ export function lineMarkerKeys(values, discrete) {
10
+ const seen = new Map();
11
+ const keys = new Map();
12
+ for (const d of values){
13
+ const base = discrete ? `${d.id}_${d.discrete}` : `${d.id}_${d.x}_${d.y}`;
14
+ const n = seen.get(base) ?? 0;
15
+ seen.set(base, n + 1);
16
+ keys.set(d, n ? `${base}_${n}` : base);
17
+ }
18
+ return keys;
19
+ }
@@ -13,6 +13,7 @@ import { fillBetweenDefaults } from "./fillBetween.js";
13
13
  import { forecastDefaults } from "./forecast.js";
14
14
  import { plotDef } from "./pipeline.js";
15
15
  import { plotShapeDefaults } from "./shapeDefaults.js";
16
+ import { shapeLabelsPossible } from "./shapeLabelLegend.js";
16
17
  import { axisValue } from "./sharedTooltip.js";
17
18
  import { stackOffsetDiverging, stackOrderTotalDescending } from "./stackHelpers.js";
18
19
  import { stackLegendSort } from "./stackLegendOrder.js";
@@ -222,6 +223,9 @@ import { themed } from "../../utils/theme.js";
222
223
  front: []
223
224
  };
224
225
  viz._previousShapes = [];
226
+ // Shapes that each show their legend entry's name stand in for the
227
+ // legend, as along-line labels do (see `shapeLabelLegend.ts`).
228
+ viz._alongLabelsPossible = shapeLabelsPossible;
225
229
  viz.schema.shape = defaults.shape;
226
230
  viz.schema.shapeConfig = assign(viz.schema.shapeConfig, plotShapeDefaults.call(viz));
227
231
  viz._shapeOrder = [
@@ -276,6 +280,7 @@ import { themed } from "../../utils/theme.js";
276
280
  viz._y = accessor("y");
277
281
  viz._yKey = "y";
278
282
  viz._yAxis = new AxisLeft().align("start");
283
+ viz._yAxis._domainEndFirst = true;
279
284
  viz._yKey = "y";
280
285
  viz._yConfig = {
281
286
  gridConfig: {
@@ -292,5 +297,6 @@ import { themed } from "../../utils/theme.js";
292
297
  viz._y2 = accessor("y2");
293
298
  viz._y2Key = "y2";
294
299
  viz._y2Axis = new AxisRight().align("end");
300
+ viz._y2Axis._domainEndFirst = true;
295
301
  viz._y2Config = {};
296
302
  }
@@ -0,0 +1,67 @@
1
+ /**
2
+ Shape labels that stand in for the legend: when every Circle, Rect, or
3
+ Bar in a Plot draws its whole label, and that label reads exactly as its
4
+ legend entry would, the color legend repeats what the labels already
5
+ say, so the default legend hides (see `alongLegend.ts`, which runs the
6
+ draw and counts these alongside the along labels).
7
+ */ /** The shapes whose own labels can name their legend entries. */ export const LEGEND_LABEL_SHAPES = [
8
+ "Bar",
9
+ "Circle",
10
+ "Rect"
11
+ ];
12
+ /**
13
+ Whether a Plot's shape labels could name every legend entry: it draws
14
+ only Circles, Rects, and Bars, none of them with `label: false`.
15
+ @param viz The chart.
16
+ */ export function shapeLabelsPossible(viz) {
17
+ const rows = viz._filteredData ?? [];
18
+ if (!rows.length) return false;
19
+ const shape = viz.schema.shape;
20
+ const config = viz.schema.shapeConfig ?? {};
21
+ if (config.label === false) return false;
22
+ const drawn = new Set(rows.map((d, i)=>typeof shape === "function" ? shape(d, i) : shape));
23
+ return [
24
+ ...drawn
25
+ ].every((s)=>LEGEND_LABEL_SHAPES.includes(s) && config[s]?.label !== false);
26
+ }
27
+ /** A label's text, its lines joined and its whitespace collapsed. */ const textOf = (lines)=>lines.map((l)=>l.text).join(" ").replace(/\s+/g, " ").trim();
28
+ /**
29
+ Counts a Plot's labelable shapes and the ones whose drawn label matches
30
+ their legend entry's into `viz._alongStats`, when every shape could be
31
+ named that way (see `shapeLabelsPossible`). A label cut short, or a
32
+ legend entry named by its color category, doesn't match.
33
+ @param viz The chart.
34
+ @param nodes The plot's shapes and their labels.
35
+ */ export function countShapeLabels(viz, nodes) {
36
+ const stats = viz._alongStats;
37
+ if (!stats || !shapeLabelsPossible(viz)) return;
38
+ const shapes = [];
39
+ // A shape's label carries the shape's datum as its own datum's `data`.
40
+ const labels = new Map();
41
+ const walk = (list)=>{
42
+ for (const n of list){
43
+ if (n.type === "text") {
44
+ const owner = n.datum?.data;
45
+ if (owner) labels.set(owner, [
46
+ ...labels.get(owner) ?? [],
47
+ textOf(n.lines)
48
+ ]);
49
+ } else if (n.datum && LEGEND_LABEL_SHAPES.includes(n.shapeType) && !`${n.key}`.endsWith("::hit")) shapes.push(n);
50
+ if (n.type === "group") walk(n.children);
51
+ }
52
+ };
53
+ walk(nodes);
54
+ const named = shapes.filter((n)=>{
55
+ if (viz._legendCategories) return false;
56
+ const d = n.datum;
57
+ const want = textOf([
58
+ {
59
+ text: viz._drawLabel(d, Number(d.i) || 0, viz._legendDepth)
60
+ }
61
+ ]);
62
+ return !!want && (labels.get(d) ?? []).includes(want);
63
+ });
64
+ stats.series += shapes.length;
65
+ stats.requested += named.length;
66
+ stats.placed += named.length;
67
+ }
@@ -6,6 +6,7 @@
6
6
  */ import { nodeColor, ownerNode, visibleColor } from "../features/tooltipSwatch.js";
7
7
  import { facetPanelAt } from "../facet/facetPanel.js";
8
8
  import { linkAs } from "../viz/linkGroup.js";
9
+ import { tooltipEnabled } from "../viz/tooltipEnabled.js";
9
10
  import { renderSharedTooltip, renderSingleTooltip, restoreTooltip } from "./sharedTooltip.js";
10
11
  import { renderTrendTooltip } from "./trendTooltip.js";
11
12
  /**
@@ -170,7 +171,7 @@ const discreteKey = (v)=>v instanceof Date ? String(v.getTime()) : String(v);
170
171
  const datum = member.wrapped.data || member.wrapped;
171
172
  const index = typeof member.wrapped.i === "number" ? member.wrapped.i : 0;
172
173
  const value = valueOf ? Number(valueOf(datum, index)) : NaN;
173
- if (!Number.isFinite(value) || !viz.schema.tooltip(datum, index)) return null;
174
+ if (!Number.isFinite(value) || !tooltipEnabled(viz, datum, index)) return null;
174
175
  const name = String(viz._drawLabel(datum, index));
175
176
  return {
176
177
  id,
@@ -7,7 +7,9 @@ import { axisDateLabel, isValidDate, parseTime } from "../../components/Axis/tim
7
7
  import { axisIsYearLike, formatYear } from "../../components/Axis/yearValues.js";
8
8
  import { configPrep } from "../../utils/index.js";
9
9
  import { leadTitleWithSwatch, tooltipSwatch, withSwatch } from "../features/tooltipSwatch.js";
10
+ import { colorScaleTooltipRows } from "../features/colorScaleTooltip.js";
10
11
  import { thresholdMemberRows } from "../features/thresholdMembers.js";
12
+ import { hasOwnClick } from "../viz/userClick.js";
11
13
  import { confidenceRows, confidenceSuffix, rangeSuffix } from "./confidenceTooltip.js";
12
14
  const other = (k)=>k === "x" ? "y" : "x";
13
15
  /** An axis's display name: its configured title, else its data key. */ export function axisName(viz, k) {
@@ -160,18 +162,25 @@ const other = (k)=>k === "x" ? "y" : "x";
160
162
  ...thresholdMemberRows(viz, r.datum, SHARED_MEMBER_LIMIT)
161
163
  ])).footer(false).arrow(false).position(snappedPosition(viz, hover, event)).render();
162
164
  }
165
+ /**
166
+ The single-mark tooltip's click hint: "Click to Expand" while the chart's
167
+ own `click.shape` handler is installed and a deeper `groupBy` level
168
+ exists for a click to drill into, else none.
169
+ */ export function singleTooltipFooter(viz) {
170
+ const deeper = viz._drawDepth < viz.schema.groupBy.length - 1;
171
+ return deeper && hasOwnClick(viz, "click.shape") ? viz.schema.translate("Click to Expand") : false;
172
+ }
163
173
  /**
164
174
  The single-mark tooltip (one series, `tooltipShared(false)`, or a
165
175
  side-by-side bar): the default title (the mark's label, unless
166
176
  `tooltipConfig` sets one), its x and y values, its `confidence` bounds,
167
- then any rows the chart's `tooltipConfig` adds, and a threshold bucket's
177
+ its colorScale value, then any rows the chart's `tooltipConfig` adds, and a threshold bucket's
168
178
  series.
169
179
  */ export function renderSingleTooltip(viz, hover, event) {
170
180
  const row = hover.rows[0];
171
- const deeper = viz._drawDepth < viz.schema.groupBy.length - 1;
172
181
  const tip = prepareTooltip(viz).data([
173
182
  row.datum
174
- ]).title(()=>viz._drawLabel(row.datum, row.index)).footer(deeper && viz.schema.on["click.shape"] ? viz.schema.translate("Click to Expand") : false).config(configPrep.bind(viz)(viz.schema.tooltipConfig));
183
+ ]).title(()=>viz._drawLabel(row.datum, row.index)).footer(singleTooltipFooter(viz)).config(configPrep.bind(viz)(viz.schema.tooltipConfig));
175
184
  // A `tbody` accessor resolves against the hovered datum, like any other cell.
176
185
  const tbody = tip.tbody();
177
186
  const extra = typeof tbody === "function" ? tbody(row.datum, row.index) : tbody;
@@ -181,6 +190,7 @@ const other = (k)=>k === "x" ? "y" : "x";
181
190
  axisRow(viz, "y", hover)
182
191
  ],
183
192
  ...row.projected ? [] : confidenceRows(viz, row.datum, row.index, (v)=>axisValue(viz, other(hover.axis), v)),
193
+ ...colorScaleTooltipRows(viz, row.datum, row.index),
184
194
  ...Array.isArray(extra) ? extra : [],
185
195
  ...thresholdMemberRows(viz, row.datum)
186
196
  ]).arrow(false).position(snappedPosition(viz, hover, event)).render();
@@ -91,7 +91,8 @@ export const polarAreaDef = {
91
91
  },
92
92
  /**
93
93
  Room (px) reserved around the circle for the category labels, or
94
- `"auto"` to size the circle to the measured labels.
94
+ `"auto"` to curve them just outside the circle when they all fit
95
+ (see `labelPosition`), else size the circle to the measured labels.
95
96
  */ {
96
97
  key: "outerPadding",
97
98
  default: "auto"
@@ -9,6 +9,7 @@
9
9
  import * as scales from "d3-scale";
10
10
  import { date } from "@d3plus/dom";
11
11
  import { nestGroups } from "@d3plus/data";
12
+ import { chartBounds } from "../features/chartGeometry.js";
12
13
  import { measureTimeAxis, renderTimeAxis } from "./timeAxis.js";
13
14
  /** Greedy first-fit lane packer; mutates `d.lane` and returns total lane count. */ const packLanes = (nested)=>{
14
15
  let maxLane = 0;
@@ -29,27 +30,30 @@ import { measureTimeAxis, renderTimeAxis } from "./timeAxis.js";
29
30
  });
30
31
  return maxLane;
31
32
  };
32
- /** Runs both axes, pushes the axis scene, and stashes scales/bandWidth on `viz.ctx`. */ const runAxesAndScales = (viz, data, maxLane)=>{
33
+ /**
34
+ Runs both axes, pushes the axis scene, and stashes scales/bandWidth on
35
+ `viz.ctx`. Everything is placed in the chart area's own coordinates: the
36
+ default `_chartTransform` moves the area to the margin origin.
37
+ */ const runAxesAndScales = (viz, data, maxLane)=>{
33
38
  const frame = {
34
39
  domain: [
35
40
  min(data, (d)=>Number(d.start)) ?? 0,
36
41
  max(data, (d)=>Number(d.end)) ?? 0
37
42
  ],
38
- height: viz.schema.height - viz._margin.top - viz._margin.bottom,
39
- width: viz.schema.width - viz._margin.left - viz._margin.right
43
+ ...chartBounds(viz)
40
44
  };
41
45
  const axis = measureTimeAxis(viz, frame);
42
46
  const xScale = renderTimeAxis(viz, {
43
47
  ...frame,
44
48
  transform: {
45
- x: viz._margin.left,
46
- y: viz._margin.top
49
+ x: 0,
50
+ y: 0
47
51
  },
48
52
  key: "priestley-axis"
49
53
  });
50
54
  const yScale = scales.scaleBand().domain(range(0, maxLane, 1).map(String)).paddingInner(viz.schema.paddingInner).paddingOuter(viz.schema.paddingOuter).rangeRound([
51
- viz.schema.height - viz._margin.bottom - axis.height - axis.padding,
52
- viz._margin.top + axis.padding
55
+ frame.height - axis.height - axis.padding,
56
+ axis.padding
53
57
  ]);
54
58
  viz.ctx.xScale = xScale;
55
59
  viz.ctx.yScale = yScale;
@@ -13,8 +13,6 @@ export const priestleyDef = {
13
13
  name: "Priestley",
14
14
  layoutStage: applyPriestleyLayout,
15
15
  emit: priestleyEmit,
16
- // Priestley positions in absolute scale coordinates — no chart transform.
17
- chartTransform: ()=>undefined,
18
16
  // The default start/end accessors are functions, so the fields' `onSet`
19
17
  // can't infer a data key to register. Seed the band-edge reducers here so
20
18
  // the time domain spans min(start)…max(end) instead of summing them.
@@ -5,6 +5,8 @@
5
5
  returns its scale.
6
6
  */ import { min, max } from "d3-array";
7
7
  import { date } from "@d3plus/dom";
8
+ import { pinMaxSize } from "../../components/Axis/axisMaxSize.js";
9
+ import { inertAxis } from "../../components/Axis/axisTooltipTargets.js";
8
10
  import accessor from "../../utils/accessor.js";
9
11
  import { fieldAccessor } from "../../utils/fieldAccessor.js";
10
12
  /** Stores a function as given and wraps a data key in an accessor. */ const timeAccessor = (v)=>typeof v === "function" ? v : fieldAccessor(v);
@@ -78,20 +80,21 @@ import { fieldAccessor } from "../../utils/fieldAccessor.js";
78
80
  }
79
81
  /**
80
82
  Renders the chart's time axis (`viz.ctx.axis`) over `frame`, pushes its
81
- scene onto `viz._chartScene` (with any extra `group` fields), and returns
82
- its scale.
83
- */ export function renderTimeAxis(viz, frame, group = {}) {
83
+ scene onto `viz._chartScene` as chrome (see `inertAxis`), and returns its
84
+ scale.
85
+ */ export function renderTimeAxis(viz, frame) {
84
86
  const axis = viz.ctx.axis;
85
- configure(viz, axis, frame).renderMode("compute").select(undefined).render();
87
+ // A `maxSize` function reads the height the test axis measured with.
88
+ const measured = viz.ctx.axisTest.schema.height;
89
+ pinMaxSize(configure(viz, axis, frame), measured).renderMode("compute").select(undefined).render();
86
90
  const axisScene = axis.toScene();
87
91
  if (axisScene) {
88
- (viz._chartScene ||= []).push({
92
+ (viz._chartScene ||= []).push(inertAxis({
89
93
  type: "group",
90
94
  key: frame.key,
91
95
  transform: frame.transform,
92
- children: axisScene.children ?? [],
93
- ...group
94
- });
96
+ children: axisScene.children ?? []
97
+ }));
95
98
  }
96
99
  return axis._d3Scale;
97
100
  }