@motionscript/charts 0.0.0-stage → 0.1.0-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 (137) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +201 -0
  3. package/dist/bar-chart/bar-chart.d.ts +286 -0
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -0
  5. package/dist/bar-chart/bar-chart.js +610 -0
  6. package/dist/bar-chart/bar-chart.js.map +1 -0
  7. package/dist/bar-chart/category-axis.d.ts +77 -0
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -0
  9. package/dist/bar-chart/category-axis.js +141 -0
  10. package/dist/bar-chart/category-axis.js.map +1 -0
  11. package/dist/bar-chart/chart-bars.d.ts +149 -0
  12. package/dist/bar-chart/chart-bars.d.ts.map +1 -0
  13. package/dist/bar-chart/chart-bars.js +236 -0
  14. package/dist/bar-chart/chart-bars.js.map +1 -0
  15. package/dist/bar-chart/index.d.ts +16 -0
  16. package/dist/bar-chart/index.d.ts.map +1 -0
  17. package/dist/bar-chart/index.js +12 -0
  18. package/dist/bar-chart/index.js.map +1 -0
  19. package/dist/bar-chart/shared.d.ts +146 -0
  20. package/dist/bar-chart/shared.d.ts.map +1 -0
  21. package/dist/bar-chart/shared.js +182 -0
  22. package/dist/bar-chart/shared.js.map +1 -0
  23. package/dist/browser/chunks/chunk-ZMBOBHYL.js +2 -0
  24. package/dist/browser/chunks/chunk-ZMBOBHYL.js.map +7 -0
  25. package/dist/browser/index.js +2 -0
  26. package/dist/browser/index.js.map +7 -0
  27. package/dist/browser/kit.js +2 -0
  28. package/dist/browser/kit.js.map +7 -0
  29. package/dist/browser/manifest.json +12 -0
  30. package/dist/engine.d.ts +27 -0
  31. package/dist/engine.d.ts.map +1 -0
  32. package/dist/engine.js +27 -0
  33. package/dist/engine.js.map +1 -0
  34. package/dist/index.d.ts +6 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +6 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/kit/chart-border.d.ts +28 -0
  39. package/dist/kit/chart-border.d.ts.map +1 -0
  40. package/dist/kit/chart-border.js +45 -0
  41. package/dist/kit/chart-border.js.map +1 -0
  42. package/dist/kit/chart-canvas.d.ts +56 -0
  43. package/dist/kit/chart-canvas.d.ts.map +1 -0
  44. package/dist/kit/chart-canvas.js +125 -0
  45. package/dist/kit/chart-canvas.js.map +1 -0
  46. package/dist/kit/chart-legend.d.ts +126 -0
  47. package/dist/kit/chart-legend.d.ts.map +1 -0
  48. package/dist/kit/chart-legend.js +212 -0
  49. package/dist/kit/chart-legend.js.map +1 -0
  50. package/dist/kit/shared.d.ts +251 -0
  51. package/dist/kit/shared.d.ts.map +1 -0
  52. package/dist/kit/shared.js +401 -0
  53. package/dist/kit/shared.js.map +1 -0
  54. package/dist/kit/vertical-axis.d.ts +99 -0
  55. package/dist/kit/vertical-axis.d.ts.map +1 -0
  56. package/dist/kit/vertical-axis.js +176 -0
  57. package/dist/kit/vertical-axis.js.map +1 -0
  58. package/dist/line-chart/chart-line.d.ts +91 -0
  59. package/dist/line-chart/chart-line.d.ts.map +1 -0
  60. package/dist/line-chart/chart-line.js +156 -0
  61. package/dist/line-chart/chart-line.js.map +1 -0
  62. package/dist/line-chart/chart-region.d.ts +47 -0
  63. package/dist/line-chart/chart-region.d.ts.map +1 -0
  64. package/dist/line-chart/chart-region.js +101 -0
  65. package/dist/line-chart/chart-region.js.map +1 -0
  66. package/dist/line-chart/horizontal-axis.d.ts +85 -0
  67. package/dist/line-chart/horizontal-axis.d.ts.map +1 -0
  68. package/dist/line-chart/horizontal-axis.js +158 -0
  69. package/dist/line-chart/horizontal-axis.js.map +1 -0
  70. package/dist/line-chart/index.d.ts +22 -0
  71. package/dist/line-chart/index.d.ts.map +1 -0
  72. package/dist/line-chart/index.js +19 -0
  73. package/dist/line-chart/index.js.map +1 -0
  74. package/dist/line-chart/line-chart.d.ts +347 -0
  75. package/dist/line-chart/line-chart.d.ts.map +1 -0
  76. package/dist/line-chart/line-chart.js +701 -0
  77. package/dist/line-chart/line-chart.js.map +1 -0
  78. package/dist/line-chart/shared.d.ts +171 -0
  79. package/dist/line-chart/shared.d.ts.map +1 -0
  80. package/dist/line-chart/shared.js +270 -0
  81. package/dist/line-chart/shared.js.map +1 -0
  82. package/dist/line-chart/x-scale.d.ts +84 -0
  83. package/dist/line-chart/x-scale.d.ts.map +1 -0
  84. package/dist/line-chart/x-scale.js +302 -0
  85. package/dist/line-chart/x-scale.js.map +1 -0
  86. package/dist/nodes.d.ts +20 -0
  87. package/dist/nodes.d.ts.map +1 -0
  88. package/dist/nodes.js +20 -0
  89. package/dist/nodes.js.map +1 -0
  90. package/dist/pie-chart/index.d.ts +18 -0
  91. package/dist/pie-chart/index.d.ts.map +1 -0
  92. package/dist/pie-chart/index.js +14 -0
  93. package/dist/pie-chart/index.js.map +1 -0
  94. package/dist/pie-chart/pie-chart.d.ts +170 -0
  95. package/dist/pie-chart/pie-chart.d.ts.map +1 -0
  96. package/dist/pie-chart/pie-chart.js +291 -0
  97. package/dist/pie-chart/pie-chart.js.map +1 -0
  98. package/dist/pie-chart/pie-legend.d.ts +60 -0
  99. package/dist/pie-chart/pie-legend.d.ts.map +1 -0
  100. package/dist/pie-chart/pie-legend.js +131 -0
  101. package/dist/pie-chart/pie-legend.js.map +1 -0
  102. package/dist/pie-chart/pie-ring.d.ts +266 -0
  103. package/dist/pie-chart/pie-ring.d.ts.map +1 -0
  104. package/dist/pie-chart/pie-ring.js +708 -0
  105. package/dist/pie-chart/pie-ring.js.map +1 -0
  106. package/dist/pie-chart/shared.d.ts +210 -0
  107. package/dist/pie-chart/shared.d.ts.map +1 -0
  108. package/dist/pie-chart/shared.js +240 -0
  109. package/dist/pie-chart/shared.js.map +1 -0
  110. package/package.json +69 -3
  111. package/registry.json +23 -0
  112. package/src/bar-chart/bar-chart.ts +804 -0
  113. package/src/bar-chart/category-axis.ts +177 -0
  114. package/src/bar-chart/chart-bars.ts +310 -0
  115. package/src/bar-chart/index.ts +31 -0
  116. package/src/bar-chart/shared.ts +354 -0
  117. package/src/engine.ts +26 -0
  118. package/src/index.ts +5 -0
  119. package/src/kit/chart-border.ts +61 -0
  120. package/src/kit/chart-canvas.ts +157 -0
  121. package/src/kit/chart-legend.ts +250 -0
  122. package/src/kit/shared.ts +675 -0
  123. package/src/kit/vertical-axis.ts +224 -0
  124. package/src/line-chart/chart-line.ts +208 -0
  125. package/src/line-chart/chart-region.ts +135 -0
  126. package/src/line-chart/horizontal-axis.ts +202 -0
  127. package/src/line-chart/index.ts +39 -0
  128. package/src/line-chart/line-chart.ts +894 -0
  129. package/src/line-chart/shared.ts +459 -0
  130. package/src/line-chart/x-scale.ts +367 -0
  131. package/src/nodes.ts +20 -0
  132. package/src/pie-chart/index.ts +37 -0
  133. package/src/pie-chart/pie-chart.ts +374 -0
  134. package/src/pie-chart/pie-legend.ts +159 -0
  135. package/src/pie-chart/pie-ring.ts +903 -0
  136. package/src/pie-chart/shared.ts +490 -0
  137. package/README.md +0 -4
