@motionscript/charts 0.1.0-alpha.0 → 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/NOTICE +49 -0
  3. package/README.md +99 -0
  4. package/dist/bar-chart/bar-chart.d.ts +133 -228
  5. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  6. package/dist/bar-chart/bar-chart.js +386 -565
  7. package/dist/bar-chart/bar-chart.js.map +1 -1
  8. package/dist/bar-chart/category-axis.d.ts +35 -41
  9. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  10. package/dist/bar-chart/category-axis.js +93 -115
  11. package/dist/bar-chart/category-axis.js.map +1 -1
  12. package/dist/bar-chart/chart-bars.d.ts +50 -70
  13. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  14. package/dist/bar-chart/chart-bars.js +155 -210
  15. package/dist/bar-chart/chart-bars.js.map +1 -1
  16. package/dist/bar-chart/index.d.ts +2 -2
  17. package/dist/bar-chart/index.d.ts.map +1 -1
  18. package/dist/bar-chart/index.js +1 -1
  19. package/dist/bar-chart/index.js.map +1 -1
  20. package/dist/bar-chart/shared.d.ts +7 -7
  21. package/dist/bar-chart/shared.d.ts.map +1 -1
  22. package/dist/bar-chart/shared.js +7 -7
  23. package/dist/bar-chart/shared.js.map +1 -1
  24. package/dist/browser/chunks/chunk-TJNHLQGV.js +2 -0
  25. package/dist/browser/chunks/chunk-TJNHLQGV.js.map +7 -0
  26. package/dist/browser/index.js +1 -1
  27. package/dist/browser/index.js.map +3 -3
  28. package/dist/browser/kit.js +1 -1
  29. package/dist/browser/manifest.json +4 -3
  30. package/dist/engine.d.ts +10 -8
  31. package/dist/engine.d.ts.map +1 -1
  32. package/dist/engine.js +10 -8
  33. package/dist/engine.js.map +1 -1
  34. package/dist/kit/cartesian.d.ts +44 -0
  35. package/dist/kit/cartesian.d.ts.map +1 -0
  36. package/dist/kit/cartesian.js +59 -0
  37. package/dist/kit/cartesian.js.map +1 -0
  38. package/dist/kit/chart-border.d.ts +10 -11
  39. package/dist/kit/chart-border.d.ts.map +1 -1
  40. package/dist/kit/chart-border.js +15 -32
  41. package/dist/kit/chart-border.js.map +1 -1
  42. package/dist/kit/chart-canvas.d.ts +32 -21
  43. package/dist/kit/chart-canvas.d.ts.map +1 -1
  44. package/dist/kit/chart-canvas.js +33 -90
  45. package/dist/kit/chart-canvas.js.map +1 -1
  46. package/dist/kit/chart-legend.d.ts +123 -85
  47. package/dist/kit/chart-legend.d.ts.map +1 -1
  48. package/dist/kit/chart-legend.js +137 -186
  49. package/dist/kit/chart-legend.js.map +1 -1
  50. package/dist/kit/entries.d.ts +17 -0
  51. package/dist/kit/entries.d.ts.map +1 -0
  52. package/dist/kit/entries.js +19 -0
  53. package/dist/kit/entries.js.map +1 -0
  54. package/dist/kit/motion.d.ts +48 -0
  55. package/dist/kit/motion.d.ts.map +1 -0
  56. package/dist/kit/motion.js +63 -0
  57. package/dist/kit/motion.js.map +1 -0
  58. package/dist/kit/paints.d.ts +10 -0
  59. package/dist/kit/paints.d.ts.map +1 -0
  60. package/dist/kit/paints.js +12 -0
  61. package/dist/kit/paints.js.map +1 -0
  62. package/dist/kit/shared.d.ts +61 -10
  63. package/dist/kit/shared.d.ts.map +1 -1
  64. package/dist/kit/shared.js +108 -13
  65. package/dist/kit/shared.js.map +1 -1
  66. package/dist/kit/vertical-axis.d.ts +48 -61
  67. package/dist/kit/vertical-axis.d.ts.map +1 -1
  68. package/dist/kit/vertical-axis.js +97 -132
  69. package/dist/kit/vertical-axis.js.map +1 -1
  70. package/dist/line-chart/chart-line.d.ts +60 -77
  71. package/dist/line-chart/chart-line.d.ts.map +1 -1
  72. package/dist/line-chart/chart-line.js +100 -121
  73. package/dist/line-chart/chart-line.js.map +1 -1
  74. package/dist/line-chart/chart-region.d.ts +32 -33
  75. package/dist/line-chart/chart-region.d.ts.map +1 -1
  76. package/dist/line-chart/chart-region.js +31 -65
  77. package/dist/line-chart/chart-region.js.map +1 -1
  78. package/dist/line-chart/horizontal-axis.d.ts +58 -64
  79. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  80. package/dist/line-chart/horizontal-axis.js +94 -123
  81. package/dist/line-chart/horizontal-axis.js.map +1 -1
  82. package/dist/line-chart/index.d.ts +3 -3
  83. package/dist/line-chart/index.d.ts.map +1 -1
  84. package/dist/line-chart/index.js +2 -2
  85. package/dist/line-chart/index.js.map +1 -1
  86. package/dist/line-chart/line-chart.d.ts +156 -303
  87. package/dist/line-chart/line-chart.d.ts.map +1 -1
  88. package/dist/line-chart/line-chart.js +410 -638
  89. package/dist/line-chart/line-chart.js.map +1 -1
  90. package/dist/line-chart/shared.d.ts +7 -7
  91. package/dist/line-chart/shared.d.ts.map +1 -1
  92. package/dist/line-chart/shared.js +23 -8
  93. package/dist/line-chart/shared.js.map +1 -1
  94. package/dist/line-chart/x-scale.d.ts +4 -11
  95. package/dist/line-chart/x-scale.d.ts.map +1 -1
  96. package/dist/line-chart/x-scale.js +16 -5
  97. package/dist/line-chart/x-scale.js.map +1 -1
  98. package/dist/nodes.d.ts +6 -9
  99. package/dist/nodes.d.ts.map +1 -1
  100. package/dist/nodes.js +7 -9
  101. package/dist/nodes.js.map +1 -1
  102. package/dist/pie-chart/index.d.ts +2 -2
  103. package/dist/pie-chart/index.d.ts.map +1 -1
  104. package/dist/pie-chart/index.js +1 -1
  105. package/dist/pie-chart/index.js.map +1 -1
  106. package/dist/pie-chart/pie-chart.d.ts +108 -126
  107. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  108. package/dist/pie-chart/pie-chart.js +202 -271
  109. package/dist/pie-chart/pie-chart.js.map +1 -1
  110. package/dist/pie-chart/pie-legend.d.ts +84 -31
  111. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  112. package/dist/pie-chart/pie-legend.js +93 -107
  113. package/dist/pie-chart/pie-legend.js.map +1 -1
  114. package/dist/pie-chart/pie-ring.d.ts +160 -122
  115. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  116. package/dist/pie-chart/pie-ring.js +333 -361
  117. package/dist/pie-chart/pie-ring.js.map +1 -1
  118. package/dist/pie-chart/shared.d.ts +12 -6
  119. package/dist/pie-chart/shared.d.ts.map +1 -1
  120. package/dist/pie-chart/shared.js +14 -8
  121. package/dist/pie-chart/shared.js.map +1 -1
  122. package/package.json +7 -4
  123. package/src/bar-chart/bar-chart.ts +424 -686
  124. package/src/bar-chart/category-axis.ts +96 -111
  125. package/src/bar-chart/chart-bars.ts +178 -201
  126. package/src/bar-chart/index.ts +2 -2
  127. package/src/bar-chart/shared.ts +7 -7
  128. package/src/engine.ts +10 -8
  129. package/src/kit/cartesian.ts +81 -0
  130. package/src/kit/chart-border.ts +23 -34
  131. package/src/kit/chart-canvas.ts +45 -80
  132. package/src/kit/chart-legend.ts +185 -206
  133. package/src/kit/entries.ts +20 -0
  134. package/src/kit/motion.ts +90 -0
  135. package/src/kit/paints.ts +15 -0
  136. package/src/kit/shared.ts +120 -13
  137. package/src/kit/vertical-axis.ts +111 -141
  138. package/src/line-chart/chart-line.ts +103 -155
  139. package/src/line-chart/chart-region.ts +36 -81
  140. package/src/line-chart/horizontal-axis.ts +102 -153
  141. package/src/line-chart/index.ts +3 -3
  142. package/src/line-chart/line-chart.ts +463 -759
  143. package/src/line-chart/shared.ts +22 -8
  144. package/src/line-chart/x-scale.ts +20 -5
  145. package/src/nodes.ts +8 -10
  146. package/src/pie-chart/index.ts +2 -2
  147. package/src/pie-chart/pie-chart.ts +225 -303
  148. package/src/pie-chart/pie-legend.ts +125 -115
  149. package/src/pie-chart/pie-ring.ts +388 -443
  150. package/src/pie-chart/shared.ts +14 -8
  151. package/dist/browser/chunks/chunk-ZMBOBHYL.js +0 -2
  152. package/dist/browser/chunks/chunk-ZMBOBHYL.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,110 @@
