@motionscript/charts 0.1.0 → 0.1.1-alpha.1

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 (215) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +98 -28
  3. package/dist/bar-chart/bar-chart.d.ts +242 -119
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  5. package/dist/bar-chart/bar-chart.js +231 -260
  6. package/dist/bar-chart/bar-chart.js.map +1 -1
  7. package/dist/bar-chart/category-axis.d.ts +16 -38
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  9. package/dist/bar-chart/category-axis.js +59 -68
  10. package/dist/bar-chart/category-axis.js.map +1 -1
  11. package/dist/bar-chart/chart-bars.d.ts +60 -91
  12. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  13. package/dist/bar-chart/chart-bars.js +88 -125
  14. package/dist/bar-chart/chart-bars.js.map +1 -1
  15. package/dist/bar-chart/index.d.ts +5 -13
  16. package/dist/bar-chart/index.d.ts.map +1 -1
  17. package/dist/bar-chart/index.js +2 -9
  18. package/dist/bar-chart/index.js.map +1 -1
  19. package/dist/bar-chart/shared.d.ts +40 -132
  20. package/dist/bar-chart/shared.d.ts.map +1 -1
  21. package/dist/bar-chart/shared.js +70 -158
  22. package/dist/bar-chart/shared.js.map +1 -1
  23. package/dist/browser/chunks/chunk-R3Q5EE6E.js +2 -0
  24. package/dist/browser/chunks/chunk-R3Q5EE6E.js.map +7 -0
  25. package/dist/browser/index.js +1 -1
  26. package/dist/browser/index.js.map +4 -4
  27. package/dist/browser/kit.js +1 -1
  28. package/dist/browser/manifest.json +1 -1
  29. package/dist/engine.d.ts +8 -17
  30. package/dist/engine.d.ts.map +1 -1
  31. package/dist/engine.js +8 -17
  32. package/dist/engine.js.map +1 -1
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/kit/cartesian.d.ts +49 -35
  38. package/dist/kit/cartesian.d.ts.map +1 -1
  39. package/dist/kit/cartesian.js +80 -42
  40. package/dist/kit/cartesian.js.map +1 -1
  41. package/dist/kit/chart-canvas.d.ts +37 -40
  42. package/dist/kit/chart-canvas.d.ts.map +1 -1
  43. package/dist/kit/chart-canvas.js +53 -47
  44. package/dist/kit/chart-canvas.js.map +1 -1
  45. package/dist/kit/chart-legend.d.ts +16 -59
  46. package/dist/kit/chart-legend.d.ts.map +1 -1
  47. package/dist/kit/chart-legend.js +38 -76
  48. package/dist/kit/chart-legend.js.map +1 -1
  49. package/dist/kit/entries.d.ts +2 -0
  50. package/dist/kit/entries.d.ts.map +1 -1
  51. package/dist/kit/entries.js +2 -0
  52. package/dist/kit/entries.js.map +1 -1
  53. package/dist/kit/horizontal-axis.d.ts +77 -0
  54. package/dist/kit/horizontal-axis.d.ts.map +1 -0
  55. package/dist/kit/horizontal-axis.js +99 -0
  56. package/dist/kit/horizontal-axis.js.map +1 -0
  57. package/dist/kit/motion.d.ts +16 -3
  58. package/dist/kit/motion.d.ts.map +1 -1
  59. package/dist/kit/motion.js +15 -1
  60. package/dist/kit/motion.js.map +1 -1
  61. package/dist/{pie-chart → kit}/pie-legend.d.ts +14 -29
  62. package/dist/kit/pie-legend.d.ts.map +1 -0
  63. package/dist/kit/pie-legend.js +93 -0
  64. package/dist/kit/pie-legend.js.map +1 -0
  65. package/dist/kit/polar.d.ts +31 -0
  66. package/dist/kit/polar.d.ts.map +1 -0
  67. package/dist/kit/polar.js +33 -0
  68. package/dist/kit/polar.js.map +1 -0
  69. package/dist/kit/shared.d.ts +60 -214
  70. package/dist/kit/shared.d.ts.map +1 -1
  71. package/dist/kit/shared.js +91 -291
  72. package/dist/kit/shared.js.map +1 -1
  73. package/dist/kit/style.d.ts +254 -0
  74. package/dist/kit/style.d.ts.map +1 -0
  75. package/dist/kit/style.js +197 -0
  76. package/dist/kit/style.js.map +1 -0
  77. package/dist/kit/vertical-axis.d.ts +36 -45
  78. package/dist/kit/vertical-axis.d.ts.map +1 -1
  79. package/dist/kit/vertical-axis.js +69 -81
  80. package/dist/kit/vertical-axis.js.map +1 -1
  81. package/dist/line-chart/chart-line.d.ts +107 -40
  82. package/dist/line-chart/chart-line.d.ts.map +1 -1
  83. package/dist/line-chart/chart-line.js +172 -89
  84. package/dist/line-chart/chart-line.js.map +1 -1
  85. package/dist/line-chart/chart-region.d.ts +14 -27
  86. package/dist/line-chart/chart-region.d.ts.map +1 -1
  87. package/dist/line-chart/chart-region.js +13 -28
  88. package/dist/line-chart/chart-region.js.map +1 -1
  89. package/dist/line-chart/index.d.ts +5 -18
  90. package/dist/line-chart/index.d.ts.map +1 -1
  91. package/dist/line-chart/index.js +3 -16
  92. package/dist/line-chart/index.js.map +1 -1
  93. package/dist/line-chart/line-chart.d.ts +272 -119
  94. package/dist/line-chart/line-chart.d.ts.map +1 -1
  95. package/dist/line-chart/line-chart.js +309 -257
  96. package/dist/line-chart/line-chart.js.map +1 -1
  97. package/dist/line-chart/shared.d.ts +73 -130
  98. package/dist/line-chart/shared.d.ts.map +1 -1
  99. package/dist/line-chart/shared.js +195 -156
  100. package/dist/line-chart/shared.js.map +1 -1
  101. package/dist/line-chart/x-scale.d.ts +16 -55
  102. package/dist/line-chart/x-scale.d.ts.map +1 -1
  103. package/dist/line-chart/x-scale.js +44 -111
  104. package/dist/line-chart/x-scale.js.map +1 -1
  105. package/dist/nodes.d.ts +3 -13
  106. package/dist/nodes.d.ts.map +1 -1
  107. package/dist/nodes.js +9 -13
  108. package/dist/nodes.js.map +1 -1
  109. package/dist/pie-chart/index.d.ts +3 -15
  110. package/dist/pie-chart/index.d.ts.map +1 -1
  111. package/dist/pie-chart/index.js +1 -11
  112. package/dist/pie-chart/index.js.map +1 -1
  113. package/dist/pie-chart/pie-chart.d.ts +147 -85
  114. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  115. package/dist/pie-chart/pie-chart.js +65 -86
  116. package/dist/pie-chart/pie-chart.js.map +1 -1
  117. package/dist/pie-chart/pie-ring.d.ts +65 -196
  118. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  119. package/dist/pie-chart/pie-ring.js +154 -292
  120. package/dist/pie-chart/pie-ring.js.map +1 -1
  121. package/dist/pie-chart/shared.d.ts +78 -172
  122. package/dist/pie-chart/shared.d.ts.map +1 -1
  123. package/dist/pie-chart/shared.js +54 -177
  124. package/dist/pie-chart/shared.js.map +1 -1
  125. package/dist/radar-chart/index.d.ts +5 -0
  126. package/dist/radar-chart/index.d.ts.map +1 -0
  127. package/dist/radar-chart/index.js +5 -0
  128. package/dist/radar-chart/index.js.map +1 -0
  129. package/dist/radar-chart/radar-chart.d.ts +218 -0
  130. package/dist/radar-chart/radar-chart.d.ts.map +1 -0
  131. package/dist/radar-chart/radar-chart.js +224 -0
  132. package/dist/radar-chart/radar-chart.js.map +1 -0
  133. package/dist/radar-chart/radar-grid.d.ts +43 -0
  134. package/dist/radar-chart/radar-grid.d.ts.map +1 -0
  135. package/dist/radar-chart/radar-grid.js +61 -0
  136. package/dist/radar-chart/radar-grid.js.map +1 -0
  137. package/dist/radar-chart/radar-series.d.ts +59 -0
  138. package/dist/radar-chart/radar-series.d.ts.map +1 -0
  139. package/dist/radar-chart/radar-series.js +71 -0
  140. package/dist/radar-chart/radar-series.js.map +1 -0
  141. package/dist/radar-chart/shared.d.ts +73 -0
  142. package/dist/radar-chart/shared.d.ts.map +1 -0
  143. package/dist/radar-chart/shared.js +123 -0
  144. package/dist/radar-chart/shared.js.map +1 -0
  145. package/dist/radial-chart/index.d.ts +6 -0
  146. package/dist/radial-chart/index.d.ts.map +1 -0
  147. package/dist/radial-chart/index.js +4 -0
  148. package/dist/radial-chart/index.js.map +1 -0
  149. package/dist/radial-chart/radial-chart.d.ts +216 -0
  150. package/dist/radial-chart/radial-chart.d.ts.map +1 -0
  151. package/dist/radial-chart/radial-chart.js +174 -0
  152. package/dist/radial-chart/radial-chart.js.map +1 -0
  153. package/dist/radial-chart/radial-rings.d.ts +121 -0
  154. package/dist/radial-chart/radial-rings.d.ts.map +1 -0
  155. package/dist/radial-chart/radial-rings.js +273 -0
  156. package/dist/radial-chart/radial-rings.js.map +1 -0
  157. package/dist/radial-chart/shared.d.ts +73 -0
  158. package/dist/radial-chart/shared.d.ts.map +1 -0
  159. package/dist/radial-chart/shared.js +79 -0
  160. package/dist/radial-chart/shared.js.map +1 -0
  161. package/package.json +4 -4
  162. package/registry.json +21 -6
  163. package/src/bar-chart/bar-chart.ts +274 -315
  164. package/src/bar-chart/category-axis.ts +53 -88
  165. package/src/bar-chart/chart-bars.ts +108 -205
  166. package/src/bar-chart/index.ts +8 -19
  167. package/src/bar-chart/shared.ts +81 -309
  168. package/src/engine.ts +8 -17
  169. package/src/index.ts +2 -0
  170. package/src/kit/cartesian.ts +118 -55
  171. package/src/kit/chart-canvas.ts +50 -80
  172. package/src/kit/chart-legend.ts +36 -97
  173. package/src/kit/entries.ts +4 -1
  174. package/src/kit/horizontal-axis.ts +114 -0
  175. package/src/kit/motion.ts +18 -2
  176. package/src/{pie-chart → kit}/pie-legend.ts +25 -65
  177. package/src/kit/polar.ts +54 -0
  178. package/src/kit/shared.ts +104 -487
  179. package/src/kit/style.ts +257 -0
  180. package/src/kit/vertical-axis.ts +81 -115
  181. package/src/line-chart/chart-line.ts +185 -91
  182. package/src/line-chart/chart-region.ts +14 -31
  183. package/src/line-chart/index.ts +14 -22
  184. package/src/line-chart/line-chart.ts +377 -315
  185. package/src/line-chart/shared.ts +229 -304
  186. package/src/line-chart/x-scale.ts +44 -121
  187. package/src/nodes.ts +9 -13
  188. package/src/pie-chart/index.ts +3 -35
  189. package/src/pie-chart/pie-chart.ts +83 -134
  190. package/src/pie-chart/pie-ring.ts +162 -368
  191. package/src/pie-chart/shared.ts +92 -379
  192. package/src/radar-chart/index.ts +4 -0
  193. package/src/radar-chart/radar-chart.ts +287 -0
  194. package/src/radar-chart/radar-grid.ts +78 -0
  195. package/src/radar-chart/radar-series.ts +88 -0
  196. package/src/radar-chart/shared.ts +146 -0
  197. package/src/radial-chart/index.ts +5 -0
  198. package/src/radial-chart/radial-chart.ts +210 -0
  199. package/src/radial-chart/radial-rings.ts +328 -0
  200. package/src/radial-chart/shared.ts +114 -0
  201. package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
  202. package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
  203. package/dist/kit/chart-border.d.ts +0 -27
  204. package/dist/kit/chart-border.d.ts.map +0 -1
  205. package/dist/kit/chart-border.js +0 -28
  206. package/dist/kit/chart-border.js.map +0 -1
  207. package/dist/line-chart/horizontal-axis.d.ts +0 -79
  208. package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
  209. package/dist/line-chart/horizontal-axis.js +0 -129
  210. package/dist/line-chart/horizontal-axis.js.map +0 -1
  211. package/dist/pie-chart/pie-legend.d.ts.map +0 -1
  212. package/dist/pie-chart/pie-legend.js +0 -117
  213. package/dist/pie-chart/pie-legend.js.map +0 -1
  214. package/src/kit/chart-border.ts +0 -50
  215. package/src/line-chart/horizontal-axis.ts +0 -151
