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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +30 -16
  3. package/dist/bar-chart/bar-chart.d.ts +93 -246
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  5. package/dist/bar-chart/bar-chart.js +378 -569
  6. package/dist/bar-chart/bar-chart.js.map +1 -1
  7. package/dist/bar-chart/category-axis.d.ts +24 -41
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  9. package/dist/bar-chart/category-axis.js +93 -115
  10. package/dist/bar-chart/category-axis.js.map +1 -1
  11. package/dist/bar-chart/chart-bars.d.ts +36 -70
  12. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  13. package/dist/bar-chart/chart-bars.js +156 -210
  14. package/dist/bar-chart/chart-bars.js.map +1 -1
  15. package/dist/bar-chart/index.d.ts +2 -2
  16. package/dist/bar-chart/index.d.ts.map +1 -1
  17. package/dist/bar-chart/index.js +1 -1
  18. package/dist/bar-chart/index.js.map +1 -1
  19. package/dist/bar-chart/shared.d.ts +3 -3
  20. package/dist/bar-chart/shared.d.ts.map +1 -1
  21. package/dist/bar-chart/shared.js +3 -3
  22. package/dist/bar-chart/shared.js.map +1 -1
  23. package/dist/browser/chunks/chunk-XROBIRQK.js +2 -0
  24. package/dist/browser/chunks/chunk-XROBIRQK.js.map +7 -0
  25. package/dist/browser/index.js +1 -1
  26. package/dist/browser/index.js.map +3 -3
  27. package/dist/browser/kit.js +1 -1
  28. package/dist/browser/manifest.json +1 -1
  29. package/dist/engine.d.ts +8 -6
  30. package/dist/engine.d.ts.map +1 -1
  31. package/dist/engine.js +8 -6
  32. package/dist/engine.js.map +1 -1
  33. package/dist/kit/cartesian.d.ts +44 -0
  34. package/dist/kit/cartesian.d.ts.map +1 -0
  35. package/dist/kit/cartesian.js +59 -0
  36. package/dist/kit/cartesian.js.map +1 -0
  37. package/dist/kit/chart-border.d.ts +8 -11
  38. package/dist/kit/chart-border.d.ts.map +1 -1
  39. package/dist/kit/chart-border.js +15 -32
  40. package/dist/kit/chart-border.js.map +1 -1
  41. package/dist/kit/chart-canvas.d.ts +23 -21
  42. package/dist/kit/chart-canvas.d.ts.map +1 -1
  43. package/dist/kit/chart-canvas.js +33 -90
  44. package/dist/kit/chart-canvas.js.map +1 -1
  45. package/dist/kit/chart-legend.d.ts +79 -67
  46. package/dist/kit/chart-legend.d.ts.map +1 -1
  47. package/dist/kit/chart-legend.js +129 -154
  48. package/dist/kit/chart-legend.js.map +1 -1
  49. package/dist/kit/entries.d.ts +17 -0
  50. package/dist/kit/entries.d.ts.map +1 -0
  51. package/dist/kit/entries.js +19 -0
  52. package/dist/kit/entries.js.map +1 -0
  53. package/dist/kit/motion.d.ts +48 -0
  54. package/dist/kit/motion.d.ts.map +1 -0
  55. package/dist/kit/motion.js +63 -0
  56. package/dist/kit/motion.js.map +1 -0
  57. package/dist/kit/paints.d.ts +10 -0
  58. package/dist/kit/paints.d.ts.map +1 -0
  59. package/dist/kit/paints.js +12 -0
  60. package/dist/kit/paints.js.map +1 -0
  61. package/dist/kit/shared.d.ts +31 -3
  62. package/dist/kit/shared.d.ts.map +1 -1
  63. package/dist/kit/shared.js +42 -3
  64. package/dist/kit/shared.js.map +1 -1
  65. package/dist/kit/vertical-axis.d.ts +36 -61
  66. package/dist/kit/vertical-axis.d.ts.map +1 -1
  67. package/dist/kit/vertical-axis.js +97 -132
  68. package/dist/kit/vertical-axis.js.map +1 -1
  69. package/dist/line-chart/chart-line.d.ts +25 -51
  70. package/dist/line-chart/chart-line.d.ts.map +1 -1
  71. package/dist/line-chart/chart-line.js +89 -120
  72. package/dist/line-chart/chart-line.js.map +1 -1
  73. package/dist/line-chart/chart-region.d.ts +14 -14
  74. package/dist/line-chart/chart-region.d.ts.map +1 -1
  75. package/dist/line-chart/chart-region.js +26 -64
  76. package/dist/line-chart/chart-region.js.map +1 -1
  77. package/dist/line-chart/horizontal-axis.d.ts +32 -56
  78. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  79. package/dist/line-chart/horizontal-axis.js +85 -123
  80. package/dist/line-chart/horizontal-axis.js.map +1 -1
  81. package/dist/line-chart/index.d.ts +2 -2
  82. package/dist/line-chart/index.d.ts.map +1 -1
  83. package/dist/line-chart/index.js +1 -1
  84. package/dist/line-chart/index.js.map +1 -1
  85. package/dist/line-chart/line-chart.d.ts +111 -319
  86. package/dist/line-chart/line-chart.d.ts.map +1 -1
  87. package/dist/line-chart/line-chart.js +403 -663
  88. package/dist/line-chart/line-chart.js.map +1 -1
  89. package/dist/line-chart/shared.d.ts +3 -3
  90. package/dist/line-chart/shared.d.ts.map +1 -1
  91. package/dist/line-chart/shared.js +3 -3
  92. package/dist/line-chart/shared.js.map +1 -1
  93. package/dist/nodes.d.ts +6 -9
  94. package/dist/nodes.d.ts.map +1 -1
  95. package/dist/nodes.js +7 -9
  96. package/dist/nodes.js.map +1 -1
  97. package/dist/pie-chart/index.d.ts +2 -2
  98. package/dist/pie-chart/index.d.ts.map +1 -1
  99. package/dist/pie-chart/index.js +1 -1
  100. package/dist/pie-chart/index.js.map +1 -1
  101. package/dist/pie-chart/pie-chart.d.ts +77 -134
  102. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  103. package/dist/pie-chart/pie-chart.js +200 -271
  104. package/dist/pie-chart/pie-chart.js.map +1 -1
  105. package/dist/pie-chart/pie-legend.d.ts +54 -31
  106. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  107. package/dist/pie-chart/pie-legend.js +93 -107
  108. package/dist/pie-chart/pie-legend.js.map +1 -1
  109. package/dist/pie-chart/pie-ring.d.ts +142 -131
  110. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  111. package/dist/pie-chart/pie-ring.js +333 -391
  112. package/dist/pie-chart/pie-ring.js.map +1 -1
  113. package/package.json +4 -4
  114. package/src/bar-chart/bar-chart.ts +415 -701
  115. package/src/bar-chart/category-axis.ts +95 -110
  116. package/src/bar-chart/chart-bars.ts +178 -200
  117. package/src/bar-chart/index.ts +2 -2
  118. package/src/bar-chart/shared.ts +3 -3
  119. package/src/engine.ts +8 -6
  120. package/src/kit/cartesian.ts +81 -0
  121. package/src/kit/chart-border.ts +22 -33
  122. package/src/kit/chart-canvas.ts +44 -79
  123. package/src/kit/chart-legend.ts +173 -189
  124. package/src/kit/entries.ts +20 -0
  125. package/src/kit/motion.ts +90 -0
  126. package/src/kit/paints.ts +15 -0
  127. package/src/kit/shared.ts +52 -3
  128. package/src/kit/vertical-axis.ts +110 -140
  129. package/src/line-chart/chart-line.ts +95 -122
  130. package/src/line-chart/chart-region.ts +30 -59
  131. package/src/line-chart/horizontal-axis.ts +99 -135
  132. package/src/line-chart/index.ts +2 -2
  133. package/src/line-chart/line-chart.ts +449 -825
  134. package/src/line-chart/shared.ts +3 -3
  135. package/src/nodes.ts +8 -10
  136. package/src/pie-chart/index.ts +2 -2
  137. package/src/pie-chart/pie-chart.ts +221 -311
  138. package/src/pie-chart/pie-legend.ts +124 -114
  139. package/src/pie-chart/pie-ring.ts +386 -473
  140. package/dist/browser/chunks/chunk-5ZPBV6BU.js +0 -2
  141. package/dist/browser/chunks/chunk-5ZPBV6BU.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @motionscript/charts
