@motionscript/charts 0.1.0-alpha.3 → 0.1.0-alpha.6

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 (154) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +201 -201
  3. package/NOTICE +48 -0
  4. package/README.md +99 -0
  5. package/dist/bar-chart/bar-chart.d.ts +93 -231
  6. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  7. package/dist/bar-chart/bar-chart.js +378 -565
  8. package/dist/bar-chart/bar-chart.js.map +1 -1
  9. package/dist/bar-chart/category-axis.d.ts +24 -41
  10. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  11. package/dist/bar-chart/category-axis.js +93 -115
  12. package/dist/bar-chart/category-axis.js.map +1 -1
  13. package/dist/bar-chart/chart-bars.d.ts +36 -70
  14. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  15. package/dist/bar-chart/chart-bars.js +156 -210
  16. package/dist/bar-chart/chart-bars.js.map +1 -1
  17. package/dist/bar-chart/index.d.ts +2 -2
  18. package/dist/bar-chart/index.d.ts.map +1 -1
  19. package/dist/bar-chart/index.js +1 -1
  20. package/dist/bar-chart/index.js.map +1 -1
  21. package/dist/bar-chart/shared.d.ts +6 -6
  22. package/dist/bar-chart/shared.d.ts.map +1 -1
  23. package/dist/bar-chart/shared.js +6 -6
  24. package/dist/bar-chart/shared.js.map +1 -1
  25. package/dist/browser/chunks/chunk-XROBIRQK.js +2 -0
  26. package/dist/browser/chunks/chunk-XROBIRQK.js.map +7 -0
  27. package/dist/browser/index.js +1 -1
  28. package/dist/browser/index.js.map +3 -3
  29. package/dist/browser/kit.js +1 -1
  30. package/dist/browser/manifest.json +3 -2
  31. package/dist/engine.d.ts +8 -6
  32. package/dist/engine.d.ts.map +1 -1
  33. package/dist/engine.js +8 -6
  34. package/dist/engine.js.map +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/kit/cartesian.d.ts +44 -0
  37. package/dist/kit/cartesian.d.ts.map +1 -0
  38. package/dist/kit/cartesian.js +59 -0
  39. package/dist/kit/cartesian.js.map +1 -0
  40. package/dist/kit/chart-border.d.ts +8 -11
  41. package/dist/kit/chart-border.d.ts.map +1 -1
  42. package/dist/kit/chart-border.js +15 -32
  43. package/dist/kit/chart-border.js.map +1 -1
  44. package/dist/kit/chart-canvas.d.ts +23 -21
  45. package/dist/kit/chart-canvas.d.ts.map +1 -1
  46. package/dist/kit/chart-canvas.js +33 -90
  47. package/dist/kit/chart-canvas.js.map +1 -1
  48. package/dist/kit/chart-legend.d.ts +79 -88
  49. package/dist/kit/chart-legend.d.ts.map +1 -1
  50. package/dist/kit/chart-legend.js +137 -186
  51. package/dist/kit/chart-legend.js.map +1 -1
  52. package/dist/kit/entries.d.ts +17 -0
  53. package/dist/kit/entries.d.ts.map +1 -0
  54. package/dist/kit/entries.js +19 -0
  55. package/dist/kit/entries.js.map +1 -0
  56. package/dist/kit/motion.d.ts +48 -0
  57. package/dist/kit/motion.d.ts.map +1 -0
  58. package/dist/kit/motion.js +63 -0
  59. package/dist/kit/motion.js.map +1 -0
  60. package/dist/kit/paints.d.ts +10 -0
  61. package/dist/kit/paints.d.ts.map +1 -0
  62. package/dist/kit/paints.js +12 -0
  63. package/dist/kit/paints.js.map +1 -0
  64. package/dist/kit/shared.d.ts +59 -8
  65. package/dist/kit/shared.d.ts.map +1 -1
  66. package/dist/kit/shared.js +105 -10
  67. package/dist/kit/shared.js.map +1 -1
  68. package/dist/kit/vertical-axis.d.ts +36 -61
  69. package/dist/kit/vertical-axis.d.ts.map +1 -1
  70. package/dist/kit/vertical-axis.js +97 -132
  71. package/dist/kit/vertical-axis.js.map +1 -1
  72. package/dist/line-chart/chart-line.d.ts +27 -53
  73. package/dist/line-chart/chart-line.d.ts.map +1 -1
  74. package/dist/line-chart/chart-line.js +89 -120
  75. package/dist/line-chart/chart-line.js.map +1 -1
  76. package/dist/line-chart/chart-region.d.ts +14 -14
  77. package/dist/line-chart/chart-region.d.ts.map +1 -1
  78. package/dist/line-chart/chart-region.js +26 -64
  79. package/dist/line-chart/chart-region.js.map +1 -1
  80. package/dist/line-chart/horizontal-axis.d.ts +32 -56
  81. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  82. package/dist/line-chart/horizontal-axis.js +85 -123
  83. package/dist/line-chart/horizontal-axis.js.map +1 -1
  84. package/dist/line-chart/index.d.ts +2 -2
  85. package/dist/line-chart/index.d.ts.map +1 -1
  86. package/dist/line-chart/index.js +1 -1
  87. package/dist/line-chart/index.js.map +1 -1
  88. package/dist/line-chart/line-chart.d.ts +111 -311
  89. package/dist/line-chart/line-chart.d.ts.map +1 -1
  90. package/dist/line-chart/line-chart.js +403 -639
  91. package/dist/line-chart/line-chart.js.map +1 -1
  92. package/dist/line-chart/shared.d.ts +6 -6
  93. package/dist/line-chart/shared.d.ts.map +1 -1
  94. package/dist/line-chart/shared.js +22 -7
  95. package/dist/line-chart/shared.js.map +1 -1
  96. package/dist/line-chart/x-scale.d.ts +1 -1
  97. package/dist/line-chart/x-scale.js +1 -1
  98. package/dist/line-chart/x-scale.js.map +1 -1
  99. package/dist/nodes.d.ts +6 -9
  100. package/dist/nodes.d.ts.map +1 -1
  101. package/dist/nodes.js +7 -9
  102. package/dist/nodes.js.map +1 -1
  103. package/dist/pie-chart/index.d.ts +2 -2
  104. package/dist/pie-chart/index.d.ts.map +1 -1
  105. package/dist/pie-chart/index.js +1 -1
  106. package/dist/pie-chart/index.js.map +1 -1
  107. package/dist/pie-chart/pie-chart.d.ts +77 -134
  108. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  109. package/dist/pie-chart/pie-chart.js +199 -268
  110. package/dist/pie-chart/pie-chart.js.map +1 -1
  111. package/dist/pie-chart/pie-legend.d.ts +54 -31
  112. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  113. package/dist/pie-chart/pie-legend.js +93 -107
  114. package/dist/pie-chart/pie-legend.js.map +1 -1
  115. package/dist/pie-chart/pie-ring.d.ts +142 -122
  116. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  117. package/dist/pie-chart/pie-ring.js +333 -361
  118. package/dist/pie-chart/pie-ring.js.map +1 -1
  119. package/dist/pie-chart/shared.d.ts +3 -3
  120. package/dist/pie-chart/shared.js +3 -3
  121. package/dist/pie-chart/shared.js.map +1 -1
  122. package/package.json +6 -5
  123. package/registry.json +23 -23
  124. package/src/bar-chart/bar-chart.ts +534 -814
  125. package/src/bar-chart/category-axis.ts +162 -177
  126. package/src/bar-chart/chart-bars.ts +288 -310
  127. package/src/bar-chart/index.ts +31 -31
  128. package/src/bar-chart/shared.ts +354 -354
  129. package/src/engine.ts +28 -26
  130. package/src/index.ts +5 -5
  131. package/src/kit/cartesian.ts +81 -0
  132. package/src/kit/chart-border.ts +50 -61
  133. package/src/kit/chart-canvas.ts +122 -157
  134. package/src/kit/chart-legend.ts +229 -250
  135. package/src/kit/entries.ts +20 -0
  136. package/src/kit/motion.ts +90 -0
  137. package/src/kit/paints.ts +15 -0
  138. package/src/kit/shared.ts +782 -675
  139. package/src/kit/vertical-axis.ts +194 -224
  140. package/src/line-chart/chart-line.ts +181 -208
  141. package/src/line-chart/chart-region.ts +106 -135
  142. package/src/line-chart/horizontal-axis.ts +166 -202
  143. package/src/line-chart/index.ts +39 -39
  144. package/src/line-chart/line-chart.ts +585 -929
  145. package/src/line-chart/shared.ts +473 -459
  146. package/src/line-chart/x-scale.ts +367 -367
  147. package/src/nodes.ts +18 -20
  148. package/src/pie-chart/index.ts +37 -37
  149. package/src/pie-chart/pie-chart.ts +293 -381
  150. package/src/pie-chart/pie-legend.ts +169 -159
  151. package/src/pie-chart/pie-ring.ts +848 -903
  152. package/src/pie-chart/shared.ts +490 -490
  153. package/dist/browser/chunks/chunk-RMHQ6GYU.js +0 -2
  154. package/dist/browser/chunks/chunk-RMHQ6GYU.js.map +0 -7