@@ -1,117 +1,106 @@
1
- import { Rect, RotatedBox, Text, Types, component2d, insetsOps, textOps, } from "@motionscript/sdk";
1
+ import { Rect, RotatedBox, Text, Types, component2d, insetsOps, } from "@motionscript/sdk";
2
+ import { enterBudget } from "@motionscript/sdk/component";
3
+ import { boundText } from "./cartesian.js";
2
4
  import { asParts, fresh } from "./entries.js";
3
5
  import { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase } from "./motion.js";
4
- import { DEFAULT_Y_AXIS, enterBudget, formatMarker, } from "./shared.js";
5
- /** How far a marker starts to the right of its slot when it enters, in px. */
6
+ import { DEFAULT_Y_AXIS, formatMarker, } from "./shared.js";
6
7
  const SLIDE = 24;
7
8
  /** What a marker's caption reads: the one listed for its value, else its bare reading. */
8
9
  export function markerCaption(s, value) {
9
10
  const index = s.markers.indexOf(value);
10
11
  return (index >= 0 ? s.captions[index] : undefined) ?? formatMarker(value);
11
12
  }
13
+ /** The gap between an axis's markers and the plot, and between the markers and the caption, read off its config. */
14
+ export function axisPads(axis, side) {
15
+ return { tick: insetsOps.resolve(axis.tickPadding)[side], title: insetsOps.resolve(axis.titlePadding)[side] };
16
+ }
12
17
  /**
13
- * The numeric vertical axis shared by the cartesian charts: a **column of
14
- * {@link Text} nodes**, one per marker value, running top-to-bottom (highest
15
- * value at the top). Pure layout — no `Graphics` — so the markers are real text
16
- * nodes the scene can measure, restyle, or animate individually.
17
- *
18
- * Each marker is positioned so its centre lands exactly on its value's fraction
19
- * across `range` within the axis's filled height, so unevenly-spaced markers
20
- * land where their values fall. Both the caption and the position are *bound*,
21
- * not snapshotted: a chart that rescales its axes (see `LineChart.zoomTo`)
22
- * tweens `range`/`markers` live. Only the marker **count** is fixed at
23
- * construction.
24
- *
25
- * `enter` staggers them in **bottom-to-top**: each marker starts pushed a
26
- * little to the right and transparent, then fades and slides left into place.
27
- * The resting state is the landed one, so a chart that is never told to enter
28
- * still reads as a finished chart.
18
+ * A column of right-aligned captions beside the plot: `place(i)` is caption
19
+ * `i`'s centre height in the column (y-up), whose height it is handed. The
20
+ * value axis and a horizontal bar chart's category axis are both this column.
21
+ */
22
+ export function captionColumn(spec) {
23
+ const pads = () => axisPads(spec.axis(), "right");
24
+ const markers = Array.from({ length: spec.count }, (_, i) => {
25
+ const column = () => marker.parent?.layoutBounds ?? { width: 0, height: 0 };
26
+ const marker = new Text({
27
+ ...boundText(() => spec.axis().labelStyle),
28
+ text: () => spec.text(i),
29
+ // Right-aligned against the tick padding: freeform children sit on the content box's centre.
30
+ x: () => (column().width - pads().tick) / 2 - marker.layoutBounds.width / 2 + arrivalOf(spec.arrivals(), i).shift,
31
+ y: () => spec.place(i, column().height),
32
+ opacity: () => arrivalOf(spec.arrivals(), i).opacity * (spec.opacity?.(i) ?? 1),
33
+ });
34
+ return marker;
35
+ });
36
+ const children = [];
37
+ if (spec.label !== "") {
38
+ // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.
39
+ children.push(new RotatedBox({
40
+ angle: -90,
41
+ width: "hug",
42
+ height: "hug",
43
+ children: new Text({
44
+ ...boundText(() => spec.axis().titleStyle),
45
+ text: spec.label,
46
+ opacity: () => arrivalOf(spec.arrivals(), "label").opacity,
47
+ x: () => arrivalOf(spec.arrivals(), "label").shift,
48
+ }),
49
+ }));
50
+ }
51
+ children.push(new Rect({ height: "fill", width: "hug", padding: () => ({ right: pads().tick }), children: markers }));
52
+ return new Rect({ flow: "horizontal", gap: () => pads().title, height: "fill", children });
53
+ }
54
+ /**
55
+ * The numeric vertical axis the cartesian charts share: a column of {@link Text}
56
+ * markers, highest at the top, each centred on its value's fraction across
57
+ * `range` and right-aligned against the plot. Caption and position are bound, so
58
+ * a rescale tweens live; only the marker count is fixed at construction. The
59
+ * resting state is landed.
29
60
  */
