@motionscript/charts 0.1.0 → 0.1.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +98 -28
- package/dist/bar-chart/bar-chart.d.ts +242 -119
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +231 -260
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +16 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +59 -68
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +60 -91
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +88 -125
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +5 -13
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +2 -9
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +40 -132
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +70 -158
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-R3Q5EE6E.js +2 -0
- package/dist/browser/chunks/chunk-R3Q5EE6E.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +8 -17
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +8 -17
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.d.ts +49 -35
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +80 -42
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +37 -40
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +53 -47
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +16 -59
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +38 -76
- 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/horizontal-axis.d.ts +77 -0
- package/dist/kit/horizontal-axis.d.ts.map +1 -0
- package/dist/kit/horizontal-axis.js +99 -0
- package/dist/kit/horizontal-axis.js.map +1 -0
- package/dist/kit/motion.d.ts +16 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +15 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/{pie-chart → kit}/pie-legend.d.ts +14 -29
- package/dist/kit/pie-legend.d.ts.map +1 -0
- package/dist/kit/pie-legend.js +93 -0
- package/dist/kit/pie-legend.js.map +1 -0
- package/dist/kit/polar.d.ts +31 -0
- package/dist/kit/polar.d.ts.map +1 -0
- package/dist/kit/polar.js +33 -0
- package/dist/kit/polar.js.map +1 -0
- package/dist/kit/shared.d.ts +60 -214
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +91 -291
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/style.d.ts +254 -0
- package/dist/kit/style.d.ts.map +1 -0
- package/dist/kit/style.js +197 -0
- package/dist/kit/style.js.map +1 -0
- package/dist/kit/vertical-axis.d.ts +36 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +69 -81
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +107 -40
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +172 -89
- 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 +13 -28
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/index.d.ts +5 -18
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +3 -16
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +272 -119
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +309 -257
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +73 -130
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +195 -156
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +16 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +44 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +3 -13
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +9 -13
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +3 -15
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -11
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +147 -85
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +65 -86
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +65 -196
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +154 -292
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +78 -172
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +54 -177
- package/dist/pie-chart/shared.js.map +1 -1
- package/dist/radar-chart/index.d.ts +5 -0
- package/dist/radar-chart/index.d.ts.map +1 -0
- package/dist/radar-chart/index.js +5 -0
- package/dist/radar-chart/index.js.map +1 -0
- package/dist/radar-chart/radar-chart.d.ts +218 -0
- package/dist/radar-chart/radar-chart.d.ts.map +1 -0
- package/dist/radar-chart/radar-chart.js +224 -0
- package/dist/radar-chart/radar-chart.js.map +1 -0
- package/dist/radar-chart/radar-grid.d.ts +43 -0
- package/dist/radar-chart/radar-grid.d.ts.map +1 -0
- package/dist/radar-chart/radar-grid.js +61 -0
- package/dist/radar-chart/radar-grid.js.map +1 -0
- package/dist/radar-chart/radar-series.d.ts +59 -0
- package/dist/radar-chart/radar-series.d.ts.map +1 -0
- package/dist/radar-chart/radar-series.js +71 -0
- package/dist/radar-chart/radar-series.js.map +1 -0
- package/dist/radar-chart/shared.d.ts +73 -0
- package/dist/radar-chart/shared.d.ts.map +1 -0
- package/dist/radar-chart/shared.js +123 -0
- package/dist/radar-chart/shared.js.map +1 -0
- package/dist/radial-chart/index.d.ts +6 -0
- package/dist/radial-chart/index.d.ts.map +1 -0
- package/dist/radial-chart/index.js +4 -0
- package/dist/radial-chart/index.js.map +1 -0
- package/dist/radial-chart/radial-chart.d.ts +216 -0
- package/dist/radial-chart/radial-chart.d.ts.map +1 -0
- package/dist/radial-chart/radial-chart.js +174 -0
- package/dist/radial-chart/radial-chart.js.map +1 -0
- package/dist/radial-chart/radial-rings.d.ts +121 -0
- package/dist/radial-chart/radial-rings.d.ts.map +1 -0
- package/dist/radial-chart/radial-rings.js +273 -0
- package/dist/radial-chart/radial-rings.js.map +1 -0
- package/dist/radial-chart/shared.d.ts +73 -0
- package/dist/radial-chart/shared.d.ts.map +1 -0
- package/dist/radial-chart/shared.js +79 -0
- package/dist/radial-chart/shared.js.map +1 -0
- package/package.json +4 -4
- package/registry.json +21 -6
- package/src/bar-chart/bar-chart.ts +274 -315
- package/src/bar-chart/category-axis.ts +53 -88
- package/src/bar-chart/chart-bars.ts +108 -205
- package/src/bar-chart/index.ts +8 -19
- package/src/bar-chart/shared.ts +81 -309
- package/src/engine.ts +8 -17
- package/src/index.ts +2 -0
- package/src/kit/cartesian.ts +118 -55
- package/src/kit/chart-canvas.ts +50 -80
- package/src/kit/chart-legend.ts +36 -97
- package/src/kit/entries.ts +4 -1
- package/src/kit/horizontal-axis.ts +114 -0
- package/src/kit/motion.ts +18 -2
- package/src/{pie-chart → kit}/pie-legend.ts +25 -65
- package/src/kit/polar.ts +54 -0
- package/src/kit/shared.ts +104 -487
- package/src/kit/style.ts +257 -0
- package/src/kit/vertical-axis.ts +81 -115
- package/src/line-chart/chart-line.ts +185 -91
- package/src/line-chart/chart-region.ts +14 -31
- package/src/line-chart/index.ts +14 -22
- package/src/line-chart/line-chart.ts +377 -315
- package/src/line-chart/shared.ts +229 -304
- package/src/line-chart/x-scale.ts +44 -121
- package/src/nodes.ts +9 -13
- package/src/pie-chart/index.ts +3 -35
- package/src/pie-chart/pie-chart.ts +83 -134
- package/src/pie-chart/pie-ring.ts +162 -368
- package/src/pie-chart/shared.ts +92 -379
- package/src/radar-chart/index.ts +4 -0
- package/src/radar-chart/radar-chart.ts +287 -0
- package/src/radar-chart/radar-grid.ts +78 -0
- package/src/radar-chart/radar-series.ts +88 -0
- package/src/radar-chart/shared.ts +146 -0
- package/src/radial-chart/index.ts +5 -0
- package/src/radial-chart/radial-chart.ts +210 -0
- package/src/radial-chart/radial-rings.ts +328 -0
- package/src/radial-chart/shared.ts +114 -0
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
- package/dist/kit/chart-border.d.ts +0 -27
- package/dist/kit/chart-border.d.ts.map +0 -1
- package/dist/kit/chart-border.js +0 -28
- package/dist/kit/chart-border.js.map +0 -1
- package/dist/line-chart/horizontal-axis.d.ts +0 -79
- package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
- package/dist/line-chart/horizontal-axis.js +0 -129
- package/dist/line-chart/horizontal-axis.js.map +0 -1
- package/dist/pie-chart/pie-legend.d.ts.map +0 -1
- package/dist/pie-chart/pie-legend.js +0 -117
- package/dist/pie-chart/pie-legend.js.map +0 -1
- package/src/kit/chart-border.ts +0 -50
- package/src/line-chart/horizontal-axis.ts +0 -151
|
@@ -1,85 +1,77 @@
|
|
|
1
|
-
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
|
|
2
|
-
import { type
|
|
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. */
|
|
1
|
+
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps as _Node2DProps, type Fill as _Fill, type FillResolved as _FillResolved } from "@motionscript/sdk";
|
|
2
|
+
import { type PieLabelMode, type PieStyle } from "./shared.js";
|
|
36
3
|
export interface PieChartValues {
|
|
37
4
|
readonly data: DataRecord[];
|
|
38
5
|
readonly categoryField: string;
|
|
39
6
|
readonly valueField: string;
|
|
40
|
-
readonly
|
|
7
|
+
readonly style: PieStyle;
|
|
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
|
-
readonly
|
|
27
|
+
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
28
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
29
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
30
|
+
} & {
|
|
31
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
32
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
33
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
34
|
+
} & {
|
|
35
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
36
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
37
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
38
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
39
|
+
} & {
|
|
40
|
+
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
41
|
+
sliceGap: import("@motionscript/sdk").Type<number, number, false>;
|
|
42
|
+
sliceRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
43
|
+
} & {
|
|
44
|
+
labelPlacement: import("@motionscript/sdk").Type<"inside" | "outside" | "none", "inside" | "outside" | "none", false>;
|
|
45
|
+
}>, import("@motionscript/sdk").StyleValues<{
|
|
46
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
47
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
48
|
+
} & {
|
|
49
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
50
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
51
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
52
|
+
} & {
|
|
53
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
54
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
55
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
56
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
57
|
+
} & {
|
|
58
|
+
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
59
|
+
sliceGap: import("@motionscript/sdk").Type<number, number, false>;
|
|
60
|
+
sliceRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
61
|
+
} & {
|
|
62
|
+
labelPlacement: import("@motionscript/sdk").Type<"inside" | "outside" | "none", "inside" | "outside" | "none", false>;
|
|
63
|
+
}>, false>;
|
|
64
|
+
/** What the ring's labels say. */
|
|
69
65
|
readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
|
|
70
|
-
|
|
66
|
+
/** Gap between the ring and the legend, in px. */
|
|
71
67
|
readonly gap: 40;
|
|
68
|
+
/** Text set in the ring's hole. */
|
|
72
69
|
readonly centerLabel: "";
|
|
70
|
+
/** Smaller second line under `centerLabel`. */
|
|
73
71
|
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
|
-
*/
|
|
72
|
+
/** 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
73
|
readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
80
|
-
/** Read as the chart is built: the
|
|
81
|
-
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. */
|
|
74
|
+
/** 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
75
|
readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
84
76
|
}>, {
|
|
85
77
|
readonly enter: {};
|
|
@@ -94,45 +86,115 @@ export declare const PieChart: import("@motionscript/sdk").Component<"pieChart",
|
|
|
94
86
|
readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
95
87
|
};
|
|
96
88
|
readonly clearSelection: {};
|
|
97
|
-
}, readonly [], Node2D<
|
|
89
|
+
}, readonly [], Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
98
90
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
91
|
+
/** Slice caption, used on the labels and the legend. */
|
|
99
92
|
readonly categoryField: "";
|
|
93
|
+
/** Slice magnitude: the wedge's share of the ring. */
|
|
100
94
|
readonly valueField: "";
|
|
101
|
-
readonly
|
|
95
|
+
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
96
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
97
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
98
|
+
} & {
|
|
99
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
100
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
101
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
102
|
+
} & {
|
|
103
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
104
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
105
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
106
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
107
|
+
} & {
|
|
108
|
+
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
109
|
+
sliceGap: import("@motionscript/sdk").Type<number, number, false>;
|
|
110
|
+
sliceRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
111
|
+
} & {
|
|
112
|
+
labelPlacement: import("@motionscript/sdk").Type<"inside" | "outside" | "none", "inside" | "outside" | "none", false>;
|
|
113
|
+
}>, import("@motionscript/sdk").StyleValues<{
|
|
114
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
115
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
116
|
+
} & {
|
|
117
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
118
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
119
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
120
|
+
} & {
|
|
121
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
122
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
123
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
124
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
125
|
+
} & {
|
|
126
|
+
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
127
|
+
sliceGap: import("@motionscript/sdk").Type<number, number, false>;
|
|
128
|
+
sliceRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
129
|
+
} & {
|
|
130
|
+
labelPlacement: import("@motionscript/sdk").Type<"inside" | "outside" | "none", "inside" | "outside" | "none", false>;
|
|
131
|
+
}>, false>;
|
|
132
|
+
/** What the ring's labels say. */
|
|
102
133
|
readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
|
|
103
|
-
|
|
134
|
+
/** Gap between the ring and the legend, in px. */
|
|
104
135
|
readonly gap: 40;
|
|
136
|
+
/** Text set in the ring's hole. */
|
|
105
137
|
readonly centerLabel: "";
|
|
138
|
+
/** Smaller second line under `centerLabel`. */
|
|
106
139
|
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
|
-
*/
|
|
140
|
+
/** 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
141
|
readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
113
|
-
/** Read as the chart is built: the
|
|
114
|
-
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. */
|
|
142
|
+
/** 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
143
|
readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
117
144
|
}>, readonly [], import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
118
145
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
146
|
+
/** Slice caption, used on the labels and the legend. */
|
|
119
147
|
readonly categoryField: "";
|
|
148
|
+
/** Slice magnitude: the wedge's share of the ring. */
|
|
120
149
|
readonly valueField: "";
|
|
121
|
-
readonly
|
|
150
|
+
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
151
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
152
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
153
|
+
} & {
|
|
154
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
155
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
156
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
157
|
+
} & {
|
|
158
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
159
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
160
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
161
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
162
|
+
} & {
|
|
163
|
+
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
164
|
+
sliceGap: import("@motionscript/sdk").Type<number, number, false>;
|
|
165
|
+
sliceRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
166
|
+
} & {
|
|
167
|
+
labelPlacement: import("@motionscript/sdk").Type<"inside" | "outside" | "none", "inside" | "outside" | "none", false>;
|
|
168
|
+
}>, import("@motionscript/sdk").StyleValues<{
|
|
169
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
170
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
171
|
+
} & {
|
|
172
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
173
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
174
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
175
|
+
} & {
|
|
176
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
177
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
178
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
179
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
180
|
+
} & {
|
|
181
|
+
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
182
|
+
sliceGap: import("@motionscript/sdk").Type<number, number, false>;
|
|
183
|
+
sliceRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
184
|
+
} & {
|
|
185
|
+
labelPlacement: import("@motionscript/sdk").Type<"inside" | "outside" | "none", "inside" | "outside" | "none", false>;
|
|
186
|
+
}>, false>;
|
|
187
|
+
/** What the ring's labels say. */
|
|
122
188
|
readonly labelMode: import("@motionscript/sdk").Type<PieLabelMode, PieLabelMode, false>;
|
|
123
|
-
|
|
189
|
+
/** Gap between the ring and the legend, in px. */
|
|
124
190
|
readonly gap: 40;
|
|
191
|
+
/** Text set in the ring's hole. */
|
|
125
192
|
readonly centerLabel: "";
|
|
193
|
+
/** Smaller second line under `centerLabel`. */
|
|
126
194
|
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
|
-
*/
|
|
195
|
+
/** 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
196
|
readonly pops: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
133
|
-
/** Read as the chart is built: the
|
|
134
|
-
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. */
|
|
197
|
+
/** 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
198
|
readonly showCenter: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
137
199
|
}>, {
|
|
138
200
|
readonly enter: {};
|
|
@@ -147,6 +209,6 @@ export declare const PieChart: import("@motionscript/sdk").Component<"pieChart",
|
|
|
147
209
|
readonly sliceIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
148
210
|
};
|
|
149
211
|
readonly clearSelection: {};
|
|
150
|
-
}, Node2D<
|
|
212
|
+
}, Node2D<_Node2DProps>>>>;
|
|
151
213
|
export type PieChart = NodeOf<typeof PieChart>;
|
|
152
214
|
//# 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,EAChC,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EACnC,MAAM,mBAAmB,CAAA;AAO1B,OAAO,EASL,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACd,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,QAAQ,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CACxB;AAqBD,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzE;AA2BD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ;;IAIjB,wDAAwD;;IAExD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGtD,kCAAkC;;IAElC,kDAAkD;;IAElD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,kIAAkI;;IAElI,yJAAyJ;;;;;;;;;;;;;;;;;IAfzJ,wDAAwD;;IAExD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGtD,kCAAkC;;IAElC,kDAAkD;;IAElD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,kIAAkI;;IAElI,yJAAyJ;;;;IAfzJ,wDAAwD;;IAExD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGtD,kCAAkC;;IAElC,kDAAkD;;IAElD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,kIAAkI;;IAElI,yJAAyJ;;;;;;;;;;;;;;;0BA0H3J,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 {
|
|
5
|
-
import { PieLegend } from "./pie-legend.js";
|
|
4
|
+
import { PieLegend } from "../kit/pie-legend.js";
|
|
6
5
|
import { PieRing } from "./pie-ring.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* the legend arriving together. Shares of the whole, so they sum to 1.
|
|
11
|
-
*/
|
|
6
|
+
import { CHART_STYLE_FAMILY, CHART_STYLE_PRESETS, paletteFill } from "../kit/style.js";
|
|
7
|
+
import { PIE_SPOTLIGHT_DIM, PIE_STYLE_GROUPS, centerConfigOf, labelConfigOf, legendOf, resolvePieSlices, ringConfigOf, selectionFade, } from "./shared.js";
|
|
8
|
+
/** How `enter` divides its duration: wedges sweeping in, then labels and legend together. Sums to 1. */
|
|
12
9
|
const SWEEP_SHARE = 0.65;
|
|
13
10
|
const LABEL_SHARE = 0.35;
|
|
14
11
|
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
12
|
function slicesOf(s) {
|
|
17
|
-
return resolvePieSlices(s.data, s.categoryField, s.valueField, s.
|
|
13
|
+
return resolvePieSlices(s.data, s.categoryField, s.valueField, s.data.map((_, i) => paletteFill(s.style, i)));
|
|
18
14
|
}
|
|
19
|
-
/** How far slice `index` is pushed out, in `[0, 1]`. */
|
|
20
15
|
function popAt(s, index) {
|
|
21
|
-
return
|
|
16
|
+
return clamp(s.pops[index] ?? 0, 0, 1);
|
|
22
17
|
}
|
|
23
|
-
/** Whether slice `index` is
|
|
18
|
+
/** Whether slice `index` is past half way out, so a slice mid-swell is not yet counted. */
|
|
24
19
|
export function isSliceSelected(s, index) {
|
|
25
20
|
return popAt(s, index) > 0.5;
|
|
26
21
|
}
|
|
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
|
-
*/
|
|
22
|
+
/** Per-slice opacity: 1 while nothing is out and for the selected slice, falling toward `dimOpacity` for the rest as the selection grows. */
|
|
32
23
|
function sliceDims(s) {
|
|
33
24
|
let focus = 0;
|
|
34
25
|
for (let i = 0; i < s.data.length; i++)
|
|
35
26
|
focus = Math.max(focus, popAt(s, i));
|
|
36
|
-
|
|
37
|
-
if (focus <= 0)
|
|
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, PIE_SPOTLIGHT_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,101 +45,99 @@ 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
|
-
data: fresh(() => []),
|
|
59
|
+
data: fresh(() => [], { kind: "dataset" }),
|
|
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
|
+
style: Types.style(CHART_STYLE_FAMILY, PIE_STYLE_GROUPS, { presets: CHART_STYLE_PRESETS }),
|
|
65
|
+
/** What the ring's labels say. */
|
|
88
66
|
labelMode: Types.custom("percent"),
|
|
89
|
-
|
|
67
|
+
/** Gap between the ring and the legend, in px. */
|
|
90
68
|
gap: 40,
|
|
69
|
+
/** Text set in the ring's hole. */
|
|
91
70
|
centerLabel: "",
|
|
71
|
+
/** Smaller second line under `centerLabel`. */
|
|
92
72
|
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
|
-
*/
|
|
73
|
+
/** 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
74
|
pops: fresh(() => []),
|
|
99
|
-
/** Read as the chart is built: the
|
|
100
|
-
showLegend: Types.boolean(true, { animatable: false }),
|
|
101
|
-
/** Read as the chart is built: whether the hole's summary is drawn at rest. */
|
|
75
|
+
/** 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
76
|
showCenter: Types.boolean(true, { animatable: false }),
|
|
103
77
|
},
|
|
104
78
|
defaults: {
|
|
105
|
-
//
|
|
79
|
+
// A node made of parts that fill would otherwise hug them.
|
|
106
80
|
width: "fill",
|
|
107
81
|
height: "fill",
|
|
108
82
|
pops: (state) => slicesOf(state).map(() => 0),
|
|
109
83
|
},
|
|
110
84
|
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.
|
|
85
|
+
// 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
86
|
children: (state) => {
|
|
115
|
-
const
|
|
87
|
+
const style = () => state.style;
|
|
116
88
|
const slices = () => slicesOf(state);
|
|
117
89
|
const parts = [
|
|
118
90
|
new PieRing({
|
|
119
91
|
width: "fill",
|
|
120
92
|
height: "fill",
|
|
121
93
|
slices,
|
|
122
|
-
ring: () =>
|
|
123
|
-
label: () =>
|
|
124
|
-
centerStyle: () =>
|
|
94
|
+
ring: () => ringConfigOf(style()),
|
|
95
|
+
label: () => labelConfigOf(style()),
|
|
96
|
+
centerStyle: () => centerConfigOf(style()),
|
|
125
97
|
labelMode: state.labelMode,
|
|
126
|
-
labelPlacement: state.labelPlacement,
|
|
98
|
+
labelPlacement: state.style.labelPlacement,
|
|
127
99
|
pops: () => state.pops,
|
|
128
|
-
dimOpacity:
|
|
100
|
+
dimOpacity: PIE_SPOTLIGHT_DIM,
|
|
129
101
|
centerLabel: state.centerLabel,
|
|
130
102
|
centerCaption: state.centerCaption,
|
|
131
103
|
centerReveal: state.showCenter === false ? 0 : 1,
|
|
132
104
|
}),
|
|
133
105
|
];
|
|
134
|
-
|
|
135
|
-
|
|
106
|
+
const position = state.style.legend;
|
|
107
|
+
if (position !== "none") {
|
|
108
|
+
const side = position === "right";
|
|
109
|
+
const legend = new PieLegend({
|
|
136
110
|
slices,
|
|
137
|
-
legend: () =>
|
|
111
|
+
legend: () => legendOf(style()),
|
|
138
112
|
dims: () => sliceDims(state),
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
113
|
+
flow: side ? "vertical" : "horizontal",
|
|
114
|
+
align: "center",
|
|
115
|
+
// Spacing is fixed as built.
|
|
116
|
+
gap: side ? legendOf(state.style).itemGap / 3 : legendOf(state.style).itemGap,
|
|
117
|
+
padding: 0,
|
|
118
|
+
});
|
|
119
|
+
if (position === "top")
|
|
120
|
+
parts.unshift(legend);
|
|
121
|
+
else
|
|
122
|
+
parts.push(legend);
|
|
144
123
|
}
|
|
145
|
-
const row = new Rect({
|
|
124
|
+
const row = new Rect({
|
|
125
|
+
flow: position === "right" || position === "none" ? "horizontal" : "vertical",
|
|
126
|
+
width: "fill",
|
|
127
|
+
height: "fill",
|
|
128
|
+
gap: state.gap,
|
|
129
|
+
padding: 24,
|
|
130
|
+
align: "center",
|
|
131
|
+
fill: () => state.style.background,
|
|
132
|
+
children: parts,
|
|
133
|
+
});
|
|
146
134
|
return asParts([row]);
|
|
147
135
|
},
|
|
148
136
|
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
|
-
*/
|
|
137
|
+
/** 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
138
|
enter: {
|
|
156
139
|
args: {},
|
|
157
|
-
// Held from
|
|
140
|
+
// Held from arrival, so it never shows finished ahead of its draw.
|
|
158
141
|
entrance: true,
|
|
159
142
|
easing: easeOut(),
|
|
160
143
|
run: (timeline, _state, children) => {
|
|
@@ -174,11 +157,7 @@ export const PieChart = component2d({
|
|
|
174
157
|
]);
|
|
175
158
|
},
|
|
176
159
|
},
|
|
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
|
-
*/
|
|
160
|
+
/** Fade the hole's summary up. Not part of `enter`: it is usually the conclusion, which a scene lands on its own beat. */
|
|
182
161
|
revealCenter: {
|
|
183
162
|
args: {},
|
|
184
163
|
easing: easeOut(),
|