@motionscript/charts 0.1.0 → 0.1.1-alpha.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 (145) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/bar-chart/bar-chart.d.ts +22 -93
  3. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  4. package/dist/bar-chart/bar-chart.js +48 -121
  5. package/dist/bar-chart/bar-chart.js.map +1 -1
  6. package/dist/bar-chart/category-axis.d.ts +11 -38
  7. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  8. package/dist/bar-chart/category-axis.js +15 -38
  9. package/dist/bar-chart/category-axis.js.map +1 -1
  10. package/dist/bar-chart/chart-bars.d.ts +43 -74
  11. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  12. package/dist/bar-chart/chart-bars.js +31 -59
  13. package/dist/bar-chart/chart-bars.js.map +1 -1
  14. package/dist/bar-chart/index.d.ts +2 -10
  15. package/dist/bar-chart/index.d.ts.map +1 -1
  16. package/dist/bar-chart/index.js +0 -7
  17. package/dist/bar-chart/index.js.map +1 -1
  18. package/dist/bar-chart/shared.d.ts +27 -90
  19. package/dist/bar-chart/shared.d.ts.map +1 -1
  20. package/dist/bar-chart/shared.js +15 -54
  21. package/dist/bar-chart/shared.js.map +1 -1
  22. package/dist/browser/chunks/chunk-4SMRCU24.js +2 -0
  23. package/dist/browser/chunks/chunk-4SMRCU24.js.map +7 -0
  24. package/dist/browser/index.js +1 -1
  25. package/dist/browser/index.js.map +3 -3
  26. package/dist/browser/kit.js +1 -1
  27. package/dist/browser/manifest.json +1 -1
  28. package/dist/engine.d.ts +4 -16
  29. package/dist/engine.d.ts.map +1 -1
  30. package/dist/engine.js +4 -16
  31. package/dist/engine.js.map +1 -1
  32. package/dist/kit/cartesian.d.ts +8 -28
  33. package/dist/kit/cartesian.d.ts.map +1 -1
  34. package/dist/kit/cartesian.js +7 -19
  35. package/dist/kit/cartesian.js.map +1 -1
  36. package/dist/kit/chart-border.d.ts +9 -18
  37. package/dist/kit/chart-border.d.ts.map +1 -1
  38. package/dist/kit/chart-border.js +4 -9
  39. package/dist/kit/chart-border.js.map +1 -1
  40. package/dist/kit/chart-canvas.d.ts +25 -36
  41. package/dist/kit/chart-canvas.d.ts.map +1 -1
  42. package/dist/kit/chart-canvas.js +13 -13
  43. package/dist/kit/chart-canvas.js.map +1 -1
  44. package/dist/kit/chart-legend.d.ts +14 -61
  45. package/dist/kit/chart-legend.d.ts.map +1 -1
  46. package/dist/kit/chart-legend.js +17 -65
  47. package/dist/kit/chart-legend.js.map +1 -1
  48. package/dist/kit/entries.d.ts +2 -0
  49. package/dist/kit/entries.d.ts.map +1 -1
  50. package/dist/kit/entries.js +2 -0
  51. package/dist/kit/entries.js.map +1 -1
  52. package/dist/kit/motion.d.ts +11 -3
  53. package/dist/kit/motion.d.ts.map +1 -1
  54. package/dist/kit/motion.js +7 -1
  55. package/dist/kit/motion.js.map +1 -1
  56. package/dist/kit/shared.d.ts +60 -175
  57. package/dist/kit/shared.d.ts.map +1 -1
  58. package/dist/kit/shared.js +40 -157
  59. package/dist/kit/shared.js.map +1 -1
  60. package/dist/kit/vertical-axis.d.ts +16 -45
  61. package/dist/kit/vertical-axis.d.ts.map +1 -1
  62. package/dist/kit/vertical-axis.js +17 -42
  63. package/dist/kit/vertical-axis.js.map +1 -1
  64. package/dist/line-chart/chart-line.d.ts +16 -41
  65. package/dist/line-chart/chart-line.d.ts.map +1 -1
  66. package/dist/line-chart/chart-line.js +14 -43
  67. package/dist/line-chart/chart-line.js.map +1 -1
  68. package/dist/line-chart/chart-region.d.ts +14 -27
  69. package/dist/line-chart/chart-region.d.ts.map +1 -1
  70. package/dist/line-chart/chart-region.js +8 -22
  71. package/dist/line-chart/chart-region.js.map +1 -1
  72. package/dist/line-chart/horizontal-axis.d.ts +16 -43
  73. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  74. package/dist/line-chart/horizontal-axis.js +13 -42
  75. package/dist/line-chart/horizontal-axis.js.map +1 -1
  76. package/dist/line-chart/index.d.ts +1 -13
  77. package/dist/line-chart/index.d.ts.map +1 -1
  78. package/dist/line-chart/index.js +0 -12
  79. package/dist/line-chart/index.js.map +1 -1
  80. package/dist/line-chart/line-chart.d.ts +23 -109
  81. package/dist/line-chart/line-chart.d.ts.map +1 -1
  82. package/dist/line-chart/line-chart.js +45 -141
  83. package/dist/line-chart/line-chart.js.map +1 -1
  84. package/dist/line-chart/shared.d.ts +33 -107
  85. package/dist/line-chart/shared.d.ts.map +1 -1
  86. package/dist/line-chart/shared.js +28 -81
  87. package/dist/line-chart/shared.js.map +1 -1
  88. package/dist/line-chart/x-scale.d.ts +14 -55
  89. package/dist/line-chart/x-scale.d.ts.map +1 -1
  90. package/dist/line-chart/x-scale.js +29 -111
  91. package/dist/line-chart/x-scale.js.map +1 -1
  92. package/dist/nodes.d.ts +0 -12
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -12
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/pie-chart/index.d.ts +1 -12
  97. package/dist/pie-chart/index.d.ts.map +1 -1
  98. package/dist/pie-chart/index.js +0 -9
  99. package/dist/pie-chart/index.js.map +1 -1
  100. package/dist/pie-chart/pie-chart.d.ts +37 -71
  101. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  102. package/dist/pie-chart/pie-chart.js +31 -65
  103. package/dist/pie-chart/pie-chart.js.map +1 -1
  104. package/dist/pie-chart/pie-legend.d.ts +11 -26
  105. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  106. package/dist/pie-chart/pie-legend.js +14 -39
  107. package/dist/pie-chart/pie-legend.js.map +1 -1
  108. package/dist/pie-chart/pie-ring.d.ts +50 -192
  109. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  110. package/dist/pie-chart/pie-ring.js +75 -247
  111. package/dist/pie-chart/pie-ring.js.map +1 -1
  112. package/dist/pie-chart/shared.d.ts +45 -131
  113. package/dist/pie-chart/shared.d.ts.map +1 -1
  114. package/dist/pie-chart/shared.js +29 -72
  115. package/dist/pie-chart/shared.js.map +1 -1
  116. package/package.json +4 -4
  117. package/src/bar-chart/bar-chart.ts +51 -165
  118. package/src/bar-chart/category-axis.ts +16 -57
  119. package/src/bar-chart/chart-bars.ts +43 -120
  120. package/src/bar-chart/index.ts +2 -10
  121. package/src/bar-chart/shared.ts +29 -97
  122. package/src/engine.ts +4 -16
  123. package/src/kit/cartesian.ts +11 -26
  124. package/src/kit/chart-border.ts +6 -20
  125. package/src/kit/chart-canvas.ts +15 -40
  126. package/src/kit/chart-legend.ts +17 -86
  127. package/src/kit/entries.ts +4 -1
  128. package/src/kit/motion.ts +11 -2
  129. package/src/kit/shared.ts +58 -219
  130. package/src/kit/vertical-axis.ts +18 -71
  131. package/src/line-chart/chart-line.ts +16 -44
  132. package/src/line-chart/chart-region.ts +10 -23
  133. package/src/line-chart/horizontal-axis.ts +13 -42
  134. package/src/line-chart/index.ts +1 -13
  135. package/src/line-chart/line-chart.ts +50 -184
  136. package/src/line-chart/shared.ts +51 -145
  137. package/src/line-chart/x-scale.ts +31 -121
  138. package/src/nodes.ts +0 -12
  139. package/src/pie-chart/index.ts +1 -12
  140. package/src/pie-chart/pie-chart.ts +34 -102
  141. package/src/pie-chart/pie-legend.ts +14 -55
  142. package/src/pie-chart/pie-ring.ts +80 -307
  143. package/src/pie-chart/shared.ts +50 -139
  144. package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
  145. package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
@@ -1,38 +1,19 @@
1
1
  /**
2
- * The vocabulary every chart node shares: what a *series* is, how an axis is
3
- * scaled and formatted, and the theme leaves each chart's own theme is assembled
4
- * from.
2
+ * What every chart shares: series, axis scaling and formatting, and the theme
3
+ * leaves each chart's theme is assembled from. No `Node` imports, so a host's
4
+ * inspector mappings can build a partial theme without the components.
5
5
  *
6
- * This module exists because the three chart types are three ways of drawing the
7
- * same table. A line chart, a bar chart and a pie chart disagree about almost
8
- * everything visible — polylines against columns against wedges — and agree
9
- * about almost everything underneath: a series is a column with a caption and a
10
- * paint, a marker is a number formatted one way, a legend is a swatch beside a
11
- * label, and a theme is a tree of paints with one mapper and one tween. Writing
12
- * that three times would mean three answers to "how does a chart round its axis"
13
- * within one app.
14
- *
15
- * Kept renderer-agnostic (no `Node` imports) so a host's own inspector
16
- * mappings can build a partial theme without pulling the components in.
17
- *
18
- * **Two conventions run through every resolver and lerp below**, inherited from
19
- * the shape system's `resolveStroke`/`resolveShadow`:
20
- *
21
- * - A **mapper** merges the author's loose, partial input onto a `previous`
22
- * resolved value and resolves every leaf, so the tween always has resolved
23
- * data to interpolate. It is idempotent.
24
- * - A **tween** interpolates two resolved values leaf by leaf. Categorical
25
- * fields (`fontFamily`, `textAlign`) and fields that are `undefined` on either
26
- * side **step at the midpoint**, because there is no meaningful in-between and
27
- * defaulting the missing side to 0 would animate a font weight down to nothing
28
- * on the way to "unset".
6
+ * A mapper merges partial input onto a `previous` resolved value (idempotent). A
7
+ * tween interpolates two resolved values leaf by leaf, but categorical fields
8
+ * (`fontFamily`, `textAlign`) and any field `undefined` on either side step at
9
+ * the midpoint: defaulting the missing side to 0 would animate a font weight
10
+ * down to nothing on the way to "unset".
29
11
  */