30
61
  export const VerticalAxis = component2d({
31
62
  key: "verticalAxis",
32
63
  state: {
33
64
  range: fresh(() => [0, 1]),
65
+ /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
34
66
  markers: fresh(() => []),
67
+ /** One caption per marker in its order; a missing one reads as the bare numeric value. */
35
68
  captions: fresh(() => []),
36
69
  axis: Types.custom(DEFAULT_Y_AXIS),
70
+ /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
37
71
  label: "",
38
72
  arrivals: arrivalsEntry(),
39
73
  },
40
- // A plain node filled its parent; one made of its markers would hug them.
74
+ // A node made of markers would otherwise hug them.
41
75
  defaults: { width: "fill", height: "fill" },
42
76
  children: (state) => {
43
- // Composed from plain entries (range/markers/label), so it's built once here.
44
- const tickPad = insetsOps.resolve(state.axis.tickPadding).right;
45
- const titlePad = insetsOps.resolve(state.axis.titlePadding).right;
46
- const row = [];
47
- // The row's parent is the axis: its box is what the markers are placed in.
48
- const box = () => row[0]?.parent?.layoutBounds ?? { width: 0, height: 0 };
49
- /** The live tick values, top → bottom (highest first) — re-read every frame. */
50
77
  const sorted = () => [...state.markers].sort((a, b) => b - a);
51
- /** Tick `i`'s fraction across the live `range`, 0 at the bottom edge. */
52
78
  const fracAt = (value) => {
53
79
  if (value === undefined)
54
80
  return 0;
55
81
  const [min, max] = state.range;
56
82
  return max <= min ? 0 : (value - min) / (max - min);
57
83
  };
58
- // One text node per marker, ordered top → bottom. A slot with no value (the
59
- // live list is shorter than the column built for it) renders as empty text
60
- // rather than repeating its neighbour.
61
- const markers = state.markers.map((_, i) => {
62
- const marker = new Text({
63
- ...textOps.styleProps(state.axis.labelStyle),
64
- text: () => {
84
+ // A slot with no value (the live list is shorter than the column built) renders empty, not its neighbour.
85
+ return asParts([
86
+ captionColumn({
87
+ count: state.markers.length,
88
+ axis: () => state.axis,
89
+ text: (i) => {
65
90
  const value = sorted()[i];
66
91
  return value === undefined ? "" : markerCaption(state, value);
67
92
  },
68
- y: () => {
69
- // Node2D space is y-up, so the fraction runs from the bottom.
70
- const height = box().height;
71
- const centred = (fracAt(sorted()[i]) - 0.5) * height;
72
- // Held inside the axis's top edge — the backstop for a chart whose
73
- // headroom is smaller than its marker text is tall, which a theme with
74
- // much larger markers can arrange. Only the top, because what lies
75
- // below the axis is the chart's own horizontal axis and legend.
76
- const limit = height / 2 - marker.layoutBounds.height / 2;
77
- return Math.min(centred, limit);
78
- },
79
- opacity: () => arrivalOf(state.arrivals, i).opacity,
80
- x: () => arrivalOf(state.arrivals, i).shift,
81
- });
82
- return marker;
83
- });
84
- const children = [];
85
- if (state.label !== "") {
86
- // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.
87
- children.push(new RotatedBox({
88
- angle: -90,
89
- width: "hug",
90
- height: "hug",
91
- children: new Text({
92
- ...textOps.styleProps(state.axis.titleStyle),
93
- text: state.label,
94
- opacity: () => arrivalOf(state.arrivals, "label").opacity,
95
- x: () => arrivalOf(state.arrivals, "label").shift,
96
- }),
97
- }));
98
- }
99
- children.push(new Rect({ height: "fill", width: "hug", padding: { right: tickPad }, children: markers }));
100
- row.push(new Rect({ flow: "horizontal", gap: titlePad, children }));
101
- return asParts(row);
93
+ place: (i, height) => (fracAt(sorted()[i]) - 0.5) * height,
94
+ arrivals: () => state.arrivals,
95
+ label: state.label,
96
+ }),
97
+ ]);
102
98
  },
103
99
  commands: {
104
100
  /**
105
- * Stagger the markers in bottom to top, then slide the caption in from the
106
- * right after them. Its first frame arms them all: shifted right by `slide`
107
- * and transparent.
108
- *
109
- * The timeline's duration is the **whole** entrance, not one marker's slide:
110
- * the stagger and the caption are carved out of it rather than added on top.
111
- * See {@link enterBudget} for why that distinction matters here.
112
- *
113
- * `stagger` is seconds between successive markers (derived when omitted);
114
- * `slide` is the starting rightward offset in px.
101
+ * Stagger markers in bottom to top, then the caption. The duration is the
102
+ * whole entrance ({@link enterBudget}). `stagger` is seconds between markers
103
+ * (derived when omitted); `slide` is the starting rightward offset in px.
115
104
  */
116
105
  enter: {
117
106
  args: {
@@ -129,9 +118,8 @@ export const VerticalAxis = component2d({
129
118
  return arm;
130
119
  const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger);
131
120
  const ease = frameEase(timeline);
132
- // Bottom marker leads: the column is top → bottom, so walk it in reverse.
121
+ // The bottom marker leads, so walk the top-to-bottom column in reverse.
133
122
  const markers = state.markers.map((_, i) => ({ at: (count - 1 - i) * step, duration: per, piece: arrival(timeline, i, from, ease) }));
134
- // Once every marker has landed, the caption slides in from the right.
135
123
  const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, "label", from, ease) }] : [];
136
124
  return timeline.together([arm, beats(timeline, [...markers, ...label])]);
137
125
  },
@@ -1 +1 @@
1
- {"version":3,"file":"vertical-axis.js","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,GAIR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,KAA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AG,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAC1E,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n RotatedBox,\n Text,\n Types,\n component2d,\n insetsOps,\n textOps,\n type NodeOf,\n type Node2D,\n type Node2DProps,\n} from \"@motionscript/sdk\"\n\nimport { asParts, fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport {\n DEFAULT_Y_AXIS,\n enterBudget,\n formatMarker,\n type AxisConfig,\n type Range,\n} from \"./shared\"\n\nexport interface VerticalAxisProps extends Node2DProps {\n /** `[min, max]` of the vertical scale the markers are positioned within. */\n range: Range\n /**\n * Tick values (in data units) to draw up the axis, each placed by its fraction\n * across {@link VerticalAxisProps.range}. Need not be evenly spaced or include\n * the ends.\n */\n markers: number[]\n /**\n * How each marker is captioned, one per entry of `markers` and in its order.\n * Empty (the default), or short, captions a marker with its bare numeric\n * reading; a chart with a number format on this axis writes them through it.\n */\n captions: string[]\n /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */\n axis: AxisConfig\n /**\n * Rotated caption drawn in the gutter to the left of the marker column. Empty\n * string (the default) hides it — no caption node is built and no label gutter\n * is reserved.\n */\n label: string\n}\n\n/** How far a marker starts to the right of its slot when it enters, in px. */\nconst SLIDE = 24\n\n/** How a tick value is captioned — see {@link VerticalAxisProps.captions}. */\nexport type MarkerLabel = (value: number) => string\n\n/** What a marker's caption reads: the one listed for its value, else its bare reading. */\nexport function markerCaption(s: { readonly markers: readonly number[]; readonly captions: readonly string[] }, value: number): string {\n const index = s.markers.indexOf(value)\n return (index >= 0 ? s.captions[index] : undefined) ?? formatMarker(value)\n}\n\n/**\n * The numeric vertical axis shared by the cartesian charts: a **column of\n * {@link Text} nodes**, one per marker value, running top-to-bottom (highest\n * value at the top). Pure layout — no `Graphics` — so the markers are real text\n * nodes the scene can measure, restyle, or animate individually.\n *\n * Each marker is positioned so its centre lands exactly on its value's fraction\n * across `range` within the axis's filled height, so unevenly-spaced markers\n * land where their values fall. Both the caption and the position are *bound*,\n * not snapshotted: a chart that rescales its axes (see `LineChart.zoomTo`)\n * tweens `range`/`markers` live. Only the marker **count** is fixed at\n * construction.\n *\n * `enter` staggers them in **bottom-to-top**: each marker starts pushed a\n * little to the right and transparent, then fades and slides left into place.\n * The resting state is the landed one, so a chart that is never told to enter\n * still reads as a finished chart.\n */\nexport const VerticalAxis = component2d({\n key: \"verticalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n markers: fresh<number[]>(() => []),\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_Y_AXIS),\n label: \"\",\n arrivals: arrivalsEntry(),\n },\n // A plain node filled its parent; one made of its markers would hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n // Composed from plain entries (range/markers/label), so it's built once here.\n const tickPad = insetsOps.resolve(state.axis.tickPadding).right\n const titlePad = insetsOps.resolve(state.axis.titlePadding).right\n\n const row: Node2D[] = []\n // The row's parent is the axis: its box is what the markers are placed in.\n const box = () => (row[0]?.parent as Node2D | null | undefined)?.layoutBounds ?? { width: 0, height: 0 }\n /** The live tick values, top → bottom (highest first) — re-read every frame. */\n const sorted = () => [...state.markers].sort((a, b) => b - a)\n /** Tick `i`'s fraction across the live `range`, 0 at the bottom edge. */\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0\n const [min, max] = state.range\n return max <= min ? 0 : (value - min) / (max - min)\n }\n\n // One text node per marker, ordered top → bottom. A slot with no value (the\n // live list is shorter than the column built for it) renders as empty text\n // rather than repeating its neighbour.\n const markers = state.markers.map((_, i) => {\n const marker: Node2D = new Text({\n ...textOps.styleProps(state.axis.labelStyle),\n text: () => {\n const value = sorted()[i]\n return value === undefined ? \"\" : markerCaption(state, value)\n },\n y: () => {\n // Node2D space is y-up, so the fraction runs from the bottom.\n const height = box().height\n const centred = (fracAt(sorted()[i]) - 0.5) * height\n // Held inside the axis's top edge — the backstop for a chart whose\n // headroom is smaller than its marker text is tall, which a theme with\n // much larger markers can arrange. Only the top, because what lies\n // below the axis is the chart's own horizontal axis and legend.\n const limit = height / 2 - marker.layoutBounds.height / 2\n return Math.min(centred, limit)\n },\n opacity: () => arrivalOf(state.arrivals, i).opacity,\n x: () => arrivalOf(state.arrivals, i).shift,\n })\n return marker\n })\n\n const children: Node2D[] = []\n if (state.label !== \"\") {\n // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.\n children.push(\n new RotatedBox({\n angle: -90,\n width: \"hug\",\n height: \"hug\",\n children: new Text({\n ...textOps.styleProps(state.axis.titleStyle),\n text: state.label,\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\n x: () => arrivalOf(state.arrivals, \"label\").shift,\n }),\n })\n )\n }\n children.push(new Rect({ height: \"fill\", width: \"hug\", padding: { right: tickPad }, children: markers }))\n row.push(new Rect({ flow: \"horizontal\", gap: titlePad, children }))\n return asParts(row)\n },\n commands: {\n /**\n * Stagger the markers in bottom to top, then slide the caption in from the\n * right after them. Its first frame arms them all: shifted right by `slide`\n * and transparent.\n *\n * The timeline's duration is the **whole** entrance, not one marker's slide:\n * the stagger and the caption are carved out of it rather than added on top.\n * See {@link enterBudget} for why that distinction matters here.\n *\n * `stagger` is seconds between successive markers (derived when omitted);\n * `slide` is the starting rightward offset in px.\n */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.markers.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n // Bottom marker leads: the column is top → bottom, so walk it in reverse.\n const markers = state.markers.map((_, i) => ({ at: (count - 1 - i) * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n // Once every marker has landed, the caption slides in from the right.\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...markers, ...label])])\n },\n },\n },\n})\n\nexport type VerticalAxis = NodeOf<typeof VerticalAxis>\n"]}
1
+ {"version":3,"file":"vertical-axis.js","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,GAKV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAgB,MAAM,UAAU,CAAA;AACnG,OAAO,EACL,cAAc,EACd,YAAY,GAGb,MAAM,UAAU,CAAA;AAEjB,MAAM,KAAK,GAAG,EAAE,CAAA;AAEhB,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,CAAgF,EAAE,KAAa;IAC3H,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACtC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAA;AAC5E,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,QAAQ,CAAC,IAAgB,EAAE,IAAqB;IAC9D,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,OAA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{\n Rect,\n RotatedBox,\n Text,\n Types,\n component2d,\n insetsOps,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\nimport { enterBudget } from \"@motionscript/sdk/component\"\n\nimport { boundText } from \"./cartesian\"\nimport { asParts, fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport {\n DEFAULT_Y_AXIS,\n formatMarker,\n type AxisConfig,\n type Range,\n} from \"./shared\"\n\nconst SLIDE = 24\n\n/** What a marker's caption reads: the one listed for its value, else its bare reading. */\nexport function markerCaption(s: { readonly markers: readonly number[]; readonly captions: readonly string[] }, value: number): string {\n const index = s.markers.indexOf(value)\n return (index >= 0 ? s.captions[index] : undefined) ?? formatMarker(value)\n}\n\n/** The gap between an axis's markers and the plot, and between the markers and the caption, read off its config. */\nexport function axisPads(axis: AxisConfig, side: \"top\" | \"right\"): { tick: number; title: number } {\n return { tick: insetsOps.resolve(axis.tickPadding)[side], title: insetsOps.resolve(axis.titlePadding)[side] }\n}\n\n/**\n * A column of right-aligned captions beside the plot: `place(i)` is caption\n * `i`'s centre height in the column (y-up), whose height it is handed. The\n * value axis and a horizontal bar chart's category axis are both this column.\n */\nexport function captionColumn(spec: {\n readonly count: number\n readonly axis: () => AxisConfig\n readonly text: (i: number) => string\n readonly place: (i: number, height: number) => number\n readonly arrivals: () => Readonly<Record<string, Arrival>>\n readonly opacity?: (i: number) => number\n readonly label: string\n}): Node2D {\n const pads = () => axisPads(spec.axis(), \"right\")\n const markers = Array.from({ length: spec.count }, (_, i) => {\n const column = () => (marker.parent as Node2D | null)?.layoutBounds ?? { width: 0, height: 0 }\n const marker: Node2D = new Text({\n ...boundText(() => spec.axis().labelStyle),\n text: () => spec.text(i),\n // Right-aligned against the tick padding: freeform children sit on the content box's centre.\n x: () => (column().width - pads().tick) / 2 - marker.layoutBounds.width / 2 + arrivalOf(spec.arrivals(), i).shift,\n y: () => spec.place(i, column().height),\n opacity: () => arrivalOf(spec.arrivals(), i).opacity * (spec.opacity?.(i) ?? 1),\n })\n return marker\n })\n const children: Node2D[] = []\n if (spec.label !== \"\") {\n // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.\n children.push(\n new RotatedBox({\n angle: -90,\n width: \"hug\",\n height: \"hug\",\n children: new Text({\n ...boundText(() => spec.axis().titleStyle),\n text: spec.label,\n opacity: () => arrivalOf(spec.arrivals(), \"label\").opacity,\n x: () => arrivalOf(spec.arrivals(), \"label\").shift,\n }),\n }) as unknown as Node2D\n )\n }\n children.push(new Rect({ height: \"fill\", width: \"hug\", padding: () => ({ right: pads().tick }), children: markers }) as unknown as Node2D)\n return new Rect({ flow: \"horizontal\", gap: () => pads().title, height: \"fill\", children }) as unknown as Node2D\n}\n\n/**\n * The numeric vertical axis the cartesian charts share: a column of {@link Text}\n * markers, highest at the top, each centred on its value's fraction across\n * `range` and right-aligned against the plot. Caption and position are bound, so\n * a rescale tweens live; only the marker count is fixed at construction. The\n * resting state is landed.\n */\nexport const VerticalAxis = component2d({\n key: \"verticalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */\n markers: fresh<number[]>(() => []),\n /** One caption per marker in its order; a missing one reads as the bare numeric value. */\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_Y_AXIS),\n /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */\n label: \"\",\n arrivals: arrivalsEntry(),\n },\n // A node made of markers would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const sorted = () => [...state.markers].sort((a, b) => b - a)\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0\n const [min, max] = state.range\n return max <= min ? 0 : (value - min) / (max - min)\n }\n // A slot with no value (the live list is shorter than the column built) renders empty, not its neighbour.\n return asParts([\n captionColumn({\n count: state.markers.length,\n axis: () => state.axis,\n text: (i) => {\n const value = sorted()[i]\n return value === undefined ? \"\" : markerCaption(state, value)\n },\n place: (i, height) => (fracAt(sorted()[i]) - 0.5) * height,\n arrivals: () => state.arrivals,\n label: state.label,\n }),\n ])\n },\n commands: {\n /**\n * Stagger markers in bottom to top, then the caption. The duration is the\n * whole entrance ({@link enterBudget}). `stagger` is seconds between markers\n * (derived when omitted); `slide` is the starting rightward offset in px.\n */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.markers.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n // The bottom marker leads, so walk the top-to-bottom column in reverse.\n const markers = state.markers.map((_, i) => ({ at: (count - 1 - i) * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...markers, ...label])])\n },\n },\n },\n})\n\nexport type VerticalAxis = NodeOf<typeof VerticalAxis>\n"]}
@@ -1,74 +1,141 @@
1
- import { type NodeOf, type Node2D as _Node2D, type Stroke, type StrokeResolved, type Vector2 } from "@motionscript/sdk";
2
- import { type RegionBox } from "./shared.js";
1
+ import { type Fill, type FillResolved, type NodeOf, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Stroke, type StrokeResolved, type Vector2 } from "@motionscript/sdk";
2
+ import { type LineCurve, type RegionBox } from "./shared.js";
3
+ /** The x a trace at `progress` has reached, across `points` ordered along x. */
4
+ export declare function traceX(points: readonly Vector2[], progress: number): number;
3
5
  /**
4
- * A single series line of a {@link LineChart}: one rounded polyline traced
5
- * through pre-mapped pixel `points`, drawn as one {@link Graphics2D} command list.
6
- * Sized and positioned by the parent, which shares the plot's coordinate frame.
7
- *
8
- * Two signals drive it: `progress` traces the line in
9
- * (animated by `enter`) and `enabled` shows or hides it wholesale.
6
+ * One series of a {@link LineChart}: its line through pre-mapped pixel `points`,
7
+ * shaped by `curve`, and a dot on each point. `progress` traces it in from the
8
+ * left; `enabled` shows or hides it wholesale.
10
9
  */
11
10
  export declare const ChartLine: import("@motionscript/sdk").Component<"chartLine", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
12
- /** The series polyline, already mapped into this node's local pixel space (origin at centre, y-up) by the parent {@link LineChart}. Ordered along x. */
11
+ /** In this node's pixel space (origin at centre, y-up), mapped by the parent and ordered along x. */
13
12
  readonly points: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
14
- /** Line colour + weight (+ optional dash/cap/join) — the per-series stroke. */
13
+ readonly curve: import("@motionscript/sdk").Type<LineCurve, LineCurve, false>;
15
14
  readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
16
- /**
17
- * Reveal of the line in `[0, 1]`: 0 hides it, 1 traces it fully from its left
18
- * end to its right. Defaults to 1, so the paused editor canvas paints the line;
19
- * `enter` drives it from 0 regardless of where it rests.
20
- */
15
+ /** A dot of `dotSize` on each point, in `dotFill`; none at size 0. */
16
+ readonly dotSize: 0;
17
+ readonly dotFill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
18
+ /** Trace from the left end, `[0, 1]`. Rests at 1 so a paused editor canvas paints the line; `enter` drives it from 0. */
21
19
  readonly progress: 1;
22
- /** Whether this line is drawn at all: the switch the chart flips alongside its legend's per-series toggle. */
20
+ /** Whether the line is drawn at all, flipped alongside its legend entry. */
23
21
  readonly enabled: true;
24
- /** A slice of the plot to spotlight, in this node's own pixel space: outside it the line drops to `dimOpacity`. */
22
+ /** In this node's pixel space; outside it the line drops to `dimOpacity`. */
25
23
  readonly spotlight: import("@motionscript/sdk").Type<RegionBox, RegionBox, false>;
26
- /** Opacity the out-of-region stretches fade to. */
27
24
  readonly dimOpacity: 0.2;
28
25
  }>, {
29
26
  readonly enter: {
30
27
  readonly from: import("@motionscript/sdk").Type<number, number, false>;
31
28
  readonly to: import("@motionscript/sdk").Type<number, number, false>;
32
29
  };
33
- }, null, _Node2D<import("@motionscript/core").Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
34
- /** The series polyline, already mapped into this node's local pixel space (origin at centre, y-up) by the parent {@link LineChart}. Ordered along x. */
30
+ readonly hold: {
31
+ readonly shown: import("@motionscript/sdk").Type<boolean, boolean, false>;
32
+ };
33
+ }, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
34
+ /** In this node's pixel space (origin at centre, y-up), mapped by the parent and ordered along x. */
35
35
  readonly points: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