1
1
  # @motionscript/charts
2
2
 
3
+ ## 0.1.0-alpha.10
4
+
5
+ ## 0.1.0-alpha.9
6
+
7
+ ## 0.1.0-alpha.8
8
+
9
+ ## 0.1.0-alpha.7
10
+
11
+ ### Minor Changes
12
+
13
+ - 737f7d0: What was left of the class authoring system is gone. Each piece existed to write or extend a node class, and a node type is a component now; no built-in, kit or host used them.
14
+
15
+ Removed from `@motionscript/core`:
16
+
17
+ - the registration functions `property`, `node`, `command` and `withdraw`, and the thirteen typed property helpers (`fillProperty`, `strokeProperty`, `shadowProperty`, `effectsProperty`, `colorProperty`, `cornerRadiusProperty`, `cornerStyleProperty`, `pathProperty`, `insetsProperty`, `alignmentProperty`, `vector2Property`, `sizeProperty`, `textProperty`) with their `AttributePropOptions` type. A component declares its entries with `Types`. `getPropertyMeta`, `getNodeDescriptor`, `getCommandMeta` and the metadata types stay;
18
+ - `TextSelection`, `TextSelectionHost`, `TextSelectionProps`, `TextRange`, `SelectionOverrides` and `normalizeRanges`: the component `Text` has no selection API, so nothing could make one. Style a range with `runs`;
19
+ - `AudioScope` and the `declareAudio` hook on `Node`: sound plays from commands (`timeline.sound`). `busPathOf` and `busPathTo` take a function answering a node's span instead of an `AudioScope`;
20
+ - the `Node.tick` hook and the `Node2D` hooks `beforeRender`, `afterRender`, `renderStroke`, `clipPathSelf`, `resolveSizeInput` and `constraints`, which only a subclass could reach;
21
+ - `NodeTypeRecord.withdrawn` and `CommandMeta.withdrawn`. `PropertyMeta.withdrawn` stays, deprecated: nothing sets it.
22
+
23
+ Removed from `@motionscript/core/component`, and so from `@motionscript/sdk/component` and `@motionscript/charts/kit`, which re-export it: the seekable composition `at`, `hold`, `sequence` and `together`, with the `Seekable` and `Placed` types. A component command returns timeline pieces.
24
+
25
+ Removed from `@motionscript/sdk`: `TextSelection`, `TextSelectionProps`, `TextRange`, `SelectionOverrides`, `AudioScope` and `AudioClip`.
26
+
27
+ ## 0.1.0-alpha.6
28
+
29
+ ### Minor Changes
30
+
31
+ - 163b708: Node types are components: one spec object handed to `component2d`, `component3d` or `componentAudio`, with no classes, decorators or JSX.
32
+
33
+ - **Writing a node type.** A component is one object literal: `key`, `state` (literals and `Types`), `defaults`, `commands`, `children`, `allowedChildren`/`allowedParents`, `provide`, `load`, and its tree's own fields (`measure`, `layout`, `render` for 2D). Behaviour comes from modules you spread in and call: `Paint`, `Flow`, `Shapes`, `Typeface`, `TextLayout`, `Aim`, `Material`, `View3D`. ADR 0007 and the custom-node docs cover it.
34
+ - **Building nodes in code** uses calls: `Rect({ fill: 'tomato', children: [Text({ text: 'Hi' })] })`, or `new Rect({...})` for the node itself.
35
+ - **Every built-in and every kit node is a component**, under the same document key. Code that tested `instanceof` a class now uses the component's `.is`, or `instanceof X.node`. Changed members:
36
+ - `SurfacePlot3d.valueAt` and `FunctionPlot.valueAt` are now the functions `surfaceValueAt` and `curveValue`.
37
+ - A system's `coordinates` is replaced by `planeMap`/`axesMap`/`systemMap`.
38
+ - `PieChart.isSelected` is replaced by `isSliceSelected`.
39
+ - `ItemGrid` is a kit module (`ItemGrid.isGrid`, `ItemGrid.define`), not a base class.
40
+ - **The sdk no longer exports the class surface:**
41
+ - the decorators: `node`, `property` and every `*Property`, `command`, `withdraw`, `driveCommand`;
42
+ - the authoring bases: `PaintNode`, `ShapeNode`, `TextBase`, `Mesh3DBase`, `Canvas3DBase` and the `*Base` geometry classes;
43
+ - `asCommand`, `compose`, `drive` and `declarePaints` from `@motionscript/sdk/component`;
44
+ - the `jsx-runtime` and `jsx-dev-runtime` subpaths.
45
+ - `Node`, `Node2D`, `Node3D` and `NodeAudio` remain as types.
46
+ - **Editor metadata leaves the engine.** The kits no longer declare `parentKey`, `forkable`, `layout`, `seed`, `within`, `beside` or `closed`; a host keeps those in its own configs. `describe()` now reports `holds`, the trees a type takes children from, and the placement checks use it, so a 2D viewport of your own that takes 3D children places them.
47
+ - A command called from code with no argument runs, and a refused child is told what its parent takes (`allowedChildren`) or where it goes (`allowedParents`).
48
+
49
+ ## 0.1.0-alpha.5
50
+
51
+ ### Patch Changes
52
+
53
+ - da6f97a: Every package ships a `NOTICE`, and a browser build lists what it bundles.
54
+
55
+ - Each tarball carries the repository `NOTICE`: the copyright line and the MIT attributions for the noise functions in `skia-render`'s fractal-noise fill (David Hoskins' "Hash without Sine", Inigo Quilez's 2D simplex noise).
56
+ - `@motionscript/canvaskit` ships `THIRD_PARTY_NOTICES.txt` with the licences of the libraries compiled into the binary: FreeType, HarfBuzz, ICU 74, zlib, libpng, Brotli, WOFF2, Emscripten and musl.
57
+ - `dist/browser/manifest.json` gains `thirdParty`, the packages the browser build bundled (`name`, `version`, `license`), and their licence and NOTICE files are written to `dist/browser/THIRD_PARTY_LICENSES.txt`. `@motionscript/browser` bundles mediabunny (MPL-2.0, unmodified; source at https://github.com/Vanilagy/mediabunny), esbuild-wasm and three; `@motionscript/math` bundles MathJax.
58
+
59
+ - 1778355: The published packages carry what a user needs and say what they are.
60
+
61
+ - `@motionscript/code` no longer ships `dist/tests/diff.bench.*`, and `@motionscript/math` no longer ships `dist/tests/harness.*` or `mathjax.setup.*`: test helpers under a `tests` folder are left out of every package's build.
62
+ - `@motionscript/sdk`'s description no longer repeats core's, and `@motionscript/math`'s names the coordinate systems, plots, 3D graphs and network graphs it has as well as formulas.
63
+ - The READMEs of `@motionscript/canvaskit`, `@motionscript/charts`, `@motionscript/geo`, `@motionscript/grids`, `@motionscript/skia-render` and `@motionscript/geography` say what to install, and `@motionscript/sdk`'s example now opens the document in an engine and plays it. Links between packages point at the repository, so they work on npm.
64
+
65
+ ## 0.1.0-alpha.4
66
+
67
+ ### Patch Changes
68
+
69
+ - d8ae489: A chart legend's entries now open and close from their own width. A series that started hidden stayed zero-width for the whole `showSeries` move and snapped open at the end, and a `hideSeries` that was seeked to straight away (a scrub or an export) collapsed at zero width, while the same hide played from before shrank from the measured width. An entry's width is now measured from its caption and swatch at any reveal, so playing and seeking give the same frame, and a fully shown entry is laid out exactly as before.
70
+ - 96d49af: A pie ring's wedge outline and shadow can be painted with an image. `PieRing` declared each slice fill and the leader stroke only, so an image in `ring.stroke` or in a `ring.shadow` fill was never loaded and the renderer failed on it. Both are now declared with the rest of the ring's paints.
71
+ - ad28707: Component kit fixes.
72
+
73
+ - Charts: a bar chart maps its columns across the plot panel as laid out (and takes the line chart's top headroom), so a column ends on its marker's grid line. A pie chart's wedges, labels and legend follow `data` and the palette once they are set. A restated value-axis or y/x-axis `range` or `ticks` in `to()` rescales continuously from the axis as drawn, instead of cutting at the midpoint. Without a legend (or without series) the entrance keeps that beat's share, so the call-out and legend land where the slot lays them out. A constant line series gets a scale with width, a `NaN` or infinite cell reads as 0, and tick captions gain decimals when the step is finer than 0.1.
74
+ - Code: the compiled highlighter is cached per style object, so two styles sharing a name no longer colour alike. A `CodeRanges` chain serialises as its ranges, so a stored `highlight` target selects what it did before it was saved.
75
+ - LaTeX: seeking from inside a morph to a time before it restores the source formula instead of leaving the last morph frame.
76
+ - Geo: custom border rings are wound for d3, so a GeoJSON counter-clockwise ring draws as the small region it encloses; a great-circle path between antipodal points runs over the north pole instead of wherever rounding lands.
77
+ - Audio: bottom-aligned waveform bars stand on the floor of the box instead of hanging from the top.
78
+ - `Code` and `Latex` take an optional props bag, so `new Registry({ nodes: NODES })` and `createBrowserEngine({ nodes: NODES })` type-check without a cast.
79
+
80
+ - 75b6908: Fixes in document validation, the clip timeline and the expression language.
81
+
82
+ - `validateDocument` reports tree and command issues at the row's place in the document. A malformed row earlier in `nodes` or `commands` used to shift every later path by one.
83
+ - The parts a command writes on a node's own children (a chart's ring, legend or bars) are restored to what they were built with before the command starts and after a seek back, so a frame no longer depends on how the playhead arrived. The chart legend's per-series reveal is now one slot, so the timeline can restore it.
84
+ - A child that enters before its parent is baselined once the parent has mounted it, so it keeps what it inherits (a text style, for example) instead of the pre-attach values.
85
+ - A row that an animated `removeChildAt` takes out of its parent is back in place before the command starts, in a fresh build and after a scrub alike.
86
+ - An unknown `targetId` is one error naming it for every node-scoped command (`to`, `set`, `save`, `moveTo`, component commands). Global-table commands used to be skipped silently, and named ones blamed the node type.
87
+ - Instant `removeChildAt` detaches the removed subtree, as `remove()` and `clear()` do.
88
+ - Expressions: `toString`, `constructor`, `__proto__` and the other `Object.prototype` names are unknown functions and constants rather than a `TypeError`, in the shared parser and the plot kit (and `alignmentOps.resolve` rejects them as `isKey` does). A blank string operand is `NaN`, not `0`. `step` and `smoothstep` propagate `NaN`, and `smoothstep` with equal edges is a step at the edge. Arity errors say "1 argument". `renameRefs` hands its callback the trimmed reference name.
89
+
90
+ ## 0.1.0-alpha.3
91
+
92
+ ### Patch Changes
93
+
94
+ - 6697bb4: Every chart command runs from a document.
95
+
96
+ - Thirteen of the twenty chart commands returned a composition of seekable parts rather than a `Command`, so a document naming one failed to compile with `TypeError: made.at is not a function`: `enter` on all three charts, `showSeries`, `hideSeries` and `spotlightSeries` on the line and bar charts, and `selectSlice`, `deselectSlice`, `selectOnlySlice` and `clearSelection` on the pie. So did `zoomTo` with a region naming neither axis, and `resetZoom` before any zoom. Each now returns a `Command` that lasts the duration it was given. A line or bar `enter` without a legend, whose beats end before that, holds its last frame for the rest of it.
97
+ - `@motionscript/sdk/component` gains `asCommand(part, duration?)`, which makes a composition built with `at`, `sequence`, `together`, `hold`, `compose` or `drive` the `Command` a `@command()` method returns. A part that ends before `duration` holds its last frame, and one that runs longer is played faster, so the command always ends where the part does.
98
+ - A line chart's first `zoomTo` from an auto axis tweens. It started from the unset range and ticks, which the axis tween steps at the midpoint, so the first zoom cut halfway through and only later ones moved. A zoom, and `resetZoom`, now start from the range and ticks the axis draws.
99
+
100
+ ## 0.1.0-alpha.2
101
+
102
+ ## 0.1.0-alpha.1
103
+
104
+ ### Minor Changes
105
+
106
+ - 59cecba: Build on `@motionscript/sdk` instead of `@motionscript/core`. The peer dependency is now `@motionscript/sdk`, every import goes through it (and `@motionscript/sdk/component` for the component machinery), and the browser build leaves `@motionscript/sdk` an import, so an import map names it once. A component copied with `ms add` imports the SDK too, and its registry item depends on `@motionscript/sdk` rather than `@motionscript/core`. `@motionscript/charts/kit` re-exports `@motionscript/sdk/component` where it re-exported `@motionscript/core/component`.
107
+
3
108
  ## 0.1.0-alpha.0
4
109
 
5
110
  Initial release.
package/NOTICE ADDED
@@ -0,0 +1,49 @@
1
+ Motionscript
2
+ Copyright 2026 Motionscript LLC
3
+
4
+ This product includes the third-party code below, each part under the MIT
5
+ License reproduced at the end of this file.
6
+
7
+ - packages/renderer/crates/renderer/src/shaders/prim.wgsl (`fn_hash2`):
8
+ "Hash without Sine" by David Hoskins (https://www.shadertoy.com/view/4djSRW).
9
+ Copyright (c) 2014 David Hoskins.
10
+
11
+ - packages/renderer/crates/renderer/src/shaders/prim.wgsl (`simplex_noise`): "Noise - simplex - 2D" by Inigo Quilez
12
+ (https://www.shadertoy.com/view/Msf3WH). Copyright (c) 2013 Inigo Quilez.
13
+
14
+ - packages/renderer/crates/render3d (in @motionscript/renderer's WebAssembly):
15
+ its shaders (src/shaders/mesh.wgsl) port three.js r185's mesh programs and
16
+ src/geometry.rs its primitive generators (https://threejs.org).
17
+ Copyright (c) 2010-2026 three.js authors.
18
+
19
+ @motionscript/renderer's WebAssembly (dist/ms_renderer_bg.wasm) compiles in
20
+ Rust crates under MIT, Apache-2.0, Zlib and Unicode-3.0 terms (wgpu, naga,
21
+ harfrust, read-fonts, kurbo, wasm-bindgen and others); their notices are in
22
+ packages/renderer/THIRD_PARTY_NOTICES.txt.
23
+
24
+ MP3 export loads @mediabunny/mp3-encoder (MPL-2.0), a WebAssembly build of
25
+ the LAME MP3 encoder (LGPL, https://lame.sourceforge.io), on first use.
26
+
27
+ The browser builds under dist/browser/ bundle each package's npm dependencies;
28
+ dist/browser/THIRD_PARTY_LICENSES.txt in each package lists them with their
29
+ licences.
30
+
31
+ MIT License
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy
34
+ of this software and associated documentation files (the "Software"), to deal
35
+ in the Software without restriction, including without limitation the rights
36
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
+ copies of the Software, and to permit persons to whom the Software is
38
+ furnished to do so, subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in all
41
+ copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # @motionscript/charts
2
+
3
+ Animated data charts for [Motion Script](https://motionscript.dev): a line chart,
4
+ a bar chart and a pie chart, built from one shared kit (plot panel, value axis,
5
+ legend, number formatting, theme resolution). Written against
6
+ [`@motionscript/sdk`](https://github.com/motionscript-dev/motionscript/tree/main/packages/sdk), which it takes as a peer dependency.
7
+
8
+ ```ts
9
+ import { NODES } from '@motionscript/charts';
10
+
11
+ export const nodes = NODES; // [LineChart, BarChart, PieChart]
12
+ ```
13
+
14
+ Importing registers nothing; the host hands `NODES` to the engine (see
15
+ [`packages/components/CLAUDE.md`](https://github.com/motionscript-dev/motionscript/blob/main/packages/components/CLAUDE.md) for the registration and import rules every kit shares).
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ npm install @motionscript/charts @motionscript/sdk
21
+ ```
22
+
23
+ ## Exports
24
+
25
+ | Path | Source | What |
26
+ |---|---|---|
27
+ | `@motionscript/charts` | `src/index.ts` | the three chart barrels, `src/engine.ts` and `NODES` |
28
+ | `@motionscript/charts/kit` | `src/engine.ts` | the shared kit (`src/kit/*`) and all of `@motionscript/sdk/component` |
29
+
30
+ Each chart folder (`line-chart/`, `bar-chart/`, `pie-chart/`) has an `index.ts`
31
+ barrel with the node, its parts, its theme (`DEFAULT_*_THEME`, `resolve*Theme`,
32
+ `lerp*Theme`) and its pure helpers (`resolveXScale`, `barSpans`, `pieArcs`, ...).
33
+ The charts and their parts (`ChartLine`, `ChartBars`, `PieRing`, `VerticalAxis`, ...)
34
+ are components (`component2d`); only the charts are registered node types, so a
35
+ document cannot name a part. A chart tells a host its key, entries and commands;
36
+ where it is shelved and the box it is seeded at are the host's to keep. `lineChartDomains` and `barChartDomain` give the axes as drawn, and
37
+ `isSliceSelected` whether a pie slice is out.
38
+
39
+ ## Nodes
40
+
41
+ | Key | Made for (w x h) | Data props | Commands |
42
+ |---|---|---|---|
43
+ | `lineChart` | 760 x 460 | `data`, `xField`, `series`, `xAxis`, `yAxis`, `region` | `enter`, `spotlightRegion`, `clearRegion`, `zoomTo`, `resetZoom`, `showSeries`/`hideSeries`/`spotlightSeries` |
44
+ | `barChart` | 760 x 460 | `data`, `categoryField`, `series`, `valueAxis`, `stacked` | `enter`, `showSeries`/`hideSeries`/`spotlightSeries`, `spotlightCategory`, `clearCategory` |
45
+ | `pieChart` | 680 x 480 | `data`, `categoryField`, `valueField` | `enter`, `revealCenter`, `selectSlice`/`deselectSlice`/`selectOnlySlice`/`clearSelection` |
46
+
47
+ Every command takes the duration its row (or call) gives, and eases out unless
48
+ given an easing. Arguments: `seriesIndex`, `sliceIndex`, `categoryIndex` (each 0
49
+ when left out), and for `spotlightRegion` and `zoomTo` a `region` of
50
+ `{ x?: [min, max], y?: [min, max] }`.
51
+
52
+ ## Rules worth knowing
53
+
54
+ - **The kit stays an import.** A copy of `line-chart` takes only `line-chart/*` and
55
+ rewrites its kit imports to `@motionscript/charts` (`registry.json`): a second
56
+ copy of `VerticalAxis` would render as nothing, with no error.
57
+ - **Resting state is the finished chart.** `enter` arms every part on its first
58
+ frame: every piece of a component command is built run to its end, and a beat
59
+ ahead of the playhead writes nothing, so the first frame writes what each later
60
+ beat moves from. `duration` is the whole entrance: a beat with nothing to do (no
61
+ legend, no series) holds its share.
62
+ - **A part's command has no duration of its own.** The charts pass every part the
63
+ duration and easing it moves with; called directly, a part's command takes the
64
+ duration it is given, and a part's own frames ease out unless given an easing.
65
+ - **Some props are read once, at construction**: the series list (count, labels,
66
+ `enabled`), `showLegend`, `showValues`, `showCenter`, axis captions, text styles and
67
+ paddings, the bar chart's category captions, the pie's label and legend-row counts,
68
+ `labelMode`, `labelPlacement`, `gap`, `centerLabel`, `centerCaption`. A `set` or `to`
69
+ of them changes nothing; a document edit re-instantiates the node, which does
70
+ refresh them. `data`, scales, ticks, theme paints, `region`, `stacked`, `weights`
71
+ and `pops` are live.
72
+ - **Non-finite cells plot as 0.** `num()` returns a cell only when it is a finite
73
+ number, so a numeric string, `NaN`, `Infinity` and a missing cell all read 0.
74
+ - **x units on the line chart.** `xAxis.range`, `xAxis.ticks` and a region's `x`
75
+ are in the x scale's own units: the number (numeric column), UTC epoch
76
+ milliseconds (time column) or the row index (ordinal column), chosen from the
77
+ column by `resolveXScale` (dates via `parseInstant`).
78
+ - **`zoomTo` remembers the resting domain once** (`home`, a private entry its
79
+ frames write) and `resetZoom`'s frames clear it, so the pair is order dependent
80
+ and a seek back before a zoom forgets it again: a `resetZoom` with no earlier
81
+ `zoomTo`, and a `zoomTo` naming neither axis, write nothing for their duration.
82
+ A zoom keeps the tick count so each marker slides.
83
+ - **A `to` of an axis `range` or `ticks` tweens from the domain as drawn**
84
+ (`lerpAxisEntry`): an auto side is held mid-move as an `AxisDomainBlend`, which
85
+ the chart settles against its data, so a rescale from an auto axis is continuous.
86
+ A restated range without ticks spreads explicit ticks across it; one side of an
87
+ auto axis restated alone leaves the other to the data.
88
+ - **Pie angles** are radians clockwise from 12 o'clock; `startAngle` is degrees.
89
+
90
+ ## Development
91
+
92
+ ```bash
93
+ pnpm --filter @motionscript/charts build
94
+ pnpm --filter @motionscript/charts test
95
+ ```
96
+
97
+ Tests sit beside the code (`*.test.ts`); `src/document.test.ts` runs the commands
98
+ through a compiled document, and `src/tests/harness.ts` supplies the attach, measure
99
+ and record helpers.