basalt-ui 2.21.0 → 2.23.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 (254) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/MIGRATING.md +452 -12
  3. package/agent/agents/basalt-design-reviewer.md +1 -1
  4. package/agent/rules/basalt-tokens.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +1 -1
  6. package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
  7. package/agent/skills/basalt-design/references/catalogue.md +1 -0
  8. package/dist/charts/BandStrip.d.ts.map +1 -1
  9. package/dist/charts/BandStrip.js +73 -3
  10. package/dist/charts/Bars.d.ts.map +1 -1
  11. package/dist/charts/Bars.js +6 -0
  12. package/dist/charts/CartesianChart.d.ts +10 -0
  13. package/dist/charts/CartesianChart.d.ts.map +1 -1
  14. package/dist/charts/CartesianChart.js +8 -5
  15. package/dist/charts/ChartCard.d.ts +12 -3
  16. package/dist/charts/ChartCard.d.ts.map +1 -1
  17. package/dist/charts/ChartCard.js +39 -8
  18. package/dist/charts/DualPanel.d.ts.map +1 -1
  19. package/dist/charts/DualPanel.js +5 -8
  20. package/dist/charts/Heatmap.d.ts +12 -1
  21. package/dist/charts/Heatmap.d.ts.map +1 -1
  22. package/dist/charts/Heatmap.js +34 -5
  23. package/dist/charts/Lines.d.ts +3 -0
  24. package/dist/charts/Lines.d.ts.map +1 -1
  25. package/dist/charts/Lines.js +29 -6
  26. package/dist/charts/MirroredBars.d.ts.map +1 -1
  27. package/dist/charts/MirroredBars.js +4 -6
  28. package/dist/charts/Sparkline.d.ts +14 -2
  29. package/dist/charts/Sparkline.d.ts.map +1 -1
  30. package/dist/charts/Sparkline.js +101 -22
  31. package/dist/charts/StackedArea.d.ts +4 -1
  32. package/dist/charts/StackedArea.d.ts.map +1 -1
  33. package/dist/charts/StackedArea.js +9 -3
  34. package/dist/charts/band-fold.d.ts +38 -1
  35. package/dist/charts/band-fold.d.ts.map +1 -1
  36. package/dist/charts/band-fold.js +18 -1
  37. package/dist/charts/chart-box.module.css +19 -0
  38. package/dist/charts/chart-card.module.css +25 -0
  39. package/dist/charts/chart-dates.d.ts +12 -0
  40. package/dist/charts/chart-dates.d.ts.map +1 -0
  41. package/dist/charts/chart-dates.js +16 -0
  42. package/dist/charts/chart-legend.module.css +7 -0
  43. package/dist/charts/compile.d.ts +25 -6
  44. package/dist/charts/compile.d.ts.map +1 -1
  45. package/dist/charts/compile.js +152 -72
  46. package/dist/charts/date-tick-format.d.ts +5 -5
  47. package/dist/charts/date-tick-format.d.ts.map +1 -1
  48. package/dist/charts/date-tick-format.js +3 -7
  49. package/dist/charts/labels.d.ts +21 -6
  50. package/dist/charts/labels.d.ts.map +1 -1
  51. package/dist/charts/labels.js +52 -17
  52. package/dist/charts/legend.d.ts +2 -0
  53. package/dist/charts/legend.d.ts.map +1 -1
  54. package/dist/charts/legend.js +7 -21
  55. package/dist/charts/marks.js +1 -1
  56. package/dist/charts/panel.d.ts +0 -6
  57. package/dist/charts/panel.d.ts.map +1 -1
  58. package/dist/charts/panel.js +1 -10
  59. package/dist/charts/ref-label.d.ts +43 -0
  60. package/dist/charts/ref-label.d.ts.map +1 -0
  61. package/dist/charts/ref-label.js +75 -0
  62. package/dist/charts/scales.d.ts +4 -1
  63. package/dist/charts/scales.d.ts.map +1 -1
  64. package/dist/charts/scales.js +14 -3
  65. package/dist/charts/sparkline.module.css +13 -17
  66. package/dist/charts/sparkline.module.css.d.ts +1 -2
  67. package/dist/charts/state.d.ts +2 -0
  68. package/dist/charts/state.d.ts.map +1 -1
  69. package/dist/charts/state.js +5 -2
  70. package/dist/charts/types.d.ts +18 -8
  71. package/dist/charts/types.d.ts.map +1 -1
  72. package/dist/cli/doctor-upgrade.d.ts +1 -0
  73. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  74. package/dist/cli/doctor-upgrade.js +1 -0
  75. package/dist/cli/init.d.ts +2 -0
  76. package/dist/cli/init.d.ts.map +1 -1
  77. package/dist/cli/init.js +68 -4
  78. package/dist/cli/shot/capture.d.ts +21 -2
  79. package/dist/cli/shot/capture.d.ts.map +1 -1
  80. package/dist/cli/shot/capture.js +202 -36
  81. package/dist/cli/shot/detect.d.ts.map +1 -1
  82. package/dist/cli/shot/detect.js +17 -1
  83. package/dist/cli/shot/playwright.d.ts +13 -2
  84. package/dist/cli/shot/playwright.d.ts.map +1 -1
  85. package/dist/cli/shot/playwright.js +5 -1
  86. package/dist/cli/shot/types.d.ts +4 -0
  87. package/dist/cli/shot/types.d.ts.map +1 -1
  88. package/dist/cli/shot/types.js +2 -0
  89. package/dist/cli/tokens-css.d.ts +5 -7
  90. package/dist/cli/tokens-css.d.ts.map +1 -1
  91. package/dist/cli/tokens-css.js +11 -12
  92. package/dist/controls/controls.module.css +11 -1
  93. package/dist/controls/filter-pill.d.ts.map +1 -1
  94. package/dist/controls/filter-pill.js +1 -0
  95. package/dist/controls/sync-button.d.ts.map +1 -1
  96. package/dist/controls/sync-button.js +22 -3
  97. package/dist/controls/sync-button.module.css +34 -2
  98. package/dist/controls/sync-button.module.css.d.ts +1 -0
  99. package/dist/dashboard/bar-list.d.ts +6 -1
  100. package/dist/dashboard/bar-list.d.ts.map +1 -1
  101. package/dist/dashboard/bar-list.js +15 -8
  102. package/dist/dashboard/bar-list.module.css +83 -0
  103. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  104. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  105. package/dist/dashboard/delta-badge.js +2 -2
  106. package/dist/dashboard/index.d.ts +1 -0
  107. package/dist/dashboard/index.d.ts.map +1 -1
  108. package/dist/dashboard/index.js +2 -0
  109. package/dist/dashboard/meter-model.d.ts +84 -5
  110. package/dist/dashboard/meter-model.d.ts.map +1 -1
  111. package/dist/dashboard/meter-model.js +100 -15
  112. package/dist/dashboard/meter-parts.d.ts +9 -1
  113. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  114. package/dist/dashboard/meter-parts.js +276 -74
  115. package/dist/dashboard/meter.d.ts +54 -65
  116. package/dist/dashboard/meter.d.ts.map +1 -1
  117. package/dist/dashboard/meter.js +21 -4
  118. package/dist/dashboard/meter.module.css +76 -0
  119. package/dist/dashboard/meter.module.css.d.ts +6 -0
  120. package/dist/dashboard/page-summary.d.ts +20 -0
  121. package/dist/dashboard/page-summary.d.ts.map +1 -0
  122. package/dist/dashboard/page-summary.js +28 -0
  123. package/dist/dashboard/page-summary.module.css +89 -0
  124. package/dist/dashboard/page-summary.module.css.d.ts +15 -0
  125. package/dist/dashboard/query-state.d.ts.map +1 -1
  126. package/dist/dashboard/query-state.js +1 -1
  127. package/dist/dashboard/section.d.ts +25 -2
  128. package/dist/dashboard/section.d.ts.map +1 -1
  129. package/dist/dashboard/section.js +10 -5
  130. package/dist/dashboard/section.module.css +23 -0
  131. package/dist/dashboard/section.module.css.d.ts +1 -0
  132. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  133. package/dist/dashboard/stat-card-parts.js +1 -1
  134. package/dist/dashboard/stat-card.d.ts +4 -2
  135. package/dist/dashboard/stat-card.d.ts.map +1 -1
  136. package/dist/dashboard/stat-card.js +7 -5
  137. package/dist/dashboard/stat-card.module.css +36 -0
  138. package/dist/dashboard/stat-group.module.css +7 -0
  139. package/dist/dashboard/stat-strip.d.ts +22 -6
  140. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  141. package/dist/dashboard/stat-strip.js +104 -60
  142. package/dist/dashboard/stat-strip.module.css +122 -53
  143. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  144. package/dist/dashboard/visual-slot.d.ts +7 -1
  145. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  146. package/dist/dashboard/visual-slot.js +3 -1
  147. package/dist/guard/index.d.ts.map +1 -1
  148. package/dist/guard/index.js +0 -5
  149. package/dist/guard/vx-names.d.ts.map +1 -1
  150. package/dist/guard/vx-names.js +2 -0
  151. package/dist/index.d.ts +1 -1
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +3 -1
  154. package/dist/styles.css +43 -4
  155. package/dist/theme/chrome-vars.d.ts +20 -5
  156. package/dist/theme/chrome-vars.d.ts.map +1 -1
  157. package/dist/theme/chrome-vars.js +46 -3
  158. package/dist/theme/controls.module.css +37 -0
  159. package/dist/theme/controls.module.css.d.ts +2 -0
  160. package/dist/theme/index.d.ts.map +1 -1
  161. package/dist/theme/index.js +18 -27
  162. package/dist/theme/status-verdict.d.ts.map +1 -1
  163. package/dist/theme/status-verdict.js +9 -1
  164. package/dist/tokens/core.d.ts +2 -1
  165. package/dist/tokens/core.d.ts.map +1 -1
  166. package/dist/tokens/core.js +6 -1
  167. package/dist/tokens/derive.d.ts +3 -1
  168. package/dist/tokens/derive.d.ts.map +1 -1
  169. package/dist/tokens/derive.js +16 -1
  170. package/dist/tokens/palette.d.ts +11 -10
  171. package/dist/tokens/palette.d.ts.map +1 -1
  172. package/dist/tokens/palette.js +11 -10
  173. package/dist/tokens/status-text.d.ts.map +1 -1
  174. package/dist/tokens/status-text.js +3 -1
  175. package/llms.txt +42 -22
  176. package/package.json +1 -1
  177. package/src/charts/BandStrip.tsx +83 -3
  178. package/src/charts/Bars.tsx +7 -0
  179. package/src/charts/CartesianChart.tsx +18 -3
  180. package/src/charts/ChartCard.tsx +54 -13
  181. package/src/charts/DualPanel.tsx +3 -6
  182. package/src/charts/Heatmap.tsx +54 -5
  183. package/src/charts/Lines.tsx +56 -10
  184. package/src/charts/MirroredBars.tsx +3 -5
  185. package/src/charts/Sparkline.tsx +135 -25
  186. package/src/charts/StackedArea.tsx +14 -4
  187. package/src/charts/band-fold.ts +50 -1
  188. package/src/charts/chart-box.module.css +19 -0
  189. package/src/charts/chart-card.module.css +25 -0
  190. package/src/charts/chart-dates.ts +30 -0
  191. package/src/charts/chart-legend.module.css +7 -0
  192. package/src/charts/compile.ts +253 -87
  193. package/src/charts/date-tick-format.ts +10 -13
  194. package/src/charts/labels.ts +81 -26
  195. package/src/charts/legend.tsx +10 -20
  196. package/src/charts/marks.ts +1 -1
  197. package/src/charts/panel.tsx +1 -16
  198. package/src/charts/ref-label.ts +131 -0
  199. package/src/charts/scales.ts +22 -2
  200. package/src/charts/sparkline.module.css +13 -17
  201. package/src/charts/sparkline.module.css.d.ts +1 -2
  202. package/src/charts/state.tsx +9 -4
  203. package/src/charts/types.ts +18 -8
  204. package/src/cli/doctor-upgrade.ts +1 -1
  205. package/src/cli/init.ts +100 -3
  206. package/src/cli/shot/capture.ts +266 -35
  207. package/src/cli/shot/detect.ts +18 -1
  208. package/src/cli/shot/playwright.ts +20 -4
  209. package/src/cli/shot/types.ts +5 -0
  210. package/src/cli/tokens-css.ts +18 -20
  211. package/src/controls/controls.module.css +11 -1
  212. package/src/controls/filter-pill.tsx +2 -0
  213. package/src/controls/sync-button.module.css +34 -2
  214. package/src/controls/sync-button.module.css.d.ts +1 -0
  215. package/src/controls/sync-button.tsx +40 -4
  216. package/src/dashboard/bar-list.module.css +83 -0
  217. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  218. package/src/dashboard/bar-list.tsx +107 -69
  219. package/src/dashboard/delta-badge.tsx +6 -2
  220. package/src/dashboard/index.ts +1 -0
  221. package/src/dashboard/meter-model.ts +207 -24
  222. package/src/dashboard/meter-parts.tsx +349 -67
  223. package/src/dashboard/meter.module.css +76 -0
  224. package/src/dashboard/meter.module.css.d.ts +6 -0
  225. package/src/dashboard/meter.tsx +72 -18
  226. package/src/dashboard/page-summary.module.css +89 -0
  227. package/src/dashboard/page-summary.module.css.d.ts +15 -0
  228. package/src/dashboard/page-summary.tsx +95 -0
  229. package/src/dashboard/query-state.tsx +1 -1
  230. package/src/dashboard/section.module.css +23 -0
  231. package/src/dashboard/section.module.css.d.ts +1 -0
  232. package/src/dashboard/section.tsx +59 -11
  233. package/src/dashboard/stat-card-parts.tsx +5 -1
  234. package/src/dashboard/stat-card.module.css +36 -0
  235. package/src/dashboard/stat-card.tsx +12 -6
  236. package/src/dashboard/stat-group.module.css +7 -0
  237. package/src/dashboard/stat-strip.module.css +122 -53
  238. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  239. package/src/dashboard/stat-strip.tsx +176 -91
  240. package/src/dashboard/visual-slot.ts +12 -3
  241. package/src/guard/index.ts +0 -5
  242. package/src/guard/vx-names.ts +2 -0
  243. package/src/index.ts +2 -0
  244. package/src/styles.css +43 -4
  245. package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
  246. package/src/theme/chrome-vars.ts +77 -8
  247. package/src/theme/controls.module.css +37 -0
  248. package/src/theme/controls.module.css.d.ts +2 -0
  249. package/src/theme/index.ts +22 -32
  250. package/src/theme/status-verdict.tsx +5 -1
  251. package/src/tokens/core.ts +4 -1
  252. package/src/tokens/derive.ts +32 -3
  253. package/src/tokens/palette.ts +11 -10
  254. package/src/tokens/status-text.ts +2 -0
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * The default Date x tick labels: chosen from the TICK step (not the data step), read in UTC like
3
3
  * the scale that placed them. A label may recur on one axis only behind a MARKER label (a day or a
4
- * year) — `12:00, 18:00, 18.10, 06:00, 12:00` is fine, `17.10, 17.10, 18.10` is not. Each span has
4
+ * year) — `12:00, 18:00, 18 Oct, 06:00, 12:00` is fine, `17 Oct, 17 Oct, 18 Oct` is not. Each span has
5
5
  * a ladder of levels, plainest first; the first level that holds the invariant wins. The last rung