36
- /** Line colour + weight (+ optional dash/cap/join) — the per-series stroke. */
36
+ readonly curve: import("@motionscript/sdk").Type<LineCurve, LineCurve, false>;
37
37
  readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
38
- /**
39
- * Reveal of the line in `[0, 1]`: 0 hides it, 1 traces it fully from its left
40
- * end to its right. Defaults to 1, so the paused editor canvas paints the line;
41
- * `enter` drives it from 0 regardless of where it rests.
42
- */
38
+ /** A dot of `dotSize` on each point, in `dotFill`; none at size 0. */
39
+ readonly dotSize: 0;
40
+ readonly dotFill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
41
+ /** Trace from the left end, `[0, 1]`. Rests at 1 so a paused editor canvas paints the line; `enter` drives it from 0. */
43
42
  readonly progress: 1;
44
- /** Whether this line is drawn at all: the switch the chart flips alongside its legend's per-series toggle. */
43
+ /** Whether the line is drawn at all, flipped alongside its legend entry. */
45
44
  readonly enabled: true;
46
- /** A slice of the plot to spotlight, in this node's own pixel space: outside it the line drops to `dimOpacity`. */
45
+ /** In this node's pixel space; outside it the line drops to `dimOpacity`. */
47
46
  readonly spotlight: import("@motionscript/sdk").Type<RegionBox, RegionBox, false>;