@@ -0,0 +1,367 @@
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
+
29
+ import type { DataRecord } from "@motionscript/core"
30
+
31
+ import {
32
+ formatMarker,
33
+ markerValues,
34
+ num,
35
+ text,
36
+ type Range,
37
+ } from "../kit/shared"
38
+ import { formatNumber } from "@motionscript/core/component"
39
+
40
+ /** How an x column's cells become positions along the axis. */
41
+ export type XScaleKind = "numeric" | "time" | "ordinal"
42
+
43
+ /**
44
+ * An x column resolved into positions, captions and ticks.
45
+ *
46
+ * The three kinds differ in all three answers, so they are three closures built
47
+ * once per (data, column) rather than a kind tag every caller switches on.
48
+ */
49
+ export interface XScale {
50
+ kind: XScaleKind
51
+ /** Position of row `index` along the axis, in this scale's own units. */
52
+ at(index: number): number
53
+ /** `[min, max]` across the rows — the scale when no range is set. */
54
+ extent: Range
55
+ /** The caption for a tick at `value`. */
56
+ label(value: number): string
57
+ /** `divisions + 1` tick values spanning `range`, ends included. */
58
+ ticks(range: Range, divisions: number): number[]
59
+ }
60
+
61
+ // ---- Time parsing --------------------------------------------------------
62
+
63
+ const DAY = 86_400_000
64
+
65
+ const MONTHS = [
66
+ "january",
67
+ "february",
68
+ "march",
69
+ "april",
70
+ "may",
71
+ "june",
72
+ "july",
73
+ "august",
74
+ "september",
75
+ "october",
76
+ "november",
77
+ "december",
78
+ ]
79
+
80
+ /**
81
+ * The year a cell that names no year is dated into.
82
+ *
83
+ * Any year would place `Jan…Dec` in the right order at the right spacing; a
84
+ * leap year is the one that also spaces February correctly against a column
85
+ * that *does* carry years, so the two read alike.
86
+ */
87
+ const NOMINAL_YEAR = 2024
88
+
89
+ /**
90
+ * Month index for any unambiguous abbreviation of a month name — `jan`, `sept`,
91
+ * `january` — or -1.
92
+ *
93
+ * Three letters minimum, and then a prefix match, which is what lets `sept`
94
+ * through without letting `janitor` through: a longer word has to still *be*
95
+ * the month.
96
+ */
97
+ function monthIndex(word: string): number {
98
+ if (word.length < 3) return -1
99
+ return MONTHS.findIndex((month) => month.startsWith(word))
100
+ }
101
+
102
+ /** The Monday of ISO week `week` in `year`, as an epoch timestamp. */
103
+ function isoWeekStart(year: number, week: number): number {
104
+ // ISO week 1 is the week containing 4 January, and weeks start on Monday.
105
+ const jan4 = Date.UTC(year, 0, 4)
106
+ const weekday = (new Date(jan4).getUTCDay() + 6) % 7 // Monday = 0
107
+ return jan4 - weekday * DAY + (week - 1) * 7 * DAY
108
+ }
109
+
110
+ /**
111
+ * One cell read as an instant, or `null` when it isn't one.
112
+ *
113
+ * Deliberately **not** `Date.parse`. That accepts `"5"`, `"Q3"` and a good deal
114
+ * else besides, differs between engines on anything non-ISO, and reads a bare
115
+ * `2026-03-14` as UTC but `2026/03/14` as local — three ways for a column to be
116
+ * silently misread as time. Every form below is matched explicitly, and an
117
+ * ambiguous all-numeric date (`03/04/2026` — March or April, depending on where
118
+ * the author lives) is deliberately not one of them.
119
+ */
120
+ export function parseInstant(raw: unknown): number | null {
121
+ if (typeof raw !== "string") return null
122
+ const s = raw.trim().toLowerCase()
123
+ if (s === "") return null
124
+
125
+ // 2026-03-14 · 2026/03/14 · 2026-03 · 2026/03
126
+ const ymd = /^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(s)
127
+ if (ymd) {
128
+ const month = Number(ymd[2])
129
+ const day = ymd[3] === undefined ? 1 : Number(ymd[3])
130
+ if (month < 1 || month > 12 || day < 1 || day > 31) return null
131
+ return Date.UTC(Number(ymd[1]), month - 1, day)
132
+ }
133
+
134
+ // 2026-W12 · 2026W12 · w12 · week 12
135
+ const week = /^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(s)
136
+ if (week) {
137
+ const n = Number(week[2])
138
+ if (n < 1 || n > 53) return null
139
+ return isoWeekStart(
140
+ week[1] === undefined ? NOMINAL_YEAR : Number(week[1]),
141
+ n
142
+ )
143
+ }
144
+
145
+ // jan · january · jan 2026 · january-2026 · 2026 jan
146
+ const named = /^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(s)
147
+ if (named) {
148
+ const month = monthIndex(named[2])
149
+ if (month >= 0) {
150
+ const year = named[1] ?? named[3]
151
+ const y = year === undefined ? NOMINAL_YEAR : Number(year)
152
+ return Date.UTC(y, month, 1)
153
+ }
154
+ }
155
+
156
+ // 14 mar 2026 · mar 14 2026 · mar 14, 2026
157
+ const dayNamed =
158
+ /^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(
159
+ s
160
+ )
161
+ if (dayNamed) {
162
+ const month = monthIndex(dayNamed[2] ?? dayNamed[3])
163
+ const day = Number(dayNamed[1] ?? dayNamed[4])
164
+ if (month >= 0 && day >= 1 && day <= 31) {
165
+ return Date.UTC(Number(dayNamed[5]), month, day)
166
+ }
167
+ }
168
+
169
+ return null
170
+ }
171
+
172
+ /**
173
+ * An instant captioned at the coarsest granularity the axis's own span can tell
174
+ * apart — a decade of samples reads as years, a year of them as months.
175
+ *
176
+ * Only reached for a tick that is *not* one of the rows (an author-set range, a
177
+ * `zoomTo` part-way through). A tick that is a sample is captioned with the
178
+ * cell the author wrote; see the note at the top of this file.
179
+ */
180
+ export function formatInstant(value: number, span: number): string {
181
+ const date = new Date(value)
182
+ const year = date.getUTCFullYear()
183
+ const month = MONTHS[date.getUTCMonth()].slice(0, 3)
184
+ const label = month.charAt(0).toUpperCase() + month.slice(1)
185
+ if (span > 4 * 365 * DAY) return String(year)
186
+ if (span > 60 * DAY) return `${label} ${year}`
187
+ return `${label} ${date.getUTCDate()}`
188
+ }
189
+
190
+ // ---- Column reading ------------------------------------------------------
191
+
192
+ /**
193
+ * Whether every non-empty cell of `field` holds a number.
194
+ *
195
+ * The same rule `numericFields` applies, asked of one column: a single text
196
+ * cell in an otherwise numeric column takes the whole column off the numeric
197
+ * scale, because plotting that row at 0 is the failure this module is here to
198
+ * stop.
199
+ */
200
+ function isNumericColumn(data: DataRecord[], field: string): boolean {
201
+ let sawValue = false
202
+ for (const row of data) {
203
+ const v = row[field]
204
+ if (v === undefined || v === null || v === "") continue
205
+ if (typeof v !== "number") return false
206
+ sawValue = true
207
+ }
208
+ return sawValue
209
+ }
210
+
211
+ /**
212
+ * Every non-empty cell of `field` parsed as an instant, or `null` if any one of
213
+ * them isn't one — in which case the column isn't a time column at all.
214
+ *
215
+ * A blank cell keeps its slot, so the returned list stays index-aligned with
216
+ * the rows, and takes the nearest known instant: a hole in an x column is a row
217
+ * whose date the file didn't say, and stacking it on the epoch would drag the
218
+ * whole scale back fifty years to make room for it.
219
+ */
220
+ function instantColumn(data: DataRecord[], field: string): number[] | null {
221
+ const parsed: (number | null)[] = []
222
+ let sawValue = false
223
+ for (const row of data) {
224
+ const raw = row[field]
225
+ if (raw === undefined || raw === null || raw === "") {
226
+ parsed.push(null)
227
+ continue
228
+ }
229
+ const t = parseInstant(raw)
230
+ if (t === null) return null
231
+ parsed.push(t)
232
+ sawValue = true
233
+ }
234
+ if (!sawValue) return null
235
+
236
+ const first = parsed.find((t): t is number => t !== null) as number
237
+ let last = first
238
+ return parsed.map((t) => (t === null ? last : (last = t)))
239
+ }
240
+
241
+ /** `[min, max]` of `values`, or `[0, 1]` when there is nothing to span. */
242
+ function extentOf(values: number[]): Range {
243
+ let lo = Infinity
244
+ let hi = -Infinity
245
+ for (const v of values) {
246
+ if (v < lo) lo = v
247
+ if (v > hi) hi = v
248
+ }
249
+ return lo <= hi ? [lo, hi] : [0, 1]
250
+ }
251
+
252
+ /**
253
+ * Ticks spanning `range`, each one **a sample** — a row the author can point at
254
+ * in their file — placed as near as it can be to where an evenly spaced tick
255
+ * would have gone.
256
+ *
257
+ * Two things have to hold at once, and picking either alone gets it wrong.
258
+ * Ticks must be *samples*, because a caption between two of them has nothing to
259
+ * say (two-thirds of the way through March is not a month, and on a category
260
+ * column it is not anything at all). And they must be *spread*, because the
261
+ * labels sit side by side in a row: taking every nth sample instead puts five
262
+ * dates in the two weeks a burst of rows happens to cover and prints them on
263
+ * top of each other, which is what a column with a gap in it does.
264
+ *
265
+ * Walking the targets rather than the samples is what satisfies both. A run of
266
+ * rows too close together to caption collapses to one tick — consecutive
267
+ * targets pick the same sample and the duplicate is dropped — so a chart asked
268
+ * for five ticks across a gappy column draws four honest ones instead of five
269
+ * overlapping.
270
+ */
271
+ function sampledTicks(
272
+ positions: number[],
273
+ [min, max]: Range,
274
+ divisions: number
275
+ ): number[] {
276
+ const inside = positions.filter((v) => v >= min && v <= max)
277
+ const unique = [...new Set(inside)].sort((a, b) => a - b)
278
+ if (unique.length === 0) return markerValues([min, max], divisions)
279
+
280
+ const nearest = (target: number) =>
281
+ unique.reduce((best, v) =>
282
+ Math.abs(v - target) < Math.abs(best - target) ? v : best
283
+ )
284
+
285
+ const out: number[] = []
286
+ for (const target of markerValues([min, max], divisions)) {
287
+ const tick = nearest(target)
288
+ if (out[out.length - 1] !== tick) out.push(tick)
289
+ }
290
+ return out
291
+ }
292
+
293
+ /**
294
+ * The caption a tick carries on a sample-based scale: the cell of the row it
295
+ * came from, or `fallback` when the tick isn't a sample after all.
296
+ */
297
+ function labelBySample(
298
+ positions: number[],
299
+ captions: string[],
300
+ value: number,
301
+ fallback: (value: number) => string
302
+ ): string {
303
+ const i = positions.indexOf(value)
304
+ return i >= 0 ? captions[i] : fallback(value)
305
+ }
306
+
307
+ /**
308
+ * How `field` positions the rows: the number it holds, the instant it names, or
309
+ * failing both, the row's own place in the file.
310
+ *
311
+ * Resolved from the data on every read rather than cached on the node: it is
312
+ * cheap (one pass to classify, one to position), and a cache keyed on a `data`
313
+ * array that `buildScene` rebuilds on every edit would miss every time anyway.
314
+ */
315
+ export function resolveXScale(
316
+ data: DataRecord[],
317
+ field: string,
318
+ /**
319
+ * The number-format pattern for a *numeric* column. Ignored by the other two
320
+ * kinds, and correctly so: a tick on those is captioned with the cell the
321
+ * author wrote, and `Jan` has no decimal places.
322
+ */
323
+ pattern?: string
324
+ ): XScale {
325
+ if (field !== "" && isNumericColumn(data, field)) {
326
+ const positions = data.map((row) => num(row, field))
327
+ return {
328
+ kind: "numeric",
329
+ at: (i) => positions[i] ?? 0,
330
+ extent: extentOf(positions),
331
+ label: (value) =>
332
+ pattern === undefined ? formatMarker(value) : formatNumber(value, pattern),
333
+ // Round numbers, evenly spaced — a continuous axis is read by its scale
334
+ // rather than by which samples happen to be on it.
335
+ ticks: markerValues,
336
+ }
337
+ }
338
+
339
+ const captions = data.map((row) => text(row, field))
340
+ const instants = field === "" ? null : instantColumn(data, field)
341
+
342
+ if (instants) {
343
+ const extent = extentOf(instants)
344
+ const span = extent[1] - extent[0]
345
+ return {
346
+ kind: "time",
347
+ at: (i) => instants[i] ?? 0,
348
+ extent,
349
+ label: (value) =>
350
+ labelBySample(instants, captions, value, (v) =>
351
+ formatInstant(v, span)
352
+ ),
353
+ ticks: (range, divisions) => sampledTicks(instants, range, divisions),
354
+ }
355
+ }
356
+
357
+ const positions = data.map((_, i) => i)
358
+ return {
359
+ kind: "ordinal",
360
+ at: (i) => i,
361
+ // `[0, n-1]` rather than the tidy `[0, n]`: the first and last rows sit on
362
+ // the plot's edges, which is where a reader looks for them.
363
+ extent: positions.length > 0 ? [0, positions.length - 1] : [0, 1],
364
+ label: (value) => captions[Math.round(value)] ?? "",
365
+ ticks: (range, divisions) => sampledTicks(positions, range, divisions),
366
+ }
367
+ }
package/src/nodes.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { LineChart } from "./line-chart";
2
+ import { BarChart } from "./bar-chart";
3
+ import { PieChart } from "./pie-chart";
4
+
5
+ /**
6
+ * Every node type this package publishes.
7
+ *
8
+ * A host registers these by handing the array to an engine —
9
+ * `new Engine(platform, { nodes: NODES })` — which reads each class's `@node()`
10
+ * key. The decorator only *declares* that key: nothing is registered by the mere
11
+ * act of importing a module, so a registry holds exactly what its owner asked
12
+ * for and two engines in one process can differ about it.
13
+ *
14
+ * Listing class **values** is also what survives bundling. This package declares
15
+ * `sideEffects: false`, which licenses a bundler to drop a module nothing
16
+ * imports a value from, and a document names a node type by string — so
17
+ * `import "./line-chart"` for its side effect is exactly what gets shaken out, where an
18
+ * array of bindings is a data dependency that cannot be.
19
+ */
20
+ export const NODES = [LineChart, BarChart, PieChart];
@@ -0,0 +1,37 @@
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 } from "./pie-chart"
11
+ export type { PieChartProps } from "./pie-chart"
12
+ export { PieRing } from "./pie-ring"
13
+ export type { PieRingProps } from "./pie-ring"
14
+ export { PieLegend } from "./pie-legend"
15
+ export type { PieLegendProps } from "./pie-legend"
16
+ export {
17
+ DEFAULT_PIE_CHART_THEME,
18
+ lerpPieChartTheme,
19
+ pieArcs,
20
+ relaxLabels,
21
+ resolvePieChartTheme,
22
+ resolvePieSlices,
23
+ ringPoint,
24
+ sliceTotal,
25
+ sliceValue,
26
+ } from "./shared"
27
+ export type {
28
+ CenterConfig,
29
+ LabelConfig,
30
+ PieArc,
31
+ PieChartConfig,
32
+ PieChartTheme,
33
+ PieLabelMode,
34
+ PieLabelPlacement,
35
+ PieSlice,
36
+ RingConfig,
37
+ } from "./shared"