@@ -1,202 +1,166 @@
1
- import {
2
- command,
3
- Node2D,
4
- Rect,
5
- Text,
6
- easeOut,
7
- property,
8
- insetsOps,
9
- textOps,
10
- type CommandArgs,
11
- type NodeConfig,
12
- type Node2DProps,
13
- } from "@motionscript/sdk";
14
-
15
- import {
16
- DEFAULT_X_AXIS,
17
- enterBudget,
18
- formatMarker,
19
- type AxisConfig,
20
- type Range,
21
- } from "../kit/shared";
22
- import { at, compose, type Seekable } from "@motionscript/sdk/component"
23
-
24
- export interface HorizontalAxisProps extends Node2DProps {
25
- /** `[min, max]` of the horizontal scale the markers are positioned within. */
26
- range: Range;
27
- /** Tick values (in data units) to draw along the axis. */
28
- markers: number[];
29
- /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
30
- axis: AxisConfig;
31
- /**
32
- * Caption drawn centred in the gutter beneath the marker row. Empty string
33
- * (the default) hides it.
34
- */
35
- label: string;
36
- }
37
-
38
- /** How far a marker starts above its slot when it enters, in px. */
39
- const SLIDE = 24;
40
-
41
- /** How a tick value is captioned — see {@link HorizontalAxis.labelFor}. */
42
- export type MarkerLabel = (value: number) => string;
43
-
44
- /**
45
- * The horizontal axis of a {@link LineChart}: a **row of {@link Text} nodes**,
46
- * one per marker value, running left-to-right. Pure layout — the mirror of the
47
- * kit's `VerticalAxis`, including its bound (not snapshotted) marker text and
48
- * positions, and its landed resting state.
49
- *
50
- * Markers are always placed **by value** across the range, whatever they say:
51
- * `2026-03` sits three months along, not three slots along. That is what keeps
52
- * it distinct from a bar chart's bottom axis, which centres a caption on each
53
- * slot and has no scale at all — the two only look alike. What the values are
54
- * captioned *as* is the chart's to decide; see {@link labelFor}.
55
- *
56
- * {@link enter} staggers the markers in **left-to-right**: each starts lifted a
57
- * little above its slot and transparent, then fades and slides down into place.
58
- */
59
- export class HorizontalAxis extends Node2D<HorizontalAxisProps> {
60
- @property({ default: () => [0, 1] as Range }) declare range: Range;
61
- @property({ default: () => [] as number[] }) declare markers: number[];
62
- @property({ default: DEFAULT_X_AXIS }) declare axis: AxisConfig;
63
- @property({ default: "" }) declare label: string;
64
-
65
- /**
66
- * How a tick value is captioned. Defaults to the numeric formatting the
67
- * vertical axis uses; a chart whose x column names months or categories
68
- * replaces it (see `x-scale.ts`).
69
- *
70
- * A plain field rather than a `@property`, because it is a **policy, not a
71
- * value**: there is nothing to tween between two formatters, and a signal
72
- * holding a function is a signal every `set`/`to` on this node would have to
73
- * know not to touch. Read inside each marker's `text` binding, so replacing it
74
- * before the first frame is enough — which is when the chart does it.
75
- */
76
- labelFor: MarkerLabel = formatMarker;
77
-
78
- /** One text node per marker, ordered left → right, for the staggered enter. */
79
- private markerNodes: Text[] = [];
80
- /** The caption node, or null when `label` is empty. */
81
- private labelNode: Text | null = null;
82
-
83
- /** The live tick values, left → right — re-read every frame, not snapshotted. */
84
- private get sortedMarkers(): number[] {
85
- return [...this.markers].sort((a, b) => a - b);
86
- }
87
-
88
- private valueAt(index: number): number | undefined {
89
- return this.sortedMarkers[index];
90
- }
91
-
92
- /** Tick `i`'s fraction across the live `range`, 0 at the left edge. */
93
- private fracAt(index: number): number {
94
- const v = this.valueAt(index);
95
- if (v === undefined) return 0;
96
- const [min, max] = this.range;
97
- return max <= min ? 0 : (v - min) / (max - min);
98
- }
99
-
100
- constructor(props?: NodeConfig<HorizontalAxis, HorizontalAxisProps>) {
101
- super(props);
102
-
103
- const tickPad = insetsOps.resolve(this.axis.tickPadding).top;
104
- const titlePad = insetsOps.resolve(this.axis.titlePadding).top;
105
-
106
- this.markerNodes = this.markers.map((_, i) => {
107
- const marker: Text = new Text({
108
- ...textOps.styleProps(this.axis.labelStyle),
109
- text: () => {
110
- const v = this.valueAt(i);
111
- return v === undefined ? "" : this.labelFor(v);
112
- },
113
- x: () => {
114
- const width = this.layoutBounds.width;
115
- const centred = (this.fracAt(i) - 0.5) * width;
116
- // Held inside the axis's right edge, which is also the *chart's*: the
117
- // last marker is centred on the last grid line, so half of `2026-06`
118
- // — or of `3300` — would be drawn outside the node's box and outside
119
- // the rectangle the editor draws around it. Only the right edge is
120
- // held, because the left one has the vertical axis's whole gutter
121
- // beyond it, and a marker overhanging into that is inside the chart.
122
- const limit = width / 2 - marker.layoutBounds.width / 2;
123
- return Math.min(centred, limit);
124
- },
125
- });
126
- return marker;
127
- });
128
-
129
- const children: Node2D[] = [
130
- new Rect({
131
- width: "fill",
132
- height: "hug",
133
- padding: { top: tickPad },
134
- children: this.markerNodes,
135
- }),
136
- ];
137
- if (this.label !== "") {
138
- this.labelNode = new Text({
139
- ...textOps.styleProps(this.axis.titleStyle),
140
- text: this.label,
141
- });
142
- children.push(this.labelNode);
143
- }
144
-
145
- this.add(
146
- new Rect({ flow: "vertical", gap: titlePad, height: "hug", width: "fill", children }),
147
- );
148
- }
149
-
150
- /**
151
- * Primes every marker (and the caption) at its pre-entrance state: lifted
152
- * above its slot and transparent. Idempotent — see {@link VerticalAxis.arm}.
153
- */
154
- arm(slide = SLIDE): void {
155
- for (const marker of this.markerNodes) marker.set({ opacity: 0, y: slide });
156
- this.labelNode?.set({ opacity: 0, y: slide });
157
- }
158
-
159
- /**
160
- * Stagger the markers in left to right, then slide the caption in after them.
161
- *
162
- * A {@link Seekable} rather than a generator. The offsets were always static —
163
- * `i * step` per marker — but expressed as `wait` inside a generator they only
164
- * existed while it ran, so knowing what the axis looked like partway through
165
- * meant running it from zero. Placed explicitly, the same stagger can be asked
166
- * for a time, which is what lets a chart scene scrub in constant time.
167
- *
168
- * `duration` is the **whole** entrance — see {@link VerticalAxis.enter} and
169
- * {@link enterBudget}.
170
- */
171
- @command()
172
- enter(
173
- args: CommandArgs<{ stagger?: number; slide?: number }> & { duration: number },
174
- ): Seekable {
175
- const { stagger, slide = SLIDE } = args.data ?? {};
176
- const duration = args.duration;
177
- const easing = args.easing ?? easeOut();
178
- const nodes = this.markerNodes;
179
- if (nodes.length === 0) return compose([]);
180
- const { step, per, caption } = enterBudget(
181
- duration,
182
- nodes.length,
183
- this.labelNode !== null,
184
- stagger,
185
- );
186
-
187
- this.arm(slide);
188
-
189
- // Left marker leads: markerNodes is already left → right.
190
- const markers = nodes.map((node, i) =>
191
- at(i * step, node.to({ data: { opacity: 1, y: 0 }, duration: per, easing })),
192
- );
193
- const lastMarkerEnds = nodes.length === 0 ? 0 : (nodes.length - 1) * step + per;
194
-
195
- return compose([
196
- ...markers,
197
- ...(this.labelNode
198
- ? [at(lastMarkerEnds, this.labelNode.to({ data: { opacity: 1, y: 0 }, duration: caption, easing }))]
199
- : []),
200
- ]);
201
- }
202
- }
1
+ import {
2
+ Rect,
3
+ Text,
4
+ Types,
5
+ component2d,
6
+ insetsOps,
7
+ textOps,
8
+ type NodeOf,
9
+ type Node2D,
10
+ type Node2DProps,
11
+ } from "@motionscript/sdk";
12
+
13
+ import { asParts, fresh } from "../kit/entries";
14
+ import { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from "../kit/motion";
15
+ import {
16
+ DEFAULT_X_AXIS,
17
+ enterBudget,
18
+ type AxisConfig,
19
+ type Range,
20
+ } from "../kit/shared";
21
+ import { markerCaption } from "../kit/vertical-axis";
22
+
23
+ export interface HorizontalAxisProps extends Node2DProps {
24
+ /** `[min, max]` of the horizontal scale the markers are positioned within. */
25
+ range: Range;
26
+ /** Tick values (in data units) to draw along the axis. */
27
+ markers: number[];
28
+ /**
29
+ * How each marker is captioned, one per entry of `markers` and in its order.
30
+ * Empty (the default), or short, captions a marker with its bare numeric
31
+ * reading; a chart whose x column names months or categories writes those.
32
+ */
33
+ captions: string[];
34
+ /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
35
+ axis: AxisConfig;
36
+ /**
37
+ * Caption drawn centred in the gutter beneath the marker row. Empty string
38
+ * (the default) hides it.
39
+ */
40
+ label: string;
41
+ }
42
+
43
+ /** How far a marker starts above its slot when it enters, in px. */
44
+ const SLIDE = 24;
45
+
46
+ /** How a tick value is captioned — see {@link HorizontalAxisProps.captions}. */
47
+ export type MarkerLabel = (value: number) => string;
48
+
49
+ /**
50
+ * The horizontal axis of a {@link LineChart}: a **row of {@link Text} nodes**,
51
+ * one per marker value, running left-to-right. Pure layout — the mirror of the
52
+ * kit's `VerticalAxis`, including its bound (not snapshotted) marker text and
53
+ * positions, and its landed resting state.
54
+ *
55
+ * Markers are always placed **by value** across the range, whatever they say:
56
+ * `2026-03` sits three months along, not three slots along. That is what keeps
57
+ * it distinct from a bar chart's bottom axis, which centres a caption on each
58
+ * slot and has no scale at all — the two only look alike. What the values are
59
+ * captioned *as* is the chart's to decide; see {@link HorizontalAxisProps.captions}.
60
+ *
61
+ * `enter` staggers the markers in **left-to-right**: each starts lifted a
62
+ * little above its slot and transparent, then fades and slides down into place.
63
+ */
64
+ export const HorizontalAxis = component2d({
65
+ key: "horizontalAxis",
66
+ state: {
67
+ range: fresh<Range>(() => [0, 1]),
68
+ markers: fresh<number[]>(() => []),
69
+ captions: fresh<string[]>(() => []),
70
+ axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),
71
+ label: "",
72
+ arrivals: arrivalsEntry(),
73
+ },
74
+ // A plain node filled its parent; one made of its markers would hug them.
75
+ defaults: { width: "fill", height: "fill" },
76
+ children: (state) => {
77
+ const tickPad = insetsOps.resolve(state.axis.tickPadding).top;
78
+ const titlePad = insetsOps.resolve(state.axis.titlePadding).top;
79
+
80
+ const column: Node2D[] = [];
81
+ // The column's parent is the axis: its box is what the markers are placed in.
82
+ const box = () => (column[0]?.parent as Node2D | null | undefined)?.layoutBounds ?? { width: 0, height: 0 };
83
+ /** The live tick values, left → right — re-read every frame, not snapshotted. */
84
+ const sorted = () => [...state.markers].sort((a, b) => a - b);
85
+ /** Tick `i`'s fraction across the live `range`, 0 at the left edge. */
86
+ const fracAt = (value: number | undefined) => {
87
+ if (value === undefined) return 0;
88
+ const [min, max] = state.range;
89
+ return max <= min ? 0 : (value - min) / (max - min);
90
+ };
91
+
92
+ const markers = state.markers.map((_, i) => {
93
+ const marker: Node2D = new Text({
94
+ ...textOps.styleProps(state.axis.labelStyle),
95
+ text: () => {
96
+ const value = sorted()[i];
97
+ return value === undefined ? "" : markerCaption(state, value);
98
+ },
99
+ x: () => {
100
+ const width = box().width;
101
+ const centred = (fracAt(sorted()[i]) - 0.5) * width;
102
+ // Held inside the axis's right edge, which is also the *chart's*: the
103
+ // last marker is centred on the last grid line, so half of `2026-06`
104
+ // — or of `3300` — would be drawn outside the node's box and outside
105
+ // the rectangle the editor draws around it. Only the right edge is
106
+ // held, because the left one has the vertical axis's whole gutter
107
+ // beyond it, and a marker overhanging into that is inside the chart.
108
+ const limit = width / 2 - marker.layoutBounds.width / 2;
109
+ return Math.min(centred, limit);
110
+ },
111
+ opacity: () => arrivalOf(state.arrivals, i).opacity,
112
+ y: () => arrivalOf(state.arrivals, i).shift,
113
+ });
114
+ return marker;
115
+ });
116
+
117
+ const children: Node2D[] = [
118
+ new Rect({ width: "fill", height: "hug", padding: { top: tickPad }, children: markers }),
119
+ ];
120
+ if (state.label !== "") {
121
+ children.push(
122
+ new Text({
123
+ ...textOps.styleProps(state.axis.titleStyle),
124
+ text: state.label,
125
+ opacity: () => arrivalOf(state.arrivals, "label").opacity,
126
+ y: () => arrivalOf(state.arrivals, "label").shift,
127
+ }),
128
+ );
129
+ }
130
+
131
+ column.push(new Rect({ flow: "vertical", gap: titlePad, height: "hug", width: "fill", children }));
132
+ return asParts(column);
133
+ },
134
+ commands: {
135
+ /**
136
+ * Stagger the markers in left to right, then slide the caption in after
137
+ * them. Its first frame arms them all: lifted by `slide` and transparent.
138
+ *
139
+ * The timeline's duration is the **whole** entrance — see
140
+ * `VerticalAxis.enter` and {@link enterBudget}.
141
+ */
142
+ enter: {
143
+ args: {
144
+ stagger: Types.custom<number | undefined>(undefined),
145
+ slide: Types.number(SLIDE),
146
+ },
147
+ run: (timeline, state) => {
148
+ const { stagger, slide } = timeline.args;
149
+ const count = state.markers.length;
150
+ const captioned = state.label !== "";
151
+ const from: Arrival = { opacity: 0, shift: slide };
152
+ const keys = [...state.markers.keys(), ...(captioned ? ["label"] : [])];
153
+ const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }));
154
+ if (count === 0) return arm;
155
+ const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger);
156
+ const ease = frameEase(timeline);
157
+ // Left marker leads: the row is already left → right.
158
+ const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }));
159
+ const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, "label", from, ease) }] : [];
160
+ return timeline.together([arm, beats(timeline, [...markers, ...label])]);
161
+ },
162
+ },
163
+ },
164
+ });
165
+
166
+ export type HorizontalAxis = NodeOf<typeof HorizontalAxis>;
@@ -1,39 +1,39 @@
1
- /**
2
- * The line chart: a cartesian plot with a traced polyline, spotlit regions and
3
- * a staggered entrance.
4
- *
5
- * {@link LineChart} composes the parts below plus the shared ones in the kit
6
- * (the plot panel, the value axis, the legend); each part is exported too, so
7
- * another node type can reuse one on its own.
8
- *
9
- * These files are what `ms add line-chart` copies. Everything they reach for
10
- * that is *not* here comes from the kit and stays a dependency — see
11
- * `../engine.ts` for why that line is where it is.
12
- */
13
- export { LineChart } from "./line-chart"
14
- export type { LineChartProps } from "./line-chart"
15
- export { ChartRegion } from "./chart-region"
16
- export { ChartLine } from "./chart-line"
17
- export { HorizontalAxis } from "./horizontal-axis"
18
- export {
19
- DEFAULT_CHART_THEME,
20
- EMPTY_REGION_BOX,
21
- clipPolylineToBox,
22
- hasRegion,
23
- lerpChartTheme,
24
- resolveChartTheme,
25
- resolveRegionBox,
26
- resolveYScale,
27
- seriesPoints,
28
- yExtent,
29
- } from "./shared"
30
- export type {
31
- ChartConfig,
32
- ChartTheme,
33
- LineSeries,
34
- PlotRegion,
35
- RegionBox,
36
- RegionConfig,
37
- } from "./shared"
38
- export { formatInstant, parseInstant, resolveXScale } from "./x-scale"
39
- export type { XScale, XScaleKind } from "./x-scale"
1
+ /**
2
+ * The line chart: a cartesian plot with a traced polyline, spotlit regions and
3
+ * a staggered entrance.
4
+ *
5
+ * {@link LineChart} composes the parts below plus the shared ones in the kit
6
+ * (the plot panel, the value axis, the legend); each part is exported too, so
7
+ * another node type can reuse one on its own.
8
+ *
9
+ * These files are what `ms add line-chart` copies. Everything they reach for
10
+ * that is *not* here comes from the kit and stays a dependency — see
11
+ * `../engine.ts` for why that line is where it is.
12
+ */
13
+ export { LineChart, lineChartDomains } from "./line-chart"
14
+ export type { LineChartDomains, LineChartProps, LineChartValues } from "./line-chart"
15
+ export { ChartRegion } from "./chart-region"
16
+ export { ChartLine } from "./chart-line"
17
+ export { HorizontalAxis } from "./horizontal-axis"
18
+ export {
19
+ DEFAULT_CHART_THEME,
20
+ EMPTY_REGION_BOX,
21
+ clipPolylineToBox,
22
+ hasRegion,
23
+ lerpChartTheme,
24
+ resolveChartTheme,
25
+ resolveRegionBox,
26
+ resolveYScale,
27
+ seriesPoints,
28
+ yExtent,
29
+ } from "./shared"
30
+ export type {
31
+ ChartConfig,
32
+ ChartTheme,
33
+ LineSeries,
34
+ PlotRegion,
35
+ RegionBox,
36
+ RegionConfig,
37
+ } from "./shared"
38
+ export { formatInstant, parseInstant, resolveXScale } from "./x-scale"
39
+ export type { XScale, XScaleKind } from "./x-scale"