48
- /** Opacity the out-of-region stretches fade to. */
49
47
  readonly dimOpacity: 0.2;
50
48
  }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
51
- /** The series polyline, already mapped into this node's local pixel space (origin at centre, y-up) by the parent {@link LineChart}. Ordered along x. */
49
+ /** In this node's pixel space (origin at centre, y-up), mapped by the parent and ordered along x. */
52
50
  readonly points: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
53
- /** Line colour + weight (+ optional dash/cap/join) — the per-series stroke. */
51
+ readonly curve: import("@motionscript/sdk").Type<LineCurve, LineCurve, false>;
54
52
  readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
55
- /**
56
- * Reveal of the line in `[0, 1]`: 0 hides it, 1 traces it fully from its left
57
- * end to its right. Defaults to 1, so the paused editor canvas paints the line;
58
- * `enter` drives it from 0 regardless of where it rests.
59
- */
53
+ /** A dot of `dotSize` on each point, in `dotFill`; none at size 0. */
54
+ readonly dotSize: 0;
55
+ readonly dotFill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
56
+ /** Trace from the left end, `[0, 1]`. Rests at 1 so a paused editor canvas paints the line; `enter` drives it from 0. */
60
57
  readonly progress: 1;
61
- /** Whether this line is drawn at all: the switch the chart flips alongside its legend's per-series toggle. */
58
+ /** Whether the line is drawn at all, flipped alongside its legend entry. */
62
59
  readonly enabled: true;
