@motionscript/charts 0.1.0 → 0.1.1-alpha.0
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 +19 -0
- package/dist/bar-chart/bar-chart.d.ts +22 -93
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +48 -121
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +11 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +15 -38
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +43 -74
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +31 -59
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -10
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +0 -7
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +27 -90
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +15 -54
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-4SMRCU24.js +2 -0
- package/dist/browser/chunks/chunk-4SMRCU24.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +4 -16
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +4 -16
- package/dist/engine.js.map +1 -1
- package/dist/kit/cartesian.d.ts +8 -28
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +7 -19
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-border.d.ts +9 -18
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +4 -9
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +25 -36
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +13 -13
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +14 -61
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +17 -65
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +2 -0
- package/dist/kit/entries.d.ts.map +1 -1
- package/dist/kit/entries.js +2 -0
- package/dist/kit/entries.js.map +1 -1
- package/dist/kit/motion.d.ts +11 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +7 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/kit/shared.d.ts +60 -175
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +40 -157
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +16 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +17 -42
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +16 -41
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +14 -43
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -27
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +8 -22
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +16 -43
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +13 -42
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +1 -13
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +0 -12
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +23 -109
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +45 -141
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +33 -107
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +28 -81
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +14 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +29 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +0 -12
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -12
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +1 -12
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +0 -9
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +37 -71
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +31 -65
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +11 -26
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +14 -39
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +50 -192
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +75 -247
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +45 -131
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +29 -72
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +51 -165
- package/src/bar-chart/category-axis.ts +16 -57
- package/src/bar-chart/chart-bars.ts +43 -120
- package/src/bar-chart/index.ts +2 -10
- package/src/bar-chart/shared.ts +29 -97
- package/src/engine.ts +4 -16
- package/src/kit/cartesian.ts +11 -26
- package/src/kit/chart-border.ts +6 -20
- package/src/kit/chart-canvas.ts +15 -40
- package/src/kit/chart-legend.ts +17 -86
- package/src/kit/entries.ts +4 -1
- package/src/kit/motion.ts +11 -2
- package/src/kit/shared.ts +58 -219
- package/src/kit/vertical-axis.ts +18 -71
- package/src/line-chart/chart-line.ts +16 -44
- package/src/line-chart/chart-region.ts +10 -23
- package/src/line-chart/horizontal-axis.ts +13 -42
- package/src/line-chart/index.ts +1 -13
- package/src/line-chart/line-chart.ts +50 -184
- package/src/line-chart/shared.ts +51 -145
- package/src/line-chart/x-scale.ts +31 -121
- package/src/nodes.ts +0 -12
- package/src/pie-chart/index.ts +1 -12
- package/src/pie-chart/pie-chart.ts +34 -102
- package/src/pie-chart/pie-legend.ts +14 -55
- package/src/pie-chart/pie-ring.ts +80 -307
- package/src/pie-chart/shared.ts +50 -139
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
|
|
1
|
+
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps as _Node2DProps } from "@motionscript/sdk";
|
|
2
2
|
import { type PieChartConfig, type PieChartTheme, type PieLabelMode, type PieLabelPlacement } from "./shared.js";
|
|
3
|
-
export interface PieChartProps extends Node2DProps {
|
|
4
|
-
/** One row per slice — a plain record of field name to value. */
|
|
5
|
-
data: DataRecord[];
|
|
6
|
-
/** Key into each row for its slice caption, used on the labels and the legend. */
|
|
7
|
-
categoryField: string;
|
|
8
|
-
/** Key into each row for its slice magnitude — the wedge's share of the ring. */
|
|
9
|
-
valueField: string;
|
|
10
|
-
/**
|
|
11
|
-
* The chart's visual theme — slice palette, ring geometry, label and centre
|
|
12
|
-
* type, legend. Every branch is optional and deep-merged onto
|
|
13
|
-
* {@link DEFAULT_PIE_CHART_THEME}.
|
|
14
|
-
*/
|
|
15
|
-
theme?: PieChartTheme;
|
|
16
|
-
/** What the ring's labels say. */
|
|
17
|
-
labelMode?: PieLabelMode;
|
|
18
|
-
/** Where they sit: inside their wedge, outside on a leader, or nowhere. */
|
|
19
|
-
labelPlacement?: PieLabelPlacement;
|
|
20
|
-
/** Whether the legend column beside the ring is drawn at all. */
|
|
21
|
-
showLegend?: boolean;
|
|
22
|
-
/** Gap between the ring and the legend, in px. */
|
|
23
|
-
gap?: number;
|
|
24
|
-
/** Text set in the ring's hole — see `revealCenter`. */
|
|
25
|
-
centerLabel?: string;
|
|
26
|
-
/** Smaller second line under {@link centerLabel}. */
|
|
27
|
-
centerCaption?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Whether the hole's summary is drawn at rest. `true` (the default) is the
|
|
30
|
-
* plain answer; a scene that wants the conclusion to land on a later beat sets
|
|
31
|
-
* this `false` and runs `revealCenter` when it gets there.
|
|
32
|
-
*/
|
|
33
|
-
showCenter?: boolean;
|
|
34
|
-
}
|
|
35
|
-
/** What the selection reads: the rows, how they are cut, and the pops the commands move. */
|
|
36
3
|
export interface PieChartValues {
|
|
37
4
|
readonly data: DataRecord[];
|
|
38
5
|
readonly categoryField: string;
|
|
@@ -40,46 +7,39 @@ export interface PieChartValues {
|
|
|
40
7
|
readonly theme: PieChartConfig;
|
|
41
8
|
readonly pops: number[];
|
|
42
9
|
}
|
|
43
|
-
/** Whether slice `index` is
|
|
10
|
+
/** Whether slice `index` is past half way out, so a slice mid-swell is not yet counted. */
|
|
44
11
|
export declare function isSliceSelected(s: PieChartValues, index: number): boolean;
|
|
45
12
|
/**
|
|
46
|
-
* A pie or donut chart
|
|
47
|
-
*
|
|
48
|
-
*
|
|
13
|
+
* A pie or donut chart: a {@link PieRing} filling what the hugging {@link PieLegend}
|
|
14
|
+
* leaves. One mark per row, not per column, and nothing to hide, since dropping
|
|
15
|
+
* a slice would re-cut every other wedge; `selectSlice` and its siblings swell
|
|
16
|
+
* a slice and dim the rest instead.
|
|
49
17
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* summary in the hole.
|
|
53
|
-
* - {@link PieLegend} — a column of swatch-and-caption rows naming each slice.
|
|
54
|
-
*
|
|
55
|
-
* **One mark per row, not per column**: a pie's palette is indexed by row and
|
|
56
|
-
* there is nothing to hide, since dropping a slice would re-cut every other
|
|
57
|
-
* wedge. `selectSlice` and its siblings are what a pie has instead — a slice
|
|
58
|
-
* swells out of the ring and everything else dims behind it.
|
|
59
|
-
*
|
|
60
|
-
* **Resting state is the finished chart**; `enter` arms every part on its first
|
|
61
|
-
* frame. The one exception is the hole's summary, which a scene can hold back
|
|
62
|
-
* with `showCenter: false`, because it is usually the chart's *conclusion*.
|
|
18
|
+
* Resting state is the finished chart, except the hole's summary, which
|
|
19
|
+
* `showCenter: false` holds back for `revealCenter`.
|
|
63
20
|
*/
|
|
64
21
|
export declare const PieChart: import("@motionscript/sdk").Component<"pieChart", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
65
22
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
23
|
+
/** Slice caption, used on the labels and the legend. */
|
|
66
24
|
readonly categoryField: "";
|
|
25
|
+
/** Slice magnitude: the wedge's share of the ring. */
|
|
67
26
|
readonly valueField: "";
|
|
68
27
|
readonly theme: import("@motionscript/sdk").Type<PieChartTheme, PieChartConfig, false>;
|
|
28
|
+
/** What the ring's labels say. */
|
|
69
29
|
readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
|
|
30
|
+
/** Where they sit: inside their wedge, outside on a leader, or nowhere. */
|
|
70
31
|
readonly labelPlacement: import("@motionscript/sdk").Type<PieLabelPlacement, PieLabelPlacement, false>;
|
|
32
|
+
/** Gap between the ring and the legend, in px. */
|
|
71
33
|
readonly gap: 40;
|
|
34
|
+
/** Text set in the ring's hole. */
|
|
72
35
|
readonly centerLabel: "";
|
|
36
|
+
/** Smaller second line under `centerLabel`. */
|
|
73
37
|
readonly centerCaption: "";
|
|
74
|
-
/**
|
|
75
|
-
* How far each slice is pushed out of the ring, `0`–`1` per index. Held here
|
|
76
|
-
* rather than on the ring because two parts read it: the wedges grow out by
|
|
77
|
-
* it, and the legend entries dim by it. Seeded flush, one to a row.
|
|
78
|
-
*/
|
|
38
|
+
/** How far each slice is pushed out, `0`-`1` per index. Here, not on the ring, because the wedges and the legend both read it. */
|
|
79
39
|
readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
80
40
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
81
41
|
readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
82
|
-
/** Read as the chart is built: whether the hole's summary is drawn at rest. */
|
|
42
|
+
/** Read as the chart is built: whether the hole's summary is drawn at rest. A scene that wants it to land later sets `false` and runs `revealCenter`. */
|
|
83
43
|
readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
84
44
|
}>, {
|
|
85
45
|
readonly enter: {};
|
|
@@ -94,45 +54,51 @@ export declare const PieChart: import("@motionscript/sdk").Component<"pieChart",
|
|
|
94
54
|
readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
95
55
|
};
|
|
96
56
|
readonly clearSelection: {};
|
|
97
|
-
}, readonly [], Node2D<
|
|
57
|
+
}, readonly [], Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
98
58
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
59
|
+
/** Slice caption, used on the labels and the legend. */
|
|
99
60
|
readonly categoryField: "";
|
|
61
|
+
/** Slice magnitude: the wedge's share of the ring. */
|
|
100
62
|
readonly valueField: "";
|
|
101
63
|
readonly theme: import("@motionscript/sdk").Type<PieChartTheme, PieChartConfig, false>;
|
|
64
|
+
/** What the ring's labels say. */
|
|
102
65
|
readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
|
|
66
|
+
/** Where they sit: inside their wedge, outside on a leader, or nowhere. */
|
|
103
67
|
readonly labelPlacement: import("@motionscript/sdk").Type<PieLabelPlacement, PieLabelPlacement, false>;
|
|
68
|
+
/** Gap between the ring and the legend, in px. */
|
|
104
69
|
readonly gap: 40;
|
|
70
|
+
/** Text set in the ring's hole. */
|
|
105
71
|
readonly centerLabel: "";
|
|
72
|
+
/** Smaller second line under `centerLabel`. */
|
|
106
73
|
readonly centerCaption: "";
|
|
107
|
-
/**
|
|
108
|
-
* How far each slice is pushed out of the ring, `0`–`1` per index. Held here
|
|
109
|
-
* rather than on the ring because two parts read it: the wedges grow out by
|
|
110
|
-
* it, and the legend entries dim by it. Seeded flush, one to a row.
|
|
111
|
-
*/
|
|
74
|
+
/** How far each slice is pushed out, `0`-`1` per index. Here, not on the ring, because the wedges and the legend both read it. */
|
|
112
75
|
readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
113
76
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
114
77
|
readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
115
|
-
/** Read as the chart is built: whether the hole's summary is drawn at rest. */
|
|
78
|
+
/** Read as the chart is built: whether the hole's summary is drawn at rest. A scene that wants it to land later sets `false` and runs `revealCenter`. */
|
|
116
79
|
readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
117
80
|
}>, readonly [], import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
118
81
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
82
|
+
/** Slice caption, used on the labels and the legend. */
|
|
119
83
|
readonly categoryField: "";
|
|
84
|
+
/** Slice magnitude: the wedge's share of the ring. */
|
|
120
85
|
readonly valueField: "";
|
|
121
86
|
readonly theme: import("@motionscript/sdk").Type<PieChartTheme, PieChartConfig, false>;
|
|
87
|
+
/** What the ring's labels say. */
|
|
122
88
|
readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
|
|
89
|
+
/** Where they sit: inside their wedge, outside on a leader, or nowhere. */
|
|
123
90
|
readonly labelPlacement: import("@motionscript/sdk").Type<PieLabelPlacement, PieLabelPlacement, false>;
|
|
91
|
+
/** Gap between the ring and the legend, in px. */
|
|
124
92
|
readonly gap: 40;
|
|
93
|
+
/** Text set in the ring's hole. */
|
|
125
94
|
readonly centerLabel: "";
|
|
95
|
+
/** Smaller second line under `centerLabel`. */
|
|
126
96
|
readonly centerCaption: "";
|
|
127
|
-
/**
|
|
128
|
-
* How far each slice is pushed out of the ring, `0`–`1` per index. Held here
|
|
129
|
-
* rather than on the ring because two parts read it: the wedges grow out by
|
|
130
|
-
* it, and the legend entries dim by it. Seeded flush, one to a row.
|
|
131
|
-
*/
|
|
97
|
+
/** How far each slice is pushed out, `0`-`1` per index. Here, not on the ring, because the wedges and the legend both read it. */
|
|
132
98
|
readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
133
99
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
134
100
|
readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
135
|
-
/** Read as the chart is built: whether the hole's summary is drawn at rest. */
|
|
101
|
+
/** Read as the chart is built: whether the hole's summary is drawn at rest. A scene that wants it to land later sets `false` and runs `revealCenter`. */
|
|
136
102
|
readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
137
103
|
}>, {
|
|
138
104
|
readonly enter: {};
|
|
@@ -147,6 +113,6 @@ export declare const PieChart: import("@motionscript/sdk").Component<"pieChart",
|
|
|
147
113
|
readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
148
114
|
};
|
|
149
115
|
readonly clearSelection: {};
|
|
150
|
-
}, Node2D<
|
|
116
|
+
}, Node2D<_Node2DProps>>>>;
|
|
151
117
|
export type PieChart = NodeOf<typeof PieChart>;
|
|
152
118
|
//# sourceMappingURL=pie-chart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart.d.ts","sourceRoot":"","sources":["../../src/pie-chart/pie-chart.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pie-chart.d.ts","sourceRoot":"","sources":["../../src/pie-chart/pie-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,IAAI,YAAY,EACjC,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAML,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAEvB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAA;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAA;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CACxB;AAgBD,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzE;AA4BD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;;IAIjB,wDAAwD;;IAExD,sDAAsD;;;IAGtD,kCAAkC;;IAElC,2EAA2E;;IAE3E,kDAAkD;;IAElD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,kIAAkI;;IAElI,oFAAoF;;IAEpF,yJAAyJ;;;;;;;;;;;;;;;;;IAnBzJ,wDAAwD;;IAExD,sDAAsD;;;IAGtD,kCAAkC;;IAElC,2EAA2E;;IAE3E,kDAAkD;;IAElD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,kIAAkI;;IAElI,oFAAoF;;IAEpF,yJAAyJ;;;;IAnBzJ,wDAAwD;;IAExD,sDAAsD;;;IAGtD,kCAAkC;;IAElC,2EAA2E;;IAE3E,kDAAkD;;IAElD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,kIAAkI;;IAElI,oFAAoF;;IAEpF,yJAAyJ;;;;;;;;;;;;;;;0BA6G3J,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAA"}
|
|
@@ -1,55 +1,40 @@
|
|
|
1
|
-
import { Rect, Types, component2d, easeOut, } from "@motionscript/sdk";
|
|
1
|
+
import { Rect, Types, clamp, component2d, easeOut, } from "@motionscript/sdk";
|
|
2
2
|
import { asParts, fresh } from "../kit/entries.js";
|
|
3
3
|
import { beats } from "../kit/motion.js";
|
|
4
|
-
import { clampUnit } from "../kit/shared.js";
|
|
5
4
|
import { PieLegend } from "./pie-legend.js";
|
|
6
5
|
import { PieRing } from "./pie-ring.js";
|
|
7
|
-
import { DEFAULT_PIE_CHART_THEME, lerpPieChartTheme, resolvePieChartTheme, resolvePieSlices, } from "./shared.js";
|
|
8
|
-
/**
|
|
9
|
-
* How `enter` divides its duration: the wedges sweeping in, then the labels and
|
|
10
|
-
* the legend arriving together. Shares of the whole, so they sum to 1.
|
|
11
|
-
*/
|
|
6
|
+
import { DEFAULT_PIE_CHART_THEME, lerpPieChartTheme, resolvePieChartTheme, resolvePieSlices, selectionFade, } from "./shared.js";
|
|
7
|
+
/** How `enter` divides its duration: wedges sweeping in, then labels and legend together. Sums to 1. */
|
|
12
8
|
const SWEEP_SHARE = 0.65;
|
|
13
9
|
const LABEL_SHARE = 0.35;
|
|
14
10
|
const SLICE_ARG = Types.number(0, { min: 0, step: 1 });
|
|
15
|
-
/** The slices the ring and the legend draw, resolved from the rows and the palette. */
|
|
16
11
|
function slicesOf(s) {
|
|
17
12
|
return resolvePieSlices(s.data, s.categoryField, s.valueField, s.theme.sliceFills);
|
|
18
13
|
}
|
|
19
|
-
/** How far slice `index` is pushed out, in `[0, 1]`. */
|
|
20
14
|
function popAt(s, index) {
|
|
21
|
-
return
|
|
15
|
+
return clamp(s.pops[index] ?? 0, 0, 1);
|
|
22
16
|
}
|
|
23
|
-
/** Whether slice `index` is
|
|
17
|
+
/** Whether slice `index` is past half way out, so a slice mid-swell is not yet counted. */
|
|
24
18
|
export function isSliceSelected(s, index) {
|
|
25
19
|
return popAt(s, index) > 0.5;
|
|
26
20
|
}
|
|
27
|
-
/**
|
|
28
|
-
* How far each slice is dimmed by the selection, one entry per slice: 1 while
|
|
29
|
-
* nothing is out, and for the selected slice itself; falling toward the theme's
|
|
30
|
-
* `dimOpacity` for the rest in proportion to how far the selection has grown.
|
|
31
|
-
*/
|
|
21
|
+
/** Per-slice opacity: 1 while nothing is out and for the selected slice, falling toward `dimOpacity` for the rest as the selection grows. */
|
|
32
22
|
function sliceDims(s) {
|
|
33
23
|
let focus = 0;
|
|
34
24
|
for (let i = 0; i < s.data.length; i++)
|
|
35
25
|
focus = Math.max(focus, popAt(s, i));
|
|
36
26
|
const dim = s.theme.spotlight.dimOpacity;
|
|
37
|
-
|
|
38
|
-
return s.data.map(() => 1);
|
|
39
|
-
return s.data.map((_, i) => 1 - (1 - clampUnit(dim)) * focus * (1 - popAt(s, i)));
|
|
27
|
+
return s.data.map((_, i) => selectionFade(focus, dim, popAt(s, i)));
|
|
40
28
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Every slice's pop eased from where it is to what `pop` asks for. A move that
|
|
43
|
-
* changes nothing still takes its slot, writing nothing.
|
|
44
|
-
*/
|
|
29
|
+
/** Every slice's pop eased to what `pop` asks for. A move that changes nothing still takes its slot. */
|
|
45
30
|
function popping(timeline, s, pop) {
|
|
46
31
|
const from = s.data.map((_, i) => popAt(s, i));
|
|
47
|
-
const targets = s.data.map((_, i) =>
|
|
32
|
+
const targets = s.data.map((_, i) => clamp(pop(i), 0, 1));
|
|
48
33
|
if (from.every((value, i) => value === targets[i]))
|
|
49
34
|
return timeline.wait(timeline.duration);
|
|
50
35
|
return timeline.animate((t) => ({ pops: from.map((value, i) => value + (targets[i] - value) * t) }));
|
|
51
36
|
}
|
|
52
|
-
/** The ring and
|
|
37
|
+
/** The ring and legend among the children; the last row is the one the chart built. */
|
|
53
38
|
function partsOf(children) {
|
|
54
39
|
for (let i = children.length - 1; i >= 0; i--) {
|
|
55
40
|
const row = children[i];
|
|
@@ -60,57 +45,48 @@ function partsOf(children) {
|
|
|
60
45
|
return null;
|
|
61
46
|
}
|
|
62
47
|
/**
|
|
63
|
-
* A pie or donut chart
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* - {@link PieRing} — the wedges, each sized by its share of the total, with its
|
|
68
|
-
* label inside its own band or pinned outside on a leader line, and the
|
|
69
|
-
* summary in the hole.
|
|
70
|
-
* - {@link PieLegend} — a column of swatch-and-caption rows naming each slice.
|
|
71
|
-
*
|
|
72
|
-
* **One mark per row, not per column**: a pie's palette is indexed by row and
|
|
73
|
-
* there is nothing to hide, since dropping a slice would re-cut every other
|
|
74
|
-
* wedge. `selectSlice` and its siblings are what a pie has instead — a slice
|
|
75
|
-
* swells out of the ring and everything else dims behind it.
|
|
48
|
+
* A pie or donut chart: a {@link PieRing} filling what the hugging {@link PieLegend}
|
|
49
|
+
* leaves. One mark per row, not per column, and nothing to hide, since dropping
|
|
50
|
+
* a slice would re-cut every other wedge; `selectSlice` and its siblings swell
|
|
51
|
+
* a slice and dim the rest instead.
|
|
76
52
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* with `showCenter: false`, because it is usually the chart's *conclusion*.
|
|
53
|
+
* Resting state is the finished chart, except the hole's summary, which
|
|
54
|
+
* `showCenter: false` holds back for `revealCenter`.
|
|
80
55
|
*/
|
|
81
56
|
export const PieChart = component2d({
|
|
82
57
|
key: "pieChart",
|
|
83
58
|
state: {
|
|
84
59
|
data: fresh(() => []),
|
|
60
|
+
/** Slice caption, used on the labels and the legend. */
|
|
85
61
|
categoryField: "",
|
|
62
|
+
/** Slice magnitude: the wedge's share of the ring. */
|
|
86
63
|
valueField: "",
|
|
87
64
|
theme: Types.custom(DEFAULT_PIE_CHART_THEME, { resolve: resolvePieChartTheme, lerp: lerpPieChartTheme }),
|
|
65
|
+
/** What the ring's labels say. */
|
|
88
66
|
labelMode: Types.custom("percent"),
|
|
67
|
+
/** Where they sit: inside their wedge, outside on a leader, or nowhere. */
|
|
89
68
|
labelPlacement: Types.custom("leader"),
|
|
69
|
+
/** Gap between the ring and the legend, in px. */
|
|
90
70
|
gap: 40,
|
|
71
|
+
/** Text set in the ring's hole. */
|
|
91
72
|
centerLabel: "",
|
|
73
|
+
/** Smaller second line under `centerLabel`. */
|
|
92
74
|
centerCaption: "",
|
|
93
|
-
/**
|
|
94
|
-
* How far each slice is pushed out of the ring, `0`–`1` per index. Held here
|
|
95
|
-
* rather than on the ring because two parts read it: the wedges grow out by
|
|
96
|
-
* it, and the legend entries dim by it. Seeded flush, one to a row.
|
|
97
|
-
*/
|
|
75
|
+
/** How far each slice is pushed out, `0`-`1` per index. Here, not on the ring, because the wedges and the legend both read it. */
|
|
98
76
|
pops: fresh(() => []),
|
|
99
77
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
100
78
|
showLegend: Types.boolean(true, { animatable: false }),
|
|
101
|
-
/** Read as the chart is built: whether the hole's summary is drawn at rest. */
|
|
79
|
+
/** Read as the chart is built: whether the hole's summary is drawn at rest. A scene that wants it to land later sets `false` and runs `revealCenter`. */
|
|
102
80
|
showCenter: Types.boolean(true, { animatable: false }),
|
|
103
81
|
},
|
|
104
82
|
defaults: {
|
|
105
|
-
//
|
|
83
|
+
// A node made of parts that fill would otherwise hug them.
|
|
106
84
|
width: "fill",
|
|
107
85
|
height: "fill",
|
|
108
86
|
pops: (state) => slicesOf(state).map(() => 0),
|
|
109
87
|
},
|
|
110
88
|
allowedChildren: [],
|
|
111
|
-
// The
|
|
112
|
-
// the slices themselves, their paint and the selection are bound, so a theme
|
|
113
|
-
// tween re-paints and a `set` of `data` re-cuts the wedges.
|
|
89
|
+
// The structure (a label and legend row per row) is read once; slices, paint and selection are bound, so a theme tween re-paints and a `set` of `data` re-cuts.
|
|
114
90
|
children: (state) => {
|
|
115
91
|
const theme = () => state.theme;
|
|
116
92
|
const slices = () => slicesOf(state);
|
|
@@ -136,8 +112,7 @@ export const PieChart = component2d({
|
|
|
136
112
|
slices,
|
|
137
113
|
legend: () => theme().legend,
|
|
138
114
|
dims: () => sliceDims(state),
|
|
139
|
-
//
|
|
140
|
-
// entries' type and chips.
|
|
115
|
+
// Spacing is fixed as built.
|
|
141
116
|
gap: state.theme.legend.itemGap / 3,
|
|
142
117
|
padding: state.theme.legend.padding,
|
|
143
118
|
}));
|
|
@@ -146,15 +121,10 @@ export const PieChart = component2d({
|
|
|
146
121
|
return asParts([row]);
|
|
147
122
|
},
|
|
148
123
|
commands: {
|
|
149
|
-
/**
|
|
150
|
-
* Animate the whole chart in: the wedges sweep in clockwise from the theme's
|
|
151
|
-
* `startAngle`, then the labels fade up and the legend staggers in together.
|
|
152
|
-
* Its first frame arms the wedges, the labels and the legend; the hole's
|
|
153
|
-
* summary keeps its own signal. `duration` is the **whole** entrance.
|
|
154
|
-
*/
|
|
124
|
+
/** Wedges sweep in clockwise from `startAngle`, then labels fade up and the legend staggers in. `duration` is the whole entrance; the hole's summary keeps its own signal. */
|
|
155
125
|
enter: {
|
|
156
126
|
args: {},
|
|
157
|
-
// Held from
|
|
127
|
+
// Held from arrival, so it never shows finished ahead of its draw.
|
|
158
128
|
entrance: true,
|
|
159
129
|
easing: easeOut(),
|
|
160
130
|
run: (timeline, _state, children) => {
|
|
@@ -174,11 +144,7 @@ export const PieChart = component2d({
|
|
|
174
144
|
]);
|
|
175
145
|
},
|
|
176
146
|
},
|
|
177
|
-
/**
|
|
178
|
-
* Fade the hole's summary up. Held out of `enter` on purpose: what sits in a
|
|
179
|
-
* donut's hole is usually the chart's conclusion, so the scene lands it on
|
|
180
|
-
* its own beat. Pair it with `showCenter: false`.
|
|
181
|
-
*/
|
|
147
|
+
/** Fade the hole's summary up. Not part of `enter`: it is usually the conclusion, which a scene lands on its own beat. */
|
|
182
148
|
revealCenter: {
|
|
183
149
|
args: {},
|
|
184
150
|
easing: easeOut(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../src/pie-chart/pie-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,GAQR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAa,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GAMjB,MAAM,UAAU,CAAA;AA4CjB;;;GAGG;AACH,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,WAAW,GAAG,IAAI,CAAA;AAExB,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAA;AAEtD,uFAAuF;AACvF,SAAS,QAAQ,CAAC,CAAiB;IACjC,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AACpF,CAAC;AAED,wDAAwD;AACxD,SAAS,KAAK,CAAC,CAAiB,EAAE,KAAa;IAC7C,OAAO,SAAS,CAAC,CAAC,CAAC,IA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AE,KAAK,EAAE,EAAE;gBACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAA;gBACtC,OAAO,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YAC7E,CAAC;SACF;QACD,6EAA6E;QAC7E,eAAe,EAAE;YACf,IAAI,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE;YAC/B,MAAM,EAAE,OAAO,EAAE;YACjB,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;gBACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAA;gBACtC,OAAO,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/D,CAAC;SACF;QACD,uEAAuE;QACvE,cAAc,EAAE;YACd,IAAI,EAAE,EAAE;YACR,MAAM,EAAE,OAAO,EAAE;YACjB,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SAC5D;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n Types,\n component2d,\n easeOut,\n type ChildView,\n type DataRecord,\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 Timeline,\n} from \"@motionscript/sdk\"\n\nimport { asParts, fresh } from \"../kit/entries\"\nimport { beats, type Beat } from \"../kit/motion\"\nimport { clampUnit } from \"../kit/shared\"\nimport { PieLegend } from \"./pie-legend\"\nimport { PieRing } from \"./pie-ring\"\nimport {\n DEFAULT_PIE_CHART_THEME,\n lerpPieChartTheme,\n resolvePieChartTheme,\n resolvePieSlices,\n type PieChartConfig,\n type PieChartTheme,\n type PieLabelMode,\n type PieLabelPlacement,\n type PieSlice,\n} from \"./shared\"\n\nexport interface PieChartProps extends Node2DProps {\n /** One row per slice — a plain record of field name to value. */\n data: DataRecord[]\n /** Key into each row for its slice caption, used on the labels and the legend. */\n categoryField: string\n /** Key into each row for its slice magnitude — the wedge's share of the ring. */\n valueField: string\n /**\n * The chart's visual theme — slice palette, ring geometry, label and centre\n * type, legend. Every branch is optional and deep-merged onto\n * {@link DEFAULT_PIE_CHART_THEME}.\n */\n theme?: PieChartTheme\n /** What the ring's labels say. */\n labelMode?: PieLabelMode\n /** Where they sit: inside their wedge, outside on a leader, or nowhere. */\n labelPlacement?: PieLabelPlacement\n /** Whether the legend column beside the ring is drawn at all. */\n showLegend?: boolean\n /** Gap between the ring and the legend, in px. */\n gap?: number\n /** Text set in the ring's hole — see `revealCenter`. */\n centerLabel?: string\n /** Smaller second line under {@link centerLabel}. */\n centerCaption?: string\n /**\n * Whether the hole's summary is drawn at rest. `true` (the default) is the\n * plain answer; a scene that wants the conclusion to land on a later beat sets\n * this `false` and runs `revealCenter` when it gets there.\n */\n showCenter?: boolean\n}\n\n/** What the selection reads: the rows, how they are cut, and the pops the commands move. */\nexport interface PieChartValues {\n readonly data: DataRecord[]\n readonly categoryField: string\n readonly valueField: string\n readonly theme: PieChartConfig\n readonly pops: number[]\n}\n\n/**\n * How `enter` divides its duration: the wedges sweeping in, then the labels and\n * the legend arriving together. Shares of the whole, so they sum to 1.\n */\nconst SWEEP_SHARE = 0.65\nconst LABEL_SHARE = 0.35\n\nconst SLICE_ARG = Types.number(0, { min: 0, step: 1 })\n\n/** The slices the ring and the legend draw, resolved from the rows and the palette. */\nfunction slicesOf(s: PieChartValues): PieSlice[] {\n return resolvePieSlices(s.data, s.categoryField, s.valueField, s.theme.sliceFills)\n}\n\n/** How far slice `index` is pushed out, in `[0, 1]`. */\nfunction popAt(s: PieChartValues, index: number): number {\n return clampUnit(s.pops[index] ?? 0)\n}\n\n/** Whether slice `index` is grown out past the ring's rim: past half way, so a slice mid-swell is not yet counted. */\nexport function isSliceSelected(s: PieChartValues, index: number): boolean {\n return popAt(s, index) > 0.5\n}\n\n/**\n * How far each slice is dimmed by the selection, one entry per slice: 1 while\n * nothing is out, and for the selected slice itself; falling toward the theme's\n * `dimOpacity` for the rest in proportion to how far the selection has grown.\n */\nfunction sliceDims(s: PieChartValues): number[] {\n let focus = 0\n for (let i = 0; i < s.data.length; i++) focus = Math.max(focus, popAt(s, i))\n const dim = s.theme.spotlight.dimOpacity\n if (focus <= 0) return s.data.map(() => 1)\n return s.data.map((_, i) => 1 - (1 - clampUnit(dim)) * focus * (1 - popAt(s, i)))\n}\n\ntype AnyTimeline = Timeline<any, any>\n\n/**\n * Every slice's pop eased from where it is to what `pop` asks for. A move that\n * changes nothing still takes its slot, writing nothing.\n */\nfunction popping(timeline: AnyTimeline, s: PieChartValues, pop: (index: number) => number) {\n const from = s.data.map((_, i) => popAt(s, i))\n const targets = s.data.map((_, i) => clampUnit(pop(i)))\n if (from.every((value, i) => value === targets[i])) return timeline.wait(timeline.duration)\n return timeline.animate((t) => ({ pops: from.map((value, i) => value + (targets[i] - value) * t) }))\n}\n\n/** The ring and the legend, found through the chart's children: the last row of them is the one it built. */\nfunction partsOf(children: readonly ChildView[]) {\n for (let i = children.length - 1; i >= 0; i--) {\n const row = children[i]\n const ring = Rect.is(row) ? row.children.find(PieRing.is) : undefined\n if (ring) return { ring, legend: row.children.find(PieLegend.is) ?? null }\n }\n return null\n}\n\n/**\n * A pie or donut chart, composed from two parts laid out by a horizontal-flow\n * {@link Rect} — the ring filling whatever the hugging legend leaves, both\n * centred:\n *\n * - {@link PieRing} — the wedges, each sized by its share of the total, with its\n * label inside its own band or pinned outside on a leader line, and the\n * summary in the hole.\n * - {@link PieLegend} — a column of swatch-and-caption rows naming each slice.\n *\n * **One mark per row, not per column**: a pie's palette is indexed by row and\n * there is nothing to hide, since dropping a slice would re-cut every other\n * wedge. `selectSlice` and its siblings are what a pie has instead — a slice\n * swells out of the ring and everything else dims behind it.\n *\n * **Resting state is the finished chart**; `enter` arms every part on its first\n * frame. The one exception is the hole's summary, which a scene can hold back\n * with `showCenter: false`, because it is usually the chart's *conclusion*.\n */\nexport const PieChart = component2d({\n key: \"pieChart\",\n state: {\n data: fresh<DataRecord[]>(() => []),\n categoryField: \"\",\n valueField: \"\",\n theme: Types.custom<PieChartTheme, PieChartConfig>(DEFAULT_PIE_CHART_THEME, { resolve: resolvePieChartTheme, lerp: lerpPieChartTheme }),\n labelMode: Types.custom<PieLabelMode>(\"percent\"),\n labelPlacement: Types.custom<PieLabelPlacement>(\"leader\"),\n gap: 40,\n centerLabel: \"\",\n centerCaption: \"\",\n /**\n * How far each slice is pushed out of the ring, `0`–`1` per index. Held here\n * rather than on the ring because two parts read it: the wedges grow out by\n * it, and the legend entries dim by it. Seeded flush, one to a row.\n */\n pops: fresh<number[]>(() => []),\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 the hole's summary is drawn at rest. */\n showCenter: Types.boolean(true, { animatable: false }),\n },\n defaults: {\n // Its parts fill it; a node made of them would hug them.\n width: \"fill\",\n height: \"fill\",\n pops: (state) => slicesOf(state).map(() => 0),\n },\n allowedChildren: [],\n // The slice *structure* (one label and one legend row per row) is read once;\n // the slices themselves, their paint and the selection are bound, so a theme\n // tween re-paints and a `set` of `data` re-cuts the wedges.\n children: (state) => {\n const theme = () => state.theme\n const slices = () => slicesOf(state)\n const parts: Node2D[] = [\n new PieRing({\n width: \"fill\",\n height: \"fill\",\n slices,\n ring: () => theme().ring,\n label: () => theme().label,\n centerStyle: () => theme().center,\n labelMode: state.labelMode,\n labelPlacement: state.labelPlacement,\n pops: () => state.pops,\n dimOpacity: () => theme().spotlight.dimOpacity,\n centerLabel: state.centerLabel,\n centerCaption: state.centerCaption,\n centerReveal: state.showCenter === false ? 0 : 1,\n }) as unknown as Node2D,\n ]\n if (state.showLegend !== false) {\n parts.push(\n new PieLegend({\n slices,\n legend: () => theme().legend,\n dims: () => sliceDims(state),\n // The column's spacing is the theme's as the chart was built, like the\n // entries' type and chips.\n gap: state.theme.legend.itemGap / 3,\n padding: state.theme.legend.padding,\n }) as unknown as Node2D\n )\n }\n const row = new Rect({ flow: \"horizontal\", width: \"fill\", height: \"fill\", gap: state.gap, align: \"center\", children: parts })\n return asParts([row as unknown as Node2D])\n },\n commands: {\n /**\n * Animate the whole chart in: the wedges sweep in clockwise from the theme's\n * `startAngle`, then the labels fade up and the legend staggers in together.\n * Its first frame arms the wedges, the labels and the legend; the hole's\n * summary keeps its own signal. `duration` is the **whole** entrance.\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 { ring, legend } = parts\n const sweep = timeline.duration * SWEEP_SHARE\n const labels = timeline.duration * LABEL_SHARE\n const at0 = (piece: Beat[\"piece\"]): Beat => ({ at: 0, duration: 0, piece })\n return beats(timeline, [\n at0(ring.to({ growth: 0, labelReveal: 0 })),\n ...(legend ? [at0(legend.run(\"arm\"))] : []),\n { at: 0, duration: sweep, piece: ring.run(\"sweep\") },\n { at: sweep, duration: labels, piece: ring.run(\"revealLabels\") },\n ...(legend ? [{ at: sweep, duration: labels, piece: legend.run(\"enter\") }] : []),\n ])\n },\n },\n /**\n * Fade the hole's summary up. Held out of `enter` on purpose: what sits in a\n * donut's hole is usually the chart's conclusion, so the scene lands it on\n * its own beat. Pair it with `showCenter: false`.\n */\n revealCenter: {\n args: {},\n easing: easeOut(),\n run: (timeline, _state, children) => partsOf(children)?.ring.run(\"revealCenter\") ?? timeline.wait(timeline.duration),\n },\n /** Grow slice `index` out past the ring's rim and dim the rest, leaving any other selected slice where it is. */\n selectSlice: {\n args: { sliceIndex: SLICE_ARG },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.sliceIndex\n return popping(timeline, state, (i) => (i === index ? 1 : popAt(state, i)))\n },\n },\n /** Settle slice `index` back flush with the ring. */\n deselectSlice: {\n args: { sliceIndex: SLICE_ARG },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.sliceIndex\n return popping(timeline, state, (i) => (i === index ? 0 : popAt(state, i)))\n },\n },\n /** Move the focus to slice `index` alone, settling whatever else was out. */\n selectOnlySlice: {\n args: { sliceIndex: SLICE_ARG },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.sliceIndex\n return popping(timeline, state, (i) => (i === index ? 1 : 0))\n },\n },\n /** Settle every slice flush and bring the whole chart back to full. */\n clearSelection: {\n args: {},\n easing: easeOut(),\n run: (timeline, state) => popping(timeline, state, () => 0),\n },\n },\n})\n\nexport type PieChart = NodeOf<typeof PieChart>\n"]}
|
|
1
|
+
{"version":3,"file":"pie-chart.js","sourceRoot":"","sources":["../../src/pie-chart/pie-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,OAAO,GAOR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAA+B,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,GAMd,MAAM,UAAU,CAAA;AAUjB,wGAAwG;AACxG,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,WAAW,GAAG,IAAI,CAAA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AC,CAAC,CAAC;SAC5D;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n Types,\n clamp,\n component2d,\n easeOut,\n type ChildView,\n type DataRecord,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\n\nimport { asParts, fresh } from \"../kit/entries\"\nimport { beats, type AnyTimeline, type Beat } from \"../kit/motion\"\nimport { PieLegend } from \"./pie-legend\"\nimport { PieRing } from \"./pie-ring\"\nimport {\n DEFAULT_PIE_CHART_THEME,\n lerpPieChartTheme,\n resolvePieChartTheme,\n resolvePieSlices,\n selectionFade,\n type PieChartConfig,\n type PieChartTheme,\n type PieLabelMode,\n type PieLabelPlacement,\n type PieSlice,\n} from \"./shared\"\n\nexport interface PieChartValues {\n readonly data: DataRecord[]\n readonly categoryField: string\n readonly valueField: string\n readonly theme: PieChartConfig\n readonly pops: number[]\n}\n\n/** How `enter` divides its duration: wedges sweeping in, then labels and legend together. Sums to 1. */\nconst SWEEP_SHARE = 0.65\nconst LABEL_SHARE = 0.35\n\nconst SLICE_ARG = Types.number(0, { min: 0, step: 1 })\n\nfunction slicesOf(s: PieChartValues): PieSlice[] {\n return resolvePieSlices(s.data, s.categoryField, s.valueField, s.theme.sliceFills)\n}\n\nfunction popAt(s: PieChartValues, index: number): number {\n return clamp(s.pops[index] ?? 0, 0, 1)\n}\n\n/** Whether slice `index` is past half way out, so a slice mid-swell is not yet counted. */\nexport function isSliceSelected(s: PieChartValues, index: number): boolean {\n return popAt(s, index) > 0.5\n}\n\n/** Per-slice opacity: 1 while nothing is out and for the selected slice, falling toward `dimOpacity` for the rest as the selection grows. */\nfunction sliceDims(s: PieChartValues): number[] {\n let focus = 0\n for (let i = 0; i < s.data.length; i++) focus = Math.max(focus, popAt(s, i))\n const dim = s.theme.spotlight.dimOpacity\n return s.data.map((_, i) => selectionFade(focus, dim, popAt(s, i)))\n}\n\n/** Every slice's pop eased to what `pop` asks for. A move that changes nothing still takes its slot. */\nfunction popping(timeline: AnyTimeline, s: PieChartValues, pop: (index: number) => number) {\n const from = s.data.map((_, i) => popAt(s, i))\n const targets = s.data.map((_, i) => clamp(pop(i), 0, 1))\n if (from.every((value, i) => value === targets[i])) return timeline.wait(timeline.duration)\n return timeline.animate((t) => ({ pops: from.map((value, i) => value + (targets[i] - value) * t) }))\n}\n\n/** The ring and legend among the children; the last row is the one the chart built. */\nfunction partsOf(children: readonly ChildView[]) {\n for (let i = children.length - 1; i >= 0; i--) {\n const row = children[i]\n const ring = Rect.is(row) ? row.children.find(PieRing.is) : undefined\n if (ring) return { ring, legend: row.children.find(PieLegend.is) ?? null }\n }\n return null\n}\n\n/**\n * A pie or donut chart: a {@link PieRing} filling what the hugging {@link PieLegend}\n * leaves. One mark per row, not per column, and nothing to hide, since dropping\n * a slice would re-cut every other wedge; `selectSlice` and its siblings swell\n * a slice and dim the rest instead.\n *\n * Resting state is the finished chart, except the hole's summary, which\n * `showCenter: false` holds back for `revealCenter`.\n */\nexport const PieChart = component2d({\n key: \"pieChart\",\n state: {\n data: fresh<DataRecord[]>(() => []),\n /** Slice caption, used on the labels and the legend. */\n categoryField: \"\",\n /** Slice magnitude: the wedge's share of the ring. */\n valueField: \"\",\n theme: Types.custom<PieChartTheme, PieChartConfig>(DEFAULT_PIE_CHART_THEME, { resolve: resolvePieChartTheme, lerp: lerpPieChartTheme }),\n /** What the ring's labels say. */\n labelMode: Types.custom<PieLabelMode>(\"percent\"),\n /** Where they sit: inside their wedge, outside on a leader, or nowhere. */\n labelPlacement: Types.custom<PieLabelPlacement>(\"leader\"),\n /** Gap between the ring and the legend, in px. */\n gap: 40,\n /** Text set in the ring's hole. */\n centerLabel: \"\",\n /** Smaller second line under `centerLabel`. */\n centerCaption: \"\",\n /** How far each slice is pushed out, `0`-`1` per index. Here, not on the ring, because the wedges and the legend both read it. */\n pops: fresh<number[]>(() => []),\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 the hole's summary is drawn at rest. A scene that wants it to land later sets `false` and runs `revealCenter`. */\n showCenter: Types.boolean(true, { animatable: false }),\n },\n defaults: {\n // A node made of parts that fill would otherwise hug them.\n width: \"fill\",\n height: \"fill\",\n pops: (state) => slicesOf(state).map(() => 0),\n },\n allowedChildren: [],\n // The structure (a label and legend row per row) is read once; slices, paint and selection are bound, so a theme tween re-paints and a `set` of `data` re-cuts.\n children: (state) => {\n const theme = () => state.theme\n const slices = () => slicesOf(state)\n const parts: Node2D[] = [\n new PieRing({\n width: \"fill\",\n height: \"fill\",\n slices,\n ring: () => theme().ring,\n label: () => theme().label,\n centerStyle: () => theme().center,\n labelMode: state.labelMode,\n labelPlacement: state.labelPlacement,\n pops: () => state.pops,\n dimOpacity: () => theme().spotlight.dimOpacity,\n centerLabel: state.centerLabel,\n centerCaption: state.centerCaption,\n centerReveal: state.showCenter === false ? 0 : 1,\n }) as unknown as Node2D,\n ]\n if (state.showLegend !== false) {\n parts.push(\n new PieLegend({\n slices,\n legend: () => theme().legend,\n dims: () => sliceDims(state),\n // Spacing is fixed as built.\n gap: state.theme.legend.itemGap / 3,\n padding: state.theme.legend.padding,\n }) as unknown as Node2D\n )\n }\n const row = new Rect({ flow: \"horizontal\", width: \"fill\", height: \"fill\", gap: state.gap, align: \"center\", children: parts })\n return asParts([row as unknown as Node2D])\n },\n commands: {\n /** Wedges sweep in clockwise from `startAngle`, then labels fade up and the legend staggers in. `duration` is the whole entrance; the hole's summary keeps its own signal. */\n enter: {\n args: {},\n // Held from 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 { ring, legend } = parts\n const sweep = timeline.duration * SWEEP_SHARE\n const labels = timeline.duration * LABEL_SHARE\n const at0 = (piece: Beat[\"piece\"]): Beat => ({ at: 0, duration: 0, piece })\n return beats(timeline, [\n at0(ring.to({ growth: 0, labelReveal: 0 })),\n ...(legend ? [at0(legend.run(\"arm\"))] : []),\n { at: 0, duration: sweep, piece: ring.run(\"sweep\") },\n { at: sweep, duration: labels, piece: ring.run(\"revealLabels\") },\n ...(legend ? [{ at: sweep, duration: labels, piece: legend.run(\"enter\") }] : []),\n ])\n },\n },\n /** Fade the hole's summary up. Not part of `enter`: it is usually the conclusion, which a scene lands on its own beat. */\n revealCenter: {\n args: {},\n easing: easeOut(),\n run: (timeline, _state, children) => partsOf(children)?.ring.run(\"revealCenter\") ?? timeline.wait(timeline.duration),\n },\n /** Grow slice `index` out past the ring's rim and dim the rest, leaving any other selected slice where it is. */\n selectSlice: {\n args: { sliceIndex: SLICE_ARG },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.sliceIndex\n return popping(timeline, state, (i) => (i === index ? 1 : popAt(state, i)))\n },\n },\n /** Settle slice `index` back flush with the ring. */\n deselectSlice: {\n args: { sliceIndex: SLICE_ARG },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.sliceIndex\n return popping(timeline, state, (i) => (i === index ? 0 : popAt(state, i)))\n },\n },\n /** Move the focus to slice `index` alone, settling whatever else was out. */\n selectOnlySlice: {\n args: { sliceIndex: SLICE_ARG },\n easing: easeOut(),\n run: (timeline, state) => {\n const index = timeline.args.sliceIndex\n return popping(timeline, state, (i) => (i === index ? 1 : 0))\n },\n },\n /** Settle every slice flush and bring the whole chart back to full. */\n clearSelection: {\n args: {},\n easing: easeOut(),\n run: (timeline, state) => popping(timeline, state, () => 0),\n },\n },\n})\n\nexport type PieChart = NodeOf<typeof PieChart>\n"]}
|
|
@@ -1,37 +1,18 @@
|
|
|
1
|
-
import { type NodeOf, type
|
|
1
|
+
import { type NodeOf, type Alignment as _Alignment, type CornerRadiusResolved as _CornerRadiusResolved, type CornerStyleResolved as _CornerStyleResolved, type Fill as _Fill, type FillResolved as _FillResolved, type FlowMode as _FlowMode, type FlowResolved as _FlowResolved, type GapSize as _GapSize, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type RectCornerRadius as _RectCornerRadius, type RectCornerStyle as _RectCornerStyle, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved, type Vector2 as _Vector2 } from "@motionscript/sdk";
|
|
2
2
|
import { type Arrival } from "../kit/motion.js";
|
|
3
3
|
import { type LegendConfig } from "../kit/shared.js";
|
|
4
4
|
import type { PieSlice } from "./shared.js";
|
|
5
|
-
export interface PieLegendProps extends RectProps {
|
|
6
|
-
/** One entry per slice, in ring order. */
|
|
7
|
-
slices: PieSlice[];
|
|
8
|
-
/** Padding, caption style, gaps, and swatch geometry — see {@link LegendConfig}. */
|
|
9
|
-
legend: LegendConfig;
|
|
10
|
-
/**
|
|
11
|
-
* Per-slice opacity multiplier, by index — the same signal that dims the ring,
|
|
12
|
-
* so an entry fades in step with the wedge it names. Missing entries read as 1.
|
|
13
|
-
*/
|
|
14
|
-
dims: number[];
|
|
15
|
-
}
|
|
16
5
|
/**
|
|
17
|
-
* The legend of a {@link PieChart}: a
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* ring rather than beneath the plot — a pie is as tall as it is wide, so the
|
|
22
|
-
* space it leaves over is a vertical strip. It is otherwise the same entry: the
|
|
23
|
-
* swatch carries the colour, the caption reads in the legend's neutral ink, and
|
|
24
|
-
* both take the shared {@link LegendConfig}.
|
|
25
|
-
*
|
|
26
|
-
* There is no show/hide here. A pie's marks are its *rows*, and a row that
|
|
27
|
-
* shouldn't be in the chart shouldn't be in the table — removing one would
|
|
28
|
-
* silently re-cut every other wedge's share, which is a different chart rather
|
|
29
|
-
* than the same chart with something hidden. Selection is what a pie has
|
|
30
|
-
* instead, and it arrives through {@link PieLegendProps.dims}.
|
|
6
|
+
* The legend of a {@link PieChart}: a column (it sits beside the ring, in the
|
|
7
|
+
* vertical strip it leaves) of caption-and-swatch entries, one per slice. No
|
|
8
|
+
* show/hide: removing a row would re-cut every other wedge's share. Selection
|
|
9
|
+
* arrives through `dims`.
|
|
31
10
|
*/
|
|
32
11
|
export declare const PieLegend: import("@motionscript/sdk").Component<"pieLegend", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
12
|
+
/** One entry per slice, in ring order. */
|
|
33
13
|
readonly slices: import("@motionscript/sdk").Type<PieSlice[], PieSlice[], false>;
|
|
34
14
|
readonly legend: import("@motionscript/sdk").Type<LegendConfig, LegendConfig, false>;
|
|
15
|
+
/** Per-slice opacity multiplier, the signal that dims the ring, so an entry fades in step with its wedge. Missing reads as 1. */
|
|
35
16
|
readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
36
17
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
37
18
|
readonly cornerRadius: import("@motionscript/sdk").Attribute<_RectCornerRadius, _CornerRadiusResolved>;
|
|
@@ -60,8 +41,10 @@ export declare const PieLegend: import("@motionscript/sdk").Component<"pieLegend
|
|
|
60
41
|
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
61
42
|
};
|
|
62
43
|
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
44
|
+
/** One entry per slice, in ring order. */
|
|
63
45
|
readonly slices: import("@motionscript/sdk").Type<PieSlice[], PieSlice[], false>;
|
|
64
46
|
readonly legend: import("@motionscript/sdk").Type<LegendConfig, LegendConfig, false>;
|
|
47
|
+
/** Per-slice opacity multiplier, the signal that dims the ring, so an entry fades in step with its wedge. Missing reads as 1. */
|
|
65
48
|
readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
66
49
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
67
50
|
readonly cornerRadius: import("@motionscript/sdk").Attribute<_RectCornerRadius, _CornerRadiusResolved>;
|
|
@@ -79,8 +62,10 @@ export declare const PieLegend: import("@motionscript/sdk").Component<"pieLegend
|
|
|
79
62
|
readonly start: import("@motionscript/sdk").Type<number, number, false>;
|
|
80
63
|
readonly end: import("@motionscript/sdk").Type<number, number, false>;
|
|
81
64
|
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
65
|
+
/** One entry per slice, in ring order. */
|
|
82
66
|
readonly slices: import("@motionscript/sdk").Type<PieSlice[], PieSlice[], false>;
|
|
83
67
|
readonly legend: import("@motionscript/sdk").Type<LegendConfig, LegendConfig, false>;
|
|
68
|
+
/** Per-slice opacity multiplier, the signal that dims the ring, so an entry fades in step with its wedge. Missing reads as 1. */
|
|
84
69
|
readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
85
70
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
86
71
|
readonly cornerRadius: import("@motionscript/sdk").Attribute<_RectCornerRadius, _CornerRadiusResolved>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pie-legend.d.ts","sourceRoot":"","sources":["../../src/pie-chart/pie-legend.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pie-legend.d.ts","sourceRoot":"","sources":["../../src/pie-chart/pie-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,MAAM,EAEX,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,oBAAoB,IAAI,qBAAqB,EAClD,KAAK,mBAAmB,IAAI,oBAAoB,EAChD,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,QAAQ,IAAI,SAAS,EAC1B,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,gBAAgB,IAAI,iBAAiB,EAC1C,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,OAAO,IAAI,QAAQ,EACzB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAA8D,KAAK,OAAO,EAAE,MAAM,eAAe,CAAA;AACxG,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAIxC;;;;;GAKG;AACH,eAAO,MAAM,SAAS;IAMlB,0CAA0C;;;IAG1C,iIAAiI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAHjI,0CAA0C;;;IAG1C,iIAAiI;;;;;;;;;;;;;;;;;;IAHjI,0CAA0C;;;IAG1C,iIAAiI;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAwEnI,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAA"}
|