6
6
  * of every ladder names the whole date (or instant) of its tick, so the invariant always holds.
7
7
  */
8
8
 
9
- const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
10
- export const pad2 = (n: number): string => String(n).padStart(2, '0')
9
+ import { axisDay, axisDayYear, monthName } from './chart-dates'
11
10
 
12
- export const monthName = (d: Date): string => MONTHS[d.getUTCMonth()]!
11
+ export const pad2 = (n: number): string => String(n).padStart(2, '0')
13
12
 
14
13
  const DAY_MS = 86_400_000
15
14
  const HOUR_MS = 3_600_000
@@ -19,18 +18,16 @@ const HOUR_MS = 3_600_000
19
18
  */
20
19
  const MONTH_STEP_MS = 27 * DAY_MS
21
20
 
22
- /** `DD.MM`, read in UTC like the time scale (a local read shifts a day west of UTC). */
23
- export function utcAxisDate(d: Date): string {
24
- return `${pad2(d.getUTCDate())}.${pad2(d.getUTCMonth() + 1)}`
25
- }
21
+ /** The day (`4 Oct`, in the page locale), read in UTC like the time scale (a local read shifts a
22
+ * day west of UTC). */
23
+ export const utcAxisDate = axisDay
26
24
 
27
25
  const utcClock = (d: Date): string => `${pad2(d.getUTCHours())}:${pad2(d.getUTCMinutes())}`