63
- /** A slice of the plot to spotlight, in this node's own pixel space: outside it the line drops to `dimOpacity`. */
60
+ /** In this node's pixel space; outside it the line drops to `dimOpacity`. */
64
61
  readonly spotlight: import("@motionscript/sdk").Type<RegionBox, RegionBox, false>;
65
- /** Opacity the out-of-region stretches fade to. */
66
62
  readonly dimOpacity: 0.2;
67
63
  }>, {
68
64
  readonly enter: {
69
65
  readonly from: import("@motionscript/sdk").Type<number, number, false>;
70
66
  readonly to: import("@motionscript/sdk").Type<number, number, false>;
71
67
  };
72
- }, _Node2D<import("@motionscript/core").Node2DProps>>>>;
68
+ readonly hold: {
69
+ readonly shown: import("@motionscript/sdk").Type<boolean, boolean, false>;
70
+ };
71
+ }, _Node2D<_Node2DProps>>>>;
73
72
  export type ChartLine = NodeOf<typeof ChartLine>;
73
+ /**
74
+ * The fill under one series of a {@link LineChart}: down to `base` (the series
75
+ * below it in a stack) or, without one, to the `baseline`. Drawn by its own node
76
+ * so every area sits under every line; the chart binds its trace, switch and
77
+ * opacity to its line's, so the two move as one.
78
+ */
79
+ export declare const ChartArea: import("@motionscript/sdk").Component<"chartArea", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
80
+ /** The series' points, as its line has them. */
81
+ readonly points: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
82
+ /** The line the area fills down to, at the same x positions; empty for the baseline. */
83
+ readonly base: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
84
+ /** Pixel y of the baseline. */
85
+ readonly baseline: 0;
86
+ readonly curve: import("@motionscript/sdk").Type<LineCurve, LineCurve, false>;
87
+ readonly area: import("@motionscript/sdk").Type<"none" | "solid" | "gradient", "none" | "solid" | "gradient", false>;
88
+ /** The series colour; the area paints it at `areaOpacity`, a gradient fading it out towards the bottom. */
89
+ readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
90
+ readonly areaOpacity: 0.4;
91
+ readonly progress: 1;
92
+ readonly enabled: true;
93
+ readonly spotlight: import("@motionscript/sdk").Type<RegionBox, RegionBox, false>;
94
+ readonly dimOpacity: 0.2;
95
+ }>, {}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
96
+ /** The series' points, as its line has them. */
97
+ readonly points: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
98
+ /** The line the area fills down to, at the same x positions; empty for the baseline. */
99
+ readonly base: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
100
+ /** Pixel y of the baseline. */
101
+ readonly baseline: 0;
102
+ readonly curve: import("@motionscript/sdk").Type<LineCurve, LineCurve, false>;
103
+ readonly area: import("@motionscript/sdk").Type<"none" | "solid" | "gradient", "none" | "solid" | "gradient", false>;
104
+ /** The series colour; the area paints it at `areaOpacity`, a gradient fading it out towards the bottom. */
105
+ readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
106
+ readonly areaOpacity: 0.4;
107
+ readonly progress: 1;
108
+ readonly enabled: true;
109
+ readonly spotlight: import("@motionscript/sdk").Type<RegionBox, RegionBox, false>;
110
+ readonly dimOpacity: 0.2;
111
+ }>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
112
+ /** The series' points, as its line has them. */
113
+ readonly points: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
114
+ /** The line the area fills down to, at the same x positions; empty for the baseline. */
115
+ readonly base: import("@motionscript/sdk").Type<Vector2[], Vector2[], false>;
116
+ /** Pixel y of the baseline. */
117
+ readonly baseline: 0;
118
+ readonly curve: import("@motionscript/sdk").Type<LineCurve, LineCurve, false>;
119
+ readonly area: import("@motionscript/sdk").Type<"none" | "solid" | "gradient", "none" | "solid" | "gradient", false>;
120
+ /** The series colour; the area paints it at `areaOpacity`, a gradient fading it out towards the bottom. */
121
+ readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
122
+ readonly areaOpacity: 0.4;
123
+ readonly progress: 1;
124
+ readonly enabled: true;
125
+ readonly spotlight: import("@motionscript/sdk").Type<RegionBox, RegionBox, false>;
126
+ readonly dimOpacity: 0.2;
127
+ }>, {}, _Node2D<_Node2DProps>>>>;
128
+ interface Span {
129
+ readonly top: number;
130
+ readonly bottom: number;
131
+ }
132
+ /**
133
+ * The area's paint for an outline spanning `own`: the series colour at
134
+ * `opacity`, or for a gradient that colour fading to nearly nothing across
135
+ * `whole`. A gradient maps onto the bounds of the shape it fills, so its ends
136
+ * are placed in `own`'s unit box (y-up) at `whole`'s top and bottom.
137
+ */
138
+ export declare function areaFill(colour: FillResolved[], area: "none" | "solid" | "gradient", opacity: number, whole: Span, own: Span): FillResolved[];
139
+ export type ChartArea = NodeOf<typeof ChartArea>;
140
+ export {};
74
141
  //# sourceMappingURL=chart-line.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chart-line.d.ts","sourceRoot":"","sources":["../../src/line-chart/chart-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,MAAM,EAEX,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,OAAO,EACb,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,UAAU,CAAA;AAuCjB;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;IAGlB,wJAAwJ;;IAExJ,+EAA+E;;IAE/E;;;;OAIG;;IAEH,8GAA8G;;IAE9G,mHAAmH;;IAEnH,mDAAmD;;;;;;;;IAdnD,wJAAwJ;;IAExJ,+EAA+E;;IAE/E;;;;OAIG;;IAEH,8GAA8G;;IAE9G,mHAAmH;;IAEnH,mDAAmD;;;IAdnD,wJAAwJ;;IAExJ,+EAA+E;;IAE/E;;;;OAIG;;IAEH,8GAA8G;;IAE9G,mHAAmH;;IAEnH,mDAAmD;;;;;;;uDAmErD,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAA"}
1
+ {"version":3,"file":"chart-line.d.ts","sourceRoot":"","sources":["../../src/line-chart/chart-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,MAAM,EAEX,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,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