@motionscript/charts 0.0.0-stage → 0.1.0-alpha.10

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 (158) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +49 -0
  4. package/README.md +98 -3
  5. package/dist/bar-chart/bar-chart.d.ts +191 -0
  6. package/dist/bar-chart/bar-chart.d.ts.map +1 -0
  7. package/dist/bar-chart/bar-chart.js +431 -0
  8. package/dist/bar-chart/bar-chart.js.map +1 -0
  9. package/dist/bar-chart/category-axis.d.ts +71 -0
  10. package/dist/bar-chart/category-axis.d.ts.map +1 -0
  11. package/dist/bar-chart/category-axis.js +119 -0
  12. package/dist/bar-chart/category-axis.js.map +1 -0
  13. package/dist/bar-chart/chart-bars.d.ts +129 -0
  14. package/dist/bar-chart/chart-bars.d.ts.map +1 -0
  15. package/dist/bar-chart/chart-bars.js +181 -0
  16. package/dist/bar-chart/chart-bars.js.map +1 -0
  17. package/dist/bar-chart/index.d.ts +16 -0
  18. package/dist/bar-chart/index.d.ts.map +1 -0
  19. package/dist/bar-chart/index.js +12 -0
  20. package/dist/bar-chart/index.js.map +1 -0
  21. package/dist/bar-chart/shared.d.ts +146 -0
  22. package/dist/bar-chart/shared.d.ts.map +1 -0
  23. package/dist/bar-chart/shared.js +182 -0
  24. package/dist/bar-chart/shared.js.map +1 -0
  25. package/dist/browser/chunks/chunk-TJNHLQGV.js +2 -0
  26. package/dist/browser/chunks/chunk-TJNHLQGV.js.map +7 -0
  27. package/dist/browser/index.js +2 -0
  28. package/dist/browser/index.js.map +7 -0
  29. package/dist/browser/kit.js +2 -0
  30. package/dist/browser/kit.js.map +7 -0
  31. package/dist/browser/manifest.json +13 -0
  32. package/dist/engine.d.ts +29 -0
  33. package/dist/engine.d.ts.map +1 -0
  34. package/dist/engine.js +29 -0
  35. package/dist/engine.js.map +1 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +6 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/kit/cartesian.d.ts +44 -0
  41. package/dist/kit/cartesian.d.ts.map +1 -0
  42. package/dist/kit/cartesian.js +59 -0
  43. package/dist/kit/cartesian.js.map +1 -0
  44. package/dist/kit/chart-border.d.ts +27 -0
  45. package/dist/kit/chart-border.d.ts.map +1 -0
  46. package/dist/kit/chart-border.js +28 -0
  47. package/dist/kit/chart-border.js.map +1 -0
  48. package/dist/kit/chart-canvas.d.ts +67 -0
  49. package/dist/kit/chart-canvas.d.ts.map +1 -0
  50. package/dist/kit/chart-canvas.js +68 -0
  51. package/dist/kit/chart-canvas.js.map +1 -0
  52. package/dist/kit/chart-legend.d.ts +164 -0
  53. package/dist/kit/chart-legend.d.ts.map +1 -0
  54. package/dist/kit/chart-legend.js +163 -0
  55. package/dist/kit/chart-legend.js.map +1 -0
  56. package/dist/kit/entries.d.ts +17 -0
  57. package/dist/kit/entries.d.ts.map +1 -0
  58. package/dist/kit/entries.js +19 -0
  59. package/dist/kit/entries.js.map +1 -0
  60. package/dist/kit/motion.d.ts +48 -0
  61. package/dist/kit/motion.d.ts.map +1 -0
  62. package/dist/kit/motion.js +63 -0
  63. package/dist/kit/motion.js.map +1 -0
  64. package/dist/kit/paints.d.ts +10 -0
  65. package/dist/kit/paints.d.ts.map +1 -0
  66. package/dist/kit/paints.js +12 -0
  67. package/dist/kit/paints.js.map +1 -0
  68. package/dist/kit/shared.d.ts +302 -0
  69. package/dist/kit/shared.d.ts.map +1 -0
  70. package/dist/kit/shared.js +496 -0
  71. package/dist/kit/shared.js.map +1 -0
  72. package/dist/kit/vertical-axis.d.ts +86 -0
  73. package/dist/kit/vertical-axis.d.ts.map +1 -0
  74. package/dist/kit/vertical-axis.js +141 -0
  75. package/dist/kit/vertical-axis.js.map +1 -0
  76. package/dist/line-chart/chart-line.d.ts +74 -0
  77. package/dist/line-chart/chart-line.d.ts.map +1 -0
  78. package/dist/line-chart/chart-line.js +135 -0
  79. package/dist/line-chart/chart-line.js.map +1 -0
  80. package/dist/line-chart/chart-region.d.ts +46 -0
  81. package/dist/line-chart/chart-region.d.ts.map +1 -0
  82. package/dist/line-chart/chart-region.js +67 -0
  83. package/dist/line-chart/chart-region.js.map +1 -0
  84. package/dist/line-chart/horizontal-axis.d.ts +79 -0
  85. package/dist/line-chart/horizontal-axis.d.ts.map +1 -0
  86. package/dist/line-chart/horizontal-axis.js +129 -0
  87. package/dist/line-chart/horizontal-axis.js.map +1 -0
  88. package/dist/line-chart/index.d.ts +22 -0
  89. package/dist/line-chart/index.d.ts.map +1 -0
  90. package/dist/line-chart/index.js +19 -0
  91. package/dist/line-chart/index.js.map +1 -0
  92. package/dist/line-chart/line-chart.d.ts +200 -0
  93. package/dist/line-chart/line-chart.d.ts.map +1 -0
  94. package/dist/line-chart/line-chart.js +473 -0
  95. package/dist/line-chart/line-chart.js.map +1 -0
  96. package/dist/line-chart/shared.d.ts +171 -0
  97. package/dist/line-chart/shared.d.ts.map +1 -0
  98. package/dist/line-chart/shared.js +285 -0
  99. package/dist/line-chart/shared.js.map +1 -0
  100. package/dist/line-chart/x-scale.d.ts +77 -0
  101. package/dist/line-chart/x-scale.d.ts.map +1 -0
  102. package/dist/line-chart/x-scale.js +313 -0
  103. package/dist/line-chart/x-scale.js.map +1 -0
  104. package/dist/nodes.d.ts +17 -0
  105. package/dist/nodes.d.ts.map +1 -0
  106. package/dist/nodes.js +18 -0
  107. package/dist/nodes.js.map +1 -0
  108. package/dist/pie-chart/index.d.ts +18 -0
  109. package/dist/pie-chart/index.d.ts.map +1 -0
  110. package/dist/pie-chart/index.js +14 -0
  111. package/dist/pie-chart/index.js.map +1 -0
  112. package/dist/pie-chart/pie-chart.d.ts +152 -0
  113. package/dist/pie-chart/pie-chart.d.ts.map +1 -0
  114. package/dist/pie-chart/pie-chart.js +222 -0
  115. package/dist/pie-chart/pie-chart.js.map +1 -0
  116. package/dist/pie-chart/pie-legend.d.ts +113 -0
  117. package/dist/pie-chart/pie-legend.d.ts.map +1 -0
  118. package/dist/pie-chart/pie-legend.js +117 -0
  119. package/dist/pie-chart/pie-legend.js.map +1 -0
  120. package/dist/pie-chart/pie-ring.d.ts +304 -0
  121. package/dist/pie-chart/pie-ring.d.ts.map +1 -0
  122. package/dist/pie-chart/pie-ring.js +680 -0
  123. package/dist/pie-chart/pie-ring.js.map +1 -0
  124. package/dist/pie-chart/shared.d.ts +216 -0
  125. package/dist/pie-chart/shared.d.ts.map +1 -0
  126. package/dist/pie-chart/shared.js +246 -0
  127. package/dist/pie-chart/shared.js.map +1 -0
  128. package/package.json +72 -3
  129. package/registry.json +23 -0
  130. package/src/bar-chart/bar-chart.ts +542 -0
  131. package/src/bar-chart/category-axis.ts +162 -0
  132. package/src/bar-chart/chart-bars.ts +287 -0
  133. package/src/bar-chart/index.ts +31 -0
  134. package/src/bar-chart/shared.ts +354 -0
  135. package/src/engine.ts +28 -0
  136. package/src/index.ts +5 -0
  137. package/src/kit/cartesian.ts +81 -0
  138. package/src/kit/chart-border.ts +50 -0
  139. package/src/kit/chart-canvas.ts +122 -0
  140. package/src/kit/chart-legend.ts +229 -0
  141. package/src/kit/entries.ts +20 -0
  142. package/src/kit/motion.ts +90 -0
  143. package/src/kit/paints.ts +15 -0
  144. package/src/kit/shared.ts +782 -0
  145. package/src/kit/vertical-axis.ts +194 -0
  146. package/src/line-chart/chart-line.ts +156 -0
  147. package/src/line-chart/chart-region.ts +90 -0
  148. package/src/line-chart/horizontal-axis.ts +151 -0
  149. package/src/line-chart/index.ts +39 -0
  150. package/src/line-chart/line-chart.ts +598 -0
  151. package/src/line-chart/shared.ts +473 -0
  152. package/src/line-chart/x-scale.ts +382 -0
  153. package/src/nodes.ts +18 -0
  154. package/src/pie-chart/index.ts +37 -0
  155. package/src/pie-chart/pie-chart.ts +296 -0
  156. package/src/pie-chart/pie-legend.ts +169 -0
  157. package/src/pie-chart/pie-ring.ts +848 -0
  158. package/src/pie-chart/shared.ts +496 -0