28
26
  const utcClockSeconds = (d: Date): string => `${utcClock(d)}:${pad2(d.getUTCSeconds())}`
29
27
  const utcClockMillis = (d: Date): string =>
30
28
  `${utcClockSeconds(d)}.${String(d.getUTCMilliseconds()).padStart(3, '0')}`
31
- /** Two digits: a widened day label stays 8 characters and still reads as the `DD.MM` family. */
32
- const utcAxisDateYear = (d: Date): string =>
33
- `${utcAxisDate(d)}.${String(d.getUTCFullYear()).slice(2)}`
29
+ /** Two digits: a widened day label stays the same family (`4 Oct 26`). */
30
+ const utcAxisDateYear = axisDayYear
34
31
 
35
32
  const isMidnight = (t: number): boolean => t % DAY_MS === 0
36
33
  const isJanuary = (d: Date): boolean => d.getUTCMonth() === 0
@@ -69,7 +66,7 @@ const subDayLevels: Level[] = [
69
66
  ]
70
67
 
71
68
  /**
72
- * A day or more: `DD.MM`. Ticks are at least a day apart here, so they fall on different UTC days
69
+ * A day or more: the day (`18 Oct`). Ticks are at least a day apart here, so they fall on different UTC days
73
70
  * and the last rung, which names the full date, cannot repeat.
74
71
  */