2
2
 
3
+ ## 0.1.0-alpha.6
4
+
5
+ ### Minor Changes
6
+
7
+ - 163b708: Node types are components: one spec object handed to `component2d`, `component3d` or `componentAudio`, with no classes, decorators or JSX.
8
+
9
+ - **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.
10
+ - **Building nodes in code** uses calls: `Rect({ fill: 'tomato', children: [Text({ text: 'Hi' })] })`, or `new Rect({...})` for the node itself.
11
+ - **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:
12
+ - `SurfacePlot3d.valueAt` and `FunctionPlot.valueAt` are now the functions `surfaceValueAt` and `curveValue`.
13
+ - A system's `coordinates` is replaced by `planeMap`/`axesMap`/`systemMap`.
14
+ - `PieChart.isSelected` is replaced by `isSliceSelected`.
15
+ - `ItemGrid` is a kit module (`ItemGrid.isGrid`, `ItemGrid.define`), not a base class.
16
+ - **The sdk no longer exports the class surface:**
17
+ - the decorators: `node`, `property` and every `*Property`, `command`, `withdraw`, `driveCommand`;
18
+ - the authoring bases: `PaintNode`, `ShapeNode`, `TextBase`, `Mesh3DBase`, `Canvas3DBase` and the `*Base` geometry classes;
19
+ - `asCommand`, `compose`, `drive` and `declarePaints` from `@motionscript/sdk/component`;
20
+ - the `jsx-runtime` and `jsx-dev-runtime` subpaths.
21
+ - `Node`, `Node2D`, `Node3D` and `NodeAudio` remain as types.
22
+ - **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.
23
+ - 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`).
24
+
3
25
  ## 0.1.0-alpha.5
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -30,20 +30,23 @@ npm install @motionscript/charts @motionscript/sdk
30
30
  Each chart folder (`line-chart/`, `bar-chart/`, `pie-chart/`) has an `index.ts`
31
31
  barrel with the node, its parts, its theme (`DEFAULT_*_THEME`, `resolve*Theme`,
32
32
  `lerp*Theme`) and its pure helpers (`resolveXScale`, `barSpans`, `pieArcs`, ...).
33
- The parts (`ChartLine`, `ChartBars`, `PieRing`, `VerticalAxis`, ...) are classes
34
- but not registered node types: a document cannot name them.
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.
35
38
 
36
39
  ## Nodes
37
40
 
38
- | Key | Seed (w x h) | Data props | Commands (default duration) |
41
+ | Key | Made for (w x h) | Data props | Commands |
39
42
  |---|---|---|---|
40
- | `lineChart` | 760 x 460 | `data`, `xField`, `series`, `xAxis`, `yAxis`, `region` | `enter` (required), `spotlightRegion` 0.5, `clearRegion` 0.5, `zoomTo` 0.8, `resetZoom` 0.8, `showSeries`/`hideSeries`/`spotlightSeries` 0.35 |
41
- | `barChart` | 760 x 460 | `data`, `categoryField`, `series`, `valueAxis`, `stacked` | `enter` (required), `showSeries`/`hideSeries`/`spotlightSeries` 0.35, `spotlightCategory` 0.4, `clearCategory` 0.4 |
42
- | `pieChart` | 680 x 480 | `data`, `categoryField`, `valueField` | `enter` (required), `revealCenter` 0.6, `selectSlice`/`deselectSlice`/`selectOnlySlice`/`clearSelection` 0.45 |
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` |
43
46
 