30
12
  import { fillOps, lerpNumber, shadowOps, strokeOps, insetsOps, textOps, } from "@motionscript/sdk";
31
13
  /**
32
- * An axis domain entry's resolve: merges the author's partial input onto
33
- * `previous`, so a later partial `.set({ yAxis: {...} })` patches
34
- * `label`/`range`/`ticks` independently. `range`/`ticks` staying `undefined`
35
- * after the merge is the auto-derive signal the scale getters read.
14
+ * Merges partial input onto `previous`, so a later `.set({ yAxis: {...} })`
15
+ * patches `label`/`range`/`ticks` independently. An unset `range`/`ticks` is the
16
+ * auto-derive signal.
36
17
  */
37
18
  export function resolveAxisDomain(domain, previous) {
38
19
  return {
@@ -43,18 +24,15 @@ export function resolveAxisDomain(domain, previous) {
43
24
  };
44
25
  }
45
26
  /**
46
- * An axis domain entry's lerp: interpolates `range`/`ticks` numerically
47
- * (pairwise by index for `ticks`), so a `to` command that restates a range
48
- * rescales the plot smoothly. `label`, and either field when one side is in
49
- * auto-derive mode, step at the midpoint.
27
+ * Interpolates `range` and `ticks` numerically (ticks pairwise by index).
28
+ * `label`, `format`, and either field when one side is auto, step at the
29
+ * midpoint: there is no halfway between `$#,##0` and `0.0%`.
50
30
  */
51
31
  export function lerpAxisDomain(from, to, t) {
52
32
  return {
53
33
  label: t < 0.5 ? from.label : to.label,
54
34
  range: lerpOptionalRange(from.range, to.range, t),
55
35
  ticks: lerpOptionalTicks(from.ticks, to.ticks, t),
56
- // Steps at the midpoint with the caption, for the same reason: there is no
57
- // halfway between `$#,##0` and `0.0%`.
58
36
  format: t < 0.5 ? from.format : to.format,
59
37
  };
60
38
  }
@@ -73,39 +51,15 @@ function lerpOptionalTicks(from, to, t) {
73
51
  }
74
52
  return out;
75
53
  }
76
- /**
77
- * Where a generic `to()` of an axis domain should land, given the domain as it
78
- * is *drawn* (`drawn`, with `range` and `ticks` resolved off the data), or
79
- * `undefined` when the request states neither a `range` nor `ticks` and the
80
- * plain property tween will do.
81
- *
82
- * The stored domain of an auto axis has no `range` and no `ticks`, and
83
- * {@link lerpAxisDomain} steps an unset side at the midpoint, so tweening the
84
- * stored value from an auto axis is a cut. The charts therefore tween between
85
- * resolved domains, as their zoom does; this builds the destination. A `range`
86
- * given without `ticks` keeps the tick *count* the axis already draws, so each
87
- * marker slides from its old value to its new one instead of the row popping.
88
- */
89
- export function axisTweenTarget(drawn, requested) {
90
- if (requested?.range === undefined && requested?.ticks === undefined)
91
- return undefined;
92
- const target = resolveAxisDomain(requested, drawn);
93
- if (requested.ticks === undefined && requested.range !== undefined) {
94
- const count = Math.max(2, drawn.ticks?.length ?? 2);
95
- target.ticks = markerValues(requested.range, count - 1);
96
- }
97
- return target;
98
- }
99
54
  function blendOf(domain) {
100
55
  return domain.blend;
101
56
  }
102
57
  /**
103
- * A chart's axis entry tween: what `to({ yAxis: { range } })` moves through.
104
- * Between two explicit domains it is {@link lerpAxisDomain}, and a restated
105
- * `range` without `ticks` spreads explicit ticks across it, keeping their count.
106
- * When either end leaves `range` or `ticks` to the data, the value between is an
107
- * {@link AxisDomainBlend}, which the chart draws as the blend of what each end
108
- * draws: a rescale from an auto axis is continuous, not a cut at the midpoint.
58
+ * The axis entry tween behind `to({ yAxis: { range } })`. Between explicit
59
+ * domains it is {@link lerpAxisDomain}, and a restated `range` without `ticks`
60
+ * spreads ticks across it, keeping their count. When either end leaves `range`
61
+ * or `ticks` to the data, the value between is an {@link AxisDomainBlend}, so a
62
+ * rescale from an auto axis is continuous rather than a cut at the midpoint.
109
63
  */