75
72
  const dayLevels: Level[] = [
@@ -121,7 +118,7 @@ function stepOf(times: readonly number[]): number {
121
118
 
122
119
  /**
123
120
  * A formatter for one tick set. A Date that is not among the ticks (a hover, a consumer reading
124
- * the axis format) reads as plain `DD.MM`: its position in the set is undefined.
121
+ * the axis format) reads as the plain day: its position in the set is undefined.
125
122
  */
126
123
  export function dateTickFormat(ticks: readonly Date[]): (d: Date) => string {
127
124
  const times = [...new Set(ticks.map((t) => t.getTime()))].toSorted((a, b) => a - b)
@@ -9,7 +9,7 @@ import { rowX } from './types'
9
9
  import type { ChartMarks, ChartSeries, ChartX, PlotContext, PlotRow } from './types'
10
10
 
11
11
  const MAX_END_LABELS = 3
12
- /** Below this vertical gap two end labels would collide; then none is drawn. */
12
+ /** Two end labels closer than this (px, vertically) are pushed apart to it. */
13
13
  const END_LABEL_MIN_GAP = 13
14
14
  const END_LABEL_DX = 6
15
15
  /**
@@ -19,10 +19,15 @@ const END_LABEL_DX = 6
19
19
  * that did not need to flip sits above its point, one that needed to and did not is cut.
20
20
  */
21
21
  const END_LABEL_GLYPH_EM = 0.85
22
- /** A label flipped inside the plot sits this far above its point. */
22
+ /** A label flipped inside the plot sits this far above (or, below its point, `BELOW`) its point. */
23
23
  const END_LABEL_FLIP_DY = -9
24
+ const END_LABEL_FLIP_DY_BELOW = 13
25
+ /** The room a label's centre keeps from the plot's top and bottom edge, px: half its line. */
26
+ const END_LABEL_EDGE = 7
24
27
 
25
28
  export type EndLabelAnchor = 'start' | 'end'
29
+ /** Which side of its line a flipped label sits: away from the line's last segment. */
30
+ export type EndLabelSide = 'above' | 'below'
26
31
 
27
32
  /**
28
33
  * The side of its point an end label takes: `start` (right of the point) unless the point leaves
@@ -42,10 +47,17 @@ export function endLabelAnchor(opts: {
42
47
  return room >= label.length * fontSize * END_LABEL_GLYPH_EM + END_LABEL_DX ? 'start' : 'end'
43
48
  }
44
49
 
50
+ /** `Lines`' one naming switch: who names the series. */
51
+ export type LinesNaming = 'auto' | 'legend' | 'endLabels'
52
+
45
53
  export type EndLabel<T, X extends ChartX> = {
46
54
  series: ChartSeries<T>
47
55
  row: PlotRow<T, X>
48
56
  anchor: EndLabelAnchor
57
+ /** Only a flipped label (left of its point) can meet its own line; it takes the clear side. */
58
+ side: EndLabelSide
59
+ /** A vertical shift in px (negative is up) that keeps this label clear of its neighbours. */
60
+ nudge: number
49
61
  }
50
62
 
51
63
  type LastPoint<T, X extends ChartX> = {
@@ -53,55 +65,97 @@ type LastPoint<T, X extends ChartX> = {
53
65
  row: PlotRow<T, X>
54
66
  y: number
55
67
  fraction: number
68
+ /** The value one finite point earlier: where the line's last segment comes from. */
69
+ prev: number | null
70
+ }
71
+
72
+ /**
73
+ * Pushes labels apart: `ys` are the labels' heights in px from the plot's bottom, returned as the
74
+ * shift each needs (positive is up) so no two sit closer than {@link END_LABEL_MIN_GAP} and the
75
+ * lowest and the topmost stay {@link END_LABEL_EDGE} inside the plot. Order is kept.
76
+ */
77
+ export function spreadLabels(ys: readonly number[], plotHeight: number): number[] {
78
+ const order = ys.map((y, i) => i).toSorted((a, b) => (ys[a] as number) - (ys[b] as number))
79
+ const placed = new Map<number, number>()
80
+ let floor = END_LABEL_EDGE
81
+ for (const i of order) {
82
+ const at = Math.max(ys[i] as number, floor)
83
+ placed.set(i, at)
84
+ floor = at + END_LABEL_MIN_GAP
85
+ }
86
+ // Pushed past the top: slide the whole stack back down, then re-sweep from the top.
87
+ const top = plotHeight - END_LABEL_EDGE
88
+ let ceiling = Infinity
89
+ for (const i of order.toReversed()) {
90
+ const at = Math.min(placed.get(i) as number, ceiling, top)
91
+ placed.set(i, at)
92
+ ceiling = at - END_LABEL_MIN_GAP
93
+ }
94
+ return ys.map((y, i) => (placed.get(i) as number) - y)
56
95
  }
57
96
 
58
97
  /**
59
- * The end labels to draw: none off the wide class, with a right axis, with more than
60
- * {@link MAX_END_LABELS} lines, or when two would collide in pixels (against the plot's height).
61
- * A series whose last point the plot's own x scale cannot place, or places outside the plot
98
+ * The end labels to draw. `auto`: on the wide class only, with ≤ {@link MAX_END_LABELS} lines and
99
+ * no right axis; `endLabels`: at every width and any line count (still no right axis, whose
100
+ * series read another scale); `legend`: none. Labels that would collide are spread apart, never
101
+ * dropped. A series whose last point the plot's own x scale cannot place, or places outside the plot
62
102
  * (`plot.xFraction` outside [0, 1]: clipped by a narrower `xDomain`), has no label.
63
103
  */
64
104
  export function endLabelPlan<T, X extends ChartX>(
65
105
  plot: PlotContext<T, X>,
66
106
  lines: readonly ChartSeries<T>[],
107
+ naming: LinesNaming = 'auto',
67
108
  ): EndLabel<T, X>[] {
68
- if (plot.containerClass !== 'wide' || plot.y2 !== undefined) return []
69
- if (lines.length === 0 || lines.length > MAX_END_LABELS) return []
109
+ if (naming === 'legend' || plot.y2 !== undefined || lines.length === 0) return []
110
+ if (naming === 'auto' && (plot.containerClass !== 'wide' || lines.length > MAX_END_LABELS))
111
+ return []
70
112
  const last = lines.flatMap((series): LastPoint<T, X>[] => {
71
- const row = plot.rows(series.key).findLast((r) => r.y !== null)
113
+ const finite = plot.rows(series.key).filter((r) => r.y !== null)
114
+ const row = finite.at(-1)
72
115
  if (row === undefined || row.y === null) return []
73
116
  const fraction = plot.xFraction(row.x)
74
117
  if (fraction === null || fraction < 0 || fraction > 1) return []
75
- return [{ series, row, y: row.y, fraction }]
118
+ return [{ series, row, y: row.y, fraction, prev: finite.at(-2)?.y ?? null }]
76
119
  })
77
- // Collision check in pixels from the plot height: labels that would overlap are not drawn at all.
78
120
  // No `y2` here (returned above), so every label reads the left domain.
79
121
  const [lo, hi] = plot.yDomain
80
- const ys = last
81
- .map(({ y }) => ((y - lo) / (hi - lo || 1)) * plot.plotHeight)
82
- .toSorted((a, b) => a - b)
83
- if (ys.some((y, i) => i > 0 && y - (ys[i - 1] as number) < END_LABEL_MIN_GAP)) return []
84
- return last.map(({ series, row, fraction }) => ({
85
- series,
86
- row,
87
- anchor: endLabelAnchor({
122
+ const placed = last.map(({ series, fraction, y, prev }) => {
123
+ const anchor = endLabelAnchor({
88
124
  fraction,
89
125
  plotWidth: plot.plotWidth,
90
126
  label: series.label,
91
127
  fontSize: VX.text.micro,
92
- }),
128
+ })
129
+ // A line falling into its end point comes from above: the label drops below it.
130
+ const side = prev !== null && prev > y ? ('below' as const) : ('above' as const)
131
+ // The label's centre, px from the plot's bottom, with its flip: what the spread keeps apart.
132
+ const centre = ((y - lo) / (hi - lo || 1)) * plot.plotHeight - endLabelOffset(anchor, side).dy
133
+ return { anchor, side, centre }
134
+ })
135
+ const shifts = spreadLabels(
136
+ placed.map((p) => p.centre),
137
+ plot.plotHeight,
138
+ )
139
+ return last.map(({ series, row }, i) => ({
140
+ series,
141
+ row,
142
+ anchor: (placed[i] as (typeof placed)[number]).anchor,
143
+ side: (placed[i] as (typeof placed)[number]).side,
144
+ nudge: 0 - (shifts[i] as number),
93
145
  }))
94
146
  }
95
147
 
96
- /** The offset of a label from its point: right of it, level; or left of it and above. */
97
- export function endLabelOffset(anchor: EndLabelAnchor): { dx: number; dy: number } {
98
- return anchor === 'end'
99
- ? { dx: -END_LABEL_DX, dy: END_LABEL_FLIP_DY }
100
- : { dx: END_LABEL_DX, dy: 0 }
148
+ /** The offset of a label from its point: right of it, level; or left of it, above or below. */
149
+ export function endLabelOffset(
150
+ anchor: EndLabelAnchor,
151
+ side: EndLabelSide = 'above',
152
+ ): { dx: number; dy: number } {
153
+ if (anchor === 'start') return { dx: END_LABEL_DX, dy: 0 }
154
+ return { dx: -END_LABEL_DX, dy: side === 'above' ? END_LABEL_FLIP_DY : END_LABEL_FLIP_DY_BELOW }
101
155
  }
102
156
 
103
157
  export function endLabelMarks<T, X extends ChartX>(plan: readonly EndLabel<T, X>[]): ChartMarks {
104
- return plan.map(({ series, row, anchor }) =>
158
+ return plan.map(({ series, row, anchor, side, nudge }) =>
105
159
  decorative(
106
160
  text([row], {
107
161
  id: `${series.key}-end-label`,
@@ -111,7 +165,8 @@ export function endLabelMarks<T, X extends ChartX>(plan: readonly EndLabel<T, X>
111
165
  fill: series.color,
112
166
  fontSize: VX.text.micro,
113
167
  anchor,
114
- ...endLabelOffset(anchor),
168
+ dx: endLabelOffset(anchor, side).dx,
169
+ dy: endLabelOffset(anchor, side).dy + nudge,
115
170
  }),
116
171
  ),
117
172
  )
@@ -49,7 +49,8 @@ const rowBaseStyle: CSSProperties = {
49
49
  flexWrap: 'wrap',
50
50
  alignItems: 'center',
51
51
  rowGap: 4,
52
- fontSize: VX.legendFontSize,
52
+ // The tick step: ticks, legend and tooltip are one size, so a chart card has at most three.
53
+ fontSize: VX.text.micro,
53
54
  color: VX.ink2,
54
55
  lineHeight: 1.35,
55
56
  }
@@ -153,29 +154,15 @@ function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement
153
154
  </>
154
155
  )
155
156
  if ((s.mark ?? 'line') === 'line') return <LineSwatch s={s} compact={mode === 'dots'} />
156
- if (mode === 'dots')
157
- return (
158
- <span
159
- aria-hidden
160
- className={classes.dot}
161
- style={{
162
- width: 8,
163
- height: 8,
164
- // theme-allow raw-surface — a legend dot is a circle, not a surface corner
165
- borderRadius: '50%',
166
- background: swatchFill(s),
167
- opacity: s.fillOpacity ?? 1,
168
- flex: 'none',
169
- }}
170
- />
171
- )
157
+ // One shape per mark kind at every width: a bar is a rounded square, compact (8) or wide (10).
158
+ const size = mode === 'dots' ? 8 : 10
172
159
  return (
173
160
  <span
174
161
  aria-hidden
175
- className={classes.chip}
162
+ className={mode === 'dots' ? classes.dot : classes.chip}
176
163
  style={{
177
- width: 10,
178
- height: 10,
164
+ width: size,
165
+ height: size,
179
166
  // theme-allow raw-surface — swatch geometry, not a surface corner
180
167
  borderRadius: 2,
181
168
  background: swatchFill(s),
@@ -196,6 +183,8 @@ export type ChartLegendProps<T> = {
196
183
  onHighlight: (key: string | null) => void
197
184
  /** Keeps the legend's box but shows and offers nothing: a chart with no marks names no series. */
198
185
  concealed?: boolean
186
+ /** `auto` mode only: gone from the wide class up, where end labels name the lines (CSS). */
187
+ hideAtWide?: boolean
199
188
  }
200
189
 
201
190
  export function ChartLegend<T>(props: ChartLegendProps<T>): ReactElement | null {
@@ -210,6 +199,7 @@ export function ChartLegend<T>(props: ChartLegendProps<T>): ReactElement | null
210
199
  // `aria-hidden` is belt-and-braces for a tree that ignores computed visibility.
211
200
  {...(props.concealed && { 'aria-hidden': true })}
212
201
  {...(auto && { className: classes.auto })}
202
+ {...(auto && props.hideAtWide && { 'data-hide-wide': '' })}
213
203
  style={rowLayout(props.mode, props.concealed === true)}
214
204
  >
215
205
  {groups.map((group, gi) => [
@@ -52,7 +52,7 @@ export function lineMark<T, X extends ChartX>(
52
52
  stroke: s.color,
53
53
  strokeWidth: s.strokeWidth ?? LINE_STROKE_WIDTH,
54
54
  strokeOpacity: (s.strokeOpacity ?? 1) * emphasis(plot.highlighted, s),
55
- curve: chartCurve(s.curve ?? 'monotone'),
55
+ curve: chartCurve(s.curve ?? 'linear'),
56
56
  ...(s.dash === 'dashed' && { strokeDasharray: DASH }),
57
57
  ...(yScale !== undefined && { yScale }),
58
58
  })
@@ -90,15 +90,12 @@ export const paneY = (opts: {
90
90
  format: (v: number) => string
91
91
  ticks: number
92
92
  cls: ContainerClass
93
- /** The whole chart's height ({@link chartHeightOf}). */
94
- height: number
95
93
  }): StoredChartSpec['scales'][string] => ({
96
94
  scale: opts.scale,
97
95
  ...yGuide({
98
96
  cfg: { ticks: opts.ticks },
99
97
  axis: { domain: opts.domain, format: opts.format },
100
98
  cls: opts.cls,
101
- height: opts.height,
102
99
  side: 'left',
103
100
  grid: true,
104
101
  }),
@@ -113,23 +110,11 @@ export const paneX = <X extends ChartX>(opts: {
113
110
  /** A consumer's x format; absent, the span-aware default ({@link xTickFormat}). */
114
111
  format?: ((v: ChartValue) => string) | undefined
115
112
  cls: ContainerClass
116
- /** The whole chart's height ({@link chartHeightOf}). */
117
- height: number
118
113
  }): StoredChartSpec['scales'][string] => ({
119
114
  scale: opts.scale,
120
- ...xGuide({
121
- model: opts.model,
122
- xTicks: undefined,
123
- format: opts.format,
124
- cls: opts.cls,
125
- height: opts.height,
126
- }),
115
+ ...xGuide({ model: opts.model, xTicks: undefined, format: opts.format, cls: opts.cls }),
127
116
  })
128
117
 
129
- /** The whole chart's height from one pane's: a pane gets `share` of the height less the gap. */
130
- export const chartHeightOf = (paneHeight: number, share: number, gap: number): number =>
131
- paneHeight > 0 && share > 0 ? paneHeight / share + gap : 0
132
-
133
118
  /** One row per datum for a series: a `null` or non-finite value is kept as a gap. */
134
119
  export function rowsOf<T, X extends ChartX>(
135
120
  data: readonly T[],
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Where a reference line's caption sits. Pure, so the rule is tested without an engine: a
3
+ * caption takes the first of four spots (end/start of the plot, above/below its line) that stays
4
+ * inside the plot and that no data line runs through; `RefLine.labelPosition` pins one.
5
+ */
6
+
7
+ export type RefLabelPosition = 'end-above' | 'end-below' | 'start-above' | 'start-below'
8
+
9
+ /** A data point as a share of the plot width and a y value on the line's own axis. */
10
+ export type RefLabelPoint = { fx: number; y: number }
11
+
12
+ /** A glyph's advance as a share of the font size (proportional Latin text, capitals included). */
13
+ const GLYPH_EM = 0.62
14
+ /** The inset from the plot edge (the text's `dx`) and the gap between caption and line, in px. */
15
+ const EDGE_INSET = 6
16
+ const LINE_GAP = 3
17
+
18
+ const ORDER_END: readonly RefLabelPosition[] = [
19
+ 'end-above',
20
+ 'end-below',
21
+ 'start-above',
22
+ 'start-below',
23
+ ]
24
+ const ORDER_START: readonly RefLabelPosition[] = [
25
+ 'start-above',
26
+ 'start-below',
27
+ 'end-above',
28
+ 'end-below',
29
+ ]
30
+
31
+ /** The y range of the polyline `points` (sorted by `fx`) between `fx0` and `fx1`, or `null`. */
32
+ function yRangeWithin(
33
+ points: readonly RefLabelPoint[],
34
+ fx0: number,
35
+ fx1: number,
36
+ ): [number, number] | null {
37
+ let lo = Infinity
38
+ let hi = -Infinity
39
+ const take = (y: number): void => {
40
+ if (y < lo) lo = y
41
+ if (y > hi) hi = y
42
+ }
43
+ const at = (a: RefLabelPoint, b: RefLabelPoint, fx: number): number =>
44
+ b.fx === a.fx ? a.y : a.y + ((b.y - a.y) * (fx - a.fx)) / (b.fx - a.fx)
45
+ for (let i = 0; i < points.length; i++) {
46
+ const p = points[i] as RefLabelPoint
47
+ if (p.fx >= fx0 && p.fx <= fx1) take(p.y)
48
+ const next = points[i + 1]
49
+ if (next === undefined || (p.fx < fx0 && next.fx < fx0) || (p.fx > fx1 && next.fx > fx1))
50
+ continue
51
+ // A segment entering or leaving the window contributes where it crosses its edge.
52
+ for (const edge of [fx0, fx1]) {
53
+ if ((p.fx < edge && next.fx > edge) || (p.fx > edge && next.fx < edge))
54
+ take(at(p.fx < next.fx ? p : next, p.fx < next.fx ? next : p, edge))
55
+ }
56
+ }
57
+ return lo <= hi ? [lo, hi] : null
58
+ }
59
+
60
+ export function refLabelPosition(opts: {
61
+ /** `RefLine.labelPosition`: wins over everything. */
62
+ pinned: RefLabelPosition | undefined
63
+ /** The default end when nothing constrains it: `true` for a right-axis line. */
64
+ startFirst: boolean
65
+ value: number
66
+ domain: readonly [number, number]
67
+ plotWidth: number
68
+ plotHeight: number
69
+ label: string
70
+ fontSize: number
71
+ /** One polyline per visible series on the line's axis. */
72
+ series: readonly (readonly RefLabelPoint[])[]
73
+ }): RefLabelPosition {
74
+ const { pinned, startFirst, value, plotWidth, plotHeight, label, fontSize, series } = opts
75
+ const order = startFirst ? ORDER_START : ORDER_END
76
+ if (pinned !== undefined) return pinned
77
+ const [lo, hi] = [Math.min(...opts.domain), Math.max(...opts.domain)]
78
+ if (hi === lo || plotWidth <= 0 || plotHeight <= 0) return order[0] as RefLabelPosition
79
+ const perPx = (hi - lo) / plotHeight
80
+ const widthFx = (label.length * fontSize * GLYPH_EM + EDGE_INSET) / plotWidth
81
+ const heightPx = fontSize + 2
82
+ const bandOf = (position: RefLabelPosition): [number, number] =>
83
+ position.endsWith('above')
84
+ ? [value + LINE_GAP * perPx, value + (LINE_GAP + heightPx) * perPx]
85
+ : [value - (LINE_GAP + heightPx) * perPx, value - LINE_GAP * perPx]
86
+ const inPlot = (position: RefLabelPosition): boolean => {
87
+ const [from, to] = bandOf(position)
88
+ return from >= lo && to <= hi
89
+ }
90
+ const clear = (position: RefLabelPosition): boolean => {
91
+ const [from, to] = bandOf(position)
92
+ const [fx0, fx1] = position.startsWith('end')
93
+ ? [1 - widthFx, 1 - EDGE_INSET / plotWidth]
94
+ : [EDGE_INSET / plotWidth, widthFx]
95
+ return series.every((points) => {
96
+ const range = yRangeWithin(points, fx0, fx1)
97
+ return range === null || range[1] < from || range[0] > to
98
+ })
99
+ }
100
+ // A caption that cannot avoid the data still stays inside the plot.
101
+ return (
102
+ order.find((p) => inPlot(p) && clear(p)) ?? order.find(inPlot) ?? (order[0] as RefLabelPosition)
103
+ )
104
+ }
105
+
106
+ /** The gap between a sparkline reference label's box and its line, px. */
107
+ const SPARK_LABEL_GAP = 2
108
+
109
+ /**
110
+ * Which side of its line a sparkline's reference label sits on, and its `dy` (the engine centres
111
+ * the text on its y): above by default, below when the line is too near the plot top for the label
112
+ * box to fit above it. The box clears the line by {@link SPARK_LABEL_GAP}, so the dashed rule never
113
+ * strikes the text, and stays inside the plot (`height` less the line inset each side).
114
+ */
115
+ export function referenceLabelPlacement(opts: {
116
+ value: number
117
+ domain: readonly [number, number]
118
+ height: number
119
+ /** The plot's margin inside the svg box, px. */
120
+ inset: number
121
+ fontSize: number
122
+ }): { side: 'above' | 'below'; dy: number } {
123
+ const { value, domain, height, inset, fontSize } = opts
124
+ const [lo, hi] = [Math.min(...domain), Math.max(...domain)]
125
+ const share = hi === lo ? 0 : (value - lo) / (hi - lo)
126
+ const line = inset + (height - 2 * inset) * (1 - share)
127
+ const reach = SPARK_LABEL_GAP + fontSize + 1
128
+ const side = line - reach >= 0 || line + reach > height ? 'above' : 'below'
129
+ const dy = (SPARK_LABEL_GAP + (fontSize + 1) / 2) * (side === 'above' ? -1 : 1)
130
+ return { side, dy }
131
+ }
@@ -7,7 +7,7 @@
7
7
  import { scaleBand } from '@tanstack/charts/scales/band'
8
8
  import { scaleLinear } from '@tanstack/charts/scales/linear'
9
9
  import { scalePoint } from '@tanstack/charts/scales/point'
10
- import { scaleLog, scaleUtc } from 'd3-scale'
10
+ import { scaleLinear as d3Linear, scaleLog, scaleUtc } from 'd3-scale'
11
11
  import type { ChartPositionScaleOptions } from '@tanstack/charts/types/core'
12
12
  import type { AxisConfig, ChartSeries, ChartX, XZoneSpec } from './types'
13
13
 
@@ -25,6 +25,23 @@ export function padAutoUpper(candidate: number, pad: number): number {
25
25
  return candidate > 0 ? candidate * pad : candidate / pad
26
26
  }
27
27
 
28
+ /**
29
+ * Raises `upper` until the axis' top tick (for `count` ticks over `[lower, upper]`) reaches `max`:
30
+ * a padded domain can end between ticks, so the line peaks above the last label. Each step adds
31
+ * one tick interval, so the loop ends within a few turns.
32
+ */
33
+ function coverTop(lower: number, upper: number, max: number, count: number): number {
34
+ let top = upper
35
+ for (let i = 0; i < 4; i++) {
36
+ const ticks = d3Linear().domain([lower, top]).ticks(count)
37
+ const last = ticks.at(-1)
38
+ const step = ticks.length > 1 ? (ticks[1] as number) - (ticks[0] as number) : 0
39
+ if (last === undefined || step <= 0 || last >= max) return top
40
+ top = last + step
41
+ }
42
+ return top
43
+ }
44
+
28
45
  /**
29
46
  * One y axis' domain. `extraBounds` are the finite zone and reference-line values pinned to this
30
47
  * axis — a target past the data must stay inside the plot. Infinite bounds clamp to the domain by
@@ -35,6 +52,9 @@ export function resolveYDomain<T>(
35
52
  data: readonly T[],
36
53
  series: readonly ChartSeries<T>[],
37
54
  extraBounds: readonly number[] = [],
55
+ /** The number of ticks the axis will draw (0: none, or its own tick values): when set, an AUTO
56
+ * domain ends on a tick at or above the data's maximum. */
57
+ tickCount = 0,
38
58
  ): readonly [number, number] {
39
59
  const domain = cfg?.domain ?? 'auto'
40
60
  if (Array.isArray(domain)) return domain as readonly [number, number]
@@ -67,7 +87,7 @@ export function resolveYDomain<T>(
67
87
  const lower = padAutoLower(Math.min(min, cfg?.autoMinCeil ?? 0), pad)
68
88
  // A flat series would be a scale with no extent: every point on one pixel.
69
89
  if (lower === upper) return [Math.min(lower, 0), upper === 0 ? 1 : upper * pad]
70
- return [lower, upper]
90
+ return [lower, tickCount > 0 && !cfg?.nice ? coverTop(lower, upper, max, tickCount) : upper]
71
91
  }
72
92
 
73
93
  /** A configured y scale instance for a resolved domain. */
@@ -1,10 +1,10 @@
1
1
  /*
2
2
  * The sparkline's hover / focus readout: one quiet chip, never a floating tooltip, so a narrow cell
3
- * cannot be escaped. It sits OUTSIDE the plot box, on the line just above it, so it can never cover
4
- * a mark: the plot is the whole box, and a chip inside it would have to hide some series (a line's
5
- * last segment, a bar, the end dot) wherever it landed. Above is always free inside a card or strip
6
- * cell (the hero value or caption is what sits there), and the chip is opaque so it reads over it.
7
- * It takes the side away from the hovered point.
3
+ * cannot be escaped. It sits INSIDE the plot box, beside the hovered point (the roomier side, so it
4
+ * flips at the edges) and on the half of the box away from the point, so it covers neither the dot
5
+ * nor anything the host draws round the sparkline (a card's delta period, a strip's caption): a chip
6
+ * above the box landed on that text, and a host slot that clips took it off the page. Where it
7
+ * crosses the line it is opaque, so it reads over it. Placement is inline (`Sparkline.tsx`).
8
8
  */
9
9
 
10
10
  .root {
@@ -13,8 +13,8 @@
13
13
 
14
14
  .readout {
15
15
  position: absolute;
16
- bottom: 100%;
17
16
  z-index: 1;
17
+ max-height: 100%;
18
18
  max-width: 100%;
19
19
  box-sizing: border-box;
20
20
  padding: 0 4px;
@@ -22,8 +22,8 @@
22
22
  font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
23
23
  font-variant-numeric: lining-nums;
24
24
  font-size: var(--vx-text-xs);
25
- /* The line a host slot reserves above the plot: it sets `--basalt-spark-readout-h` to the same
26
- * value (`stat-card.module.css`, `stat-strip.module.css`), so the chip lands in reserved space. */
25
+ /* The chip's height: hosts that reserve a line for it set `--basalt-spark-readout-h` to the same
26
+ * value (`stat-card.module.css`, `stat-strip.module.css`). */
27
27
  block-size: var(--basalt-spark-readout-h, 1.125rem);
28
28
  line-height: calc(var(--basalt-spark-readout-h, 1.125rem) - 2px);
29
29
  color: var(--vx-tooltip-text);
@@ -35,19 +35,15 @@
35
35
  border-radius: var(--vx-radius-ctrl);
36
36
  }
37
37
 
38
- .start {
39
- left: 0;
40
- }
41
-
42
- .end {
43
- right: 0;
44
- }
45
-
46
38
  .label {
47
- font-family: var(--basalt-font-mono);
48
39
  opacity: 0.7;
49
40
  }
50
41
 
42
+ .layer {
43
+ position: absolute;
44
+ pointer-events: none;
45
+ }
46
+
51
47
  .dot {
52
48
  position: absolute;
53
49
  width: 6px;
@@ -5,9 +5,8 @@
5
5
  declare const classes: {
6
6
  readonly root: string
7
7
  readonly readout: string
8
- readonly start: string
9
- readonly end: string
10
8
  readonly label: string
9
+ readonly layer: string
11
10
  readonly dot: string
12
11
  }
13
12
  export default classes
@@ -53,6 +53,8 @@ const dotStyle: CSSProperties = {
53
53
  const errorStyle: CSSProperties = {
54
54
  ...boxStyle,
55
55
  alignItems: 'flex-start',
56
+ justifyContent: 'flex-start',
57
+ paddingBottom: VX.space.controlGap,
56
58
  textAlign: 'start',
57
59
  fontSize: VX.text.sm,
58
60
  gap: VX.space.controlGap,
@@ -68,7 +70,7 @@ const errorHeadStyle: CSSProperties = {
68
70
  const errorMessageStyle: CSSProperties = { color: VX.muted }
69
71
 
70
72
  const emptyLabel = (state: ChartState | undefined): string =>
71
- typeof state?.empty === 'string' ? state.empty : 'No data'
73
+ typeof state?.empty === 'string' ? state.empty : 'Nothing recorded in this range.'
72
74
 
73
75
  /** Fills the same {@link ChartBox} the chart will, so a pending, failed or empty chart (and a
74
76
  * `<Suspense>` fallback built from one) occupies the final chart's height. */
@@ -84,12 +86,15 @@ export function ChartPlaceholder(props: {
84
86
  /** For a box too small to hold a sentence (a sparkline): error and empty show a `—` and carry the
85
87
  * label as the accessible name and the hover title. */
86
88
  compact?: boolean
89
+ /** Error only: what failed to load, "Could not load {noun}". Default: no noun. */
90
+ noun?: string
87
91
  }): ReactElement | null {
88
92
  const kind = resolveChartState(props.state)
89
93
  if (kind === null) return null
90
94
  const style = kind === 'pending' ? pendingStyle : kind === 'error' ? errorStyle : boxStyle
91
- // An error GROWS past the final chart's height rather than clip its action: the box's height is
92
- // the floor, not the size.
95
+ // An error keeps the chart's height as a floor (the frame does not jump, `ssr-contract`) and may
96
+ // grow past it rather than clip its action; its anatomy is top-aligned, so the room is plain
97
+ // card below the content, not a block of text floating mid-card.
93
98
  const fit = (node: ReactElement): ReactElement => (
94
99
  <ChartBox height={props.height} {...(kind === 'error' && { className: growClass })}>
95
100
  {node}
@@ -110,7 +115,7 @@ export function ChartPlaceholder(props: {
110
115
  {kind === 'error' && (
111
116
  <span style={errorHeadStyle}>
112
117
  <span aria-hidden="true" data-basalt-status-dot="" style={dotStyle} />
113
- Could not load this chart
118
+ Could not load{props.noun === undefined ? '' : ` ${props.noun}`}
114
119
  </span>
115
120
  )}
116
121
  <span style={errorMessageStyle}>{label}</span>