@motionscript/charts 0.1.0-alpha.8 → 0.1.0-alpha.9
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.
- package/CHANGELOG.md +2 -0
- package/LICENSE +201 -201
- package/NOTICE +49 -49
- package/README.md +99 -99
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/{chunk-XROBIRQK.js → chunk-TJNHLQGV.js} +1 -1
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/kit.js +1 -1
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.js.map +1 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/kit/paints.js.map +1 -1
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +1 -1
- package/dist/line-chart/index.js +1 -1
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/registry.json +23 -23
- package/src/bar-chart/bar-chart.ts +542 -542
- package/src/bar-chart/category-axis.ts +162 -162
- package/src/bar-chart/chart-bars.ts +287 -287
- package/src/bar-chart/index.ts +31 -31
- package/src/bar-chart/shared.ts +354 -354
- package/src/engine.ts +28 -28
- package/src/index.ts +5 -5
- package/src/kit/cartesian.ts +81 -81
- package/src/kit/chart-border.ts +50 -50
- package/src/kit/chart-canvas.ts +122 -122
- package/src/kit/chart-legend.ts +229 -229
- package/src/kit/entries.ts +20 -20
- package/src/kit/motion.ts +90 -90
- package/src/kit/paints.ts +15 -15
- package/src/kit/shared.ts +782 -782
- package/src/kit/vertical-axis.ts +194 -194
- package/src/line-chart/chart-line.ts +156 -156
- package/src/line-chart/chart-region.ts +90 -90
- package/src/line-chart/horizontal-axis.ts +151 -151
- package/src/line-chart/index.ts +39 -39
- package/src/line-chart/line-chart.ts +598 -598
- package/src/line-chart/shared.ts +473 -473
- package/src/line-chart/x-scale.ts +382 -382
- package/src/nodes.ts +18 -18
- package/src/pie-chart/index.ts +37 -37
- package/src/pie-chart/pie-chart.ts +296 -296
- package/src/pie-chart/pie-legend.ts +169 -169
- package/src/pie-chart/pie-ring.ts +848 -848
- package/src/pie-chart/shared.ts +496 -496
- package/dist/browser/chunks/chunk-XROBIRQK.js.map +0 -7
- package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
package/README.md
CHANGED
|
@@ -1,99 +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.**
|
|
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.
|
|
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-chart.js","sourceRoot":"","sources":["../../src/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,GAUR,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAa,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,EACb,UAAU,EACV,YAAY,EACZ,GAAG,EACH,iBAAiB,EACjB,gBAAgB,GAGjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAA;AAC1D,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,aAAa,GAId,MAAM,UAAU,CAAA;AA8C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I,CAAC,MAAM;oBAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;gBACpF,MAAM,IAAI,GAAG,KAAK,CAAC,eAAe,CAAA;gBAClC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YAChG,CAAC;SACF;QACD;;;;WAIG;QACH,aAAa,EAAE;YACb,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,OAAO,EAAE;YACjB,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;gBACvB,MAAM,IAAI,GAAG,KAAK,CAAC,eAAe,CAAA;gBAClC,IAAI,IAAI,KAAK,CAAC;oBAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;gBACvD,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAA;gBAC3B,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1I,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\r\n Rect,\r\n Types,\r\n component2d,\r\n easeOut,\r\n type ChildView,\r\n type DataRecord,\r\n type EntryOptions,\r\n type NodeOf,\r\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\r\n type Node2D,\r\n type Node2DProps,\r\n type Size2D,\r\n type Timeline,\r\n} from \"@motionscript/sdk\"\r\nimport { formatNumber } from \"@motionscript/sdk/component\"\r\n\r\nimport { cartesianFrame, cartesianViews, laidOutSize } from \"../kit/cartesian\"\r\nimport { ChartBorder } from \"../kit/chart-border\"\r\nimport { ChartCanvas } from \"../kit/chart-canvas\"\r\nimport { ChartLegend } from \"../kit/chart-legend\"\r\nimport { asParts, fresh } from \"../kit/entries\"\r\nimport { beats, type Beat } from \"../kit/motion\"\r\nimport { VerticalAxis } from \"../kit/vertical-axis\"\r\nimport {\r\n clampUnit,\r\n formatMarker,\r\n lerpAxisDomain,\r\n lerpAxisEntry,\r\n markerStep,\r\n markerValues,\r\n num,\r\n resolveAxisDomain,\r\n settleAxisDomain,\r\n type AxisDomainConfig,\r\n type Range,\r\n} from \"../kit/shared\"\r\nimport { CategoryAxis } from \"./category-axis\"\r\nimport { ChartBars, type BarGeometry } from \"./chart-bars\"\r\nimport {\r\n DEFAULT_BAR_CHART_THEME,\r\n barCategories,\r\n barSpans,\r\n lerpBarChartTheme,\r\n resolveBarChartTheme,\r\n resolveBarFill,\r\n resolveBarScale,\r\n stackCapIndex,\r\n type BarChartConfig,\r\n type BarChartTheme,\r\n type BarSeries,\r\n} from \"./shared\"\r\n\r\nexport interface BarChartProps extends Node2DProps {\r\n /** One row per category — a plain record of field name to value. */\r\n data: DataRecord[]\r\n /**\r\n * Key into each row for its category caption, drawn beneath the baseline.\r\n * Named `categoryField` rather than `category` for the same reason the line\r\n * chart's is `xField`: it names a *column*, not a value.\r\n */\r\n categoryField: string\r\n /** One entry per bar series: which column it plots, its `label`, its `fill`. */\r\n series: BarSeries[]\r\n /**\r\n * When `true` every category's series stack into one column; when `false`\r\n * (the default) each series gets its own bar, grouped side by side within the\r\n * category's slot.\r\n */\r\n stacked?: boolean\r\n /** The value axis's domain: caption, scale range, and tick placement. */\r\n valueAxis?: AxisDomainConfig\r\n /** The category axis's domain. Only its `label` is read — the slots are the rows. */\r\n categoryAxis?: AxisDomainConfig\r\n /**\r\n * The chart's visual theme — bar palette and geometry, axis furniture, plot\r\n * panel paint, legend, value figures. Every branch is optional and deep-merged\r\n * onto {@link DEFAULT_BAR_CHART_THEME}.\r\n */\r\n theme?: BarChartTheme\r\n /** Whether the legend row below the plot is drawn at all. */\r\n showLegend?: boolean\r\n /** Whether each column prints the figure it plots. */\r\n showValues?: boolean\r\n}\r\n\r\n/** What a bar chart plots, as its entries hold it. */\r\nexport interface BarChartValues {\r\n readonly data: DataRecord[]\r\n readonly series: BarSeries[]\r\n readonly stacked: boolean\r\n readonly valueAxis: AxisDomainConfig\r\n}\r\n\r\n/** The value axis's domain with its range and ticks resolved. */\r\nexport type BarChartDomain = AxisDomainConfig & { readonly range: Range; readonly ticks: number[] }\r\n\r\n/** The argument every per-series command takes: an index into `series`, offered by name. */\r\nconst SERIES_ARG = Types.custom<number, number, EntryOptions & { readonly min: number; readonly step: number }>(0, { kind: \"series\", min: 0, step: 1 })\r\n\r\n/** How far the legend starts below its slot when it enters, in px. */\r\nconst LEGEND_SLIDE = 20\r\n\r\n/** Fallback marker count when the value axis states no ticks. */\r\nconst DEFAULT_MARKERS = 5\r\n\r\n/**\r\n * How `enter` divides its duration between its three beats: the axes arriving,\r\n * the columns rising, and the legend coming up. Shares of the whole, so they\r\n * must sum to 1.\r\n */\r\nconst AXES_SHARE = 0.35\r\nconst BARS_SHARE = 0.5\r\nconst LEGEND_SHARE = 0.15\r\n\r\n/** What the geometry reads: what the chart plots, its theme and the signals its commands move. */\r\ninterface BarState extends BarChartValues {\r\n readonly theme: BarChartConfig\r\n readonly weights: number[]\r\n readonly spotlight: number | null\r\n readonly spotlightReveal: number\r\n}\r\n\r\n/** The value axis with its range and ticks resolved: the explicit ones, else five across the scale. */\r\nfunction drawnValue(s: BarChartValues, domain: AxisDomainConfig): AxisDomainConfig {\r\n const divisions = (domain.ticks?.length ?? DEFAULT_MARKERS) - 1\r\n const range = resolveBarScale(s.data, s.series, s.stacked, domain.range, divisions)\r\n return { ...domain, range, ticks: domain.ticks ?? markerValues(range, DEFAULT_MARKERS - 1) }\r\n}\r\n\r\n/** The last domain worked out from each data array, and what else it was read from. */\r\nconst domainsDrawn = new WeakMap<DataRecord[], Omit<BarChartValues, \"data\"> & { readonly domain: BarChartDomain }>()\r\n\r\n/** The value axis as a bar chart draws it now, an auto range or tick row read back as itself. */\r\nexport function barChartDomain(s: BarChartValues): BarChartDomain {\r\n const { data, series, stacked, valueAxis } = s\r\n const kept = domainsDrawn.get(data)\r\n if (kept && kept.series === series && kept.stacked === stacked && kept.valueAxis === valueAxis) return kept.domain\r\n const domain = settleAxisDomain(valueAxis, (d) => drawnValue(s, d)) as BarChartDomain\r\n domainsDrawn.set(data, { series, stacked, valueAxis, domain })\r\n return domain\r\n}\r\n\r\n/**\r\n * A value written down as this chart's value axis says: the ticks and the\r\n * figures printed on the columns both read through here, so the two cannot\r\n * disagree about what a number looks like.\r\n */\r\nfunction valueLabel(s: BarChartValues, domain: BarChartDomain, value: number): string {\r\n const pattern = s.valueAxis.format\r\n return pattern === undefined ? formatMarker(value, markerStep(domain.ticks)) : formatNumber(value, pattern)\r\n}\r\n\r\n/** A value on the plot's **centred** pixel space (origin at its centre, y-up). */\r\nfunction valueToY(domain: BarChartDomain, plot: Size2D, value: number): number {\r\n const [min, max] = domain.range\r\n if (max <= min) return -plot.height / 2\r\n return ((value - min) / (max - min) - 0.5) * plot.height\r\n}\r\n\r\n/**\r\n * Pixel y of the line every column grows from: zero clamped onto the scale, so\r\n * a cropped axis grows its columns from the plot floor.\r\n */\r\nfunction baselinePx(domain: BarChartDomain, plot: Size2D): number {\r\n const [min, max] = domain.range\r\n return valueToY(domain, plot, Math.min(Math.max(0, min), max))\r\n}\r\n\r\n/** Series `i`'s live share of the slot; 0 once it has been hidden. */\r\nfunction weightAt(s: BarState, index: number): number {\r\n return Math.max(0, s.weights[index] ?? 1)\r\n}\r\n\r\n/** `row` with each series' value scaled by its live weight: what the stacked spans are measured from. */\r\nfunction weightedRow(s: BarState, row: DataRecord): DataRecord {\r\n const scaled: DataRecord = { ...row }\r\n s.series.forEach((series, i) => {\r\n const value = row[series.field]\r\n if (typeof value === \"number\") scaled[series.field] = value * weightAt(s, i)\r\n })\r\n return scaled\r\n}\r\n\r\n/**\r\n * Series `index`'s columns, mapped into the plot's centred pixel space. A\r\n * grouped series divides the slot with its siblings by their live weights, a\r\n * stacked one takes the whole slot and runs from the running total below it,\r\n * so hiding a series reflows rather than punching a hole.\r\n */\r\nfunction seriesBars(s: BarState, index: number, plot: Size2D, captioned: boolean): BarGeometry[] {\r\n const series = s.series[index]\r\n if (!series) return []\r\n const domain = barChartDomain(s)\r\n const n = s.data.length\r\n const slotWidth = n > 0 ? plot.width / n : 0\r\n const slotCenter = (i: number) => -plot.width / 2 + slotWidth * (i + 0.5)\r\n const inner = slotWidth * clampUnit(s.theme.bar.slotFill)\r\n const gap = s.theme.bar.groupGap\r\n let total = 0\r\n for (let i = 0; i < s.series.length; i++) total += weightAt(s, i)\r\n const unit = inner / (total > 0 ? total : 1)\r\n const weight = weightAt(s, index)\r\n let before = 0\r\n for (let i = 0; i < index; i++) before += weightAt(s, i)\r\n\r\n return s.data.map((row, rowIndex) => {\r\n // The stack is built from the *live* contributions, so a series fading out\r\n // lowers the segments above it as it goes.\r\n const spans = barSpans(s.stacked ? weightedRow(s, row) : row, s.series, s.stacked)\r\n const span = spans[index] ?? { from: 0, to: 0, value: 0 }\r\n const cap = s.stacked ? stackCapIndex(row, s.series) : index\r\n const slotLeft = slotCenter(rowIndex) - inner / 2\r\n const x = s.stacked ? slotCenter(rowIndex) : slotLeft + unit * before + (unit * weight) / 2\r\n const width = s.stacked ? inner : Math.max(0, unit * weight - (s.series.length > 1 ? gap : 0))\r\n // The figure printed is the row's own value, not the weighted one.\r\n const value = num(row, series.field)\r\n return {\r\n x,\r\n width,\r\n from: valueToY(domain, plot, span.from),\r\n to: valueToY(domain, plot, span.to),\r\n round: cap === index,\r\n value,\r\n ...(captioned && { caption: valueLabel(s, domain, value) }),\r\n }\r\n })\r\n}\r\n\r\n/**\r\n * How far each category is dimmed by the spotlight, one entry per row: 1 while\r\n * nothing is spotlit, falling to the theme's `dimOpacity` for every category but\r\n * the chosen one as the reveal climbs.\r\n */\r\nfunction categoryDims(s: BarState): number[] {\r\n const focus = clampUnit(s.spotlightReveal)\r\n const dim = s.theme.spotlight.dimOpacity\r\n const chosen = s.spotlight\r\n return s.data.map((_, i) => (focus <= 0 || chosen === i ? 1 : 1 - (1 - dim) * focus))\r\n}\r\n\r\ntype AnyTimeline = Timeline<any, any>\r\n\r\n/** The parts a bar chart's commands drive, found through its children. */\r\nfunction partsOf(children: readonly ChildView[]) {\r\n const frame = cartesianViews(children)\r\n if (!frame) return null\r\n const cAxis = frame.below.find(CategoryAxis.is)\r\n if (!VerticalAxis.is(frame.axis) || !cAxis) return null\r\n return {\r\n vAxis: frame.axis,\r\n cAxis,\r\n bars: frame.plot.filter(ChartBars.is),\r\n legend: frame.below.find(ChartLegend.is) ?? null,\r\n }\r\n}\r\n\r\n/**\r\n * Move series `index`'s slot share to `target` with its legend entry, the group\r\n * reflowing. Its columns are drawn for every frame the move covers, and switch\r\n * off only once a hide has landed, so arriving at a time backwards shows what\r\n * arriving forwards does.\r\n */\r\nfunction toggling(timeline: AnyTimeline, state: BarState & { readonly showing: boolean[] }, children: readonly ChildView[], index: number, target: number) {\r\n const parts = partsOf(children)\r\n if (!parts || !parts.bars[index]) return timeline.wait(timeline.duration)\r\n // Read through `weightAt`, so a chart whose stored weights are short still\r\n // tweens from the 1 it is drawing at.\r\n const from = state.series.map((_, i) => weightAt(state, i))\r\n const start = from[index] ?? 1\r\n const showing = state.series.map((s, i) => state.showing[i] ?? (s.enabled ?? true))\r\n return timeline.together([\r\n timeline.animate((t) => {\r\n const weights = [...from]\r\n weights[index] = start + (target - start) * timeline.ease(t)\r\n const shown = [...showing]\r\n shown[index] = target > 0 || t < 1\r\n return { weights, showing: shown }\r\n }, { eased: false }),\r\n ...(parts.legend ? [parts.legend.run(target > 0 ? \"showSeries\" : \"hideSeries\", { index })] : []),\r\n ])\r\n}\r\n\r\n/**\r\n * A grouped or stacked bar chart, the sibling of the line chart and built the\r\n * same way, out of several of the same pieces:\r\n *\r\n * - `ChartCanvas` — the plot panel with a horizontal grid, under everything.\r\n * - `VerticalAxis` — the numeric value markers, staggering in bottom-to-top.\r\n * - {@link CategoryAxis} — the row of names beneath the baseline, one per row.\r\n * - {@link ChartBars} (one per series) — that series' column in every category,\r\n * plus the figures printed on them.\r\n * - `ChartLegend` — a row of entries below the chart, one per series.\r\n *\r\n * Every part reads the chart's entries through bindings, and the columns map\r\n * across the plot panel's own laid-out box, so a column's end lands exactly on\r\n * its marker. **Zero is always on the scale**, and the columns grow about it, so\r\n * a negative value draws downward out of the same `growth` signal.\r\n *\r\n * **Resting state is the finished chart**; `enter` arms every part on its first\r\n * frame. `showSeries`/`hideSeries`/`spotlightSeries` pick out a *series* (hiding\r\n * one reflows the group), `spotlightCategory`/`clearCategory` a *column of the\r\n * table*. A `to` of the value axis's `range` or `ticks` tweens from the domain\r\n * as drawn, so an auto axis rescales the columns continuously.\r\n */\r\nexport const BarChart = component2d({\r\n key: \"barChart\",\r\n state: {\r\n data: fresh<DataRecord[]>(() => []),\r\n categoryField: \"\",\r\n series: fresh<BarSeries[]>(() => []),\r\n stacked: false,\r\n valueAxis: Types.custom<AxisDomainConfig>({}, { resolve: resolveAxisDomain, lerp: lerpAxisEntry }),\r\n categoryAxis: Types.custom<AxisDomainConfig>({}, { resolve: resolveAxisDomain, lerp: lerpAxisDomain }),\r\n theme: Types.custom<BarChartTheme, BarChartConfig>(DEFAULT_BAR_CHART_THEME, { resolve: resolveBarChartTheme, lerp: lerpBarChartTheme }),\r\n /**\r\n * Global rise of every column in `[0, 1]`, measured about the baseline: 0\r\n * collapses them all onto it, 1 draws them at full length.\r\n */\r\n growth: 1,\r\n /**\r\n * How much of the slot each series claims, one entry per series: a weight\r\n * rather than a switch, so hiding one is the others widening into the space.\r\n * Seeded from each series' `enabled`.\r\n */\r\n weights: fresh<number[]>(() => []),\r\n /** The category spotlit, or `null` for none. The choice snaps; `spotlightReveal` is the animation. */\r\n spotlight: Types.custom<number | null>(null),\r\n /** How far the category spotlight is drawn in, `[0, 1]`. */\r\n spotlightReveal: 0,\r\n /** Read as the chart is built: the legend is a part the chart builds or doesn't. */\r\n showLegend: Types.boolean(true, { animatable: false }),\r\n /** Read as the chart is built: whether each column prints the figure it plots. */\r\n showValues: Types.boolean(false, { animatable: false }),\r\n /** Whether each series' columns are drawn: on for every frame a show or hide covers, off once a hide lands. */\r\n showing: Types.custom<boolean[]>([], { private: true }),\r\n },\r\n defaults: {\r\n // Its parts fill it; a node made of them would hug them.\r\n width: \"fill\",\r\n height: \"fill\",\r\n weights: (state) => state.series.map((s) => ((s.enabled ?? true) ? 1 : 0)),\r\n showing: (state) => state.series.map((s) => s.enabled ?? true),\r\n },\r\n allowedChildren: [],\r\n children: (state) => {\r\n const theme = () => state.theme\r\n const domain = () => barChartDomain(state)\r\n let plot: Node2D | undefined\r\n // Before the panel is built or laid out it has no size, and the columns map onto nothing.\r\n const plotSize = () => laidOutSize(plot)\r\n const captioned = state.showValues === true\r\n\r\n const vAxis = new VerticalAxis({\r\n range: () => domain().range,\r\n markers: () => domain().ticks,\r\n captions: () => {\r\n const d = domain()\r\n return d.ticks.map((value) => valueLabel(state, d, value))\r\n },\r\n axis: () => theme().yAxis,\r\n label: state.valueAxis.label ?? \"\",\r\n width: \"hug\",\r\n height: \"fill\",\r\n })\r\n\r\n const cAxis = new CategoryAxis({\r\n categories: barCategories(state.data, state.categoryField),\r\n axis: () => theme().xAxis,\r\n label: state.categoryAxis.label ?? \"\",\r\n dims: () => categoryDims(state),\r\n width: \"fill\",\r\n height: \"hug\",\r\n }) as unknown as Node2D\r\n\r\n const barSets = state.series.map(\r\n (s, i) =>\r\n new ChartBars({\r\n bars: () => seriesBars(state, i, plotSize(), captioned),\r\n baseline: () => baselinePx(domain(), plotSize()),\r\n fill: () => resolveBarFill(theme().seriesFills, s, i),\r\n barStroke: () => theme().bar.stroke,\r\n barShadow: () => theme().bar.shadow,\r\n cornerRadius: () => theme().bar.cornerRadius,\r\n growth: () => state.growth,\r\n dims: () => categoryDims(state),\r\n showValues: captioned,\r\n valueStyle: state.theme.valueStyle,\r\n enabled: () => state.showing[i] ?? (s.enabled ?? true),\r\n }) as unknown as Node2D\r\n )\r\n\r\n const below: Node2D[] = [cAxis]\r\n if (state.showLegend !== false) {\r\n below.push(\r\n new ChartLegend({\r\n series: state.series,\r\n swatches: () => state.series.map((s, i) => resolveBarFill(theme().seriesFills, s, i)),\r\n legend: () => theme().legend,\r\n // The row's spacing is the theme's as the chart was built, like the\r\n // entries' type and chips: a theme tween re-paints the swatches only.\r\n gap: state.theme.legend.itemGap,\r\n padding: state.theme.legend.padding,\r\n }) as unknown as Node2D\r\n )\r\n }\r\n\r\n plot = new Rect({\r\n clip: true,\r\n children: [\r\n new ChartCanvas({\r\n fill: () => theme().plotArea.fill,\r\n shadow: () => theme().plotArea.shadow,\r\n xGridStroke: () => theme().xAxis.lineStyle,\r\n yGridStroke: () => theme().yAxis.lineStyle,\r\n // No vertical rules: the horizontal axis is categorical, so there is no\r\n // numeric position along it for a grid line to mark.\r\n xMarkers: [],\r\n yMarkers: () => domain().ticks,\r\n xExtent: () => [0, 1] as Range,\r\n yExtent: () => domain().range,\r\n }),\r\n ...barSets,\r\n new ChartBorder({ stroke: () => theme().plotArea.stroke }),\r\n ],\r\n }) as unknown as Node2D\r\n\r\n const gutter = new VerticalAxis({\r\n opacity: 0,\r\n range: () => domain().range,\r\n markers: () => domain().ticks,\r\n axis: () => theme().yAxis,\r\n label: state.valueAxis.label ?? \"\",\r\n width: \"hug\",\r\n height: 0,\r\n }) as unknown as Node2D\r\n\r\n return asParts([cartesianFrame({ axis: vAxis as unknown as Node2D, plot, gutter, below })])\r\n },\r\n commands: {\r\n /**\r\n * Animate the whole chart in: the two axes stagger their markers and\r\n * captions in, the columns rise from the baseline, and the legend fades up\r\n * last. Its first frame arms every part: markers and captions shifted and\r\n * transparent, columns collapsed, the legend dropped and transparent.\r\n * `duration` is the **whole** entrance; the beats are shares of it.\r\n */\r\n enter: {\r\n args: {},\r\n // Held from the chart's arrival, so it never shows finished ahead of its draw.\r\n entrance: true,\r\n easing: easeOut(),\r\n run: (timeline, _state, children) => {\r\n const parts = partsOf(children)\r\n if (!parts) return timeline.wait(timeline.duration)\r\n const duration = timeline.duration\r\n const axes = duration * AXES_SHARE\r\n const rise = duration * BARS_SHARE\r\n const { legend } = parts\r\n const at0 = (piece: Beat[\"piece\"]): Beat => ({ at: 0, duration: 0, piece })\r\n // Without a legend the beat is still its share of the whole.\r\n return beats(timeline, [\r\n at0(timeline.animate(() => ({ growth: 0 }))),\r\n ...(legend ? [at0(legend.to({ opacity: 0, y: -LEGEND_SLIDE }))] : []),\r\n { at: 0, duration: axes, piece: parts.vAxis.run(\"enter\", { slide: 24 }) },\r\n { at: 0, duration: axes, piece: parts.cAxis.run(\"enter\", { slide: 24 }) },\r\n // No priming to 0 first: the value at `t` is a function of `t`.\r\n { at: axes, duration: rise, piece: timeline.animate((t) => ({ growth: t })) },\r\n ...(legend ? [{ at: axes + rise, duration: duration * LEGEND_SHARE, piece: legend.to({ opacity: 1, y: 0 }) }] : []),\r\n ])\r\n },\r\n },\r\n /** Show series `index`: its columns come back, the group reflowing to make room, with its legend entry. */\r\n showSeries: {\r\n args: { seriesIndex: SERIES_ARG },\r\n easing: easeOut(),\r\n run: (timeline, state, children) => toggling(timeline, state, children, timeline.args.seriesIndex, 1),\r\n },\r\n /**\r\n * Hide series `index`: its columns narrow away (or, stacked, sink out of the\r\n * stack) while the rest of the group widens into the space — the mirror of\r\n * `showSeries`.\r\n */\r\n hideSeries: {\r\n args: { seriesIndex: SERIES_ARG },\r\n easing: easeOut(),\r\n run: (timeline, state, children) => toggling(timeline, state, children, timeline.args.seriesIndex, 0),\r\n },\r\n /**\r\n * Fade every other series — its columns **and its legend entry** — to focus\r\n * on `index`, which comes back to full. Nothing moves, so the group doesn't\r\n * reflow.\r\n */\r\n spotlightSeries: {\r\n args: { seriesIndex: SERIES_ARG },\r\n easing: easeOut(),\r\n run: (timeline, state, children) => {\r\n const parts = partsOf(children)\r\n if (!parts) return timeline.wait(timeline.duration)\r\n const index = timeline.args.seriesIndex\r\n const dim = state.theme.spotlight.dimOpacity\r\n return timeline.together([\r\n ...parts.bars.map((bars, i) => bars.to({ opacity: i === index ? 1 : dim })),\r\n ...(parts.legend ? [parts.legend.run(\"spotlightSeries\", { index })] : []),\r\n ])\r\n },\r\n },\r\n /**\r\n * Spotlight one **category**: every other category's columns and caption\r\n * fade to the theme's `dimOpacity`. Called while another is lit, the focus\r\n * moves directly: only the dimming changes, so nothing retracts first. A\r\n * category that is not there takes its slot and changes nothing.\r\n */\r\n spotlightCategory: {\r\n args: { categoryIndex: Types.number(0, { min: 0, step: 1 }) },\r\n easing: easeOut(),\r\n run: (timeline, state) => {\r\n const index = timeline.args.categoryIndex\r\n if (index < 0 || index >= state.data.length) return timeline.wait(timeline.duration)\r\n const from = state.spotlightReveal\r\n return timeline.animate((t) => ({ spotlight: index, spotlightReveal: from + (1 - from) * t }))\r\n },\r\n },\r\n /**\r\n * Drop the category spotlight, every category back to full. The lit\r\n * category is held until the fade lands; a no-op when nothing is lit, which\r\n * still takes its slot.\r\n */\r\n clearCategory: {\r\n args: {},\r\n easing: easeOut(),\r\n run: (timeline, state) => {\r\n const from = state.spotlightReveal\r\n if (from === 0) return timeline.wait(timeline.duration)\r\n const lit = state.spotlight\r\n return timeline.animate((t) => (t >= 1 ? { spotlight: null, spotlightReveal: 0 } : { spotlight: lit, spotlightReveal: from * (1 - t) }))\r\n },\r\n },\r\n },\r\n})\r\n\r\nexport type BarChart = NodeOf<typeof BarChart>\r\n"]}
|
|
1
|
+
{"version":3,"file":"bar-chart.js","sourceRoot":"","sources":["../../src/bar-chart/bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EAC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;QACH,aAAa,EAAE;YACb,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,OAAO,EAAE;YACjB,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;gBACvB,MAAM,IAAI,GAAG,KAAK,CAAC,eAAe,CAAA;gBAClC,IAAI,IAAI,KAAK,CAAC;oBAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;gBACvD,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAA;gBAC3B,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1I,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n Types,\n component2d,\n easeOut,\n type ChildView,\n type DataRecord,\n type EntryOptions,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\n type Node2D,\n type Node2DProps,\n type Size2D,\n type Timeline,\n} from \"@motionscript/sdk\"\nimport { formatNumber } from \"@motionscript/sdk/component\"\n\nimport { cartesianFrame, cartesianViews, laidOutSize } from \"../kit/cartesian\"\nimport { ChartBorder } from \"../kit/chart-border\"\nimport { ChartCanvas } from \"../kit/chart-canvas\"\nimport { ChartLegend } from \"../kit/chart-legend\"\nimport { asParts, fresh } from \"../kit/entries\"\nimport { beats, type Beat } from \"../kit/motion\"\nimport { VerticalAxis } from \"../kit/vertical-axis\"\nimport {\n clampUnit,\n formatMarker,\n lerpAxisDomain,\n lerpAxisEntry,\n markerStep,\n markerValues,\n num,\n resolveAxisDomain,\n settleAxisDomain,\n type AxisDomainConfig,\n type Range,\n} from \"../kit/shared\"\nimport { CategoryAxis } from \"./category-axis\"\nimport { ChartBars, type BarGeometry } from \"./chart-bars\"\nimport {\n DEFAULT_BAR_CHART_THEME,\n barCategories,\n barSpans,\n lerpBarChartTheme,\n resolveBarChartTheme,\n resolveBarFill,\n resolveBarScale,\n stackCapIndex,\n type BarChartConfig,\n type BarChartTheme,\n type BarSeries,\n} from \"./shared\"\n\nexport interface BarChartProps extends Node2DProps {\n /** One row per category — a plain record of field name to value. */\n data: DataRecord[]\n /**\n * Key into each row for its category caption, drawn beneath the baseline.\n * Named `categoryField` rather than `category` for the same reason the line\n * chart's is `xField`: it names a *column*, not a value.\n */\n categoryField: string\n /** One entry per bar series: which column it plots, its `label`, its `fill`. */\n series: BarSeries[]\n /**\n * When `true` every category's series stack into one column; when `false`\n * (the default) each series gets its own bar, grouped side by side within the\n * category's slot.\n */\n stacked?: boolean\n /** The value axis's domain: caption, scale range, and tick placement. */\n valueAxis?: AxisDomainConfig\n /** The category axis's domain. Only its `label` is read — the slots are the rows. */\n categoryAxis?: AxisDomainConfig\n /**\n * The chart's visual theme — bar palette and geometry, axis furniture, plot\n * panel paint, legend, value figures. Every branch is optional and deep-merged\n * onto {@link DEFAULT_BAR_CHART_THEME}.\n */\n theme?: BarChartTheme\n /** Whether the legend row below the plot is drawn at all. */\n showLegend?: boolean\n /** Whether each column prints the figure it plots. */\n showValues?: boolean\n}\n\n/** What a bar chart plots, as its entries hold it. */\nexport interface BarChartValues {\n readonly data: DataRecord[]\n readonly series: BarSeries[]\n readonly stacked: boolean\n readonly valueAxis: AxisDomainConfig\n}\n\n/** The value axis's domain with its range and ticks resolved. */\nexport type BarChartDomain = AxisDomainConfig & { readonly range: Range; readonly ticks: number[] }\n\n/** The argument every per-series command takes: an index into `series`, offered by name. */\nconst SERIES_ARG = Types.custom<number, number, EntryOptions & { readonly min: number; readonly step: number }>(0, { kind: \"series\", min: 0, step: 1 })\n\n/** How far the legend starts below its slot when it enters, in px. */\nconst LEGEND_SLIDE = 20\n\n/** Fallback marker count when the value axis states no ticks. */\nconst DEFAULT_MARKERS = 5\n\n/**\n * How `enter` divides its duration between its three beats: the axes arriving,\n * the columns rising, and the legend coming up. Shares of the whole, so they\n * must sum to 1.\n */\nconst AXES_SHARE = 0.35\nconst BARS_SHARE = 0.5\nconst LEGEND_SHARE = 0.15\n\n/** What the geometry reads: what the chart plots, its theme and the signals its commands move. */\ninterface BarState extends BarChartValues {\n readonly theme: BarChartConfig\n readonly weights: number[]\n readonly spotlight: number | null\n readonly spotlightReveal: number\n}\n\n/** The value axis with its range and ticks resolved: the explicit ones, else five across the scale. */\nfunction drawnValue(s: BarChartValues, domain: AxisDomainConfig): AxisDomainConfig {\n const divisions = (domain.ticks?.length ?? DEFAULT_MARKERS) - 1\n const range = resolveBarScale(s.data, s.series, s.stacked, domain.range, divisions)\n return { ...domain, range, ticks: domain.ticks ?? markerValues(range, DEFAULT_MARKERS - 1) }\n}\n\n/** The last domain worked out from each data array, and what else it was read from. */\nconst domainsDrawn = new WeakMap<DataRecord[], Omit<BarChartValues, \"data\"> & { readonly domain: BarChartDomain }>()\n\n/** The value axis as a bar chart draws it now, an auto range or tick row read back as itself. */\nexport function barChartDomain(s: BarChartValues): BarChartDomain {\n const { data, series, stacked, valueAxis } = s\n const kept = domainsDrawn.get(data)\n if (kept && kept.series === series && kept.stacked === stacked && kept.valueAxis === valueAxis) return kept.domain\n const domain = settleAxisDomain(valueAxis, (d) => drawnValue(s, d)) as BarChartDomain\n domainsDrawn.set(data, { series, stacked, valueAxis, domain })\n return domain\n}\n\n/**\n * A value written down as this chart's value axis says: the ticks and the\n * figures printed on the columns both read through here, so the two cannot\n * disagree about what a number looks like.\n */\nfunction valueLabel(s: BarChartValues, domain: BarChartDomain, value: number): string {\n const pattern = s.valueAxis.format\n return pattern === undefined ? formatMarker(value, markerStep(domain.ticks)) : formatNumber(value, pattern)\n}\n\n/** A value on the plot's **centred** pixel space (origin at its centre, y-up). */\nfunction valueToY(domain: BarChartDomain, plot: Size2D, value: number): number {\n const [min, max] = domain.range\n if (max <= min) return -plot.height / 2\n return ((value - min) / (max - min) - 0.5) * plot.height\n}\n\n/**\n * Pixel y of the line every column grows from: zero clamped onto the scale, so\n * a cropped axis grows its columns from the plot floor.\n */\nfunction baselinePx(domain: BarChartDomain, plot: Size2D): number {\n const [min, max] = domain.range\n return valueToY(domain, plot, Math.min(Math.max(0, min), max))\n}\n\n/** Series `i`'s live share of the slot; 0 once it has been hidden. */\nfunction weightAt(s: BarState, index: number): number {\n return Math.max(0, s.weights[index] ?? 1)\n}\n\n/** `row` with each series' value scaled by its live weight: what the stacked spans are measured from. */\nfunction weightedRow(s: BarState, row: DataRecord): DataRecord {\n const scaled: DataRecord = { ...row }\n s.series.forEach((series, i) => {\n const value = row[series.field]\n if (typeof value === \"number\") scaled[series.field] = value * weightAt(s, i)\n })\n return scaled\n}\n\n/**\n * Series `index`'s columns, mapped into the plot's centred pixel space. A\n * grouped series divides the slot with its siblings by their live weights, a\n * stacked one takes the whole slot and runs from the running total below it,\n * so hiding a series reflows rather than punching a hole.\n */\nfunction seriesBars(s: BarState, index: number, plot: Size2D, captioned: boolean): BarGeometry[] {\n const series = s.series[index]\n if (!series) return []\n const domain = barChartDomain(s)\n const n = s.data.length\n const slotWidth = n > 0 ? plot.width / n : 0\n const slotCenter = (i: number) => -plot.width / 2 + slotWidth * (i + 0.5)\n const inner = slotWidth * clampUnit(s.theme.bar.slotFill)\n const gap = s.theme.bar.groupGap\n let total = 0\n for (let i = 0; i < s.series.length; i++) total += weightAt(s, i)\n const unit = inner / (total > 0 ? total : 1)\n const weight = weightAt(s, index)\n let before = 0\n for (let i = 0; i < index; i++) before += weightAt(s, i)\n\n return s.data.map((row, rowIndex) => {\n // The stack is built from the *live* contributions, so a series fading out\n // lowers the segments above it as it goes.\n const spans = barSpans(s.stacked ? weightedRow(s, row) : row, s.series, s.stacked)\n const span = spans[index] ?? { from: 0, to: 0, value: 0 }\n const cap = s.stacked ? stackCapIndex(row, s.series) : index\n const slotLeft = slotCenter(rowIndex) - inner / 2\n const x = s.stacked ? slotCenter(rowIndex) : slotLeft + unit * before + (unit * weight) / 2\n const width = s.stacked ? inner : Math.max(0, unit * weight - (s.series.length > 1 ? gap : 0))\n // The figure printed is the row's own value, not the weighted one.\n const value = num(row, series.field)\n return {\n x,\n width,\n from: valueToY(domain, plot, span.from),\n to: valueToY(domain, plot, span.to),\n round: cap === index,\n value,\n ...(captioned && { caption: valueLabel(s, domain, value) }),\n }\n })\n}\n\n/**\n * How far each category is dimmed by the spotlight, one entry per row: 1 while\n * nothing is spotlit, falling to the theme's `dimOpacity` for every category but\n * the chosen one as the reveal climbs.\n */\nfunction categoryDims(s: BarState): number[] {\n const focus = clampUnit(s.spotlightReveal)\n const dim = s.theme.spotlight.dimOpacity\n const chosen = s.spotlight\n return s.data.map((_, i) => (focus <= 0 || chosen === i ? 1 : 1 - (1 - dim) * focus))\n}\n\ntype AnyTimeline = Timeline<any, any>\n\n/** The parts a bar chart's commands drive, found through its children. */\nfunction partsOf(children: readonly ChildView[]) {\n const frame = cartesianViews(children)\n if (!frame) return null\n const cAxis = frame.below.find(CategoryAxis.is)\n if (!VerticalAxis.is(frame.axis) || !cAxis) return null\n return {\n vAxis: frame.axis,\n cAxis,\n bars: frame.plot.filter(ChartBars.is),\n legend: frame.below.find(ChartLegend.is) ?? null,\n }\n}\n\n/**\n * Move series `index`'s slot share to `target` with its legend entry, the group\n * reflowing. Its columns are drawn for every frame the move covers, and switch\n * off only once a hide has landed, so arriving at a time backwards shows what\n * arriving forwards does.\n */\nfunction toggling(timeline: AnyTimeline, state: BarState & { readonly showing: boolean[] }, children: readonly ChildView[], index: number, target: number) {\n const parts = partsOf(children)\n if (!parts || !parts.bars[index]) return timeline.wait(timeline.duration)\n // Read through `weightAt`, so a chart whose stored weights are short still\n // tweens from the 1 it is drawing at.\n const from = state.series.map((_, i) => weightAt(state, i))\n const start = from[index] ?? 1\n const showing = state.series.map((s, i) => state.showing[i] ?? (s.enabled ?? true))\n return timeline.together([\n timeline.animate((t) => {\n const weights = [...from]\n weights[index] = start + (target - start) * timeline.ease(t)\n const shown = [...showing]\n shown[index] = target > 0 || t < 1\n return { weights, showing: shown }\n }, { eased: false }),\n ...(parts.legend ? [parts.legend.run(target > 0 ? \"showSeries\" : \"hideSeries\", { index })] : []),\n ])\n}\n\n/**\n * A grouped or stacked bar chart, the sibling of the line chart and built the\n * same way, out of several of the same pieces:\n *\n * - `ChartCanvas` — the plot panel with a horizontal grid, under everything.\n * - `VerticalAxis` — the numeric value markers, staggering in bottom-to-top.\n * - {@link CategoryAxis} — the row of names beneath the baseline, one per row.\n * - {@link ChartBars} (one per series) — that series' column in every category,\n * plus the figures printed on them.\n * - `ChartLegend` — a row of entries below the chart, one per series.\n *\n * Every part reads the chart's entries through bindings, and the columns map\n * across the plot panel's own laid-out box, so a column's end lands exactly on\n * its marker. **Zero is always on the scale**, and the columns grow about it, so\n * a negative value draws downward out of the same `growth` signal.\n *\n * **Resting state is the finished chart**; `enter` arms every part on its first\n * frame. `showSeries`/`hideSeries`/`spotlightSeries` pick out a *series* (hiding\n * one reflows the group), `spotlightCategory`/`clearCategory` a *column of the\n * table*. A `to` of the value axis's `range` or `ticks` tweens from the domain\n * as drawn, so an auto axis rescales the columns continuously.\n */\nexport const BarChart = component2d({\n key: \"barChart\",\n state: {\n data: fresh<DataRecord[]>(() => []),\n categoryField: \"\",\n series: fresh<BarSeries[]>(() => []),\n stacked: false,\n valueAxis: Types.custom<AxisDomainConfig>({}, { resolve: resolveAxisDomain, lerp: lerpAxisEntry }),\n categoryAxis: Types.custom<AxisDomainConfig>({}, { resolve: resolveAxisDomain, lerp: lerpAxisDomain }),\n theme: Types.custom<BarChartTheme, BarChartConfig>(DEFAULT_BAR_CHART_THEME, { resolve: resolveBarChartTheme, lerp: lerpBarChartTheme }),\n /**\n * Global rise of every column in `[0, 1]`, measured about the baseline: 0\n * collapses them all onto it, 1 draws them at full length.\n */\n growth: 1,\n /**\n * How much of the slot each series claims, one entry per series: a weight\n * rather than a switch, so hiding one is the others widening into the space.\n * Seeded from each series' `enabled`.\n */\n weights: fresh<number[]>(() => []),\n /** The category spotlit, or `null` for none. The choice snaps; `spotlightReveal` is the animation. */\n spotlight: Types.custom<number | null>(null),\n /** How far the category spotlight is drawn in, `[0, 1]`. */\n spotlightReveal: 0,\n /** Read as the chart is built: the legend is a part the chart builds or doesn't. */\n showLegend: Types.boolean(true, { animatable: false }),\n /** Read as the chart is built: whether each column prints the figure it plots. */\n showValues: Types.boolean(false, { animatable: false }),\n /** Whether each series' columns are drawn: on for every frame a show or hide covers, off once a hide lands. */\n showing: Types.custom<boolean[]>([], { private: true }),\n },\n defaults: {\n // Its parts fill it; a node made of them would hug them.\n width: \"fill\",\n height: \"fill\",\n weights: (state) => state.series.map((s) => ((s.enabled ?? true) ? 1 : 0)),\n showing: (state) => state.series.map((s) => s.enabled ?? true),\n },\n allowedChildren: [],\n children: (state) => {\n const theme = () => state.theme\n const domain = () => barChartDomain(state)\n let plot: Node2D | undefined\n // Before the panel is built or laid out it has no size, and the columns map onto nothing.\n const plotSize = () => laidOutSize(plot)\n const captioned = state.showValues === true\n\n const vAxis = new VerticalAxis({\n range: () => domain().range,\n markers: () => domain().ticks,\n captions: () => {\n const d = domain()\n return d.ticks.map((value) => valueLabel(state, d, value))\n },\n axis: () => theme().yAxis,\n label: state.valueAxis.label ?? \"\",\n width: \"hug\",\n height: \"fill\",\n })\n\n const cAxis = new CategoryAxis({\n categories: barCategories(state.data, state.categoryField),\n axis: () => theme().xAxis,\n label: state.categoryAxis.label ?? \"\",\n dims: () => categoryDims(state),\n width: \"fill\",\n height: \"hug\",\n }) as unknown as Node2D\n\n const barSets = state.series.map(\n (s, i) =>\n new ChartBars({\n bars: () => seriesBars(state, i, plotSize(), captioned),\n baseline: () => baselinePx(domain(), plotSize()),\n fill: () => resolveBarFill(theme().seriesFills, s, i),\n barStroke: () => theme().bar.stroke,\n barShadow: () => theme().bar.shadow,\n cornerRadius: () => theme().bar.cornerRadius,\n growth: () => state.growth,\n dims: () => categoryDims(state),\n showValues: captioned,\n valueStyle: state.theme.valueStyle,\n enabled: () => state.showing[i] ?? (s.enabled ?? true),\n }) as unknown as Node2D\n )\n\n const below: Node2D[] = [cAxis]\n if (state.showLegend !== false) {\n below.push(\n new ChartLegend({\n series: state.series,\n swatches: () => state.series.map((s, i) => resolveBarFill(theme().seriesFills, s, i)),\n legend: () => theme().legend,\n // The row's spacing is the theme's as the chart was built, like the\n // entries' type and chips: a theme tween re-paints the swatches only.\n gap: state.theme.legend.itemGap,\n padding: state.theme.legend.padding,\n }) as unknown as Node2D\n )\n }\n\n plot = new Rect({\n clip: true,\n children: [\n new ChartCanvas({\n fill: () => theme().plotArea.fill,\n shadow: () => theme().plotArea.shadow,\n xGridStroke: () => theme().xAxis.lineStyle,\n yGridStroke: () => theme().yAxis.lineStyle,\n // No vertical rules: the horizontal axis is categorical, so there is no\n // numeric position along it for a grid line to mark.\n xMarkers: [],\n yMarkers: () => domain().ticks,\n xExtent: () => [0, 1] as Range,\n yExtent: () => domain().range,\n }),\n ...barSets,\n new ChartBorder({ stroke: () => theme().plotArea.stroke }),\n ],\n }) as unknown as Node2D\n\n const gutter = new VerticalAxis({\n opacity: 0,\n range: () => domain().range,\n markers: () => domain().ticks,\n axis: () => theme().yAxis,\n label: state.valueAxis.label ?? \"\",\n width: \"hug\",\n height: 0,\n }) as unknown as Node2D\n\n return asParts([cartesianFrame({ axis: vAxis as unknown as Node2D, plot, gutter, below })])\n },\n commands: {\n /**\n * Animate the whole chart in: the two axes stagger their markers and\n * captions in, the columns rise from the baseline, and the legend fades up\n * last. Its first frame arms every part: markers and captions shifted and\n * transparent, columns collapsed, the legend dropped and transparent.\n * `duration` is the **whole** entrance; the beats are shares of it.\n */\n enter: {\n args: {},\n // Held from the chart's arrival, so it never shows finished ahead of its draw.\n entrance: true,\n easing: easeOut(),\n run: (timeline, _state, children) => {\n const parts = partsOf(children)\n if (!parts) return timeline.wait(timeline.duration)\n const duration = timeline.duration\n const axes = duration * AXES_SHARE\n const rise = duration * BARS_SHARE\n const { legend } = parts\n const at0 = (piece: Beat[\"piece\"]): Beat => ({ at: 0, duration: 0, piece })\n // Without a legend the beat is still its share of the whole.\n return beats(timeline, [\n at0(timeline.animate(() => ({ growth: 0 }))),\n ...(legend ? [at0(legend.to({ opacity: 0, y: -LEGEND_SLIDE }))] : []),\n { at: 0, duration: axes, piece: parts.vAxis.run(\"enter\", { slide: 24 }) },\n { at: 0, duration: axes, piece: parts.cAxis.run(\"enter\", { slide: 24 }) },\n // No priming to 0 first: the value at `t` is a function of `t`.\n { at: axes, duration: rise, piece: timeline.animate((t) => ({ growth: t })) },\n ...(legend ? [{ at: axes + rise, duration: duration * LEGEND_SHARE, piece: legend.to({ opacity: 1, y: 0 }) }] : []),\n ])\n },\n },\n /** Show series `index`: its columns come back, the group reflowing to make room, with its legend entry. */\n showSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, state, children) => toggling(timeline, state, children, timeline.args.seriesIndex, 1),\n },\n /**\n * Hide series `index`: its columns narrow away (or, stacked, sink out of the\n * stack) while the rest of the group widens into the space — the mirror of\n * `showSeries`.\n */\n hideSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, state, children) => toggling(timeline, state, children, timeline.args.seriesIndex, 0),\n },\n /**\n * Fade every other series — its columns **and its legend entry** — to focus\n * on `index`, which comes back to full. Nothing moves, so the group doesn't\n * reflow.\n */\n spotlightSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, state, children) => {\n const parts = partsOf(children)\n if (!parts) return timeline.wait(timeline.duration)\n const index = timeline.args.seriesIndex\n const dim = state.theme.spotlight.dimOpacity\n return timeline.together([\n ...parts.bars.map((bars, i) => bars.to({ opacity: i === index ? 1 : dim })),\n ...(parts.legend ? [parts.legend.run(\"spotlightSeries\", { index })] : []),\n ])\n },\n },\n /**\n * Spotlight one **category**: every other category's columns and caption\n * fade to the theme's `dimOpacity`. Called while another is lit, the focus\n * moves directly: only the dimming changes, so nothing retracts first. A\n * category that is not there takes its slot and changes nothing.\n */\n spotlightCategory: {\n args: { categoryIndex: Types.number(0, { min: 0, step: 1 }) },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.categoryIndex\n if (index < 0 || index >= state.data.length) return timeline.wait(timeline.duration)\n const from = state.spotlightReveal\n return timeline.animate((t) => ({ spotlight: index, spotlightReveal: from + (1 - from) * t }))\n },\n },\n /**\n * Drop the category spotlight, every category back to full. The lit\n * category is held until the fade lands; a no-op when nothing is lit, which\n * still takes its slot.\n */\n clearCategory: {\n args: {},\n easing: easeOut(),\n run: (timeline, state) => {\n const from = state.spotlightReveal\n if (from === 0) return timeline.wait(timeline.duration)\n const lit = state.spotlight\n return timeline.animate((t) => (t >= 1 ? { spotlight: null, spotlightReveal: 0 } : { spotlight: lit, spotlightReveal: from * (1 - t) }))\n },\n },\n },\n})\n\nexport type BarChart = NodeOf<typeof BarChart>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-axis.js","sourceRoot":"","sources":["../../src/bar-chart/category-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,GAIR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAA;AACxG,OAAO,EACL,cAAc,EACd,SAAS,EACT,WAAW,GAEZ,MAAM,eAAe,CAAA;AAoBtB,qEAAqE;AACrE,MAAM,KAAK,GAAG,EAAE,CAAA;AAEhB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,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K,KAAK,CAAC;oBAAE,OAAO,GAAG,CAAA;gBAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;gBACxF,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;gBAChC,MAAM,eAAe,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAA;gBAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC3H,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;gBAC1H,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3E,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\r\n Rect,\r\n Text,\r\n Types,\r\n component2d,\r\n insetsOps,\r\n textOps,\r\n type NodeOf,\r\n type Node2D,\r\n type Node2DProps,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { asParts, fresh } from \"../kit/entries\"\r\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"../kit/motion\"\r\nimport {\r\n DEFAULT_X_AXIS,\r\n clampUnit,\r\n enterBudget,\r\n type AxisConfig,\r\n} from \"../kit/shared\"\r\n\r\nexport interface CategoryAxisProps extends Node2DProps {\r\n /** One caption per category slot, left to right — the chart's rows, in order. */\r\n categories: string[]\r\n /** Caption/title text style and gutters — see {@link AxisConfig}. */\r\n axis: AxisConfig\r\n /**\r\n * Caption drawn centred in the gutter beneath the category row. Empty string\r\n * (the default) hides it.\r\n */\r\n label: string\r\n /**\r\n * Per-category opacity multiplier — how the chart's category spotlight reaches\r\n * the captions, so the name under a dimmed column dims with it. Missing\r\n * entries read as 1.\r\n */\r\n dims: number[]\r\n}\r\n\r\n/** How far a caption starts above its slot when it enters, in px. */\r\nconst SLIDE = 24\r\n\r\n/**\r\n * The **categorical** horizontal axis of a {@link BarChart}: a row of\r\n * {@link Text} captions, one per row of the data, each centred on its slot\r\n * beneath the baseline.\r\n *\r\n * Not a variant of the line chart's `HorizontalAxis` and deliberately not\r\n * folded into it: that axis places markers by *value* across a numeric range,\r\n * this one divides its width into equal slots and centres a name in each. The\r\n * two look alike on screen and share nothing underneath — one reads a scale,\r\n * the other counts rows.\r\n *\r\n * The slot arithmetic is the same as the plot's, because this node is laid out\r\n * to exactly the plot's width (the chart reserves the axis gutter with an\r\n * invisible twin of the value axis, as the line chart does), so a caption lands\r\n * under the columns it names without either side being told about the other.\r\n *\r\n * `enter` staggers the captions in left-to-right, each lifted a little above\r\n * its slot and transparent; the resting state is the landed one, so a chart\r\n * that is never told to enter still reads as finished.\r\n */\r\nexport const CategoryAxis = component2d({\r\n key: \"categoryAxis\",\r\n state: {\r\n categories: fresh<string[]>(() => []),\r\n axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),\r\n label: \"\",\r\n dims: fresh<number[]>(() => []),\r\n arrivals: arrivalsEntry(),\r\n },\r\n // A plain node filled its parent; one made of its captions would hug them.\r\n defaults: { width: \"fill\", height: \"fill\" },\r\n children: (state) => {\r\n const tickPad = insetsOps.resolve(state.axis.tickPadding).top\r\n const titlePad = insetsOps.resolve(state.axis.titlePadding).top\r\n\r\n const column: Node2D[] = []\r\n // The column's parent is the axis: its box is what the slots divide.\r\n const width = () => (column[0]?.parent as Node2D | null | undefined)?.layoutBounds.width ?? 0\r\n /** Centre x of slot `i`, in the node's centred space. */\r\n const slotCenter = (index: number) => {\r\n const n = state.categories.length\r\n if (n <= 0) return 0\r\n return -width() / 2 + (width() / n) * (index + 0.5)\r\n }\r\n\r\n // Each caption sits in a hug box carrying the spotlight dim, so the\r\n // entrance can animate the text's own opacity without the two fighting over\r\n // one value — opacity multiplies down the tree, which is exactly the\r\n // composition wanted here.\r\n const slots = state.categories.map((caption, i) =>\r\n new Rect({\r\n width: \"hug\",\r\n height: \"hug\",\r\n flow: \"freeform\",\r\n opacity: () => clampUnit(state.dims[i] ?? 1),\r\n x: () => slotCenter(i),\r\n children: [\r\n new Text({\r\n ...textOps.styleProps(state.axis.labelStyle),\r\n text: caption,\r\n opacity: () => arrivalOf(state.arrivals, i).opacity,\r\n y: () => arrivalOf(state.arrivals, i).shift,\r\n }),\r\n ],\r\n })\r\n )\r\n\r\n const children: Node2D[] = [new Rect({ width: \"fill\", height: \"hug\", padding: { top: tickPad }, children: slots })]\r\n if (state.label !== \"\") {\r\n children.push(\r\n new Text({\r\n ...textOps.styleProps(state.axis.titleStyle),\r\n text: state.label,\r\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\r\n y: () => arrivalOf(state.arrivals, \"label\").shift,\r\n })\r\n )\r\n }\r\n\r\n column.push(new Rect({ flow: \"vertical\", gap: titlePad, height: \"hug\", width: \"fill\", children }))\r\n return asParts(column)\r\n },\r\n commands: {\r\n /**\r\n * Slide + fade every caption in from above, staggered left-to-right, then\r\n * bring the title down behind them. Its first frame arms them all: lifted\r\n * by `slide` and transparent.\r\n *\r\n * The timeline's duration is the **whole** entrance — the stagger and the\r\n * title are carved out of it rather than added on top. See {@link enterBudget}.\r\n *\r\n * `stagger` is seconds between successive captions (derived when omitted);\r\n * `slide` is the starting upward offset in px (node space is y-up, so a\r\n * positive start slides *down* into place).\r\n */\r\n enter: {\r\n args: {\r\n stagger: Types.custom<number | undefined>(undefined),\r\n slide: Types.number(SLIDE),\r\n },\r\n run: (timeline, state) => {\r\n const { stagger, slide } = timeline.args\r\n const count = state.categories.length\r\n const captioned = state.label !== \"\"\r\n const from: Arrival = { opacity: 0, shift: slide }\r\n const keys = [...state.categories.keys(), ...(captioned ? [\"label\"] : [])]\r\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\r\n if (count === 0) return arm\r\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\r\n const ease = frameEase(timeline)\r\n const lastCaptionEnds = (count - 1) * step + per\r\n const captions = state.categories.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }))\r\n const label = captioned ? [{ at: lastCaptionEnds, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\r\n return timeline.together([arm, beats(timeline, [...captions, ...label])])\r\n },\r\n },\r\n },\r\n})\r\n\r\nexport type CategoryAxis = NodeOf<typeof CategoryAxis>\r\n"]}
|
|
1
|
+
{"version":3,"file":"category-axis.js","sourceRoot":"","sources":["../../src/bar-chart/category-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,GAIR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAA;AACxG,OAAO,EACL,cAAc,EACd,SAAS,EACT,WAAW,GAEZ,MAAM,eAAe,CAAA;AAoBtB,qEAAqE;AACrE,MAAM,KAAK,GAAG,EAAE,CAAA;AAEhB;;;;;;;;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C,CAAC,CAAA;gBACrE,IAAI,KAAK,KAAK,CAAC;oBAAE,OAAO,GAAG,CAAA;gBAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;gBACxF,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;gBAChC,MAAM,eAAe,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAA;gBAChD,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC3H,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;gBAC1H,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3E,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n Text,\n Types,\n component2d,\n insetsOps,\n textOps,\n type NodeOf,\n type Node2D,\n type Node2DProps,\n} from \"@motionscript/sdk\"\n\nimport { asParts, fresh } from \"../kit/entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"../kit/motion\"\nimport {\n DEFAULT_X_AXIS,\n clampUnit,\n enterBudget,\n type AxisConfig,\n} from \"../kit/shared\"\n\nexport interface CategoryAxisProps extends Node2DProps {\n /** One caption per category slot, left to right — the chart's rows, in order. */\n categories: string[]\n /** Caption/title text style and gutters — see {@link AxisConfig}. */\n axis: AxisConfig\n /**\n * Caption drawn centred in the gutter beneath the category row. Empty string\n * (the default) hides it.\n */\n label: string\n /**\n * Per-category opacity multiplier — how the chart's category spotlight reaches\n * the captions, so the name under a dimmed column dims with it. Missing\n * entries read as 1.\n */\n dims: number[]\n}\n\n/** How far a caption starts above its slot when it enters, in px. */\nconst SLIDE = 24\n\n/**\n * The **categorical** horizontal axis of a {@link BarChart}: a row of\n * {@link Text} captions, one per row of the data, each centred on its slot\n * beneath the baseline.\n *\n * Not a variant of the line chart's `HorizontalAxis` and deliberately not\n * folded into it: that axis places markers by *value* across a numeric range,\n * this one divides its width into equal slots and centres a name in each. The\n * two look alike on screen and share nothing underneath — one reads a scale,\n * the other counts rows.\n *\n * The slot arithmetic is the same as the plot's, because this node is laid out\n * to exactly the plot's width (the chart reserves the axis gutter with an\n * invisible twin of the value axis, as the line chart does), so a caption lands\n * under the columns it names without either side being told about the other.\n *\n * `enter` staggers the captions in left-to-right, each lifted a little above\n * its slot and transparent; the resting state is the landed one, so a chart\n * that is never told to enter still reads as finished.\n */\nexport const CategoryAxis = component2d({\n key: \"categoryAxis\",\n state: {\n categories: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),\n label: \"\",\n dims: fresh<number[]>(() => []),\n arrivals: arrivalsEntry(),\n },\n // A plain node filled its parent; one made of its captions would hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const tickPad = insetsOps.resolve(state.axis.tickPadding).top\n const titlePad = insetsOps.resolve(state.axis.titlePadding).top\n\n const column: Node2D[] = []\n // The column's parent is the axis: its box is what the slots divide.\n const width = () => (column[0]?.parent as Node2D | null | undefined)?.layoutBounds.width ?? 0\n /** Centre x of slot `i`, in the node's centred space. */\n const slotCenter = (index: number) => {\n const n = state.categories.length\n if (n <= 0) return 0\n return -width() / 2 + (width() / n) * (index + 0.5)\n }\n\n // Each caption sits in a hug box carrying the spotlight dim, so the\n // entrance can animate the text's own opacity without the two fighting over\n // one value — opacity multiplies down the tree, which is exactly the\n // composition wanted here.\n const slots = state.categories.map((caption, i) =>\n new Rect({\n width: \"hug\",\n height: \"hug\",\n flow: \"freeform\",\n opacity: () => clampUnit(state.dims[i] ?? 1),\n x: () => slotCenter(i),\n children: [\n new Text({\n ...textOps.styleProps(state.axis.labelStyle),\n text: caption,\n opacity: () => arrivalOf(state.arrivals, i).opacity,\n y: () => arrivalOf(state.arrivals, i).shift,\n }),\n ],\n })\n )\n\n const children: Node2D[] = [new Rect({ width: \"fill\", height: \"hug\", padding: { top: tickPad }, children: slots })]\n if (state.label !== \"\") {\n children.push(\n new Text({\n ...textOps.styleProps(state.axis.titleStyle),\n text: state.label,\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\n y: () => arrivalOf(state.arrivals, \"label\").shift,\n })\n )\n }\n\n column.push(new Rect({ flow: \"vertical\", gap: titlePad, height: \"hug\", width: \"fill\", children }))\n return asParts(column)\n },\n commands: {\n /**\n * Slide + fade every caption in from above, staggered left-to-right, then\n * bring the title down behind them. Its first frame arms them all: lifted\n * by `slide` and transparent.\n *\n * The timeline's duration is the **whole** entrance — the stagger and the\n * title are carved out of it rather than added on top. See {@link enterBudget}.\n *\n * `stagger` is seconds between successive captions (derived when omitted);\n * `slide` is the starting upward offset in px (node space is y-up, so a\n * positive start slides *down* into place).\n */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.categories.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.categories.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n const lastCaptionEnds = (count - 1) * step + per\n const captions = state.categories.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n const label = captioned ? [{ at: lastCaptionEnds, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...captions, ...label])])\n },\n },\n },\n})\n\nexport type CategoryAxis = NodeOf<typeof CategoryAxis>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-bars.js","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,OAAO,GAYR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AA+BlD,gFAAgF;AAChF,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,oFAAoF;AACpF,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,kFAAkF;AAClF,MAAM,UAAU,GAAG,EAAE,CAAA;AAsDrB;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,CAAU,EAAE,KAAa;IACtC,IAAI,CAAC,CAAC,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IACxB,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AACtC,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gBAC5B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,QAAQ,EAAE,CAAA;IAChB,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\r\n Graphics2D,\r\n Text,\r\n Types,\r\n component2d,\r\n fillOps,\r\n shadowOps,\r\n strokeOps,\r\n textOps,\r\n type Fill,\r\n type FillResolved,\r\n type NodeOf,\r\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\r\n type Node2D as _Node2D,\r\n type Node2DProps,\r\n type Shadow,\r\n type ShadowResolved,\r\n type Stroke,\r\n type StrokeResolved,\r\n type TextStyle,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { fresh } from \"../kit/entries\"\r\nimport { frameEase } from \"../kit/motion\"\r\nimport { loadPaints } from \"../kit/paints\"\r\nimport { clampUnit, formatMarker } from \"../kit/shared\"\r\nimport { DEFAULT_BAR_CHART_THEME } from \"./shared\"\r\n\r\n/**\r\n * One drawn column, already mapped into the plot's **centred pixel space**\r\n * (origin at the plot centre, y-up) by the parent {@link BarChart}.\r\n *\r\n * `from`/`to` are the two ends of the column rather than a base and a height,\r\n * for the same reason {@link BarSpan} is a span: it is the one shape that fits a\r\n * grouped bar, a stacked segment and a negative value without a special case.\r\n */\r\nexport interface BarGeometry {\r\n /** Centre x of the column. */\r\n x: number\r\n /** Column width in px. */\r\n width: number\r\n /** Pixel y of the column's base — the baseline when grouped, the running stack top when stacked. */\r\n from: number\r\n /** Pixel y of its far end, at full {@link ChartBarsProps.growth}. */\r\n to: number\r\n /** Whether the far end takes the theme's corner radius (the stack's cap). */\r\n round: boolean\r\n /** The value this column plots, for the figure printed on it. */\r\n value: number\r\n /**\r\n * The figure printed on it, written as the chart's value axis writes its\r\n * ticks, so the two cannot disagree. Absent, the bare marker reading of\r\n * {@link value}.\r\n */\r\n caption?: string\r\n}\r\n\r\n/** Gap between a grouped column's end and the figure printed over it, in px. */\r\nconst VALUE_GAP = 10\r\n/** A segment shorter than this many multiples of the type size prints no figure. */\r\nconst VALUE_FIT = 1.6\r\n/** Fallback type size when the theme's value style leaves it unset or autofit. */\r\nconst VALUE_SIZE = 24\r\n\r\nexport interface ChartBarsProps extends Node2DProps {\r\n /** This series' columns, one per row of the chart's data. */\r\n bars: BarGeometry[]\r\n /** Pixel y of value 0 — where every column grows *from*. */\r\n baseline: number\r\n /** Column paint — this series' own, or the theme palette's entry for its index. */\r\n fill: Fill\r\n /** Optional outline on every column. */\r\n barStroke: Stroke\r\n /** Optional drop shadow on every column. */\r\n barShadow: Shadow\r\n /** Radius of the far-end corners, in px. */\r\n cornerRadius: number\r\n /**\r\n * Rise of every column in `[0, 1]`, measured **about the baseline**: 0\r\n * collapses them all onto it, 1 draws them at full length.\r\n *\r\n * Scaling about the baseline rather than about each column's own base is what\r\n * keeps a stack flush mid-animation — every segment's base and end travel by\r\n * the same factor, so the segments stay stacked instead of the upper ones\r\n * floating above the still-growing lower ones. It also means a negative\r\n * column grows *down* out of the same signal.\r\n */\r\n growth: number\r\n /**\r\n * Per-column opacity multiplier, by row index — how the chart's category\r\n * spotlight reaches a single column without touching the series it belongs\r\n * to. Missing entries read as 1.\r\n */\r\n dims: number[]\r\n /** Whether the figure each column plots is printed on it. */\r\n showValues: boolean\r\n /** Type style for those figures. */\r\n valueStyle: TextStyle\r\n /**\r\n * Whether this series draws at all — the wholesale switch behind\r\n * `BarChart.showSeries`/`hideSeries`, alongside the slot weight that animates\r\n * the reflow. Off skips the columns *and* their figures.\r\n */\r\n enabled: boolean\r\n}\r\n\r\n/** What the column geometry reads. */\r\ninterface Columns {\r\n readonly bars: readonly BarGeometry[]\r\n readonly baseline: number\r\n readonly growth: number\r\n readonly dims: readonly number[]\r\n readonly enabled: boolean\r\n readonly valueStyle: TextStyle\r\n}\r\n\r\n/**\r\n * How far column `i` is dimmed — the chart's category spotlight, and the series\r\n * switch on top of it.\r\n *\r\n * The captions read this rather than being hidden by `render`'s guard: they are\r\n * real child nodes, so a `return` in the draw would leave them on screen over a\r\n * series that isn't there.\r\n */\r\nfunction dimAt(s: Columns, index: number): number {\r\n if (!s.enabled) return 0\r\n return clampUnit(s.dims[index] ?? 1)\r\n}\r\n\r\n/** The two ends of column `i` at the current growth. */\r\nfunction endsAt(s: Columns, index: number): { base: number; end: number } | null {\r\n const bar = s.bars[index]\r\n if (!bar) return null\r\n const g = clampUnit(s.growth)\r\n return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g }\r\n}\r\n\r\n/** The type size the figures are set at, guarding the autofit/unset cases. */\r\nfunction valueSize(s: Columns): number {\r\n const size = s.valueStyle.fontSize\r\n return typeof size === \"number\" ? size : VALUE_SIZE\r\n}\r\n\r\n/** Whether column `i`'s figure sits inside the column (a stacked segment) or past its end. */\r\nfunction insideAt(s: Columns, index: number): boolean {\r\n const bar = s.bars[index]\r\n return bar !== undefined && Math.abs(bar.from - s.baseline) > 0.5\r\n}\r\n\r\n/**\r\n * The figure printed on column `i`, or `\"\"` where there is no room for it.\r\n *\r\n * Blanking the text rather than dropping the node keeps the caption list\r\n * index-aligned with the columns, so a chart that rescales into more room simply\r\n * starts printing again.\r\n */\r\nfunction captionAt(s: Columns, index: number): string {\r\n const bar = s.bars[index]\r\n if (!bar || bar.value === 0) return \"\"\r\n // An interior segment prints inside itself, so it has to be tall enough to\r\n // hold a line of type; a grouped column prints in the headroom above its end,\r\n // where the only constraint is the plot's own top.\r\n if (insideAt(s, index)) {\r\n const ends = endsAt(s, index)\r\n if (!ends) return \"\"\r\n if (Math.abs(ends.end - ends.base) < valueSize(s) * VALUE_FIT) return \"\"\r\n }\r\n return bar.caption ?? formatMarker(bar.value)\r\n}\r\n\r\n/** Where column `i`'s figure sits, in the node's centred y-up space. */\r\nfunction captionY(s: Columns, index: number): number {\r\n const ends = endsAt(s, index)\r\n if (!ends) return 0\r\n if (insideAt(s, index)) return (ends.base + ends.end) / 2\r\n // Text is centred on its `y`, so clear the column's end by the gap plus half a\r\n // line — on whichever side of the baseline the column actually reached.\r\n const direction = ends.end >= ends.base ? 1 : -1\r\n return ends.end + direction * (VALUE_GAP + valueSize(s) / 2)\r\n}\r\n\r\n/**\r\n * One **series** of a {@link BarChart}, drawn as one command list: its column in\r\n * every category, plus the figures printed on them.\r\n *\r\n * A node per series rather than a node per bar, deliberately — it is the same\r\n * unit `ChartLine` is, which is what lets `showSeries`/`hideSeries`/\r\n * `spotlightSeries` mean exactly the same thing on a bar chart as on a line\r\n * chart: enable the node, or tween its opacity. The columns' *positions* come\r\n * from the parent (it owns the slot arithmetic both modes share), so this part\r\n * only has to know how to draw a span and grow it.\r\n *\r\n * The figures are real {@link Text} children rather than glyphs in the command\r\n * list, so they take the theme's type style, are measured by the layout engine,\r\n * and ride the node's own opacity — which is why hiding the series takes its\r\n * figures with it for free.\r\n */\r\nexport const ChartBars = component2d({\r\n key: \"chartBars\",\r\n state: {\r\n bars: fresh<BarGeometry[]>(() => []),\r\n baseline: 0,\r\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\r\n barStroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_BAR_CHART_THEME.bar.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\r\n barShadow: Types.custom<Shadow, ShadowResolved[]>(DEFAULT_BAR_CHART_THEME.bar.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),\r\n cornerRadius: DEFAULT_BAR_CHART_THEME.bar.cornerRadius,\r\n growth: 1,\r\n dims: fresh<number[]>(() => []),\r\n showValues: false,\r\n valueStyle: Types.custom<TextStyle>(DEFAULT_BAR_CHART_THEME.valueStyle),\r\n enabled: true,\r\n },\r\n // A plain node filled its parent; one made of its figures would hug them.\r\n defaults: { width: \"fill\", height: \"fill\" },\r\n // One caption per column, built once (the row count is fixed at construction,\r\n // like an axis's marker count) and bound to the live geometry so it travels\r\n // with its column as the chart grows, rescales or reflows.\r\n children: (state) => {\r\n if (!state.showValues) return []\r\n return state.bars.map((_, i) =>\r\n Text({\r\n ...textOps.styleProps(state.valueStyle),\r\n text: () => captionAt(state, i),\r\n x: () => state.bars[i]?.x ?? 0,\r\n y: () => captionY(state, i),\r\n opacity: () => dimAt(state, i),\r\n })\r\n )\r\n },\r\n // The column stroke and shadow are named past the conventional slots, so they are named here.\r\n load: (loader, state) =>\r\n loadPaints(loader, { fills: [state.fill], shadows: [state.barShadow], strokes: [state.barStroke] }),\r\n commands: {\r\n /**\r\n * Raise every column from the baseline by tweening `growth` `0 → 1`.\r\n *\r\n * The mirror of `ChartLine.enter`: same contract that the resting state is\r\n * the finished one, so the chart arms this back to 0 before animating rather\r\n * than the node hiding itself at construction. No priming to 0 first: the\r\n * value at `t` is a function of `t`, so a repeat call re-raises by definition.\r\n */\r\n enter: (timeline) => {\r\n const ease = frameEase(timeline)\r\n return timeline.animate((t) => ({ growth: ease(t) }))\r\n },\r\n },\r\n render: (ctx, state) => {\r\n if (state.enabled) {\r\n for (let i = 0; i < state.bars.length; i++) {\r\n const bar = state.bars[i]\r\n const ends = endsAt(state, i)\r\n if (!ends || bar.width <= 0) continue\r\n const height = Math.abs(ends.end - ends.base)\r\n if (height <= 0) continue\r\n\r\n const radius = bar.round ? Math.min(state.cornerRadius, height) : 0\r\n // A column per `Graphics2D` rather than one list for the series: the\r\n // category spotlight dims individual columns, and opacity is a property\r\n // of the command list rather than of a shape within it.\r\n const g = new Graphics2D()\r\n const rect = g.rect({\r\n x: bar.x,\r\n y: (ends.base + ends.end) / 2,\r\n width: bar.width,\r\n height,\r\n // Corner keys are visual (the renderer keeps them in y-up author space),\r\n // so a column reaching *up* rounds its `top*` corners and one reaching\r\n // down its `bottom*` ones. Only the far end rounds, which is what makes\r\n // a stack read as a single capped column.\r\n cornerRadius:\r\n radius > 0\r\n ? ends.end >= ends.base\r\n ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 }\r\n : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 }\r\n : 0,\r\n })\r\n rect.shadow(state.barShadow)\r\n rect.fill(state.fill)\r\n rect.stroke(state.barStroke)\r\n ctx.draw(g.opacity(dimAt(state, i)))\r\n }\r\n }\r\n ctx.children()\r\n },\r\n})\r\n\r\nexport type ChartBars = NodeOf<typeof ChartBars>\r\n"]}
|
|
1
|
+
{"version":3,"file":"chart-bars.js","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,OAAO,GAYR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AA+BlD,gFAAgF;AAChF,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,oFAAoF;AACpF,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,kFAAkF;AAClF,MAAM,UAAU,GAAG,EAAE,CAAA;AAsDrB;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,CAAU,EAAE,KAAa;IACtC,IAAI,CAAC,CAAC,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IACxB,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AACtC,CAAC;AAED,wDAAwD;AACxD,SAAS,MAAM,CAAC,CAAU,EAAE,KAAa;IACvC,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACz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C;QACD,GAAG,CAAC,QAAQ,EAAE,CAAA;IAChB,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n Graphics2D,\n Text,\n Types,\n component2d,\n fillOps,\n shadowOps,\n strokeOps,\n textOps,\n type Fill,\n type FillResolved,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"../kit/entries\"\nimport { frameEase } from \"../kit/motion\"\nimport { loadPaints } from \"../kit/paints\"\nimport { clampUnit, formatMarker } from \"../kit/shared\"\nimport { DEFAULT_BAR_CHART_THEME } from \"./shared\"\n\n/**\n * One drawn column, already mapped into the plot's **centred pixel space**\n * (origin at the plot centre, y-up) by the parent {@link BarChart}.\n *\n * `from`/`to` are the two ends of the column rather than a base and a height,\n * for the same reason {@link BarSpan} is a span: it is the one shape that fits a\n * grouped bar, a stacked segment and a negative value without a special case.\n */\nexport interface BarGeometry {\n /** Centre x of the column. */\n x: number\n /** Column width in px. */\n width: number\n /** Pixel y of the column's base — the baseline when grouped, the running stack top when stacked. */\n from: number\n /** Pixel y of its far end, at full {@link ChartBarsProps.growth}. */\n to: number\n /** Whether the far end takes the theme's corner radius (the stack's cap). */\n round: boolean\n /** The value this column plots, for the figure printed on it. */\n value: number\n /**\n * The figure printed on it, written as the chart's value axis writes its\n * ticks, so the two cannot disagree. Absent, the bare marker reading of\n * {@link value}.\n */\n caption?: string\n}\n\n/** Gap between a grouped column's end and the figure printed over it, in px. */\nconst VALUE_GAP = 10\n/** A segment shorter than this many multiples of the type size prints no figure. */\nconst VALUE_FIT = 1.6\n/** Fallback type size when the theme's value style leaves it unset or autofit. */\nconst VALUE_SIZE = 24\n\nexport interface ChartBarsProps extends Node2DProps {\n /** This series' columns, one per row of the chart's data. */\n bars: BarGeometry[]\n /** Pixel y of value 0 — where every column grows *from*. */\n baseline: number\n /** Column paint — this series' own, or the theme palette's entry for its index. */\n fill: Fill\n /** Optional outline on every column. */\n barStroke: Stroke\n /** Optional drop shadow on every column. */\n barShadow: Shadow\n /** Radius of the far-end corners, in px. */\n cornerRadius: number\n /**\n * Rise of every column in `[0, 1]`, measured **about the baseline**: 0\n * collapses them all onto it, 1 draws them at full length.\n *\n * Scaling about the baseline rather than about each column's own base is what\n * keeps a stack flush mid-animation — every segment's base and end travel by\n * the same factor, so the segments stay stacked instead of the upper ones\n * floating above the still-growing lower ones. It also means a negative\n * column grows *down* out of the same signal.\n */\n growth: number\n /**\n * Per-column opacity multiplier, by row index — how the chart's category\n * spotlight reaches a single column without touching the series it belongs\n * to. Missing entries read as 1.\n */\n dims: number[]\n /** Whether the figure each column plots is printed on it. */\n showValues: boolean\n /** Type style for those figures. */\n valueStyle: TextStyle\n /**\n * Whether this series draws at all — the wholesale switch behind\n * `BarChart.showSeries`/`hideSeries`, alongside the slot weight that animates\n * the reflow. Off skips the columns *and* their figures.\n */\n enabled: boolean\n}\n\n/** What the column geometry reads. */\ninterface Columns {\n readonly bars: readonly BarGeometry[]\n readonly baseline: number\n readonly growth: number\n readonly dims: readonly number[]\n readonly enabled: boolean\n readonly valueStyle: TextStyle\n}\n\n/**\n * How far column `i` is dimmed — the chart's category spotlight, and the series\n * switch on top of it.\n *\n * The captions read this rather than being hidden by `render`'s guard: they are\n * real child nodes, so a `return` in the draw would leave them on screen over a\n * series that isn't there.\n */\nfunction dimAt(s: Columns, index: number): number {\n if (!s.enabled) return 0\n return clampUnit(s.dims[index] ?? 1)\n}\n\n/** The two ends of column `i` at the current growth. */\nfunction endsAt(s: Columns, index: number): { base: number; end: number } | null {\n const bar = s.bars[index]\n if (!bar) return null\n const g = clampUnit(s.growth)\n return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g }\n}\n\n/** The type size the figures are set at, guarding the autofit/unset cases. */\nfunction valueSize(s: Columns): number {\n const size = s.valueStyle.fontSize\n return typeof size === \"number\" ? size : VALUE_SIZE\n}\n\n/** Whether column `i`'s figure sits inside the column (a stacked segment) or past its end. */\nfunction insideAt(s: Columns, index: number): boolean {\n const bar = s.bars[index]\n return bar !== undefined && Math.abs(bar.from - s.baseline) > 0.5\n}\n\n/**\n * The figure printed on column `i`, or `\"\"` where there is no room for it.\n *\n * Blanking the text rather than dropping the node keeps the caption list\n * index-aligned with the columns, so a chart that rescales into more room simply\n * starts printing again.\n */\nfunction captionAt(s: Columns, index: number): string {\n const bar = s.bars[index]\n if (!bar || bar.value === 0) return \"\"\n // An interior segment prints inside itself, so it has to be tall enough to\n // hold a line of type; a grouped column prints in the headroom above its end,\n // where the only constraint is the plot's own top.\n if (insideAt(s, index)) {\n const ends = endsAt(s, index)\n if (!ends) return \"\"\n if (Math.abs(ends.end - ends.base) < valueSize(s) * VALUE_FIT) return \"\"\n }\n return bar.caption ?? formatMarker(bar.value)\n}\n\n/** Where column `i`'s figure sits, in the node's centred y-up space. */\nfunction captionY(s: Columns, index: number): number {\n const ends = endsAt(s, index)\n if (!ends) return 0\n if (insideAt(s, index)) return (ends.base + ends.end) / 2\n // Text is centred on its `y`, so clear the column's end by the gap plus half a\n // line — on whichever side of the baseline the column actually reached.\n const direction = ends.end >= ends.base ? 1 : -1\n return ends.end + direction * (VALUE_GAP + valueSize(s) / 2)\n}\n\n/**\n * One **series** of a {@link BarChart}, drawn as one command list: its column in\n * every category, plus the figures printed on them.\n *\n * A node per series rather than a node per bar, deliberately — it is the same\n * unit `ChartLine` is, which is what lets `showSeries`/`hideSeries`/\n * `spotlightSeries` mean exactly the same thing on a bar chart as on a line\n * chart: enable the node, or tween its opacity. The columns' *positions* come\n * from the parent (it owns the slot arithmetic both modes share), so this part\n * only has to know how to draw a span and grow it.\n *\n * The figures are real {@link Text} children rather than glyphs in the command\n * list, so they take the theme's type style, are measured by the layout engine,\n * and ride the node's own opacity — which is why hiding the series takes its\n * figures with it for free.\n */\nexport const ChartBars = component2d({\n key: \"chartBars\",\n state: {\n bars: fresh<BarGeometry[]>(() => []),\n baseline: 0,\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n barStroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_BAR_CHART_THEME.bar.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n barShadow: Types.custom<Shadow, ShadowResolved[]>(DEFAULT_BAR_CHART_THEME.bar.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),\n cornerRadius: DEFAULT_BAR_CHART_THEME.bar.cornerRadius,\n growth: 1,\n dims: fresh<number[]>(() => []),\n showValues: false,\n valueStyle: Types.custom<TextStyle>(DEFAULT_BAR_CHART_THEME.valueStyle),\n enabled: true,\n },\n // A plain node filled its parent; one made of its figures would hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n // One caption per column, built once (the row count is fixed at construction,\n // like an axis's marker count) and bound to the live geometry so it travels\n // with its column as the chart grows, rescales or reflows.\n children: (state) => {\n if (!state.showValues) return []\n return state.bars.map((_, i) =>\n Text({\n ...textOps.styleProps(state.valueStyle),\n text: () => captionAt(state, i),\n x: () => state.bars[i]?.x ?? 0,\n y: () => captionY(state, i),\n opacity: () => dimAt(state, i),\n })\n )\n },\n // The column stroke and shadow are named past the conventional slots, so they are named here.\n load: (loader, state) =>\n loadPaints(loader, { fills: [state.fill], shadows: [state.barShadow], strokes: [state.barStroke] }),\n commands: {\n /**\n * Raise every column from the baseline by tweening `growth` `0 → 1`.\n *\n * The mirror of `ChartLine.enter`: same contract that the resting state is\n * the finished one, so the chart arms this back to 0 before animating rather\n * than the node hiding itself at construction. No priming to 0 first: the\n * value at `t` is a function of `t`, so a repeat call re-raises by definition.\n */\n enter: (timeline) => {\n const ease = frameEase(timeline)\n return timeline.animate((t) => ({ growth: ease(t) }))\n },\n },\n render: (ctx, state) => {\n if (state.enabled) {\n for (let i = 0; i < state.bars.length; i++) {\n const bar = state.bars[i]\n const ends = endsAt(state, i)\n if (!ends || bar.width <= 0) continue\n const height = Math.abs(ends.end - ends.base)\n if (height <= 0) continue\n\n const radius = bar.round ? Math.min(state.cornerRadius, height) : 0\n // A column per `Graphics2D` rather than one list for the series: the\n // category spotlight dims individual columns, and opacity is a property\n // of the command list rather than of a shape within it.\n const g = new Graphics2D()\n const rect = g.rect({\n x: bar.x,\n y: (ends.base + ends.end) / 2,\n width: bar.width,\n height,\n // Corner keys are visual (the renderer keeps them in y-up author space),\n // so a column reaching *up* rounds its `top*` corners and one reaching\n // down its `bottom*` ones. Only the far end rounds, which is what makes\n // a stack read as a single capped column.\n cornerRadius:\n radius > 0\n ? ends.end >= ends.base\n ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 }\n : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 }\n : 0,\n })\n rect.shadow(state.barShadow)\n rect.fill(state.fill)\n rect.stroke(state.barStroke)\n ctx.draw(g.opacity(dimAt(state, i)))\n }\n }\n ctx.children()\n },\n})\n\nexport type ChartBars = NodeOf<typeof ChartBars>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAA","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAA","sourcesContent":["/**\n * The bar chart: grouped or stacked columns off a category axis.\n *\n * Shares the plot panel, the value axis and the legend with the line chart —\n * which is what lets a scene swap one for the other without re-theming — and\n * brings its own category axis, since a band scale is not a continuous one.\n */\nexport { BarChart, barChartDomain } from \"./bar-chart\"\nexport type { BarChartDomain, BarChartProps, BarChartValues } from \"./bar-chart\"\nexport { ChartBars } from \"./chart-bars\"\nexport type { BarGeometry, ChartBarsProps } from \"./chart-bars\"\nexport { CategoryAxis } from \"./category-axis\"\nexport type { CategoryAxisProps } from \"./category-axis\"\nexport {\n DEFAULT_BAR_CHART_THEME,\n barCategories,\n barSpans,\n barValueExtent,\n lerpBarChartTheme,\n resolveBarChartTheme,\n resolveBarFill,\n resolveBarScale,\n stackCapIndex,\n} from \"./shared\"\nexport type {\n BarChartConfig,\n BarChartTheme,\n BarSeries,\n BarSpan,\n BarStyleConfig,\n} from \"./shared\"\n"]}
|