110
64
  export function lerpAxisEntry(from, to, t) {
111
65
  // The mapper merged the request onto `from`, so a field it left unstated is `from`'s own, by identity.
@@ -125,30 +79,21 @@ export function lerpAxisEntry(from, to, t) {
125
79
  const blend = { ...lerpAxisDomain(from, target, t), blend: { from, to: target, t } };
126
80
  return blend;
127
81
  }
128
- /**
129
- * `domain` as the chart draws it: `drawn` resolves a plain domain's auto `range`
130
- * and `ticks` off the data, and a blend is the lerp of what its two ends draw.
131
- */
82
+ /** `domain` as drawn: `drawn` resolves a plain domain's auto `range` and `ticks`; a blend is the lerp of what its ends draw. */
132
83
  export function settleAxisDomain(domain, drawn) {
133
84
  const blend = blendOf(domain);
134
85
  if (!blend)
135
86
  return drawn(domain);
136
87
  return lerpAxisDomain(settleAxisDomain(blend.from, drawn), settleAxisDomain(blend.to, drawn), blend.t);
137
88
  }
138
- /**
139
- * The low-level colour tokens the default themes are built from — a dark plot
140
- * panel with warm-grey axis furniture.
141
- */
89
+ /** The colour tokens the default themes are built from: a dark plot panel with warm-grey axis furniture. */
142
90
  export const CHART_PALETTE = {
143
- /** Fill of the plot panel behind the marks. */
144
91
  plotFill: "#15130e",
145
- /** Colour of the plot's thick border. */
146
92
  borderColor: "#4a4036",
147
- /** Colour of the faint grid lines spanning the plot. */
148
93
  gridColor: "#2c2820",
149
- /** Colour of the numeric axis markers, axis captions, and legend labels. */
94
+ /** Axis markers, axis captions and legend labels. */
150
95
  markerColor: "#8a7f70",
151
- /** Colour of a spotlit region's dashed rules and its wash. */
96
+ /** A spotlit region's dashed rules and wash. */
152
97
  regionColor: "#d99a3a",
153
98
  };
154
99
  /** The out-of-the-box series palette, cycled by series index. */
@@ -159,23 +104,11 @@ export const DEFAULT_SERIES_COLORS = [
159
104
  "#5e9d6b",
160
105
  "#9ec85a",
161
106
  ];
162
- /**
163
- * Opacity an *un*-spotlighted series fades to — its mark and its legend entry
164
- * alike, so the two dim together.
165
- */
107
+ /** Opacity an un-spotlighted series fades to, mark and legend entry alike. */
166
108
  export const SPOTLIGHT_DIM = 0.2;
167
- /** Clamp a number into `[0, 1]` — the range every reveal signal here runs in. */
168
- export function clampUnit(value) {
169
- return value < 0 ? 0 : value > 1 ? 1 : value;
170
- }
171
- // ---- Row readers ---------------------------------------------------------
172
109
  /**
173
- * Read a numeric field off a row, defaulting missing, non-numeric and non-finite
174
- * values to 0.
175
- *
176
- * A column left as strings silently plots as 0, which is why the CSV parser's
177
- * numeric auto-coercion matters — a quoted or unit-suffixed column won't plot
178
- * until it's coerced.
110
+ * Reads a numeric field off a row. A string column plots as 0, so a quoted or
111
+ * unit-suffixed column needs the CSV parser's numeric coercion first.
179
112
  */
180
113
  export function num(row, field) {
181
114
  if (field === undefined)
@@ -185,12 +118,7 @@ export function num(row, field) {
185
118
  // as 0, it cannot poison the scale and turn every point into `NaN`.
186
119
  return typeof v === "number" && Number.isFinite(v) ? v : 0;
187
120
  }
188
- /**
189
- * Read a field off a row as its caption — the counterpart to {@link num} for
190
- * the columns a chart *names* things by rather than measures them by (a bar's
191
- * category, a wedge's slice). A missing cell reads as empty rather than as the
192
- * string `"undefined"`.
193
- */
121
+ /** The counterpart to {@link num} for the columns a chart names things by; a missing cell reads as empty, not `"undefined"`. */
194
122
  export function text(row, field) {
195
123
  if (field === undefined || field === "")
196
124
  return "";
@@ -198,13 +126,9 @@ export function text(row, field) {
198
126
  return v === undefined || v === null ? "" : String(v);
199
127
  }
200
128
  /**
201
- * Every column that holds numbers across `data`, in header order, skipping the
202
- * names in `exclude` (typically the category column).
203
- *
204
- * A column counts as numeric only if every non-empty cell in it is a number, so
205
- * a stray text cell leaves the column out rather than plotting zeros. This is
206
- * what lets a chart plot "every other column" without the author naming twenty
207
- * fields.
129
+ * Every numeric column of `data` in header order, skipping `exclude`. A column
130
+ * is numeric only if every non-empty cell is a number, so a stray text cell
131
+ * drops the column rather than plotting zeros.
208
132
  */
209
133
  export function numericFields(data, exclude = []) {
210
134
  if (data.length === 0)
@@ -244,7 +168,6 @@ const AXIS_TITLE_STYLE = {
244
168
  fill: CHART_PALETTE.markerColor,
245
169
  };
246
170
  const AXIS_LINE_STYLE = { weight: 2, fill: CHART_PALETTE.gridColor };
247
- /** The default styling of a horizontal (marker row beneath the plot) axis. */
248
171
  export const DEFAULT_X_AXIS = {
249
172
  labelStyle: AXIS_LABEL_STYLE,
250
173
  titleStyle: AXIS_TITLE_STYLE,
@@ -252,7 +175,6 @@ export const DEFAULT_X_AXIS = {
252
175
  tickPadding: 20,
253
176
  titlePadding: 4,
254
177
  };
255
- /** The default styling of a vertical (marker column beside the plot) axis. */
256
178
  export const DEFAULT_Y_AXIS = {
257
179
  labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: "right" },
258
180
  titleStyle: AXIS_TITLE_STYLE,
@@ -260,17 +182,12 @@ export const DEFAULT_Y_AXIS = {
260
182
  tickPadding: 40,
261
183
  titlePadding: 24,
262
184
  };
263
- /**
264
- * The default plot panel: **unpainted**, framed. A chart reads against the
265
- * stage rather than punching a panel into it, which is the look the family was
266
- * designed at.
267
- */
185
+ /** Unpainted but framed: a chart reads against the stage rather than punching a panel into it. */
268
186
  export const DEFAULT_PLOT_AREA = {
269
187
  fill: [],
270
188
  stroke: { weight: 6, fill: CHART_PALETTE.borderColor },
271
189
  shadow: [],
272
190
  };
273
- /** The default legend styling, shared by every chart that draws one. */
274
191
  export const DEFAULT_LEGEND = {
275
192
  padding: 0,
276
193
  textStyle: {
@@ -288,14 +205,10 @@ export const DEFAULT_LEGEND = {
288
205
  shadow: [],
289
206
  },
290
207
  };
291
- /** The default per-series stroke palette — {@link DEFAULT_SERIES_COLORS}, drawn 4px. */
208
+ /** {@link DEFAULT_SERIES_COLORS} as 4px strokes. */
292
209
  export const DEFAULT_SERIES_STROKES = DEFAULT_SERIES_COLORS.map((fill) => ({ weight: 4, fill }));
293
- /** The default per-series fill palette — the same colours, as solid paint. */
210
+ /** {@link DEFAULT_SERIES_COLORS} as solid fills. */
294
211
  export const DEFAULT_SERIES_FILLS = DEFAULT_SERIES_COLORS.map((fill) => fill);
295
- // ---- Theme branch resolvers ----------------------------------------------
296
- // Each chart type assembles its own theme out of these, so "the axis furniture"
297
- // means one thing across the family and each chart still declares only the
298
- // branches it actually draws.
299
212
  export function resolveAxisConfig(axis, previous) {
300
213
  return {
301
214
  labelStyle: textOps.resolveStyle(axis?.labelStyle, previous.labelStyle),
@@ -362,7 +275,7 @@ export function lerpLegendConfig(from, to, t) {
362
275
  markerStyle: lerpLegendMarkerConfig(from.markerStyle, to.markerStyle, t),
363
276
  };
364
277
  }
365
- /** A whole-palette override replaces the previous palette outright. */
278
+ /** A palette override replaces the previous palette outright. */
366
279
  export function resolveSeriesStrokes(styles, previous) {
367
280
  return (styles ?? previous).map((s) => strokeOps.resolve(s));
368
281
  }
@@ -392,11 +305,9 @@ export function lerpSeriesFills(from, to, t) {
392
305
  }
393
306
  return out;
394
307
  }
395
- // ---- Per-series paint ----------------------------------------------------
396
308
  /**
397
- * The effective stroke for series `index`: the palette's entry at
398
- * `index % palette.length`, with the series' own `fill`, if set, overriding just
399
- * the last (topmost) layer's colour.
309
+ * The stroke for series `index`: the palette's entry at `index % palette.length`,
310
+ * with the series' own `fill`, if set, replacing just the topmost layer's colour.
400
311
  */
401
312
  export function resolveSeriesStroke(palette, series, index) {
402
313
  const entry = palette.length > 0
@@ -414,39 +325,15 @@ export function resolveSeriesStroke(palette, series, index) {
414
325
  };
415
326
  return next;
416
327
  }
417
- /**
418
- * The effective *colour* for series `index` — the same colour
419
- * {@link resolveSeriesStroke} draws its line in — for contexts (a legend
420
- * swatch) that only need the fill.
421
- */
328
+ /** The colour {@link resolveSeriesStroke} draws series `index` in, for a legend swatch. */
422
329
  export function resolveSeriesFill(palette, series, index) {
423
330
  const layers = strokeOps.resolve(resolveSeriesStroke(palette, series, index));
424
331
  return layers[layers.length - 1]?.fill ?? "white";
425
332
  }
426
333
  /**
427
- * The effective paint for mark `index` of a **filled** chart (a bar, a wedge):
428
- * the series' own `fill` when it carries one, else the palette's entry for its
429
- * index, cycled.
430
- *
431
- * The stroke twin above has to reach inside a stroke to swap one layer's colour;
432
- * a filled mark has no such geometry wrapped around its paint, so an override is
433
- * simply the whole answer.
434
- */
435
- export function resolvePalettePaint(palette, override, index) {
436
- if (override != null)
437
- return override;
438
- if (palette.length === 0)
439
- return "white";
440
- return palette[index % palette.length];
441
- }
442
- // ---- Scales and formatting -----------------------------------------------
443
- /**
444
- * Format a marker value: integers plain, otherwise trimmed to one decimal, or to
445
- * as many as the axis's tick `step` needs to tell neighbouring ticks apart.
446
- *
447
- * One decimal is the floor, so a step of 0.1 or more reads exactly as it always
448
- * has; a finer step (a unit axis ticked every 0.05) gets two, instead of five
449
- * ticks captioned `0.1 0.1 0.2 0.2 0.3`. Trailing zeros are dropped either way.
334
+ * Format a marker value: integers plain, otherwise one decimal, or as many as
335
+ * the tick `step` needs to tell neighbours apart (a unit axis ticked every 0.05
336
+ * gets two, not `0.1 0.1 0.2 0.2 0.3`). Trailing zeros are dropped.
450
337
  */
451
338
  export function formatMarker(value, step) {
452
339
  if (Number.isInteger(value))
@@ -489,8 +376,4 @@ export function markerValues([min, max], markerCount) {
489
376
  const n = Math.max(2, Math.round(markerCount));
490
377
  return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i);
491
378
  }
492
- // Lifted into the engine, because a graph and a diagram want them too — see
493
- // `@motionscript/sdk/component`. Re-exported so a chart, and anything that
494
- // copied one, still reaches them where it always did.
495
- export { niceStep, enterBudget } from "@motionscript/sdk/component";
496
379
  //# sourceMappingURL=shared.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,GAWR,MAAM,mBAAmB,CAAA;AAuD1B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoC,EACpC,QAA2B;IAE3B,OAAO;QACL,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC7C,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM;KAC3C,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAsB,EACtB,EAAoB,EACpB,CAAS;IAET,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK;QACtC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,2EAA2E;QAC3E,uCAAuC;QACvC,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC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C,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7E,CAAC;AAED,4EAA4E;AAC5E,2EAA2E;AAC3E,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA","sourcesContent":["/**\n * The vocabulary every chart node shares: what a *series* is, how an axis is\n * scaled and formatted, and the theme leaves each chart's own theme is assembled\n * from.\n *\n * This module exists because the three chart types are three ways of drawing the\n * same table. A line chart, a bar chart and a pie chart disagree about almost\n * everything visible — polylines against columns against wedges — and agree\n * about almost everything underneath: a series is a column with a caption and a\n * paint, a marker is a number formatted one way, a legend is a swatch beside a\n * label, and a theme is a tree of paints with one mapper and one tween. Writing\n * that three times would mean three answers to \"how does a chart round its axis\"\n * within one app.\n *\n * Kept renderer-agnostic (no `Node` imports) so a host's own inspector\n * mappings can build a partial theme without pulling the components in.\n *\n * **Two conventions run through every resolver and lerp below**, inherited from\n * the shape system's `resolveStroke`/`resolveShadow`:\n *\n * - A **mapper** merges the author's loose, partial input onto a `previous`\n * resolved value and resolves every leaf, so the tween always has resolved\n * data to interpolate. It is idempotent.\n * - A **tween** interpolates two resolved values leaf by leaf. Categorical\n * fields (`fontFamily`, `textAlign`) and fields that are `undefined` on either\n * side **step at the midpoint**, because there is no meaningful in-between and\n * defaulting the missing side to 0 would animate a font weight down to nothing\n * on the way to \"unset\".\n */\n\nimport {\n fillOps,\n lerpNumber,\n shadowOps,\n strokeOps,\n insetsOps,\n textOps,\n type DataRecord,\n type Fill,\n type FillResolved,\n type Insets,\n type InsetsResolved,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\n/**\n * One series of a chart: a column of the table, captioned and painted.\n *\n * `field` names the column carrying this series' values. What that becomes is\n * the chart's business — a traced polyline, a column of bars, a wedge — but the\n * three questions asked of it are the same everywhere: which column, what to\n * call it, what to paint it, and whether it is currently drawn.\n *\n * `fill` is an **override**: omit it and the series takes the theme palette's\n * entry for its own index, which is what makes a chart nobody has themed come\n * out in five distinct colours rather than five identical ones.\n */\nexport interface ChartSeries {\n /** Key into each data row for this series' value. */\n field: string\n /** Legend caption for this series. */\n label: string\n /**\n * Paint override for this series' mark and its legend swatch. Omit to take\n * the theme palette's entry for this series' index.\n */\n fill?: Fill\n /** Whether the series shows by default. Defaults to `true`. */\n enabled?: boolean\n}\n\n/** A `[min, max]` numeric range in data units. */\nexport type Range = [min: number, max: number]\n\n/**\n * One axis's *data* domain — what it shows — as opposed to {@link AxisConfig},\n * which is how it's *styled*. Every field is optional: `range`/`ticks` derive\n * from the plotted data when omitted, and `label` defaults to `\"\"`.\n */\nexport interface AxisDomainConfig {\n /** Caption drawn alongside the axis. Pass `\"\"` (the default) to hide it. */\n label?: string\n /** `[min, max]` of the scale. Derived from the data bounds when omitted. */\n range?: Range\n /** Tick values (in data units). Derived (five evenly-spaced) when omitted. */\n ticks?: number[]\n /**\n * How a tick value is written down — a `number-format` pattern such as\n * `#,##0.00` or `$#,##0`.\n *\n * Here rather than in {@link AxisConfig} because it is a statement about the\n * *numbers*, not about the ink they are set in: `$` on a revenue axis says\n * what the column holds, and it has to survive a re-theme. It sits beside\n * `range` and `ticks` for the same reason those do.\n */\n format?: string\n}\n\n/**\n * An axis domain entry's resolve: merges the author's partial input onto\n * `previous`, so a later partial `.set({ yAxis: {...} })` patches\n * `label`/`range`/`ticks` independently. `range`/`ticks` staying `undefined`\n * after the merge is the auto-derive signal the scale getters read.\n */\nexport function resolveAxisDomain(\n domain: AxisDomainConfig | undefined,\n previous?: AxisDomainConfig\n): AxisDomainConfig {\n return {\n label: domain?.label ?? previous?.label ?? \"\",\n range: domain?.range ?? previous?.range,\n ticks: domain?.ticks ?? previous?.ticks,\n format: domain?.format ?? previous?.format,\n }\n}\n\n/**\n * An axis domain entry's lerp: interpolates `range`/`ticks` numerically\n * (pairwise by index for `ticks`), so a `to` command that restates a range\n * rescales the plot smoothly. `label`, and either field when one side is in\n * auto-derive mode, step at the midpoint.\n */\nexport function lerpAxisDomain(\n from: AxisDomainConfig,\n to: AxisDomainConfig,\n t: number\n): AxisDomainConfig {\n return {\n label: t < 0.5 ? from.label : to.label,\n range: lerpOptionalRange(from.range, to.range, t),\n ticks: lerpOptionalTicks(from.ticks, to.ticks, t),\n // Steps at the midpoint with the caption, for the same reason: there is no\n // halfway between `$#,##0` and `0.0%`.\n format: t < 0.5 ? from.format : to.format,\n }\n}\n\nfunction lerpOptionalRange(\n from: Range | undefined,\n to: Range | undefined,\n t: number\n): Range | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n return [lerpNumber(from[0], to[0], t), lerpNumber(from[1], to[1], t)]\n}\n\nfunction lerpOptionalTicks(\n from: number[] | undefined,\n to: number[] | undefined,\n t: number\n): number[] | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n const n = Math.max(from.length, to.length)\n const out: number[] = []\n for (let i = 0; i < n; i++) {\n out.push(lerpNumber(from[i] ?? to[i], to[i] ?? from[i], t))\n }\n return out\n}\n\n/**\n * Where a generic `to()` of an axis domain should land, given the domain as it\n * is *drawn* (`drawn`, with `range` and `ticks` resolved off the data), or\n * `undefined` when the request states neither a `range` nor `ticks` and the\n * plain property tween will do.\n *\n * The stored domain of an auto axis has no `range` and no `ticks`, and\n * {@link lerpAxisDomain} steps an unset side at the midpoint, so tweening the\n * stored value from an auto axis is a cut. The charts therefore tween between\n * resolved domains, as their zoom does; this builds the destination. A `range`\n * given without `ticks` keeps the tick *count* the axis already draws, so each\n * marker slides from its old value to its new one instead of the row popping.\n */\nexport function axisTweenTarget(\n drawn: AxisDomainConfig,\n requested: AxisDomainConfig | undefined\n): AxisDomainConfig | undefined {\n if (requested?.range === undefined && requested?.ticks === undefined) return undefined\n const target = resolveAxisDomain(requested, drawn)\n if (requested.ticks === undefined && requested.range !== undefined) {\n const count = Math.max(2, drawn.ticks?.length ?? 2)\n target.ticks = markerValues(requested.range, count - 1)\n }\n return target\n}\n\n/**\n * An axis domain part-way through a tween that leaves or reaches a `range` or\n * `ticks` left to the data: both ends as stored, and how far along. Only the\n * chart knows what an auto side draws as, so {@link settleAxisDomain} resolves\n * it there. Its own fields are the plain {@link lerpAxisDomain} of its ends, so\n * a mapper merging onto one still reads a domain.\n */\nexport interface AxisDomainBlend extends AxisDomainConfig {\n readonly blend: { readonly from: AxisDomainConfig; readonly to: AxisDomainConfig; readonly t: number }\n}\n\nfunction blendOf(domain: AxisDomainConfig): AxisDomainBlend[\"blend\"] | undefined {\n return (domain as Partial<AxisDomainBlend>).blend\n}\n\n/**\n * A chart's axis entry tween: what `to({ yAxis: { range } })` moves through.\n * Between two explicit domains it is {@link lerpAxisDomain}, and a restated\n * `range` without `ticks` spreads explicit ticks across it, keeping their count.\n * When either end leaves `range` or `ticks` to the data, the value between is an\n * {@link AxisDomainBlend}, which the chart draws as the blend of what each end\n * draws: a rescale from an auto axis is continuous, not a cut at the midpoint.\n */\nexport function lerpAxisEntry(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig {\n // The mapper merged the request onto `from`, so a field it left unstated is `from`'s own, by identity.\n const rangeMoved = to.range !== from.range\n const target = rangeMoved && to.range && to.ticks && to.ticks === from.ticks\n ? { ...to, ticks: markerValues(to.range, Math.max(2, to.ticks.length) - 1) }\n : to\n const blended = blendOf(from) !== undefined\n const moved = blended || rangeMoved || target.ticks !== from.ticks\n const auto = blended || from.range === undefined || from.ticks === undefined || target.range === undefined || target.ticks === undefined\n if (!moved || !auto) return lerpAxisDomain(from, target, t)\n if (t === 0) return from\n if (t === 1) return target\n const blend: AxisDomainBlend = { ...lerpAxisDomain(from, target, t), blend: { from, to: target, t } }\n return blend\n}\n\n/**\n * `domain` as the chart draws it: `drawn` resolves a plain domain's auto `range`\n * and `ticks` off the data, and a blend is the lerp of what its two ends draw.\n */\nexport function settleAxisDomain(domain: AxisDomainConfig, drawn: (domain: AxisDomainConfig) => AxisDomainConfig): AxisDomainConfig {\n const blend = blendOf(domain)\n if (!blend) return drawn(domain)\n return lerpAxisDomain(settleAxisDomain(blend.from, drawn), settleAxisDomain(blend.to, drawn), blend.t)\n}\n\n/**\n * The low-level colour tokens the default themes are built from — a dark plot\n * panel with warm-grey axis furniture.\n */\nexport const CHART_PALETTE = {\n /** Fill of the plot panel behind the marks. */\n plotFill: \"#15130e\",\n /** Colour of the plot's thick border. */\n borderColor: \"#4a4036\",\n /** Colour of the faint grid lines spanning the plot. */\n gridColor: \"#2c2820\",\n /** Colour of the numeric axis markers, axis captions, and legend labels. */\n markerColor: \"#8a7f70\",\n /** Colour of a spotlit region's dashed rules and its wash. */\n regionColor: \"#d99a3a\",\n} as const\n\n/** The out-of-the-box series palette, cycled by series index. */\nexport const DEFAULT_SERIES_COLORS = [\n \"#d9603b\",\n \"#8194ad\",\n \"#e0a93b\",\n \"#5e9d6b\",\n \"#9ec85a\",\n] as const\n\n/**\n * Opacity an *un*-spotlighted series fades to — its mark and its legend entry\n * alike, so the two dim together.\n */\nexport const SPOTLIGHT_DIM = 0.2\n\n/** Clamp a number into `[0, 1]` — the range every reveal signal here runs in. */\nexport function clampUnit(value: number): number {\n return value < 0 ? 0 : value > 1 ? 1 : value\n}\n\n// ---- Row readers ---------------------------------------------------------\n\n/**\n * Read a numeric field off a row, defaulting missing, non-numeric and non-finite\n * values to 0.\n *\n * A column left as strings silently plots as 0, which is why the CSV parser's\n * numeric auto-coercion matters — a quoted or unit-suffixed column won't plot\n * until it's coerced.\n */\nexport function num(row: DataRecord, field: string | undefined): number {\n if (field === undefined) return 0\n const v = row[field]\n // A `NaN` or infinite cell is no more a measurement than a missing one: read\n // as 0, it cannot poison the scale and turn every point into `NaN`.\n return typeof v === \"number\" && Number.isFinite(v) ? v : 0\n}\n\n/**\n * Read a field off a row as its caption — the counterpart to {@link num} for\n * the columns a chart *names* things by rather than measures them by (a bar's\n * category, a wedge's slice). A missing cell reads as empty rather than as the\n * string `\"undefined\"`.\n */\nexport function text(row: DataRecord, field: string | undefined): string {\n if (field === undefined || field === \"\") return \"\"\n const v = row[field]\n return v === undefined || v === null ? \"\" : String(v)\n}\n\n/**\n * Every column that holds numbers across `data`, in header order, skipping the\n * names in `exclude` (typically the category column).\n *\n * A column counts as numeric only if every non-empty cell in it is a number, so\n * a stray text cell leaves the column out rather than plotting zeros. This is\n * what lets a chart plot \"every other column\" without the author naming twenty\n * fields.\n */\nexport function numericFields(\n data: DataRecord[],\n exclude: string[] = []\n): string[] {\n if (data.length === 0) return []\n const skip = new Set(exclude)\n const seen = new Set<string>()\n const order: string[] = []\n for (const row of data)\n for (const key of Object.keys(row))\n if (!skip.has(key) && !seen.has(key)) {\n seen.add(key)\n order.push(key)\n }\n\n return order.filter((key) => {\n let sawValue = false\n for (const row of data) {\n const v = row[key]\n if (v === undefined || v === \"\") continue\n if (typeof v !== \"number\") return false\n sawValue = true\n }\n return sawValue\n })\n}\n\n// ---- Theme branches ------------------------------------------------------\n\n/** One axis's (x or y) style vocabulary. */\nexport interface AxisConfig {\n /** Style of each marker along the axis. */\n labelStyle: TextStyle\n /** Style of the axis caption. */\n titleStyle: TextStyle\n /**\n * This axis's direction of the plot's internal grid — weight+fill honoured,\n * dash/cap/join ignored (grid lines are drawn as filled rects).\n */\n lineStyle: Stroke\n /**\n * Gap between the plot and the marker row. Only the side facing the plot is\n * read — `.top` for a horizontal axis, `.right` for a vertical one.\n */\n tickPadding: Insets\n /** Gap between the marker row and the caption, read the same side. */\n titlePadding: Insets\n}\n\n/** A legend's per-series colour swatch — a rounded chip, not the caption. */\nexport interface LegendMarkerConfig {\n width: number\n height: number\n borderRadius: number\n stroke: Stroke\n shadow: Shadow\n}\n\n/** A legend's visual theme. */\nexport interface LegendConfig {\n padding: Insets\n /** Caption style — only the swatch carries the series colour. */\n textStyle: TextStyle\n /** Gap between legend entries. */\n itemGap: number\n markerStyle: LegendMarkerConfig\n}\n\n/** The plot panel a cartesian chart draws its marks over. */\nexport interface PlotAreaConfig {\n stroke: Stroke\n fill: Fill\n shadow: Shadow\n}\n\nconst AXIS_LABEL_STYLE: TextStyle = {\n fontSize: 24,\n fontWeight: 700,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_TITLE_STYLE: TextStyle = {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_LINE_STYLE: Stroke = { weight: 2, fill: CHART_PALETTE.gridColor }\n\n/** The default styling of a horizontal (marker row beneath the plot) axis. */\nexport const DEFAULT_X_AXIS: AxisConfig = {\n labelStyle: AXIS_LABEL_STYLE,\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 20,\n titlePadding: 4,\n}\n\n/** The default styling of a vertical (marker column beside the plot) axis. */\nexport const DEFAULT_Y_AXIS: AxisConfig = {\n labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: \"right\" },\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 40,\n titlePadding: 24,\n}\n\n/**\n * The default plot panel: **unpainted**, framed. A chart reads against the\n * stage rather than punching a panel into it, which is the look the family was\n * designed at.\n */\nexport const DEFAULT_PLOT_AREA: PlotAreaConfig = {\n fill: [],\n stroke: { weight: 6, fill: CHART_PALETTE.borderColor },\n shadow: [],\n}\n\n/** The default legend styling, shared by every chart that draws one. */\nexport const DEFAULT_LEGEND: LegendConfig = {\n padding: 0,\n textStyle: {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"left\",\n fill: CHART_PALETTE.markerColor,\n },\n itemGap: 44,\n markerStyle: {\n width: 60,\n height: 24,\n borderRadius: 6,\n stroke: [],\n shadow: [],\n },\n}\n\n/** The default per-series stroke palette — {@link DEFAULT_SERIES_COLORS}, drawn 4px. */\nexport const DEFAULT_SERIES_STROKES: Stroke[] = DEFAULT_SERIES_COLORS.map(\n (fill) => ({ weight: 4, fill })\n)\n\n/** The default per-series fill palette — the same colours, as solid paint. */\nexport const DEFAULT_SERIES_FILLS: Fill[] = DEFAULT_SERIES_COLORS.map(\n (fill) => fill\n)\n\n// ---- Theme branch resolvers ----------------------------------------------\n// Each chart type assembles its own theme out of these, so \"the axis furniture\"\n// means one thing across the family and each chart still declares only the\n// branches it actually draws.\n\nexport function resolveAxisConfig(\n axis: Partial<AxisConfig> | undefined,\n previous: AxisConfig\n): AxisConfig {\n return {\n labelStyle: textOps.resolveStyle(axis?.labelStyle, previous.labelStyle),\n titleStyle: textOps.resolveStyle(axis?.titleStyle, previous.titleStyle),\n lineStyle: strokeOps.resolve(axis?.lineStyle ?? previous.lineStyle),\n tickPadding: insetsOps.resolve(\n axis?.tickPadding ?? previous.tickPadding,\n previous.tickPadding as InsetsResolved\n ),\n titlePadding: insetsOps.resolve(\n axis?.titlePadding ?? previous.titlePadding,\n previous.titlePadding as InsetsResolved\n ),\n }\n}\n\nexport function lerpAxisConfig(\n from: AxisConfig,\n to: AxisConfig,\n t: number\n): AxisConfig {\n return {\n labelStyle: textOps.lerpStyle(from.labelStyle, to.labelStyle, t),\n titleStyle: textOps.lerpStyle(from.titleStyle, to.titleStyle, t),\n lineStyle: strokeOps.lerp(\n from.lineStyle as StrokeResolved[],\n to.lineStyle as StrokeResolved[],\n t\n ),\n tickPadding: insetsOps.lerp(\n from.tickPadding as InsetsResolved,\n to.tickPadding as InsetsResolved,\n t\n ),\n titlePadding: insetsOps.lerp(\n from.titlePadding as InsetsResolved,\n to.titlePadding as InsetsResolved,\n t\n ),\n }\n}\n\nexport function resolvePlotArea(\n plotArea: Partial<PlotAreaConfig> | undefined,\n previous: PlotAreaConfig\n): PlotAreaConfig {\n return {\n fill: fillOps.resolve(plotArea?.fill ?? previous.fill),\n stroke: strokeOps.resolve(plotArea?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(plotArea?.shadow ?? previous.shadow),\n }\n}\n\nexport function lerpPlotArea(\n from: PlotAreaConfig,\n to: PlotAreaConfig,\n t: number\n): PlotAreaConfig {\n return {\n fill: fillOps.lerp(\n from.fill as FillResolved[],\n to.fill as FillResolved[],\n t\n ),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\nfunction resolveLegendMarkerConfig(\n marker: Partial<LegendMarkerConfig> | undefined,\n previous: LegendMarkerConfig\n): LegendMarkerConfig {\n return {\n width: marker?.width ?? previous.width,\n height: marker?.height ?? previous.height,\n borderRadius: marker?.borderRadius ?? previous.borderRadius,\n stroke: strokeOps.resolve(marker?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(marker?.shadow ?? previous.shadow),\n }\n}\n\nfunction lerpLegendMarkerConfig(\n from: LegendMarkerConfig,\n to: LegendMarkerConfig,\n t: number\n): LegendMarkerConfig {\n return {\n width: lerpNumber(from.width, to.width, t),\n height: lerpNumber(from.height, to.height, t),\n borderRadius: lerpNumber(from.borderRadius, to.borderRadius, t),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\n/** A legend theme as the author may state it — every branch optional. */\nexport type LegendTheme = Partial<Omit<LegendConfig, \"markerStyle\">> & {\n markerStyle?: Partial<LegendMarkerConfig>\n}\n\nexport function resolveLegendConfig(\n legend: LegendTheme | undefined,\n previous: LegendConfig\n): LegendConfig {\n return {\n padding: insetsOps.resolve(\n legend?.padding ?? previous.padding,\n previous.padding as InsetsResolved\n ),\n textStyle: textOps.resolveStyle(legend?.textStyle, previous.textStyle),\n itemGap: legend?.itemGap ?? previous.itemGap,\n markerStyle: resolveLegendMarkerConfig(\n legend?.markerStyle,\n previous.markerStyle\n ),\n }\n}\n\nexport function lerpLegendConfig(\n from: LegendConfig,\n to: LegendConfig,\n t: number\n): LegendConfig {\n return {\n padding: insetsOps.lerp(\n from.padding as InsetsResolved,\n to.padding as InsetsResolved,\n t\n ),\n textStyle: textOps.lerpStyle(from.textStyle, to.textStyle, t),\n itemGap: lerpNumber(from.itemGap, to.itemGap, t),\n markerStyle: lerpLegendMarkerConfig(from.markerStyle, to.markerStyle, t),\n }\n}\n\n/** A whole-palette override replaces the previous palette outright. */\nexport function resolveSeriesStrokes(\n styles: Stroke[] | undefined,\n previous: Stroke[]\n): Stroke[] {\n return (styles ?? previous).map((s) => strokeOps.resolve(s))\n}\n\n/** Pairwise by index; a palette that grows/shrinks holds the longer side's tail. */\nexport function lerpSeriesStrokes(\n from: Stroke[],\n to: Stroke[],\n t: number\n): Stroke[] {\n const n = Math.max(from.length, to.length)\n const out: Stroke[] = []\n for (let i = 0; i < n; i++) {\n const a = (from[i] ?? to[i]) as StrokeResolved[]\n const b = (to[i] ?? from[i]) as StrokeResolved[]\n out.push(strokeOps.lerp(a, b, t))\n }\n return out\n}\n\n/** The fill-palette twin of {@link resolveSeriesStrokes}, for filled marks. */\nexport function resolveSeriesFills(\n fills: Fill[] | undefined,\n previous: Fill[]\n): Fill[] {\n return (fills ?? previous).map((f) => fillOps.resolve(f))\n}\n\n/** The fill-palette twin of {@link lerpSeriesStrokes}. */\nexport function lerpSeriesFills(from: Fill[], to: Fill[], t: number): Fill[] {\n const n = Math.max(from.length, to.length)\n const out: Fill[] = []\n for (let i = 0; i < n; i++) {\n const a = (from[i] ?? to[i]) as FillResolved[]\n const b = (to[i] ?? from[i]) as FillResolved[]\n out.push(fillOps.lerp(a, b, t))\n }\n return out\n}\n\n// ---- Per-series paint ----------------------------------------------------\n\n/**\n * The effective stroke for series `index`: the palette's entry at\n * `index % palette.length`, with the series' own `fill`, if set, overriding just\n * the last (topmost) layer's colour.\n */\nexport function resolveSeriesStroke(\n palette: Stroke[],\n series: ChartSeries,\n index: number\n): Stroke {\n const entry: Stroke =\n palette.length > 0\n ? palette[index % palette.length]\n : { weight: 4, fill: \"white\" }\n if (series.fill == null) return entry\n const layers = strokeOps.resolve(entry)\n if (layers.length === 0) return { weight: 4, fill: series.fill }\n const next = [...layers]\n next[next.length - 1] = {\n ...next[next.length - 1],\n fill: fillOps.resolve(series.fill),\n }\n return next\n}\n\n/**\n * The effective *colour* for series `index` — the same colour\n * {@link resolveSeriesStroke} draws its line in — for contexts (a legend\n * swatch) that only need the fill.\n */\nexport function resolveSeriesFill(\n palette: Stroke[],\n series: ChartSeries,\n index: number\n): Fill {\n const layers = strokeOps.resolve(resolveSeriesStroke(palette, series, index))\n return layers[layers.length - 1]?.fill ?? \"white\"\n}\n\n/**\n * The effective paint for mark `index` of a **filled** chart (a bar, a wedge):\n * the series' own `fill` when it carries one, else the palette's entry for its\n * index, cycled.\n *\n * The stroke twin above has to reach inside a stroke to swap one layer's colour;\n * a filled mark has no such geometry wrapped around its paint, so an override is\n * simply the whole answer.\n */\nexport function resolvePalettePaint(\n palette: Fill[],\n override: Fill | undefined,\n index: number\n): Fill {\n if (override != null) return override\n if (palette.length === 0) return \"white\"\n return palette[index % palette.length]\n}\n\n// ---- Scales and formatting -----------------------------------------------\n\n\n/**\n * Format a marker value: integers plain, otherwise trimmed to one decimal, or to\n * as many as the axis's tick `step` needs to tell neighbouring ticks apart.\n *\n * One decimal is the floor, so a step of 0.1 or more reads exactly as it always\n * has; a finer step (a unit axis ticked every 0.05) gets two, instead of five\n * ticks captioned `0.1 0.1 0.2 0.2 0.3`. Trailing zeros are dropped either way.\n */\nexport function formatMarker(value: number, step?: number): string {\n if (Number.isInteger(value)) return String(value)\n const decimals = Math.max(1, step === undefined ? 1 : decimalsFor(step))\n return value.toFixed(decimals).replace(/(\\.\\d*?)0+$/, \"$1\").replace(/\\.$/, \"\")\n}\n\n/** Decimal places needed to write `step` exactly, capped at six. */\nfunction decimalsFor(step: number): number {\n if (!(step > 0) || !Number.isFinite(step)) return 1\n for (let d = 0; d <= 6; d++) {\n const scaled = step * 10 ** d\n if (Math.abs(scaled - Math.round(scaled)) < 1e-6 * Math.max(1, scaled)) return d\n }\n // An irrational-looking step (a third): as many places as separate the ticks.\n return Math.min(6, Math.max(1, Math.ceil(-Math.log10(step)) + 1))\n}\n\n/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */\nexport function markerStep(markers: readonly number[]): number | undefined {\n const sorted = [...markers].filter(Number.isFinite).sort((a, b) => a - b)\n let step: number | undefined\n for (let i = 1; i < sorted.length; i++) {\n const gap = sorted[i] - sorted[i - 1]\n if (gap > 1e-12 && (step === undefined || gap < step)) step = gap\n }\n return step\n}\n\n/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */\nexport function formatPercent(fraction: number): string {\n const pct = fraction * 100\n if (Number.isInteger(pct)) return `${pct}%`\n return `${pct.toFixed(1).replace(/\\.0$/, \"\")}%`\n}\n\n/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */\nexport function markerValues([min, max]: Range, markerCount: number): number[] {\n const n = Math.max(2, Math.round(markerCount))\n return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i)\n}\n\n// Lifted into the engine, because a graph and a diagram want them too — see\n// `@motionscript/sdk/component`. Re-exported so a chart, and anything that\n// copied one, still reaches them where it always did.\nexport { niceStep, enterBudget } from \"@motionscript/sdk/component\"\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,GAWR,MAAM,mBAAmB,CAAA;AAmC1B;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoC,EACpC,QAA2B;IAE3B,OAAO;QACL,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC7C,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ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AAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAA;AACjD,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,CAAQ,EAAE,WAAmB;IACjE,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAA;IAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7E,CAAC","sourcesContent":["/**\n * What every chart shares: series, axis scaling and formatting, and the theme\n * leaves each chart's theme is assembled from. No `Node` imports, so a host's\n * inspector mappings can build a partial theme without the components.\n *\n * A mapper merges partial input onto a `previous` resolved value (idempotent). A\n * tween interpolates two resolved values leaf by leaf, but categorical fields\n * (`fontFamily`, `textAlign`) and any field `undefined` on either side step at\n * the midpoint: defaulting the missing side to 0 would animate a font weight\n * down to nothing on the way to \"unset\".\n */\n\nimport {\n fillOps,\n lerpNumber,\n shadowOps,\n strokeOps,\n insetsOps,\n textOps,\n type DataRecord,\n type Fill,\n type FillResolved,\n type Insets,\n type InsetsResolved,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\n/** One series of a chart: a column of the table, captioned and painted. */\nexport interface ChartSeries {\n /** Key into each data row for this series' value. */\n field: string\n label: string\n /** Overrides the theme palette's entry for this series' index, for its mark and legend swatch. */\n fill?: Fill\n /** Defaults to `true`. */\n enabled?: boolean\n}\n\n/** A `[min, max]` numeric range in data units. */\nexport type Range = [min: number, max: number]\n\n/** One axis's *data* domain, as opposed to {@link AxisConfig}, which is how it is styled. */\nexport interface AxisDomainConfig {\n /** Caption drawn alongside the axis; `\"\"` hides it. */\n label?: string\n /** Derived from the data bounds when omitted. */\n range?: Range\n /** Derived (five evenly spaced) when omitted. */\n ticks?: number[]\n /**\n * A `number-format` pattern such as `#,##0.00` or `$#,##0`. It lives here, not\n * in {@link AxisConfig}, because it says what the column holds and has to\n * survive a re-theme.\n */\n format?: string\n}\n\n/** An {@link AxisDomainConfig} with `range` and `ticks` worked out. */\nexport type ResolvedAxisDomain = AxisDomainConfig & { readonly range: Range; readonly ticks: number[] }\n\n/**\n * Merges partial input onto `previous`, so a later `.set({ yAxis: {...} })`\n * patches `label`/`range`/`ticks` independently. An unset `range`/`ticks` is the\n * auto-derive signal.\n */\nexport function resolveAxisDomain(\n domain: AxisDomainConfig | undefined,\n previous?: AxisDomainConfig\n): AxisDomainConfig {\n return {\n label: domain?.label ?? previous?.label ?? \"\",\n range: domain?.range ?? previous?.range,\n ticks: domain?.ticks ?? previous?.ticks,\n format: domain?.format ?? previous?.format,\n }\n}\n\n/**\n * Interpolates `range` and `ticks` numerically (ticks pairwise by index).\n * `label`, `format`, and either field when one side is auto, step at the\n * midpoint: there is no halfway between `$#,##0` and `0.0%`.\n */\nexport function lerpAxisDomain(\n from: AxisDomainConfig,\n to: AxisDomainConfig,\n t: number\n): AxisDomainConfig {\n return {\n label: t < 0.5 ? from.label : to.label,\n range: lerpOptionalRange(from.range, to.range, t),\n ticks: lerpOptionalTicks(from.ticks, to.ticks, t),\n format: t < 0.5 ? from.format : to.format,\n }\n}\n\nfunction lerpOptionalRange(\n from: Range | undefined,\n to: Range | undefined,\n t: number\n): Range | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n return [lerpNumber(from[0], to[0], t), lerpNumber(from[1], to[1], t)]\n}\n\nfunction lerpOptionalTicks(\n from: number[] | undefined,\n to: number[] | undefined,\n t: number\n): number[] | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n const n = Math.max(from.length, to.length)\n const out: number[] = []\n for (let i = 0; i < n; i++) {\n out.push(lerpNumber(from[i] ?? to[i], to[i] ?? from[i], t))\n }\n return out\n}\n\n/**\n * An axis domain part-way through a tween that leaves or reaches a `range` or\n * `ticks` left to the data: both ends as stored, and how far along. Only the\n * chart knows what an auto side draws as, so {@link settleAxisDomain} resolves\n * it there. Its own fields are the plain {@link lerpAxisDomain} of its ends, so\n * a mapper merging onto one still reads a domain.\n */\nexport interface AxisDomainBlend extends AxisDomainConfig {\n readonly blend: { readonly from: AxisDomainConfig; readonly to: AxisDomainConfig; readonly t: number }\n}\n\nfunction blendOf(domain: AxisDomainConfig): AxisDomainBlend[\"blend\"] | undefined {\n return (domain as Partial<AxisDomainBlend>).blend\n}\n\n/**\n * The axis entry tween behind `to({ yAxis: { range } })`. Between explicit\n * domains it is {@link lerpAxisDomain}, and a restated `range` without `ticks`\n * spreads ticks across it, keeping their count. When either end leaves `range`\n * or `ticks` to the data, the value between is an {@link AxisDomainBlend}, so a\n * rescale from an auto axis is continuous rather than a cut at the midpoint.\n */\nexport function lerpAxisEntry(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig {\n // The mapper merged the request onto `from`, so a field it left unstated is `from`'s own, by identity.\n const rangeMoved = to.range !== from.range\n const target = rangeMoved && to.range && to.ticks && to.ticks === from.ticks\n ? { ...to, ticks: markerValues(to.range, Math.max(2, to.ticks.length) - 1) }\n : to\n const blended = blendOf(from) !== undefined\n const moved = blended || rangeMoved || target.ticks !== from.ticks\n const auto = blended || from.range === undefined || from.ticks === undefined || target.range === undefined || target.ticks === undefined\n if (!moved || !auto) return lerpAxisDomain(from, target, t)\n if (t === 0) return from\n if (t === 1) return target\n const blend: AxisDomainBlend = { ...lerpAxisDomain(from, target, t), blend: { from, to: target, t } }\n return blend\n}\n\n/** `domain` as drawn: `drawn` resolves a plain domain's auto `range` and `ticks`; a blend is the lerp of what its ends draw. */\nexport function settleAxisDomain(domain: AxisDomainConfig, drawn: (domain: AxisDomainConfig) => AxisDomainConfig): AxisDomainConfig {\n const blend = blendOf(domain)\n if (!blend) return drawn(domain)\n return lerpAxisDomain(settleAxisDomain(blend.from, drawn), settleAxisDomain(blend.to, drawn), blend.t)\n}\n\n/** The colour tokens the default themes are built from: a dark plot panel with warm-grey axis furniture. */\nexport const CHART_PALETTE = {\n plotFill: \"#15130e\",\n borderColor: \"#4a4036\",\n gridColor: \"#2c2820\",\n /** Axis markers, axis captions and legend labels. */\n markerColor: \"#8a7f70\",\n /** A spotlit region's dashed rules and wash. */\n regionColor: \"#d99a3a\",\n} as const\n\n/** The out-of-the-box series palette, cycled by series index. */\nexport const DEFAULT_SERIES_COLORS = [\n \"#d9603b\",\n \"#8194ad\",\n \"#e0a93b\",\n \"#5e9d6b\",\n \"#9ec85a\",\n] as const\n\n/** Opacity an un-spotlighted series fades to, mark and legend entry alike. */\nexport const SPOTLIGHT_DIM = 0.2\n\n/**\n * Reads a numeric field off a row. A string column plots as 0, so a quoted or\n * unit-suffixed column needs the CSV parser's numeric coercion first.\n */\nexport function num(row: DataRecord, field: string | undefined): number {\n if (field === undefined) return 0\n const v = row[field]\n // A `NaN` or infinite cell is no more a measurement than a missing one: read\n // as 0, it cannot poison the scale and turn every point into `NaN`.\n return typeof v === \"number\" && Number.isFinite(v) ? v : 0\n}\n\n/** The counterpart to {@link num} for the columns a chart names things by; a missing cell reads as empty, not `\"undefined\"`. */\nexport function text(row: DataRecord, field: string | undefined): string {\n if (field === undefined || field === \"\") return \"\"\n const v = row[field]\n return v === undefined || v === null ? \"\" : String(v)\n}\n\n/**\n * Every numeric column of `data` in header order, skipping `exclude`. A column\n * is numeric only if every non-empty cell is a number, so a stray text cell\n * drops the column rather than plotting zeros.\n */\nexport function numericFields(\n data: DataRecord[],\n exclude: string[] = []\n): string[] {\n if (data.length === 0) return []\n const skip = new Set(exclude)\n const seen = new Set<string>()\n const order: string[] = []\n for (const row of data)\n for (const key of Object.keys(row))\n if (!skip.has(key) && !seen.has(key)) {\n seen.add(key)\n order.push(key)\n }\n\n return order.filter((key) => {\n let sawValue = false\n for (const row of data) {\n const v = row[key]\n if (v === undefined || v === \"\") continue\n if (typeof v !== \"number\") return false\n sawValue = true\n }\n return sawValue\n })\n}\n\n/** One axis's (x or y) style vocabulary. */\nexport interface AxisConfig {\n /** Style of each marker along the axis. */\n labelStyle: TextStyle\n titleStyle: TextStyle\n /** This axis's grid lines: weight and fill honoured, dash/cap/join ignored (they are filled rects). */\n lineStyle: Stroke\n /** Gap between the plot and the marker row; only the side facing the plot is read (`.top` horizontal, `.right` vertical). */\n tickPadding: Insets\n /** Gap between the marker row and the caption, read the same side. */\n titlePadding: Insets\n}\n\n/** A legend's per-series colour swatch. */\nexport interface LegendMarkerConfig {\n width: number\n height: number\n borderRadius: number\n stroke: Stroke\n shadow: Shadow\n}\n\nexport interface LegendConfig {\n padding: Insets\n /** Only the swatch carries the series colour. */\n textStyle: TextStyle\n itemGap: number\n markerStyle: LegendMarkerConfig\n}\n\n/** The plot panel a cartesian chart draws its marks over. */\nexport interface PlotAreaConfig {\n stroke: Stroke\n fill: Fill\n shadow: Shadow\n}\n\nconst AXIS_LABEL_STYLE: TextStyle = {\n fontSize: 24,\n fontWeight: 700,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_TITLE_STYLE: TextStyle = {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_LINE_STYLE: Stroke = { weight: 2, fill: CHART_PALETTE.gridColor }\n\nexport const DEFAULT_X_AXIS: AxisConfig = {\n labelStyle: AXIS_LABEL_STYLE,\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 20,\n titlePadding: 4,\n}\n\nexport const DEFAULT_Y_AXIS: AxisConfig = {\n labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: \"right\" },\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 40,\n titlePadding: 24,\n}\n\n/** Unpainted but framed: a chart reads against the stage rather than punching a panel into it. */\nexport const DEFAULT_PLOT_AREA: PlotAreaConfig = {\n fill: [],\n stroke: { weight: 6, fill: CHART_PALETTE.borderColor },\n shadow: [],\n}\n\nexport const DEFAULT_LEGEND: LegendConfig = {\n padding: 0,\n textStyle: {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"left\",\n fill: CHART_PALETTE.markerColor,\n },\n itemGap: 44,\n markerStyle: {\n width: 60,\n height: 24,\n borderRadius: 6,\n stroke: [],\n shadow: [],\n },\n}\n\n/** {@link DEFAULT_SERIES_COLORS} as 4px strokes. */\nexport const DEFAULT_SERIES_STROKES: Stroke[] = DEFAULT_SERIES_COLORS.map(\n (fill) => ({ weight: 4, fill })\n)\n\n/** {@link DEFAULT_SERIES_COLORS} as solid fills. */\nexport const DEFAULT_SERIES_FILLS: Fill[] = DEFAULT_SERIES_COLORS.map(\n (fill) => fill\n)\n\nexport function resolveAxisConfig(\n axis: Partial<AxisConfig> | undefined,\n previous: AxisConfig\n): AxisConfig {\n return {\n labelStyle: textOps.resolveStyle(axis?.labelStyle, previous.labelStyle),\n titleStyle: textOps.resolveStyle(axis?.titleStyle, previous.titleStyle),\n lineStyle: strokeOps.resolve(axis?.lineStyle ?? previous.lineStyle),\n tickPadding: insetsOps.resolve(\n axis?.tickPadding ?? previous.tickPadding,\n previous.tickPadding as InsetsResolved\n ),\n titlePadding: insetsOps.resolve(\n axis?.titlePadding ?? previous.titlePadding,\n previous.titlePadding as InsetsResolved\n ),\n }\n}\n\nexport function lerpAxisConfig(\n from: AxisConfig,\n to: AxisConfig,\n t: number\n): AxisConfig {\n return {\n labelStyle: textOps.lerpStyle(from.labelStyle, to.labelStyle, t),\n titleStyle: textOps.lerpStyle(from.titleStyle, to.titleStyle, t),\n lineStyle: strokeOps.lerp(\n from.lineStyle as StrokeResolved[],\n to.lineStyle as StrokeResolved[],\n t\n ),\n tickPadding: insetsOps.lerp(\n from.tickPadding as InsetsResolved,\n to.tickPadding as InsetsResolved,\n t\n ),\n titlePadding: insetsOps.lerp(\n from.titlePadding as InsetsResolved,\n to.titlePadding as InsetsResolved,\n t\n ),\n }\n}\n\nexport function resolvePlotArea(\n plotArea: Partial<PlotAreaConfig> | undefined,\n previous: PlotAreaConfig\n): PlotAreaConfig {\n return {\n fill: fillOps.resolve(plotArea?.fill ?? previous.fill),\n stroke: strokeOps.resolve(plotArea?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(plotArea?.shadow ?? previous.shadow),\n }\n}\n\nexport function lerpPlotArea(\n from: PlotAreaConfig,\n to: PlotAreaConfig,\n t: number\n): PlotAreaConfig {\n return {\n fill: fillOps.lerp(\n from.fill as FillResolved[],\n to.fill as FillResolved[],\n t\n ),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\nfunction resolveLegendMarkerConfig(\n marker: Partial<LegendMarkerConfig> | undefined,\n previous: LegendMarkerConfig\n): LegendMarkerConfig {\n return {\n width: marker?.width ?? previous.width,\n height: marker?.height ?? previous.height,\n borderRadius: marker?.borderRadius ?? previous.borderRadius,\n stroke: strokeOps.resolve(marker?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(marker?.shadow ?? previous.shadow),\n }\n}\n\nfunction lerpLegendMarkerConfig(\n from: LegendMarkerConfig,\n to: LegendMarkerConfig,\n t: number\n): LegendMarkerConfig {\n return {\n width: lerpNumber(from.width, to.width, t),\n height: lerpNumber(from.height, to.height, t),\n borderRadius: lerpNumber(from.borderRadius, to.borderRadius, t),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\n/** A legend theme as the author may state it: every branch optional. */\nexport type LegendTheme = Partial<Omit<LegendConfig, \"markerStyle\">> & {\n markerStyle?: Partial<LegendMarkerConfig>\n}\n\nexport function resolveLegendConfig(\n legend: LegendTheme | undefined,\n previous: LegendConfig\n): LegendConfig {\n return {\n padding: insetsOps.resolve(\n legend?.padding ?? previous.padding,\n previous.padding as InsetsResolved\n ),\n textStyle: textOps.resolveStyle(legend?.textStyle, previous.textStyle),\n itemGap: legend?.itemGap ?? previous.itemGap,\n markerStyle: resolveLegendMarkerConfig(\n legend?.markerStyle,\n previous.markerStyle\n ),\n }\n}\n\nexport function lerpLegendConfig(\n from: LegendConfig,\n to: LegendConfig,\n t: number\n): LegendConfig {\n return {\n padding: insetsOps.lerp(\n from.padding as InsetsResolved,\n to.padding as InsetsResolved,\n t\n ),\n textStyle: textOps.lerpStyle(from.textStyle, to.textStyle, t),\n itemGap: lerpNumber(from.itemGap, to.itemGap, t),\n markerStyle: lerpLegendMarkerConfig(from.markerStyle, to.markerStyle, t),\n }\n}\n\n/** A palette override replaces the previous palette outright. */\nexport function resolveSeriesStrokes(\n styles: Stroke[] | undefined,\n previous: Stroke[]\n): Stroke[] {\n return (styles ?? previous).map((s) => strokeOps.resolve(s))\n}\n\n/** Pairwise by index; a palette that grows/shrinks holds the longer side's tail. */\nexport function lerpSeriesStrokes(\n from: Stroke[],\n to: Stroke[],\n t: number\n): Stroke[] {\n const n = Math.max(from.length, to.length)\n const out: Stroke[] = []\n for (let i = 0; i < n; i++) {\n const a = (from[i] ?? to[i]) as StrokeResolved[]\n const b = (to[i] ?? from[i]) as StrokeResolved[]\n out.push(strokeOps.lerp(a, b, t))\n }\n return out\n}\n\n/** The fill-palette twin of {@link resolveSeriesStrokes}, for filled marks. */\nexport function resolveSeriesFills(\n fills: Fill[] | undefined,\n previous: Fill[]\n): Fill[] {\n return (fills ?? previous).map((f) => fillOps.resolve(f))\n}\n\n/** The fill-palette twin of {@link lerpSeriesStrokes}. */\nexport function lerpSeriesFills(from: Fill[], to: Fill[], t: number): Fill[] {\n const n = Math.max(from.length, to.length)\n const out: Fill[] = []\n for (let i = 0; i < n; i++) {\n const a = (from[i] ?? to[i]) as FillResolved[]\n const b = (to[i] ?? from[i]) as FillResolved[]\n out.push(fillOps.lerp(a, b, t))\n }\n return out\n}\n\n/**\n * The stroke for series `index`: the palette's entry at `index % palette.length`,\n * with the series' own `fill`, if set, replacing just the topmost layer's colour.\n */\nexport function resolveSeriesStroke(\n palette: Stroke[],\n series: ChartSeries,\n index: number\n): Stroke {\n const entry: Stroke =\n palette.length > 0\n ? palette[index % palette.length]\n : { weight: 4, fill: \"white\" }\n if (series.fill == null) return entry\n const layers = strokeOps.resolve(entry)\n if (layers.length === 0) return { weight: 4, fill: series.fill }\n const next = [...layers]\n next[next.length - 1] = {\n ...next[next.length - 1],\n fill: fillOps.resolve(series.fill),\n }\n return next\n}\n\n/** The colour {@link resolveSeriesStroke} draws series `index` in, for a legend swatch. */\nexport function resolveSeriesFill(\n palette: Stroke[],\n series: ChartSeries,\n index: number\n): Fill {\n const layers = strokeOps.resolve(resolveSeriesStroke(palette, series, index))\n return layers[layers.length - 1]?.fill ?? \"white\"\n}\n\n/**\n * Format a marker value: integers plain, otherwise one decimal, or as many as\n * the tick `step` needs to tell neighbours apart (a unit axis ticked every 0.05\n * gets two, not `0.1 0.1 0.2 0.2 0.3`). Trailing zeros are dropped.\n */\nexport function formatMarker(value: number, step?: number): string {\n if (Number.isInteger(value)) return String(value)\n const decimals = Math.max(1, step === undefined ? 1 : decimalsFor(step))\n return value.toFixed(decimals).replace(/(\\.\\d*?)0+$/, \"$1\").replace(/\\.$/, \"\")\n}\n\n/** Decimal places needed to write `step` exactly, capped at six. */\nfunction decimalsFor(step: number): number {\n if (!(step > 0) || !Number.isFinite(step)) return 1\n for (let d = 0; d <= 6; d++) {\n const scaled = step * 10 ** d\n if (Math.abs(scaled - Math.round(scaled)) < 1e-6 * Math.max(1, scaled)) return d\n }\n // An irrational-looking step (a third): as many places as separate the ticks.\n return Math.min(6, Math.max(1, Math.ceil(-Math.log10(step)) + 1))\n}\n\n/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */\nexport function markerStep(markers: readonly number[]): number | undefined {\n const sorted = [...markers].filter(Number.isFinite).sort((a, b) => a - b)\n let step: number | undefined\n for (let i = 1; i < sorted.length; i++) {\n const gap = sorted[i] - sorted[i - 1]\n if (gap > 1e-12 && (step === undefined || gap < step)) step = gap\n }\n return step\n}\n\n/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */\nexport function formatPercent(fraction: number): string {\n const pct = fraction * 100\n if (Number.isInteger(pct)) return `${pct}%`\n return `${pct.toFixed(1).replace(/\\.0$/, \"\")}%`\n}\n\n/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */\nexport function markerValues([min, max]: Range, markerCount: number): number[] {\n const n = Math.max(2, Math.round(markerCount))\n return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i)\n}\n"]}
@@ -1,60 +1,25 @@
1
- import { type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
1
+ import { type NodeOf, type Node2D, type Node2DProps as _Node2DProps } from "@motionscript/sdk";
2
2
  import { type Arrival } from "./motion.js";
3
3
  import { type AxisConfig, type Range } from "./shared.js";
4
- export interface VerticalAxisProps extends Node2DProps {
5
- /** `[min, max]` of the vertical scale the markers are positioned within. */
6
- range: Range;
7
- /**
8
- * Tick values (in data units) to draw up the axis, each placed by its fraction
9
- * across {@link VerticalAxisProps.range}. Need not be evenly spaced or include
10
- * the ends.
11
- */
12
- markers: number[];
13
- /**
14
- * How each marker is captioned, one per entry of `markers` and in its order.
15
- * Empty (the default), or short, captions a marker with its bare numeric
16
- * reading; a chart with a number format on this axis writes them through it.
17
- */
18
- captions: string[];
19
- /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
20
- axis: AxisConfig;
21
- /**
22
- * Rotated caption drawn in the gutter to the left of the marker column. Empty
23
- * string (the default) hides it — no caption node is built and no label gutter
24
- * is reserved.
25
- */
26
- label: string;
27
- }
28
- /** How a tick value is captioned — see {@link VerticalAxisProps.captions}. */
29
- export type MarkerLabel = (value: number) => string;
30
4
  /** What a marker's caption reads: the one listed for its value, else its bare reading. */
31
5
  export declare function markerCaption(s: {
32
6
  readonly markers: readonly number[];
33
7
  readonly captions: readonly string[];
34
8
  }, value: number): string;
35
9
  /**
36
- * The numeric vertical axis shared by the cartesian charts: a **column of
37
- * {@link Text} nodes**, one per marker value, running top-to-bottom (highest
38
- * value at the top). Pure layout — no `Graphics` — so the markers are real text
39
- * nodes the scene can measure, restyle, or animate individually.
40
- *
41
- * Each marker is positioned so its centre lands exactly on its value's fraction
42
- * across `range` within the axis's filled height, so unevenly-spaced markers
43
- * land where their values fall. Both the caption and the position are *bound*,
44
- * not snapshotted: a chart that rescales its axes (see `LineChart.zoomTo`)
45
- * tweens `range`/`markers` live. Only the marker **count** is fixed at
46
- * construction.
47
- *
48
- * `enter` staggers them in **bottom-to-top**: each marker starts pushed a
49
- * little to the right and transparent, then fades and slides left into place.
50
- * The resting state is the landed one, so a chart that is never told to enter
51
- * still reads as a finished chart.
10
+ * The numeric vertical axis the cartesian charts share: a column of {@link Text}
11
+ * markers, highest at the top, each centred on its value's fraction across
12
+ * `range`. Caption and position are bound, so a rescale tweens live; only the
13
+ * marker count is fixed at construction. The resting state is landed.
52
14
  */
53
15
  export declare const VerticalAxis: import("@motionscript/sdk").Component<"verticalAxis", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
54
16
  readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
17
+ /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
55
18
  readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
19
+ /** One caption per marker in its order; a missing one reads as the bare numeric value. */
56
20
  readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
57
21
  readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
22
+ /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
58
23
  readonly label: "";
59
24
  readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
60
25
  }>, {
@@ -62,18 +27,24 @@ export declare const VerticalAxis: import("@motionscript/sdk").Component<"vertic
62
27
  readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
63
28
  readonly slide: import("@motionscript/sdk").Type<number, number, false>;
64
29
  };
65
- }, null, Node2D<Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
30
+ }, null, Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
66
31
  readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
32
+ /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
67
33
  readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
34
+ /** One caption per marker in its order; a missing one reads as the bare numeric value. */
68
35
  readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
69
36
  readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
37
+ /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
70
38
  readonly label: "";
71
39
  readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
72
40
  }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
73
41
  readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
42
+ /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
74
43
  readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
44
+ /** One caption per marker in its order; a missing one reads as the bare numeric value. */
75
45
  readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
76
46
  readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
47
+ /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
77
48
  readonly label: "";
78
49
  readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
79
50
  }>, {
@@ -81,6 +52,6 @@ export declare const VerticalAxis: import("@motionscript/sdk").Component<"vertic
81
52
  readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
82
53
  readonly slide: import("@motionscript/sdk").Type<number, number, false>;
83
54
  };
84
- }, Node2D<Node2DProps>>>>;
55
+ }, Node2D<_Node2DProps>>>>;
85
56
  export type VerticalAxis = NodeOf<typeof VerticalAxis>;
86
57
  //# sourceMappingURL=vertical-axis.d.ts.map