@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @motionscript/charts
2
2
 
3
+ ## 0.1.1-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1810e8a: **Breaking:** the charts are rebuilt around one `style` entry, and the kit gains a radar and a radial chart.
8
+
9
+ - **One look entry.** Every chart's `theme` (and its `DEFAULT_*_THEME`, `resolve*Theme`, `lerp*Theme`) is gone, along with `showLegend` and the bar chart's `showValues`. Each chart has `style: Types.style("chart", …)` instead, with fields grouped as colours (`palette`, `foreground`, `muted`, `background`), text (`fontFamily`, `fontSize`, `fontWeight`), grid (`horizontalGrid`, `verticalGrid` and `axisStroke` on a line or bar chart, `gridStroke` and `spokeStroke` on a radar, all strokes, so weight, colour, dash and caps come with them and an empty one draws nothing), marks, labels and legend (`legend`: bottom, top, right or none; `swatch`: square, circle or line). A chart takes only the fields it draws, and one style dresses any chart. `CHART_STYLE_PRESETS` (midnight, paper, ember, neon, ocean, sunset, pastel, mono) are partial looks to spread in; `to({ style })` tweens a restyle.
10
+ - **Line and area are one chart.** `lineChart` draws curves `smooth` (monotone, never overshooting), `linear` or `step`, optional dots, and `style.area` of `none`, `solid` or `gradient` under each line. `stack` is `none`, `stacked` or `percent`. Up to twelve categorical or dated samples each get a tick.
11
+ - **Bars.** `barChart` takes `orientation` (`vertical` or `horizontal`) and `stack` (`none`, `stacked` or `percent`; replaces `stacked`). Negative values grow from zero, only a stack's outer end is rounded, and `style.values` puts figures at the `end` of a bar or `inside` it.
12
+ - **Pie.** `style.innerRadius` makes a donut; `sliceGap`, `sliceRadius` and `labelPlacement` (`inside`, `outside`, `none`) are style fields.
13
+ - **New: `radarChart`.** One spoke per row, one polygon per series, a `polygon` or `circle` grid, with `enter` and the series commands.
14
+ - **A line is a stroke, an area is a fill.** A radial's `track` is a fill (empty for none). There is no grid width, dash, axis-line, spoke or track switch, and no `gridColor`. A series' `label` is optional: the legend shows `label || field`.
15
+ - **New: `radialChart`.** One ring per row, swept by `value / max` over `style.sweep` degrees from `style.startAngle`, with tracks, round caps, ring labels, a centre summary, `enter`, `selectRing`, `clearSelection` and `revealCenter`.
16
+ - **The kit** draws no plot border by default, puts each legend swatch before its caption, and moves `HorizontalAxis`, the polar helpers (`kit/polar`) and `PieLegend` behind the kit barrel, so a copied chart reaches only the kit. Removed from `./kit`: `ChartBorder`, `CHART_PALETTE`, `DEFAULT_PLOT_AREA`, `PlotAreaConfig`, `DEFAULT_SERIES_COLORS` (use `CHART_PALETTE_DEFAULT`), `DEFAULT_SERIES_STROKES`, `DEFAULT_SERIES_FILLS`, `LegendTheme`, and the theme helpers `resolveAxisConfig`, `lerpAxisConfig`, `resolvePlotArea`, `lerpPlotArea`, `resolveLegendConfig`, `lerpLegendConfig`, `resolveSeriesStrokes`, `lerpSeriesStrokes`, `resolveSeriesFills`, `lerpSeriesFills`, `resolveSeriesStroke` and `resolveSeriesFill` (a chart's colours come from `seriesFill`/`paletteFill` over its style).
17
+
18
+ The renderer's path and paint cache keys no longer collide for shapes mirrored through the origin, which drew two symmetric grid rules as one.
19
+
20
+ Migration: nothing converts a stored chart. A document row's `theme`, `showLegend`, `showValues` and `stacked` are dropped on open and the chart draws in the default style; a host with stored charts rewrites them: `theme` → a `style` partial (series colours to `palette`, text colours to `foreground`/`muted`), `showLegend: false` → `style.legend: "none"`, `showValues: true` → `style.values: "end"`, `stacked: true` → `stack: "stacked"`, `gridColor`/`gridWidth`/`gridDashed` → `horizontalGrid`/`verticalGrid` (or `gridStroke` on a radar), `grid: "vertical"` → `verticalGrid` on and `horizontalGrid: []`, `axisLine` → `axisStroke`, `spokes: false` → `spokeStroke: []`, a radial's `track: false` → `track: []`, and a pie's `labelPlacement` → `style.labelPlacement` (`leader` is now `outside`).
21
+
22
+ ## 0.1.1-alpha.0
23
+
24
+ ### Patch Changes
25
+
26
+ - e279864: **Breaking:** the component kits drop exports nothing used.
27
+
28
+ - **math:** the hand-mirrored `*Props` interfaces of 24 components (`AngleMarkProps`, `CurlyBraceProps`, `EmphasisMarkProps`, `CurveAreaProps`, `DropLinesProps`, `PlotPointProps`, `RiemannSumProps`, `TangentLineProps`, `VectorArrowProps`, `PointsPlotProps`, `StreamLinesProps`, `TracedPathProps`, `VectorFieldProps`, `NetworkGraphProps`, `SampleSpaceProps`, `NumberLineProps`, `NumberPlaneProps`, `PolarPlaneProps`, `LatexMatrixProps`, `Axes3dProps`, `CurvePlot3dProps`, `PlotPoint3dProps`, `SurfacePlot3dProps`, `VectorArrow3dProps`), `FILL_PAINT`, `STROKE_PAINT`, `OUTLINE_TRIM` and `spaceOf` from `./kit`, and `LatexPathResult.commands`.
29
+ - **charts:** `LineChartProps`, `BarChartProps`, `PieChartProps`, `PieRingProps`, `PieLegendProps`, `ChartBarsProps`, `CategoryAxisProps`, `ChartBorderProps`, `ChartCanvasProps`, `ChartLegendProps`, `VerticalAxisProps`, and from `./kit` `axisTweenTarget`, `resolvePalettePaint`, `legendShows`, `MarkerLabel`, `clampUnit` (use the SDK's `clamp`). `niceStep` and `enterBudget` stay reachable from `@motionscript/sdk/component`.
30
+ - **audio:** `FullWaveformProps`, `LiveWaveformProps`, and `clamp01` from `./kit`.
31
+ - **patterns:** `DotGridPatternProps`, `GridPatternProps`, `LineGridPatternProps`.
32
+ - **code:** `DEFAULT_THEMES`, `splitTokensAt`, `LINE_ALIGN_CELLS`, `EDIT_ALIGN_CELLS`, and `phasesFor` (use `defaultCodePhases`). `ensureHighlighter`, `loadCodeLanguage`, `initSyntaxHighlighter` and `canHighlight` lose their ignored theme argument.
33
+ - **grids:** the `findNode2D` and `frameIn` re-exports (import them from `@motionscript/sdk`), `ArrangementKind`, `PathGridShape`, `RectangularGridProps`, `RadialGridProps`, `PathGridProps`, `SphereGridProps`.
34
+ - **geography:** `GeoBorderProps`.
35
+
36
+ Migration: no stored document is affected; only TypeScript imports change. Code that imported a removed `*Props` interface states the props it passes inline, and code that used a removed helper uses the replacement named beside it above.
37
+
38
+ - Updated dependencies [e279864]
39
+ - @motionscript/sdk@0.1.1-alpha.0
40
+
3
41
  ## 0.1.0
4
42
 
5
43
  ## 0.1.0-alpha.10
package/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # @motionscript/charts
2
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
3
+ Animated data charts for [Motion Script](https://motionscript.dev): a line chart
4
+ (which is also the area chart), a bar chart, a pie chart, a radar chart and a
5
+ radial chart, built from one shared kit (plot panel, value axis, legend, number
6
+ formatting) and dressed by one `style` entry. Written against
6
7
  [`@motionscript/sdk`](https://github.com/motionscript-dev/motionscript/tree/main/packages/sdk), which it takes as a peer dependency.
7
8
 
8
9
  ```ts
9
10
  import { NODES } from '@motionscript/charts';
10
11
 
11
- export const nodes = NODES; // [LineChart, BarChart, PieChart]
12
+ export const nodes = NODES; // [LineChart, BarChart, PieChart, RadarChart, RadialChart]
12
13
  ```
13
14
 
14
15
  Importing registers nothing; the host hands `NODES` to the engine (see
@@ -24,36 +25,98 @@ npm install @motionscript/charts @motionscript/sdk
24
25
 
25
26
  | Path | Source | What |
26
27
  |---|---|---|
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.
28
+ | `@motionscript/charts` | `src/index.ts` | the five chart barrels, `src/engine.ts` and `NODES` |
29
+ | `@motionscript/charts/kit` | `src/engine.ts` | the shared kit (`src/kit/*`, including `kit/style`, `kit/polar` and `PieLegend`) and all of `@motionscript/sdk/component` |
30
+
31
+ Each chart folder (`line-chart/`, `bar-chart/`, `pie-chart/`, `radar-chart/`,
32
+ `radial-chart/`) has an `index.ts` barrel with the node, its parts and its pure
33
+ helpers (`resolveXScale`, `barSpans`, `pieArcs`, ...). The charts and their parts
34
+ (`ChartLine`, `ChartBars`, `PieRing`, `VerticalAxis`, ...) are components
35
+ (`component2d`); only the charts are registered node types, so a document cannot
36
+ name a part. A chart tells a host its key, entries and commands; where it is
37
+ shelved and the box it is seeded at are the host's to keep. `lineChartDomains` and
38
+ `barChartDomain` give the axes as drawn, and `isSliceSelected` whether a pie slice
39
+ is out.
40
+
41
+ The style kit exports `CHART_STYLE_FAMILY` (`"chart"`), `CHART_STYLE_PRESETS`,
42
+ `CHART_PALETTE_DEFAULT` and the shared field groups (`CHART_COLORS`,
43
+ `CHART_TEXT`, `CARTESIAN_GRID`, `CHART_LEGEND`).
38
44
 
39
45
  ## Nodes
40
46
 
41
47
  | Key | Made for (w x h) | Data props | Commands |
42
48
  |---|---|---|---|
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` |
49
+ | `lineChart` | 760 x 460 | `data`, `xField`, `series`, `stack`, `xAxis`, `yAxis`, `region` | `enter`, `spotlightRegion`, `clearRegion`, `zoomTo`, `resetZoom`, `showSeries`/`hideSeries`/`spotlightSeries` |
50
+ | `barChart` | 760 x 460 | `data`, `categoryField`, `series`, `orientation`, `stack`, `valueAxis`, `categoryAxis` | `enter`, `showSeries`/`hideSeries`/`spotlightSeries`, `spotlightCategory`, `clearCategory` |
51
+ | `pieChart` | 680 x 480 | `data`, `categoryField`, `valueField`, `labelMode`, `centerLabel`, `centerCaption` | `enter`, `revealCenter`, `selectSlice`/`deselectSlice`/`selectOnlySlice`/`clearSelection` |
52
+ | `radarChart` | 680 x 480 | `data`, `categoryField`, `series`, `min`, `max` | `enter`, `showSeries`/`hideSeries`/`spotlightSeries` |
53
+ | `radialChart` | 560 x 560 | `data`, `categoryField`, `valueField`, `max`, `centerLabel`, `centerCaption` | `enter`, `revealCenter`, `selectRing`, `clearSelection` |
46
54
 
47
55
  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] }`.
56
+ given an easing. Arguments: `seriesIndex`, `sliceIndex`, `categoryIndex`,
57
+ `ringIndex` (each 0 when left out), and for `spotlightRegion` and `zoomTo` a
58
+ `region` of `{ x?: [min, max], y?: [min, max] }`.
59
+
60
+ `lineChart` draws a line or an area chart: `style.area` of `none`, `solid` or
61
+ `gradient` fills under each line. `pieChart` draws a donut once `style.innerRadius`
62
+ is above 0.
63
+
64
+ ## Styling
65
+
66
+ Each chart has one look entry, `style`, and nothing else about colour or type:
67
+ no `theme`, no `showLegend`. Its fields come in groups, written grouped and read
68
+ flat (`state.style.fontSize`):
69
+
70
+ | Group | Fields | On |
71
+ |---|---|---|
72
+ | colors | `palette`, `foreground`, `muted`, `background` | every chart |
73
+ | text | `fontFamily`, `fontSize`, `fontWeight` | every chart |
74
+ | grid | `horizontalGrid` (a 2px `white/15` stroke), `verticalGrid` (none), `axisStroke` (none), `showXAxis`, `showYAxis` | line, bar |
75
+ | grid | `gridShape`, `gridLevels`, `gridStroke` (rings), `spokeStroke` (spokes), `spokeLabels` | radar |
76
+ | marks | the chart's own: `strokeWidth`, `curve`, `dots`, `area`, `barRadius`, `innerRadius`, `sweep`, ... | every chart |
77
+ | labels | `values` (line, bar), `labelPlacement` (pie), `ringLabels` (radial) | |
78
+
79
+ A line is a stroke and an area is a fill: `horizontalGrid`, `verticalGrid`, `axisStroke`, `gridStroke`
80
+ and `spokeStroke` are `Types.stroke` entries (weight, colour, dash and caps; empty draws
81
+ nothing), and a radial's `track` is a `Types.fill` (empty draws no track). A series' `label`
82
+ is optional; the legend shows `label || field`.
83
+ | legend | `legend` (`bottom`, `top`, `right`, `none`), `swatch` (`square`, `circle`, `line`) | every chart |
84
+
85
+ A chart takes only the fields it draws. A style is a partial laid over the chart's
86
+ previous style, and a key the chart does not have is dropped, so one style dresses
87
+ every chart in the family.
88
+
89
+ `CHART_STYLE_PRESETS` (`midnight`, `paper`, `ember`, `neon`, `ocean`, `sunset`,
90
+ `pastel`, `mono`) are colour-only partials. Spread one into a style and add to it:
91
+
92
+ ```ts
93
+ import { CHART_STYLE_PRESETS } from '@motionscript/charts';
94
+
95
+ const props = {
96
+ // ...data, series
97
+ style: { ...CHART_STYLE_PRESETS.paper, fontSize: 32, area: 'gradient' },
98
+ };
99
+ ```
100
+
101
+ Restyle with a `to` command, which tweens colours, sizes and weights and steps
102
+ everything else at the midpoint:
103
+
104
+ ```ts
105
+ { id: 'restyle', type: 'to', targetId: 'chart', at: 3, duration: 1,
106
+ args: { style: CHART_STYLE_PRESETS.ember } }
107
+ ```
108
+
109
+ Fields marked read-once below (`legend`, `showXAxis`, `showYAxis`, `values`,
110
+ `labelPlacement`, `spokeLabels`) shape which parts are built; a `to` of them
111
+ steps rather than tweens, and a document edit rebuilds the node.
51
112
 
52
113
  ## Rules worth knowing
53
114
 
54
115
  - **The kit stays an import.** A copy of `line-chart` takes only `line-chart/*` and
55
116
  rewrites its kit imports to `@motionscript/charts` (`registry.json`): a second
56
- copy of `VerticalAxis` would render as nothing, with no error.
117
+ copy of `VerticalAxis` would render as nothing, with no error. The kit includes
118
+ `kit/polar` and `PieLegend`, which the pie, radar and radial charts reach for, so
119
+ a copy of any chart reaches only the kit.
57
120
  - **Resting state is the finished chart.** `enter` arms every part on its first
58
121
  frame: every piece of a component command is built run to its end, and a beat
59
122
  ahead of the playhead writes nothing, so the first frame writes what each later
@@ -63,14 +126,18 @@ when left out), and for `spotlightRegion` and `zoomTo` a `region` of
63
126
  duration and easing it moves with; called directly, a part's command takes the
64
127
  duration it is given, and a part's own frames ease out unless given an easing.
65
128
  - **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`
129
+ `enabled`), `orientation`, `showCenter`, axis captions, the bar chart's category
130
+ captions, the pie's and radial's label and legend-row counts, `labelMode`, `gap`,
131
+ `centerLabel`, `centerCaption`, and the style fields `legend`, `showXAxis`,
132
+ `showYAxis`, `values`, `labelPlacement`, `spokeLabels`. A `set` or `to` of them
133
+ changes nothing; a document edit re-instantiates the node, which does refresh
134
+ them. `data`, scales, ticks, every other style field, `region`, `stack`, `weights`
71
135
  and `pops` are live.
72
136
  - **Non-finite cells plot as 0.** `num()` returns a cell only when it is a finite
73
137
  number, so a numeric string, `NaN`, `Infinity` and a missing cell all read 0.
138
+ - **`horizontalGrid` and `verticalGrid` are literal.** They name the lines drawn, not an axis: a
139
+ horizontal bar chart that wants rules along its value axis sets `verticalGrid` and
140
+ `horizontalGrid: []`.
74
141
  - **x units on the line chart.** `xAxis.range`, `xAxis.ticks` and a region's `x`
75
142
  are in the x scale's own units: the number (numeric column), UTC epoch
76
143
  milliseconds (time column) or the row index (ordinal column), chosen from the
@@ -85,7 +152,10 @@ when left out), and for `spotlightRegion` and `zoomTo` a `region` of
85
152
  the chart settles against its data, so a rescale from an auto axis is continuous.
86
153
  A restated range without ticks spreads explicit ticks across it; one side of an
87
154
  auto axis restated alone leaves the other to the data.
88
- - **Pie angles** are radians clockwise from 12 o'clock; `startAngle` is degrees.
155
+ - **Pie angles** are radians clockwise from 12 o'clock. A radial's `startAngle` and
156
+ `sweep` are degrees, `startAngle` clockwise from 12 o'clock.
157
+ - **Centre text needs a hole.** A pie shows `centerLabel` and `centerCaption` only
158
+ with `style.innerRadius` above 0; a radial's hole is `style.innerRadius` too.
89
159
 
90
160
  ## Development
91
161