44
- Every command returns a `Command` (composed entrances go through `asCommand`), so
45
- all of them compile from a document. Arguments: `seriesIndex`, `sliceIndex`,
46
- `categoryIndex`, and for `spotlightRegion` and `zoomTo` a `region` of
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
47
50
  `{ x?: [min, max], y?: [min, max] }`.
48
51
 
49
52
  ## Rules worth knowing
@@ -51,9 +54,14 @@ all of them compile from a document. Arguments: `seriesIndex`, `sliceIndex`,
51
54
  - **The kit stays an import.** `ms add line-chart` copies only `line-chart/*` and
52
55
  rewrites its kit imports to `@motionscript/charts` (`registry.json`): a second
53
56
  copy of `VerticalAxis` would render as nothing, with no error.
54
- - **Resting state is the finished chart.** `enter` arms every part back to its
55
- pre-entrance state as the command is built (`arm()`), and `duration` is the whole
56
- entrance: a beat with nothing to do (no legend, no series) holds its share.
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.
57
65
  - **Some props are read once, at construction**: the series list (count, labels,
58
66
  `enabled`), `showLegend`, `showValues`, `showCenter`, axis captions, text styles and
59
67
  paddings, the bar chart's category captions, the pie's label and legend-row counts,
@@ -67,10 +75,16 @@ all of them compile from a document. Arguments: `seriesIndex`, `sliceIndex`,
67
75
  are in the x scale's own units: the number (numeric column), UTC epoch