@@ -0,0 +1,313 @@
1
+ /**
2
+ * What a line chart's x column *means* — the one question that has to be
3
+ * answered before a row can be given a position along the bottom of the plot.
4
+ *
5
+ * A y column is always a magnitude. An x column is one of three things, and
6
+ * which one is a property of the data rather than something the author states:
7
+ *
8
+ * - **numeric** — `0, 5, 10` — plot the number.
9
+ * - **time** — `Jan`, `2026-03`, `2026-W12`, `2026-03-14` — plot the instant,
10
+ * so samples a month apart sit a month apart and a gap in the data reads as a
11
+ * gap.
12
+ * - **ordinal** — anything else — plot the row's position, evenly spaced.
13
+ *
14
+ * Before this, every x column went through `num()`, which reads a non-numeric
15
+ * cell as `0`. A `Month` column of `Jan…Dec` therefore stacked all twelve
16
+ * points on one x and drew a vertical line — no error, no empty chart, just a
17
+ * wrong picture. That is the failure this module exists to remove: every column
18
+ * now plots as *something*, and the something is the reading a person would
19
+ * give it.
20
+ *
21
+ * The captions come back off the rows rather than out of a formatter. A tick on
22
+ * a time or ordinal scale is chosen *from the data* (see {@link XScale.ticks}),
23
+ * so the label it wants is the cell the author wrote — `Jan`, not `1970-01-01`,
24
+ * and `2026-W12`, not the Monday it resolves to. Only a tick that is not a
25
+ * sample — an author-set range, or a `zoomTo` mid-flight — needs formatting,
26
+ * and that is the one case {@link formatInstant} covers.
27
+ */
28
+ import { formatMarker, markerValues, num, text, } from "../kit/shared.js";
29
+ import { formatNumber } from "@motionscript/sdk/component";
30
+ // ---- Time parsing --------------------------------------------------------
31
+ const DAY = 86_400_000;
32
+ const MONTHS = [
33
+ "january",
34
+ "february",
35
+ "march",
36
+ "april",
37
+ "may",
38
+ "june",
39
+ "july",
40
+ "august",
41
+ "september",
42
+ "october",
43
+ "november",
44
+ "december",
45
+ ];
46
+ /**
47
+ * The year a cell that names no year is dated into.
48
+ *
49
+ * Any year would place `Jan…Dec` in the right order at the right spacing; a
50
+ * leap year is the one that also spaces February correctly against a column
51
+ * that *does* carry years, so the two read alike.
52
+ */
53
+ const NOMINAL_YEAR = 2024;
54
+ /**
55
+ * Month index for any unambiguous abbreviation of a month name — `jan`, `sept`,
56
+ * `january` — or -1.
57
+ *
58
+ * Three letters minimum, and then a prefix match, which is what lets `sept`
59
+ * through without letting `janitor` through: a longer word has to still *be*
60
+ * the month.
61
+ */
62
+ function monthIndex(word) {
63
+ if (word.length < 3)
64
+ return -1;
65
+ return MONTHS.findIndex((month) => month.startsWith(word));
66
+ }
67
+ /** The Monday of ISO week `week` in `year`, as an epoch timestamp. */
68
+ function isoWeekStart(year, week) {
69
+ // ISO week 1 is the week containing 4 January, and weeks start on Monday.
70
+ const jan4 = Date.UTC(year, 0, 4);
71
+ const weekday = (new Date(jan4).getUTCDay() + 6) % 7; // Monday = 0
72
+ return jan4 - weekday * DAY + (week - 1) * 7 * DAY;
73
+ }
74
+ /**
75
+ * One cell read as an instant, or `null` when it isn't one.
76
+ *
77
+ * Deliberately **not** `Date.parse`. That accepts `"5"`, `"Q3"` and a good deal
78
+ * else besides, differs between engines on anything non-ISO, and reads a bare
79
+ * `2026-03-14` as UTC but `2026/03/14` as local — three ways for a column to be
80
+ * silently misread as time. Every form below is matched explicitly, and an
81
+ * ambiguous all-numeric date (`03/04/2026` — March or April, depending on where
82
+ * the author lives) is deliberately not one of them.
83
+ */
84
+ export function parseInstant(raw) {
85
+ if (typeof raw !== "string")
86
+ return null;
87
+ const s = raw.trim().toLowerCase();
88
+ if (s === "")
89
+ return null;
90
+ // 2026-03-14 · 2026/03/14 · 2026-03 · 2026/03
91
+ const ymd = /^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(s);
92
+ if (ymd) {
93
+ const month = Number(ymd[2]);
94
+ const day = ymd[3] === undefined ? 1 : Number(ymd[3]);
95
+ if (month < 1 || month > 12 || day < 1 || day > 31)
96
+ return null;
97
+ return Date.UTC(Number(ymd[1]), month - 1, day);
98
+ }
99
+ // 2026-W12 · 2026W12 · w12 · week 12
100
+ const week = /^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(s);
101
+ if (week) {
102
+ const n = Number(week[2]);
103
+ if (n < 1 || n > 53)
104
+ return null;
105
+ return isoWeekStart(week[1] === undefined ? NOMINAL_YEAR : Number(week[1]), n);
106
+ }
107
+ // jan · january · jan 2026 · january-2026 · 2026 jan
108
+ const named = /^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(s);
109
+ if (named) {
110
+ const month = monthIndex(named[2]);
111
+ if (month >= 0) {
112
+ const year = named[1] ?? named[3];
113
+ const y = year === undefined ? NOMINAL_YEAR : Number(year);
114
+ return Date.UTC(y, month, 1);
115
+ }
116
+ }
117
+ // 14 mar 2026 · mar 14 2026 · mar 14, 2026
118
+ const dayNamed = /^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(s);
119
+ if (dayNamed) {
120
+ const month = monthIndex(dayNamed[2] ?? dayNamed[3]);
121
+ const day = Number(dayNamed[1] ?? dayNamed[4]);
122
+ if (month >= 0 && day >= 1 && day <= 31) {
123
+ return Date.UTC(Number(dayNamed[5]), month, day);
124
+ }
125
+ }
126
+ return null;
127
+ }
128
+ /**
129
+ * An instant captioned at the coarsest granularity the axis's own span can tell
130
+ * apart — a decade of samples reads as years, a year of them as months.
131
+ *
132
+ * Only reached for a tick that is *not* one of the rows (an author-set range, a
133
+ * `zoomTo` part-way through). A tick that is a sample is captioned with the
134
+ * cell the author wrote; see the note at the top of this file.
135
+ */
136
+ export function formatInstant(value, span) {
137
+ const date = new Date(value);
138
+ const year = date.getUTCFullYear();
139
+ const month = MONTHS[date.getUTCMonth()].slice(0, 3);
140
+ const label = month.charAt(0).toUpperCase() + month.slice(1);
141
+ if (span > 4 * 365 * DAY)
142
+ return String(year);
143
+ if (span > 60 * DAY)
144
+ return `${label} ${year}`;
145
+ return `${label} ${date.getUTCDate()}`;
146
+ }
147
+ // ---- Column reading ------------------------------------------------------
148
+ /**
149
+ * Whether every non-empty cell of `field` holds a number.
150
+ *
151
+ * The same rule `numericFields` applies, asked of one column: a single text
152
+ * cell in an otherwise numeric column takes the whole column off the numeric
153
+ * scale, because plotting that row at 0 is the failure this module is here to
154
+ * stop.
155
+ */
156
+ function isNumericColumn(data, field) {
157
+ let sawValue = false;
158
+ for (const row of data) {
159
+ const v = row[field];
160
+ if (v === undefined || v === null || v === "")
161
+ continue;
162
+ if (typeof v !== "number")
163
+ return false;
164
+ sawValue = true;
165
+ }
166
+ return sawValue;
167
+ }
168
+ /**
169
+ * Every non-empty cell of `field` parsed as an instant, or `null` if any one of
170
+ * them isn't one — in which case the column isn't a time column at all.
171
+ *
172
+ * A blank cell keeps its slot, so the returned list stays index-aligned with
173
+ * the rows, and takes the nearest known instant: a hole in an x column is a row
174
+ * whose date the file didn't say, and stacking it on the epoch would drag the
175
+ * whole scale back fifty years to make room for it.
176
+ */
177
+ function instantColumn(data, field) {
178
+ const parsed = [];
179
+ let sawValue = false;
180
+ for (const row of data) {
181
+ const raw = row[field];
182
+ if (raw === undefined || raw === null || raw === "") {
183
+ parsed.push(null);
184
+ continue;
185
+ }
186
+ const t = parseInstant(raw);
187
+ if (t === null)
188
+ return null;
189
+ parsed.push(t);
190
+ sawValue = true;
191
+ }
192
+ if (!sawValue)
193
+ return null;
194
+ const first = parsed.find((t) => t !== null);
195
+ let last = first;
196
+ return parsed.map((t) => (t === null ? last : (last = t)));
197
+ }
198
+ /** `[min, max]` of `values`, or `[0, 1]` when there is nothing to span. */
199
+ function extentOf(values) {
200
+ let lo = Infinity;
201
+ let hi = -Infinity;
202
+ for (const v of values) {
203
+ if (v < lo)
204
+ lo = v;
205
+ if (v > hi)
206
+ hi = v;
207
+ }
208
+ return lo <= hi ? [lo, hi] : [0, 1];
209
+ }
210
+ /**
211
+ * Ticks spanning `range`, each one **a sample** — a row the author can point at
212
+ * in their file — placed as near as it can be to where an evenly spaced tick
213
+ * would have gone.
214
+ *
215
+ * Two things have to hold at once, and picking either alone gets it wrong.
216
+ * Ticks must be *samples*, because a caption between two of them has nothing to
217
+ * say (two-thirds of the way through March is not a month, and on a category
218
+ * column it is not anything at all). And they must be *spread*, because the
219
+ * labels sit side by side in a row: taking every nth sample instead puts five
220
+ * dates in the two weeks a burst of rows happens to cover and prints them on
221
+ * top of each other, which is what a column with a gap in it does.
222
+ *
223
+ * Walking the targets rather than the samples is what satisfies both. A run of
224
+ * rows too close together to caption collapses to one tick — consecutive
225
+ * targets pick the same sample and the duplicate is dropped — so a chart asked
226
+ * for five ticks across a gappy column draws four honest ones instead of five
227
+ * overlapping.
228
+ */
229
+ function sampledTicks(positions, [min, max], divisions) {
230
+ const inside = positions.filter((v) => v >= min && v <= max);
231
+ const unique = [...new Set(inside)].sort((a, b) => a - b);
232
+ if (unique.length === 0)
233
+ return markerValues([min, max], divisions);
234
+ const nearest = (target) => unique.reduce((best, v) => Math.abs(v - target) < Math.abs(best - target) ? v : best);
235
+ const out = [];
236
+ for (const target of markerValues([min, max], divisions)) {
237
+ const tick = nearest(target);
238
+ if (out[out.length - 1] !== tick)
239
+ out.push(tick);
240
+ }
241
+ return out;
242
+ }
243
+ /**
244
+ * The caption a tick carries on a sample-based scale: the cell of the row it
245
+ * came from, or `fallback` when the tick isn't a sample after all.
246
+ */
247
+ function labelBySample(positions, captions, value, fallback) {
248
+ const i = positions.indexOf(value);
249
+ return i >= 0 ? captions[i] : fallback(value);
250
+ }
251
+ /** Scales already resolved, by data array, then by field and pattern. */
252
+ const scales = new WeakMap();
253
+ /**
254
+ * How `field` positions the rows: the number it holds, the instant it names, or
255
+ * failing both, the row's own place in the file.
256
+ *
257
+ * Kept per `data` array: a chart's bound props ask a dozen times a frame, and
258
+ * parsing every row's instant each time was most of a frame.
259
+ */
260
+ export function resolveXScale(data, field, pattern) {
261
+ let byKey = scales.get(data);
262
+ if (!byKey)
263
+ scales.set(data, (byKey = new Map()));
264
+ const key = JSON.stringify([field, pattern ?? null]);
265
+ let scale = byKey.get(key);
266
+ if (!scale)
267
+ byKey.set(key, (scale = xScaleOf(data, field, pattern)));
268
+ return scale;
269
+ }
270
+ function xScaleOf(data, field,
271
+ /**
272
+ * The number-format pattern for a *numeric* column. Ignored by the other two
273
+ * kinds, and correctly so: a tick on those is captioned with the cell the
274
+ * author wrote, and `Jan` has no decimal places.
275
+ */
276
+ pattern) {
277
+ if (field !== "" && isNumericColumn(data, field)) {
278
+ const positions = data.map((row) => num(row, field));
279
+ return {
280
+ kind: "numeric",
281
+ at: (i) => positions[i] ?? 0,
282
+ extent: extentOf(positions),
283
+ label: (value) => pattern === undefined ? formatMarker(value) : formatNumber(value, pattern),
284
+ // Round numbers, evenly spaced — a continuous axis is read by its scale
285
+ // rather than by which samples happen to be on it.
286
+ ticks: markerValues,
287
+ };
288
+ }
289
+ const captions = data.map((row) => text(row, field));
290
+ const instants = field === "" ? null : instantColumn(data, field);
291
+ if (instants) {
292
+ const extent = extentOf(instants);
293
+ const span = extent[1] - extent[0];
294
+ return {
295
+ kind: "time",
296
+ at: (i) => instants[i] ?? 0,
297
+ extent,
298
+ label: (value) => labelBySample(instants, captions, value, (v) => formatInstant(v, span)),
299
+ ticks: (range, divisions) => sampledTicks(instants, range, divisions),
300
+ };
301
+ }
302
+ const positions = data.map((_, i) => i);
303
+ return {
304
+ kind: "ordinal",
305
+ at: (i) => i,
306
+ // `[0, n-1]` rather than the tidy `[0, n]`: the first and last rows sit on
307
+ // the plot's edges, which is where a reader looks for them.
308
+ extent: positions.length > 0 ? [0, positions.length - 1] : [0, 1],
309
+ label: (value) => captions[Math.round(value)] ?? "",
310
+ ticks: (range, divisions) => sampledTicks(positions, range, divisions),
311
+ };
312
+ }
313
+ //# sourceMappingURL=x-scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x-scale.js","sourceRoot":"","sources":["../../src/line-chart/x-scale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,GAAG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AAE,EAAE,CAAC,CAAC;QACZ,2EAA2E;QAC3E,4DAA4D;QAC5D,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACjE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;QACnD,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC;KACvE,CAAA;AACH,CAAC","sourcesContent":["/**\n * What a line chart's x column *means* — the one question that has to be\n * answered before a row can be given a position along the bottom of the plot.\n *\n * A y column is always a magnitude. An x column is one of three things, and\n * which one is a property of the data rather than something the author states:\n *\n * - **numeric** — `0, 5, 10` — plot the number.\n * - **time** — `Jan`, `2026-03`, `2026-W12`, `2026-03-14` — plot the instant,\n * so samples a month apart sit a month apart and a gap in the data reads as a\n * gap.\n * - **ordinal** — anything else — plot the row's position, evenly spaced.\n *\n * Before this, every x column went through `num()`, which reads a non-numeric\n * cell as `0`. A `Month` column of `Jan…Dec` therefore stacked all twelve\n * points on one x and drew a vertical line — no error, no empty chart, just a\n * wrong picture. That is the failure this module exists to remove: every column\n * now plots as *something*, and the something is the reading a person would\n * give it.\n *\n * The captions come back off the rows rather than out of a formatter. A tick on\n * a time or ordinal scale is chosen *from the data* (see {@link XScale.ticks}),\n * so the label it wants is the cell the author wrote — `Jan`, not `1970-01-01`,\n * and `2026-W12`, not the Monday it resolves to. Only a tick that is not a\n * sample — an author-set range, or a `zoomTo` mid-flight — needs formatting,\n * and that is the one case {@link formatInstant} covers.\n */\n\nimport type { DataRecord } from \"@motionscript/sdk\"\n\nimport {\n formatMarker,\n markerValues,\n num,\n text,\n type Range,\n} from \"../kit/shared\"\nimport { formatNumber } from \"@motionscript/sdk/component\"\n\n/** How an x column's cells become positions along the axis. */\nexport type XScaleKind = \"numeric\" | \"time\" | \"ordinal\"\n\n/**\n * An x column resolved into positions, captions and ticks.\n *\n * The three kinds differ in all three answers, so they are three closures built\n * once per (data, column) rather than a kind tag every caller switches on.\n */\nexport interface XScale {\n kind: XScaleKind\n /** Position of row `index` along the axis, in this scale's own units. */\n at(index: number): number\n /** `[min, max]` across the rows — the scale when no range is set. */\n extent: Range\n /** The caption for a tick at `value`. */\n label(value: number): string\n /** `divisions + 1` tick values spanning `range`, ends included. */\n ticks(range: Range, divisions: number): number[]\n}\n\n// ---- Time parsing --------------------------------------------------------\n\nconst DAY = 86_400_000\n\nconst MONTHS = [\n \"january\",\n \"february\",\n \"march\",\n \"april\",\n \"may\",\n \"june\",\n \"july\",\n \"august\",\n \"september\",\n \"october\",\n \"november\",\n \"december\",\n]\n\n/**\n * The year a cell that names no year is dated into.\n *\n * Any year would place `Jan…Dec` in the right order at the right spacing; a\n * leap year is the one that also spaces February correctly against a column\n * that *does* carry years, so the two read alike.\n */\nconst NOMINAL_YEAR = 2024\n\n/**\n * Month index for any unambiguous abbreviation of a month name — `jan`, `sept`,\n * `january` — or -1.\n *\n * Three letters minimum, and then a prefix match, which is what lets `sept`\n * through without letting `janitor` through: a longer word has to still *be*\n * the month.\n */\nfunction monthIndex(word: string): number {\n if (word.length < 3) return -1\n return MONTHS.findIndex((month) => month.startsWith(word))\n}\n\n/** The Monday of ISO week `week` in `year`, as an epoch timestamp. */\nfunction isoWeekStart(year: number, week: number): number {\n // ISO week 1 is the week containing 4 January, and weeks start on Monday.\n const jan4 = Date.UTC(year, 0, 4)\n const weekday = (new Date(jan4).getUTCDay() + 6) % 7 // Monday = 0\n return jan4 - weekday * DAY + (week - 1) * 7 * DAY\n}\n\n/**\n * One cell read as an instant, or `null` when it isn't one.\n *\n * Deliberately **not** `Date.parse`. That accepts `\"5\"`, `\"Q3\"` and a good deal\n * else besides, differs between engines on anything non-ISO, and reads a bare\n * `2026-03-14` as UTC but `2026/03/14` as local — three ways for a column to be\n * silently misread as time. Every form below is matched explicitly, and an\n * ambiguous all-numeric date (`03/04/2026` — March or April, depending on where\n * the author lives) is deliberately not one of them.\n */\nexport function parseInstant(raw: unknown): number | null {\n if (typeof raw !== \"string\") return null\n const s = raw.trim().toLowerCase()\n if (s === \"\") return null\n\n // 2026-03-14 · 2026/03/14 · 2026-03 · 2026/03\n const ymd = /^(\\d{4})[-/](\\d{1,2})(?:[-/](\\d{1,2}))?$/.exec(s)\n if (ymd) {\n const month = Number(ymd[2])\n const day = ymd[3] === undefined ? 1 : Number(ymd[3])\n if (month < 1 || month > 12 || day < 1 || day > 31) return null\n return Date.UTC(Number(ymd[1]), month - 1, day)\n }\n\n // 2026-W12 · 2026W12 · w12 · week 12\n const week = /^(?:(\\d{4})[-\\s]?)?w(?:ee)?k?[-\\s]?(\\d{1,2})$/.exec(s)\n if (week) {\n const n = Number(week[2])\n if (n < 1 || n > 53) return null\n return isoWeekStart(\n week[1] === undefined ? NOMINAL_YEAR : Number(week[1]),\n n\n )\n }\n\n // jan · january · jan 2026 · january-2026 · 2026 jan\n const named = /^(?:(\\d{4})[-\\s]+)?([a-z]+)(?:[-\\s]+(\\d{4}))?$/.exec(s)\n if (named) {\n const month = monthIndex(named[2])\n if (month >= 0) {\n const year = named[1] ?? named[3]\n const y = year === undefined ? NOMINAL_YEAR : Number(year)\n return Date.UTC(y, month, 1)\n }\n }\n\n // 14 mar 2026 · mar 14 2026 · mar 14, 2026\n const dayNamed =\n /^(?:(\\d{1,2})[-\\s]+([a-z]+)|([a-z]+)[-\\s]+(\\d{1,2}),?)[-\\s]+(\\d{4})$/.exec(\n s\n )\n if (dayNamed) {\n const month = monthIndex(dayNamed[2] ?? dayNamed[3])\n const day = Number(dayNamed[1] ?? dayNamed[4])\n if (month >= 0 && day >= 1 && day <= 31) {\n return Date.UTC(Number(dayNamed[5]), month, day)\n }\n }\n\n return null\n}\n\n/**\n * An instant captioned at the coarsest granularity the axis's own span can tell\n * apart — a decade of samples reads as years, a year of them as months.\n *\n * Only reached for a tick that is *not* one of the rows (an author-set range, a\n * `zoomTo` part-way through). A tick that is a sample is captioned with the\n * cell the author wrote; see the note at the top of this file.\n */\nexport function formatInstant(value: number, span: number): string {\n const date = new Date(value)\n const year = date.getUTCFullYear()\n const month = MONTHS[date.getUTCMonth()].slice(0, 3)\n const label = month.charAt(0).toUpperCase() + month.slice(1)\n if (span > 4 * 365 * DAY) return String(year)\n if (span > 60 * DAY) return `${label} ${year}`\n return `${label} ${date.getUTCDate()}`\n}\n\n// ---- Column reading ------------------------------------------------------\n\n/**\n * Whether every non-empty cell of `field` holds a number.\n *\n * The same rule `numericFields` applies, asked of one column: a single text\n * cell in an otherwise numeric column takes the whole column off the numeric\n * scale, because plotting that row at 0 is the failure this module is here to\n * stop.\n */\nfunction isNumericColumn(data: DataRecord[], field: string): boolean {\n let sawValue = false\n for (const row of data) {\n const v = row[field]\n if (v === undefined || v === null || v === \"\") continue\n if (typeof v !== \"number\") return false\n sawValue = true\n }\n return sawValue\n}\n\n/**\n * Every non-empty cell of `field` parsed as an instant, or `null` if any one of\n * them isn't one — in which case the column isn't a time column at all.\n *\n * A blank cell keeps its slot, so the returned list stays index-aligned with\n * the rows, and takes the nearest known instant: a hole in an x column is a row\n * whose date the file didn't say, and stacking it on the epoch would drag the\n * whole scale back fifty years to make room for it.\n */\nfunction instantColumn(data: DataRecord[], field: string): number[] | null {\n const parsed: (number | null)[] = []\n let sawValue = false\n for (const row of data) {\n const raw = row[field]\n if (raw === undefined || raw === null || raw === \"\") {\n parsed.push(null)\n continue\n }\n const t = parseInstant(raw)\n if (t === null) return null\n parsed.push(t)\n sawValue = true\n }\n if (!sawValue) return null\n\n const first = parsed.find((t): t is number => t !== null) as number\n let last = first\n return parsed.map((t) => (t === null ? last : (last = t)))\n}\n\n/** `[min, max]` of `values`, or `[0, 1]` when there is nothing to span. */\nfunction extentOf(values: number[]): Range {\n let lo = Infinity\n let hi = -Infinity\n for (const v of values) {\n if (v < lo) lo = v\n if (v > hi) hi = v\n }\n return lo <= hi ? [lo, hi] : [0, 1]\n}\n\n/**\n * Ticks spanning `range`, each one **a sample** — a row the author can point at\n * in their file — placed as near as it can be to where an evenly spaced tick\n * would have gone.\n *\n * Two things have to hold at once, and picking either alone gets it wrong.\n * Ticks must be *samples*, because a caption between two of them has nothing to\n * say (two-thirds of the way through March is not a month, and on a category\n * column it is not anything at all). And they must be *spread*, because the\n * labels sit side by side in a row: taking every nth sample instead puts five\n * dates in the two weeks a burst of rows happens to cover and prints them on\n * top of each other, which is what a column with a gap in it does.\n *\n * Walking the targets rather than the samples is what satisfies both. A run of\n * rows too close together to caption collapses to one tick — consecutive\n * targets pick the same sample and the duplicate is dropped — so a chart asked\n * for five ticks across a gappy column draws four honest ones instead of five\n * overlapping.\n */\nfunction sampledTicks(\n positions: number[],\n [min, max]: Range,\n divisions: number\n): number[] {\n const inside = positions.filter((v) => v >= min && v <= max)\n const unique = [...new Set(inside)].sort((a, b) => a - b)\n if (unique.length === 0) return markerValues([min, max], divisions)\n\n const nearest = (target: number) =>\n unique.reduce((best, v) =>\n Math.abs(v - target) < Math.abs(best - target) ? v : best\n )\n\n const out: number[] = []\n for (const target of markerValues([min, max], divisions)) {\n const tick = nearest(target)\n if (out[out.length - 1] !== tick) out.push(tick)\n }\n return out\n}\n\n/**\n * The caption a tick carries on a sample-based scale: the cell of the row it\n * came from, or `fallback` when the tick isn't a sample after all.\n */\nfunction labelBySample(\n positions: number[],\n captions: string[],\n value: number,\n fallback: (value: number) => string\n): string {\n const i = positions.indexOf(value)\n return i >= 0 ? captions[i] : fallback(value)\n}\n\n/** Scales already resolved, by data array, then by field and pattern. */\nconst scales = new WeakMap<DataRecord[], Map<string, XScale>>()\n\n/**\n * How `field` positions the rows: the number it holds, the instant it names, or\n * failing both, the row's own place in the file.\n *\n * Kept per `data` array: a chart's bound props ask a dozen times a frame, and\n * parsing every row's instant each time was most of a frame.\n */\nexport function resolveXScale(\n data: DataRecord[],\n field: string,\n pattern?: string\n): XScale {\n let byKey = scales.get(data)\n if (!byKey) scales.set(data, (byKey = new Map()))\n const key = JSON.stringify([field, pattern ?? null])\n let scale = byKey.get(key)\n if (!scale) byKey.set(key, (scale = xScaleOf(data, field, pattern)))\n return scale\n}\n\nfunction xScaleOf(\n data: DataRecord[],\n field: string,\n /**\n * The number-format pattern for a *numeric* column. Ignored by the other two\n * kinds, and correctly so: a tick on those is captioned with the cell the\n * author wrote, and `Jan` has no decimal places.\n */\n pattern?: string\n): XScale {\n if (field !== \"\" && isNumericColumn(data, field)) {\n const positions = data.map((row) => num(row, field))\n return {\n kind: \"numeric\",\n at: (i) => positions[i] ?? 0,\n extent: extentOf(positions),\n label: (value) =>\n pattern === undefined ? formatMarker(value) : formatNumber(value, pattern),\n // Round numbers, evenly spaced — a continuous axis is read by its scale\n // rather than by which samples happen to be on it.\n ticks: markerValues,\n }\n }\n\n const captions = data.map((row) => text(row, field))\n const instants = field === \"\" ? null : instantColumn(data, field)\n\n if (instants) {\n const extent = extentOf(instants)\n const span = extent[1] - extent[0]\n return {\n kind: \"time\",\n at: (i) => instants[i] ?? 0,\n extent,\n label: (value) =>\n labelBySample(instants, captions, value, (v) =>\n formatInstant(v, span)\n ),\n ticks: (range, divisions) => sampledTicks(instants, range, divisions),\n }\n }\n\n const positions = data.map((_, i) => i)\n return {\n kind: \"ordinal\",\n at: (i) => i,\n // `[0, n-1]` rather than the tidy `[0, n]`: the first and last rows sit on\n // the plot's edges, which is where a reader looks for them.\n extent: positions.length > 0 ? [0, positions.length - 1] : [0, 1],\n label: (value) => captions[Math.round(value)] ?? \"\",\n ticks: (range, divisions) => sampledTicks(positions, range, divisions),\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { LineChart } from "./line-chart/index.js";
2
+ import { BarChart } from "./bar-chart/index.js";
3
+ import { PieChart } from "./pie-chart/index.js";
4
+ /**
5
+ * Every node type this package publishes.
6
+ *
7
+ * A host registers these by handing the array to an engine —
8
+ * `new Engine(platform, { nodes: NODES })` — which reads each component's key.
9
+ * Defining a component only *declares* that key: nothing is registered by
10
+ * importing a module, so a registry holds exactly what its owner asked for.
11
+ *
12
+ * Listing the component **values** is also what survives bundling: this package
13
+ * declares `sideEffects: false`, and a document names a node type by string, so
14
+ * an import kept only for its side effect is exactly what gets shaken out.
15
+ */
16
+ export declare const NODES: (typeof LineChart | typeof BarChart | typeof PieChart)[];
17
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,KAAK,EAAE,CAAC,OAAO,SAAS,GAAG,OAAO,QAAQ,GAAG,OAAO,QAAQ,CAAC,EAAoC,CAAC"}
package/dist/nodes.js ADDED
@@ -0,0 +1,18 @@
1
+ import { LineChart } from "./line-chart/index.js";
2
+ import { BarChart } from "./bar-chart/index.js";
3
+ import { PieChart } from "./pie-chart/index.js";
4
+ /**
5
+ * Every node type this package publishes.
6
+ *
7
+ * A host registers these by handing the array to an engine —
8
+ * `new Engine(platform, { nodes: NODES })` — which reads each component's key.
9
+ * Defining a component only *declares* that key: nothing is registered by
10
+ * importing a module, so a registry holds exactly what its owner asked for.
11
+ *
12
+ * Listing the component **values** is also what survives bundling: this package
13
+ * declares `sideEffects: false`, and a document names a node type by string, so
14
+ * an import kept only for its side effect is exactly what gets shaken out.
15
+ */
16
+ // Typed by name, so the declaration names each component rather than spelling out its type through core.
17
+ export const NODES = [LineChart, BarChart, PieChart];
18
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,yGAAyG;AACzG,MAAM,CAAC,MAAM,KAAK,GAA6D,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["import { LineChart } from \"./line-chart\";\nimport { BarChart } from \"./bar-chart\";\nimport { PieChart } from \"./pie-chart\";\n\n/**\n * Every node type this package publishes.\n *\n * A host registers these by handing the array to an engine —\n * `new Engine(platform, { nodes: NODES })` — which reads each component's key.\n * Defining a component only *declares* that key: nothing is registered by\n * importing a module, so a registry holds exactly what its owner asked for.\n *\n * Listing the component **values** is also what survives bundling: this package\n * declares `sideEffects: false`, and a document names a node type by string, so\n * an import kept only for its side effect is exactly what gets shaken out.\n */\n// Typed by name, so the declaration names each component rather than spelling out its type through core.\nexport const NODES: (typeof LineChart | typeof BarChart | typeof PieChart)[] = [LineChart, BarChart, PieChart];\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The pie chart: the one in the family that draws a mark per **row** rather
3
+ * than per column.
4
+ *
5
+ * So it shares the legend and the theme machinery with its siblings and none of
6
+ * the cartesian geometry. Set the theme's `ring.holeRadius` to 0 for a solid
7
+ * pie; it defaults to a donut, because the hole is the only place a chart has
8
+ * to put its conclusion.
9
+ */
10
+ export { PieChart, isSliceSelected } from "./pie-chart.js";
11
+ export type { PieChartProps, PieChartValues } from "./pie-chart.js";
12
+ export { PieRing } from "./pie-ring.js";
13
+ export type { PieRingProps } from "./pie-ring.js";
14
+ export { PieLegend } from "./pie-legend.js";
15
+ export type { PieLegendProps } from "./pie-legend.js";
16
+ export { DEFAULT_PIE_CHART_THEME, lerpPieChartTheme, pieArcs, relaxLabels, resolvePieChartTheme, resolvePieSlices, ringPoint, sliceTotal, sliceValue, } from "./shared.js";
17
+ export type { CenterConfig, LabelConfig, PieArc, PieChartConfig, PieChartTheme, PieLabelMode, PieLabelPlacement, PieSlice, RingConfig, } from "./shared.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pie-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,MAAM,EACN,cAAc,EACd,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,UAAU,GACX,MAAM,UAAU,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The pie chart: the one in the family that draws a mark per **row** rather
3
+ * than per column.
4
+ *
5
+ * So it shares the legend and the theme machinery with its siblings and none of
6
+ * the cartesian geometry. Set the theme's `ring.holeRadius` to 0 for a solid
7
+ * pie; it defaults to a donut, because the hole is the only place a chart has
8
+ * to put its conclusion.
9
+ */
10
+ export { PieChart, isSliceSelected } from "./pie-chart.js";
11
+ export { PieRing } from "./pie-ring.js";
12
+ export { PieLegend } from "./pie-legend.js";
13
+ export { DEFAULT_PIE_CHART_THEME, lerpPieChartTheme, pieArcs, relaxLabels, resolvePieChartTheme, resolvePieSlices, ringPoint, sliceTotal, sliceValue, } from "./shared.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pie-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,UAAU,GACX,MAAM,UAAU,CAAA","sourcesContent":["/**\n * The pie chart: the one in the family that draws a mark per **row** rather\n * than per column.\n *\n * So it shares the legend and the theme machinery with its siblings and none of\n * the cartesian geometry. Set the theme's `ring.holeRadius` to 0 for a solid\n * pie; it defaults to a donut, because the hole is the only place a chart has\n * to put its conclusion.\n */\nexport { PieChart, isSliceSelected } from \"./pie-chart\"\nexport type { PieChartProps, PieChartValues } from \"./pie-chart\"\nexport { PieRing } from \"./pie-ring\"\nexport type { PieRingProps } from \"./pie-ring\"\nexport { PieLegend } from \"./pie-legend\"\nexport type { PieLegendProps } from \"./pie-legend\"\nexport {\n DEFAULT_PIE_CHART_THEME,\n lerpPieChartTheme,\n pieArcs,\n relaxLabels,\n resolvePieChartTheme,\n resolvePieSlices,\n ringPoint,\n sliceTotal,\n sliceValue,\n} from \"./shared\"\nexport type {\n CenterConfig,\n LabelConfig,\n PieArc,\n PieChartConfig,\n PieChartTheme,\n PieLabelMode,\n PieLabelPlacement,\n PieSlice,\n RingConfig,\n} from \"./shared\"\n"]}
@@ -0,0 +1,152 @@
1
+ import { type DataRecord, type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
2
+ import { type PieChartConfig, type PieChartTheme, type PieLabelMode, type PieLabelPlacement } from "./shared.js";
3
+ export interface PieChartProps extends Node2DProps {
4
+ /** One row per slice — a plain record of field name to value. */
5
+ data: DataRecord[];
6
+ /** Key into each row for its slice caption, used on the labels and the legend. */
7
+ categoryField: string;
8
+ /** Key into each row for its slice magnitude — the wedge's share of the ring. */
9
+ valueField: string;
10
+ /**
11
+ * The chart's visual theme — slice palette, ring geometry, label and centre
12
+ * type, legend. Every branch is optional and deep-merged onto
13
+ * {@link DEFAULT_PIE_CHART_THEME}.
14
+ */
15
+ theme?: PieChartTheme;
16
+ /** What the ring's labels say. */
17
+ labelMode?: PieLabelMode;
18
+ /** Where they sit: inside their wedge, outside on a leader, or nowhere. */
19
+ labelPlacement?: PieLabelPlacement;
20
+ /** Whether the legend column beside the ring is drawn at all. */
21
+ showLegend?: boolean;
22
+ /** Gap between the ring and the legend, in px. */
23
+ gap?: number;
24
+ /** Text set in the ring's hole — see `revealCenter`. */
25
+ centerLabel?: string;
26
+ /** Smaller second line under {@link centerLabel}. */
27
+ centerCaption?: string;
28
+ /**
29
+ * Whether the hole's summary is drawn at rest. `true` (the default) is the
30
+ * plain answer; a scene that wants the conclusion to land on a later beat sets
31
+ * this `false` and runs `revealCenter` when it gets there.
32
+ */
33
+ showCenter?: boolean;
34
+ }
35
+ /** What the selection reads: the rows, how they are cut, and the pops the commands move. */
36
+ export interface PieChartValues {
37
+ readonly data: DataRecord[];
38
+ readonly categoryField: string;
39
+ readonly valueField: string;
40
+ readonly theme: PieChartConfig;
41
+ readonly pops: number[];
42
+ }
43
+ /** Whether slice `index` is grown out past the ring's rim: past half way, so a slice mid-swell is not yet counted. */
44
+ export declare function isSliceSelected(s: PieChartValues, index: number): boolean;
45
+ /**
46
+ * A pie or donut chart, composed from two parts laid out by a horizontal-flow
47
+ * {@link Rect} — the ring filling whatever the hugging legend leaves, both
48
+ * centred:
49
+ *
50
+ * - {@link PieRing} — the wedges, each sized by its share of the total, with its
51
+ * label inside its own band or pinned outside on a leader line, and the
52
+ * summary in the hole.
53
+ * - {@link PieLegend} — a column of swatch-and-caption rows naming each slice.
54
+ *
55
+ * **One mark per row, not per column**: a pie's palette is indexed by row and
56
+ * there is nothing to hide, since dropping a slice would re-cut every other
57
+ * wedge. `selectSlice` and its siblings are what a pie has instead — a slice
58
+ * swells out of the ring and everything else dims behind it.
59
+ *
60
+ * **Resting state is the finished chart**; `enter` arms every part on its first
61
+ * frame. The one exception is the hole's summary, which a scene can hold back
62
+ * with `showCenter: false`, because it is usually the chart's *conclusion*.
63
+ */
64
+ export declare const PieChart: import("@motionscript/sdk").Component<"pieChart", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
65
+ readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
66
+ readonly categoryField: "";
67
+ readonly valueField: "";
68
+ readonly theme: import("@motionscript/sdk").Type<PieChartTheme, PieChartConfig, false>;
69
+ readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
70
+ readonly labelPlacement: import("@motionscript/sdk").Type<PieLabelPlacement, PieLabelPlacement, false>;
71
+ readonly gap: 40;
72
+ readonly centerLabel: "";
73
+ readonly centerCaption: "";
74
+ /**
75
+ * How far each slice is pushed out of the ring, `0`–`1` per index. Held here
76
+ * rather than on the ring because two parts read it: the wedges grow out by
77
+ * it, and the legend entries dim by it. Seeded flush, one to a row.
78
+ */
79
+ readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
80
+ /** Read as the chart is built: the legend is a part the chart builds or doesn't. */
81
+ readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
82
+ /** Read as the chart is built: whether the hole's summary is drawn at rest. */
83
+ readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
84
+ }>, {
85
+ readonly enter: {};
86
+ readonly revealCenter: {};
87
+ readonly selectSlice: {
88
+ readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
89
+ };
90
+ readonly deselectSlice: {
91
+ readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
92
+ };
93
+ readonly selectOnlySlice: {
94
+ readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
95
+ };
96
+ readonly clearSelection: {};
97
+ }, readonly [], Node2D<Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
98
+ readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
99
+ readonly categoryField: "";
100
+ readonly valueField: "";
101
+ readonly theme: import("@motionscript/sdk").Type<PieChartTheme, PieChartConfig, false>;
102
+ readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
103
+ readonly labelPlacement: import("@motionscript/sdk").Type<PieLabelPlacement, PieLabelPlacement, false>;
104
+ readonly gap: 40;
105
+ readonly centerLabel: "";
106
+ readonly centerCaption: "";
107
+ /**
108
+ * How far each slice is pushed out of the ring, `0`–`1` per index. Held here
109
+ * rather than on the ring because two parts read it: the wedges grow out by
110
+ * it, and the legend entries dim by it. Seeded flush, one to a row.
111
+ */
112
+ readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
113
+ /** Read as the chart is built: the legend is a part the chart builds or doesn't. */
114
+ readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
115
+ /** Read as the chart is built: whether the hole's summary is drawn at rest. */
116
+ readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
117
+ }>, readonly [], import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
118
+ readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
119
+ readonly categoryField: "";
120
+ readonly valueField: "";
121
+ readonly theme: import("@motionscript/sdk").Type<PieChartTheme, PieChartConfig, false>;
122
+ readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
123
+ readonly labelPlacement: import("@motionscript/sdk").Type<PieLabelPlacement, PieLabelPlacement, false>;
124
+ readonly gap: 40;
125
+ readonly centerLabel: "";
126
+ readonly centerCaption: "";
127
+ /**
128
+ * How far each slice is pushed out of the ring, `0`–`1` per index. Held here
129
+ * rather than on the ring because two parts read it: the wedges grow out by
130
+ * it, and the legend entries dim by it. Seeded flush, one to a row.
131
+ */
132
+ readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
133
+ /** Read as the chart is built: the legend is a part the chart builds or doesn't. */
134
+ readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
135
+ /** Read as the chart is built: whether the hole's summary is drawn at rest. */
136
+ readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
137
+ }>, {
138
+ readonly enter: {};
139
+ readonly revealCenter: {};
140
+ readonly selectSlice: {
141
+ readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
142
+ };
143
+ readonly deselectSlice: {
144
+ readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
145
+ };
146
+ readonly selectOnlySlice: {
147
+ readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
148
+ };
149
+ readonly clearSelection: {};
150
+ }, Node2D<Node2DProps>>>>;
151
+ export type PieChart = NodeOf<typeof PieChart>;
152
+ //# sourceMappingURL=pie-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pie-chart.d.ts","sourceRoot":"","sources":["../../src/pie-chart/pie-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAA;AAO1B,OAAO,EAKL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAEvB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,iEAAiE;IACjE,IAAI,EAAE,UAAU,EAAE,CAAA;IAClB,kF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