68
76
  milliseconds (time column) or the row index (ordinal column), chosen from the
69
77
  column by `resolveXScale` (dates via `parseInstant`).
70
- - **`zoomTo` captures the resting domain once** (`home`) and `resetZoom` reads and
71
- clears it as the command is built, so the pair is order dependent: a `resetZoom`
72
- with no earlier `zoomTo`, and a `zoomTo` naming neither axis, write nothing for
73
- their duration. A zoom keeps the tick count so each marker slides.
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.
74
88
  - **Pie angles** are radians clockwise from 12 o'clock; `startAngle` is degrees.
75
89
 
76
90
  ## Development
@@ -1,6 +1,6 @@
1
- import { Node2D, type CommandArgs, type DataRecord, type Command, type NodeConfig, type Node2DProps } from "@motionscript/sdk";
2
- import { type AxisDomainConfig } from "../kit/shared.js";
3
- import { type BarChartTheme, type BarSeries } from "./shared.js";
1
+ import { type DataRecord, type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
2
+ import { type AxisDomainConfig, type Range } from "../kit/shared.js";
3
+ import { type BarChartConfig, type BarChartTheme, type BarSeries } from "./shared.js";
4
4
  export interface BarChartProps extends Node2DProps {
5
5
  /** One row per category — a plain record of field name to value. */
6
6
  data: DataRecord[];
@@ -33,268 +33,115 @@ export interface BarChartProps extends Node2DProps {
33
33
  /** Whether each column prints the figure it plots. */
34
34
  showValues?: boolean;
35
35
  }
36
- /**
37
- * How {@link BarChart.enter} divides its duration between its three beats: the
38
- * axes arriving, the columns rising, and the legend coming up. Shares of the
39
- * whole, so they must sum to 1 — the entrance takes exactly the time it was
40
- * given, for the reason spelt out on `LineChart.enter`.
41
- */
42
- /**
43
- * The signals the bar chart's own commands move, as props types.
44
- *
45
- * Written out rather than reusing `BarChartProps` because these are signals of
46
- * the chart's own — how far the columns have risen, and which category is lit —
47
- * rather than part of what an author states about it. Same reason the line chart
48
- * types its `RegionState` separately.
49
- */
50
- type CategorySpotlight = {
51
- spotlight: number | null;
52
- spotlightReveal: number;
36
+ /** What a bar chart plots, as its entries hold it. */
37
+ export interface BarChartValues {
38
+ readonly data: DataRecord[];
39
+ readonly series: BarSeries[];
40
+ readonly stacked: boolean;
41
+ readonly valueAxis: AxisDomainConfig;
42
+ }
43
+ /** The value axis's domain with its range and ticks resolved. */
44
+ export type BarChartDomain = AxisDomainConfig & {
45
+ readonly range: Range;
46
+ readonly ticks: number[];
53
47
  };
48
+ /** The value axis as a bar chart draws it now, an auto range or tick row read back as itself. */
49
+ export declare function barChartDomain(s: BarChartValues): BarChartDomain;
54
50
  /**
55
- * A grouped or stacked bar chart, composed from independent parts rather than
56
- * one monolithic draw — the sibling of the {@link LineChart} family, built the
57
- * same way and out of several of the same pieces:
51
+ * A grouped or stacked bar chart, the sibling of the line chart and built the
52
+ * same way, out of several of the same pieces:
58
53
  *
59
54
  * - `ChartCanvas` — the plot panel with a horizontal grid, under everything.
60
55
  * - `VerticalAxis` — the numeric value markers, staggering in bottom-to-top.
61
- * - {@link CategoryAxis} — the row of names beneath the baseline, one per row of
62
- * the data, staggering in left-to-right.
56
+ * - {@link CategoryAxis} — the row of names beneath the baseline, one per row.
63
57
  * - {@link ChartBars} (one per series) — that series' column in every category,
64
58
  * plus the figures printed on them.
65
59
  * - `ChartLegend` — a row of entries below the chart, one per series.
66
60
  *
67
- * The parts are laid out from this node's `layoutBounds` exactly as the line
68
- * chart's are: the value axis on the left, the category captions below, the
69
- * plot filling what's left, and the legend row beneath the whole thing. The
70
- * columns are mapped across the plot panel's own laid-out box and read the same
71
- * resolved scale the axis does, so a column's end lands exactly on its marker
72
- * and the chart re-flows if its box changes.
61
+ * Every part reads the chart's entries through bindings, and the columns map
62
+ * across the plot panel's own laid-out box, so a column's end lands exactly on
63
+ * its marker. **Zero is always on the scale**, and the columns grow about it, so
64
+ * a negative value draws downward out of the same `growth` signal.
73
65
  *
74
- * **Resting state is the finished chart** — the same bargain the line chart
75
- * makes: an editor paints a node's Initial state on a paused canvas, so a chart
76
- * that only appeared once a command had run would be edited blind. {@link enter}
77
- * arms every part back to its pre-entrance state before animating.
78
- *
79
- * **Zero is always on the scale** (see `barValueExtent`), and the columns
80
- * grow about it rather than about the plot floor, so a negative value draws
81
- * downward out of the same `growth` signal that draws a positive one up.
82
- *
83
- * Past the entrance, two things move the chart:
84
- * {@link showSeries}/{@link hideSeries}/{@link spotlightSeries} pick out a
85
- * *series* — and hiding one **reflows the group**, the remaining columns
86
- * widening into the space as it goes, rather than leaving a hole where it was —
87
- * while {@link spotlightCategory}/{@link clearCategory} pick out a *column of
88
- * the table*, dimming every other category and its caption with it.
66
+ * **Resting state is the finished chart**; `enter` arms every part on its first
67
+ * frame. `showSeries`/`hideSeries`/`spotlightSeries` pick out a *series* (hiding
68
+ * one reflows the group), `spotlightCategory`/`clearCategory` a *column of the
69
+ * table*. A `to` of the value axis's `range` or `ticks` tweens from the domain
70
+ * as drawn, so an auto axis rescales the columns continuously.
89
71
  */
90
- export declare class BarChart extends Node2D<BarChartProps> {
91
- data: DataRecord[];
92
- categoryField: string;
93
- series: BarSeries[];
94
- stacked: boolean;
95
- /**
96
- * The value axis's domain (label/range/ticks), tweenable and mappable exactly
97
- * as the line chart's axes are: the mapper merges a partial input onto the
98
- * previous resolved domain and the tween interpolates numerically, so
99
- * `chart.to({ data: { valueAxis: { range: [0, 10] } }, duration: 1 })` smoothly
100
- * rescales every column. The axis *label* text is captured once at construction.
101
- */
102
- valueAxis: AxisDomainConfig;
103
- categoryAxis: AxisDomainConfig;
104
- theme: BarChartTheme;
72
+ export declare const BarChart: import("@motionscript/sdk").Component<"barChart", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
73
+ readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
74
+ readonly categoryField: "";
75
+ readonly series: import("@motionscript/sdk").Type<import("../index.js").ChartSeries[], import("../index.js").ChartSeries[], false>;
76
+ readonly stacked: false;
77
+ readonly valueAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
78
+ readonly categoryAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
79
+ readonly theme: import("@motionscript/sdk").Type<BarChartTheme, BarChartConfig, false>;
105
80
  /**
106
81
  * Global rise of every column in `[0, 1]`, measured about the baseline: 0
107
- * collapses them all onto it, 1 draws them at full length. Each
108
- * {@link ChartBars}' own `growth` is bound to this, so tweening this one
109
- * signal raises the whole chart in proportion.
110
- */
111
- growth: number;
112
- /**
113
- * How much of the slot each series currently claims, one entry per series.
114
- *
115
- * A *weight* rather than a boolean, because that is what makes hiding a series
116
- * an animation instead of a jump: the grouped columns divide the slot in
117
- * proportion to these, so tweening one to 0 has the remaining columns widen
118
- * into the space as it shrinks away, and a stacked segment's contribution to
119
- * the stack fades out with it. Seeded from each series' `enabled` field.
82
+ * collapses them all onto it, 1 draws them at full length.
120
83
  */
121
- weights: number[];
84
+ readonly growth: 1;
122
85
  /**
123
- * The category currently spotlit, or `null` for none. Held as a plain reactive
124
- * value rather than a tweened one: the *choice* snaps, and the animation is
125
- * {@link spotlightReveal} dimming everything else.
86
+ * How much of the slot each series claims, one entry per series: a weight
87
+ * rather than a switch, so hiding one is the others widening into the space.
88
+ * Seeded from each series' `enabled`.
126
89
  */
127
- spotlight: number | null;
90
+ readonly weights: import("@motionscript/sdk").Type<number[], number[], false>;
91
+ /** The category spotlit, or `null` for none. The choice snaps; `spotlightReveal` is the animation. */
92
+ readonly spotlight: import("@motionscript/sdk").Type<number | null, number | null, false>;
128
93
  /** How far the category spotlight is drawn in, `[0, 1]`. */
129
- spotlightReveal: number;
130
- private vAxis;
131
- private cAxis;
132
- private legend;
133
- private barSets;
134
- /** The plot panel: the box the grid, the columns and the border all share. */
135
- private plotRect;
136
- /**
137
- * `this.theme` read back through its *resolved* shape — the same
138
- * loose-declared/resolved-stored idiom as a shape's `fill`/`stroke`, and as
139
- * the line chart's own theme.
140
- */
141
- private get resolvedTheme();
142
- /** Fallback marker count when the value axis states no ticks. */
143
- private static readonly DEFAULT_MARKERS;
144
- private get valueScale();
145
- /**
146
- * A value written down as this chart's value axis says — the axis ticks and
147
- * the figures printed on the columns both read through here, so the two
148
- * cannot disagree about what a number looks like.
149
- */
150
- private valueLabel;
151
- /** The value axis ticks: the explicit ones, else five across the scale. */
152
- private get resolvedMarkers();
153
- /**
154
- * The plot panel's size, **as laid out**.
155
- *
156
- * The value axis is `width: "hug"` and the category row and legend are as tall
157
- * as their text, so the panel's real box is whatever the layout makes it. An
158
- * estimate built from gutter constants never matched it, and the columns sat a
159
- * few percent off the grid line they were supposed to end on. Asking the panel
160
- * is exact by construction: the grid, the columns and the border all resolve
161
- * against the one box they are drawn in. Zero until the first layout pass, like
162
- * any other `layoutBounds` read; the bindings that call this re-run on the
163
- * next frame.
164
- */
165
- private plotSize;
166
- /** Map a value onto the plot's **centred** pixel space (origin at its centre, y-up). */
167
- private valueToY;
168
- /**
169
- * Pixel y of the line every column grows from.
170
- *
171
- * Zero, clamped onto the scale — so an author who *did* crop the axis to
172
- * `[40, 100]` gets columns rising from the plot floor rather than from a
173
- * baseline off the bottom of the panel.
174
- */
175
- private get baselinePx();
176
- /** Width of one category's slot across the plot. */
177
- private get slotWidth();
178
- /** Centre x of category `i`'s slot, in the plot's centred space. */
179
- private slotCenter;
180
- /** The part of a slot the columns fill — the rest is the channel between categories. */
181
- private get slotInner();
182
- /** Series `i`'s live share of the slot; 0 once it has been hidden. */
183
- private weightAt;
184
- /** Total live share across the series — the slot's inner width divides by this. */
185
- private get totalWeight();
186
- /** Live share of every series *before* `index`, for the grouped offset. */
187
- private weightBefore;
94
+ readonly spotlightReveal: 0;
95
+ /** Read as the chart is built: the legend is a part the chart builds or doesn't. */
96
+ readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
97
+ /** Read as the chart is built: whether each column prints the figure it plots. */
98
+ readonly showValues: import("@motionscript/sdk").Type<boolean, boolean, false>;
99
+ /** Whether each series' columns are drawn: on for every frame a show or hide covers, off once a hide lands. */
100
+ readonly showing: import("@motionscript/sdk").Type<boolean[], boolean[], false>;
101
+ }>, {
102
+ readonly enter: {};
103
+ readonly showSeries: {
104
+ readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
105
+ };
106
+ readonly hideSeries: {
107
+ readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
108
+ };
109
+ readonly spotlightSeries: {
110
+ readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
111
+ };
112
+ readonly spotlightCategory: {
113
+ readonly categoryIndex: import("@motionscript/sdk").Type<number, number, false>;
114
+ };
115
+ readonly clearCategory: {};
116
+ }, null, Node2D<Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
117
+ readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
118
+ readonly categoryField: "";
119
+ readonly series: import("@motionscript/sdk").Type<import("../index.js").ChartSeries[], import("../index.js").ChartSeries[], false>;
120
+ readonly stacked: false;
121
+ readonly valueAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
122
+ readonly categoryAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
123
+ readonly theme: import("@motionscript/sdk").Type<BarChartTheme, BarChartConfig, false>;
188
124
  /**
189
- * Series `index`'s columns, mapped into the plot's centred pixel space.
190
- *
191
- * Both modes come out of one walk over the rows: a grouped series divides the
192
- * slot with its siblings and every column runs from zero, a stacked one takes
193
- * the whole slot and each column runs from the running total below it. The
194
- * live {@link weights} scale the grouped widths and the stacked contributions
195
- * alike, which is what lets `hideSeries` reflow rather than punch a hole.
196
- */
197
- private seriesBars;
198
- /**
199
- * `row` with each series' value scaled by that series' live {@link weights}
200
- * entry — what the stacked spans are measured from.
201
- */
202
- private weightedRow;
203
- /**
204
- * How far each category is dimmed by the spotlight, one entry per row —
205
- * 1 while nothing is spotlit, falling to the theme's `dimOpacity` for every
206
- * category but the chosen one as the reveal climbs.
207
- */
208
- private categoryDims;
209
- constructor(props?: NodeConfig<BarChart, BarChartProps>);
210
- /**
211
- * Prime every part at its pre-entrance state — axis markers and captions
212
- * shifted and transparent, columns collapsed onto the baseline, legend dropped
213
- * and transparent.
214
- *
215
- * Called by {@link enter} before its first frame so nothing flashes ahead of
216
- * its beat. Idempotent, and public so a scene can hide a chart ahead of time
217
- * without starting the entrance.
218
- */
219
- arm(): void;
220
- /**
221
- * Animate the whole chart in: the two axes stagger their markers and captions
222
- * in, the columns rise from the baseline, and the legend fades up last.
223
- *
224
- * `duration` is the **whole** entrance. The phases are shares of it, not
225
- * multiples — a command that declares 1.4 seconds has to take 1.4 seconds,
226
- * because that is the slot the timeline lays out for it, the length its
227
- * parallel siblings are timed against, and its contribution to the scene's own
228
- * duration.
229
- */
230
- enter(args: CommandArgs<Record<string, never>> & {
231
- duration: number;
232
- }): Command<Record<string, never>>;
233
- /**
234
- * Move props to new values; a restated value-axis `range` or `ticks` tweens
235
- * from the domain as drawn, so an auto axis (the default) rescales the columns
236
- * continuously instead of cutting at the midpoint of the move.
237
- */
238
- to<D extends Partial<BarChartProps> = Partial<BarChartProps>>(args: CommandArgs<D> & {
239
- duration: number;
240
- }): Command<BarChartProps>;
241
- /** Tween {@link growth} `0 → 1`, raising every column about the baseline. */
242
- private riseBars;
243
- /**
244
- * Show series `index`: bring its columns back, the group reflowing to make
245
- * room as they arrive, in lockstep with its legend entry growing in.
246
- */
247
- showSeries(args: CommandArgs<{
248
- seriesIndex: number;
249
- }>): Command<Record<string, never>>;
250
- /**
251
- * Hide series `index`: its columns narrow away (or, stacked, sink out of the
252
- * stack) while the rest of the group widens into the space, its legend entry
253
- * shrinking beside them — the mirror of {@link showSeries}.
254
- */
255
- hideSeries(args: CommandArgs<{
256
- seriesIndex: number;
257
- }>): Command<Record<string, never>>;
258
- /**
259
- * Move series `index`'s slot share to `target`, with its legend entry.
260
- *
261
- * One method for both directions, so the pair cannot drift apart. `enabled`
262
- * rides in the same value as the weight rather than being set before or after,
263
- * which is what makes arriving at a time backwards show what arriving forwards
264
- * does.
265
- */
266
- private toggleSeries;
267
- /**
268
- * Fade out every other series — its columns **and its legend entry** — to
269
- * focus attention on `index`, which comes back to full. Nothing moves, so the
270
- * group doesn't reflow.
271
- */
272
- spotlightSeries(args: CommandArgs<{
273
- seriesIndex: number;
274
- }>): Command<Record<string, never>>;
275
- /** Ease series `index`'s slot share toward `target`, reflowing the group. */
276
- private tweenWeight;
277
- /**
278
- * Spotlight one **category** — one column of the table rather than one series:
279
- * every other category's bars and its caption fade to the theme's
280
- * `dimOpacity`, and the chosen one stays full.
281
- *
282
- * The counterpart of the line chart's `spotlightRegion`, and the same shape of
283
- * thing: it picks out a slice of the plot without changing what is drawn.
284
- * Calling it while another category is already lit moves the focus directly —
285
- * only the dimming changes, so there is nothing to retract first.
125
+ * Global rise of every column in `[0, 1]`, measured about the baseline: 0
126
+ * collapses them all onto it, 1 draws them at full length.
286
127
  */
287
- spotlightCategory(args: CommandArgs<{
288
- categoryIndex: number;
289
- }>): Command<CategorySpotlight>;
128
+ readonly growth: 1;
290
129
  /**
291
- * Drop the category spotlight, bringing every category back to full. A no-op
292
- * when nothing is lit — but it still takes its slot on the timeline, for the
293
- * reason `LineChart.clearRegion` does.
130
+ * How much of the slot each series claims, one entry per series: a weight
131
+ * rather than a switch, so hiding one is the others widening into the space.
132
+ * Seeded from each series' `enabled`.
294
133
  */
295
- clearCategory(args: CommandArgs<Record<string, never>>): Command<CategorySpotlight>;
296
- /** The no-op both of the above return — see {@link hold}. */
297
- private holdSpotlight;
298
- }
299
- export {};
134
+ readonly weights: import("@motionscript/sdk").Type<number[], number[], false>;
135
+ /** The category spotlit, or `null` for none. The choice snaps; `spotlightReveal` is the animation. */
136
+ readonly spotlight: import("@motionscript/sdk").Type<number | null, number | null, false>;
137
+ /** How far the category spotlight is drawn in, `[0, 1]`. */
138
+ readonly spotlightReveal: 0;
139
+ /** Read as the chart is built: the legend is a part the chart builds or doesn't. */
140
+ readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
141
+ /** Read as the chart is built: whether each column prints the figure it plots. */
142
+ readonly showValues: import("@motionscript/sdk").Type<boolean, boolean, false>;
143
+ /** Whether each series' columns are drawn: on for every frame a show or hide covers, off once a hide lands. */
144
+ readonly showing: import("@motionscript/sdk").Type<boolean[], boolean[], false>;
145
+ }>, null>>;
146
+ export type BarChart = NodeOf<typeof BarChart>;
300
147
  //# sourceMappingURL=bar-chart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bar-chart.d.ts","sourceRoot":"","sources":["../../src/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAIN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,OAAO,EAEZ,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EASL,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAA;AAYtB,OAAO,EAUL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,oEAAoE;IACpE,IAAI,EAAE,UAAU,EAAE,CAAA;IAClB;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,gFAAgF;IAChF,MAAM,EAAE,SAAS,EAAE,CAAA;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yEAAyE;IACzE,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,qFAAqF;IACrF,YAAY,CAAC,EAAE,gBAAgB,CAAA;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,sDAAsD;IACtD,UAAU,CAAC,EAAE,OAAO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