@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
package/dist/pie-chart/shared.js
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
+
import { Types } from "@motionscript/sdk";
|
|
2
|
+
import { CHART_COLORS, CHART_LEGEND, CHART_TEXT, legendConfigOf, } from "../kit/style.js";
|
|
3
|
+
import { num, text } from "../kit/shared.js";
|
|
4
|
+
import { DEG, PIE_SPOTLIGHT_DIM, ringPoint, selectionFade } from "../kit/polar.js";
|
|
5
|
+
export { DEG, PIE_SPOTLIGHT_DIM, ringPoint, selectionFade };
|
|
1
6
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The one chart in the family that draws **one mark per row** rather than one
|
|
7
|
-
* per column, which is why almost nothing about its geometry is shared: there is
|
|
8
|
-
* no scale, no axis and no baseline, only a circle divided by share. What it
|
|
9
|
-
* *does* share — the legend, the theme leaf resolvers, the palette, the
|
|
10
|
-
* percentage format — comes from `../kit/shared.ts`.
|
|
11
|
-
*
|
|
12
|
-
* Kept renderer-agnostic (no `Node` imports) so a host's inspector mapping
|
|
13
|
-
* can build a partial {@link PieChartTheme} without
|
|
14
|
-
* pulling the node classes in.
|
|
15
|
-
*/
|
|
16
|
-
import { lerpNumber, shadowOps, strokeOps, textOps, } from "@motionscript/sdk";
|
|
17
|
-
import { CHART_PALETTE, DEFAULT_LEGEND, DEFAULT_SERIES_FILLS, lerpLegendConfig, lerpSeriesFills, num, resolveLegendConfig, resolveSeriesFills, text, } from "../kit/shared.js";
|
|
18
|
-
/**
|
|
19
|
-
* Resolve tabular rows into slices: one per row, captioned by the `category`
|
|
20
|
-
* column, sized by the `value` column, painted from `palette` by row order
|
|
21
|
-
* (cycling when the palette is shorter than the data).
|
|
22
|
-
*
|
|
23
|
-
* Paint comes from the palette rather than from the rows because a pie draws one
|
|
24
|
-
* mark per *row* — unlike the line and bar charts, where a colour belongs to a
|
|
25
|
-
* series (a whole column) and rides on the series entry instead. Keeping it out
|
|
26
|
-
* of the rows is what lets a pie be fed straight from a CSV of plain numbers.
|
|
7
|
+
* One slice per row, painted from `palette` by row order (cycling). Paint comes
|
|
8
|
+
* from the palette, not the rows, because a pie's mark is a row where a line's
|
|
9
|
+
* colour belongs to a column; that lets a pie be fed a CSV of plain numbers.
|
|
27
10
|
*/
|
|
28
11
|
export function resolvePieSlices(data, category, value, palette) {
|
|
29
12
|
return data.map((row, i) => ({
|
|
@@ -32,13 +15,11 @@ export function resolvePieSlices(data, category, value, palette) {
|
|
|
32
15
|
fill: palette.length > 0 ? palette[i % palette.length] : "white",
|
|
33
16
|
}));
|
|
34
17
|
}
|
|
35
|
-
/** Degrees → radians. */
|
|
36
|
-
export const DEG = Math.PI / 180;
|
|
37
18
|
/** A slice's plotted value: negatives and non-finite values count as 0. */
|
|
38
19
|
export function sliceValue(slice) {
|
|
39
20
|
return slice.value > 0 && Number.isFinite(slice.value) ? slice.value : 0;
|
|
40
21
|
}
|
|
41
|
-
/** Sum of every slice's plotted value
|
|
22
|
+
/** Sum of every slice's plotted value, the denominator of every share. */
|
|
42
23
|
export function sliceTotal(slices) {
|
|
43
24
|
let sum = 0;
|
|
44
25
|
for (const slice of slices)
|
|
@@ -46,24 +27,10 @@ export function sliceTotal(slices) {
|
|
|
46
27
|
return sum;
|
|
47
28
|
}
|
|
48
29
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
|
|
53
|
-
export function ringPoint(r, a) {
|
|
54
|
-
return { x: r * Math.sin(a), y: r * Math.cos(a) };
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Resolve slices into per-slice arcs: each covers exactly its share of the
|
|
58
|
-
* circle, walking clockwise from `startDegrees` (0 = 12 o'clock), with the arcs
|
|
59
|
-
* abutting. Zero/negative slices are skipped entirely; an all-zero list yields
|
|
60
|
-
* no arcs.
|
|
61
|
-
*
|
|
62
|
-
* Arcs are the *undivided* shares — the gap between neighbours is not carved out
|
|
63
|
-
* here, because a fixed angular gap reads as a wedge: wide at the rim, pinched
|
|
64
|
-
* shut at the hole. It's applied when the wedge is drawn instead, as a
|
|
65
|
-
* constant-width inset off both ends of every arc, so a slice still covers its
|
|
66
|
-
* true percentage of the circle.
|
|
30
|
+
* One arc per positive slice, walking clockwise from `startDegrees` and abutting.
|
|
31
|
+
* Arcs are the undivided shares: a fixed angular gap would pinch shut at the
|
|
32
|
+
* hole, so the gap is applied when the wedge is drawn, as a constant-width inset
|
|
33
|
+
* off both ends.
|
|
67
34
|
*/
|
|
68
35
|
export function pieArcs(slices, startDegrees) {
|
|
69
36
|
const total = sliceTotal(slices);
|
|
@@ -84,16 +51,11 @@ export function pieArcs(slices, startDegrees) {
|
|
|
84
51
|
return arcs;
|
|
85
52
|
}
|
|
86
53
|
/**
|
|
87
|
-
* Spread one column of labels so
|
|
88
|
-
* `
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* `minGap`; if that pushes the tail past `bottom`, a reverse pass lifts it back
|
|
93
|
-
* up. When there are more labels than the column can hold, the reverse pass wins
|
|
94
|
-
* and the crowding is shared evenly rather than dumped off the bottom edge.
|
|
95
|
-
*
|
|
96
|
-
* Mutates each slot's `y` and returns `slots` re-ordered top-to-bottom.
|
|
54
|
+
* Spread one column of labels so none overlap, each near its `ideal` y and all
|
|
55
|
+
* inside `[bottom, top]`. A top-down pass clears each label from the one above
|
|
56
|
+
* by `minGap`; a reverse pass lifts a tail pushed past `bottom`. When the column
|
|
57
|
+
* cannot hold them all, the reverse pass wins and the crowding is shared evenly.
|
|
58
|
+
* Mutates each `y` and returns `slots` ordered top to bottom.
|
|
97
59
|
*/
|
|
98
60
|
export function relaxLabels(slots, minGap, top, bottom) {
|
|
99
61
|
slots.sort((a, b) => b.ideal - a.ideal);
|
|
@@ -109,138 +71,53 @@ export function relaxLabels(slots, minGap, top, bottom) {
|
|
|
109
71
|
}
|
|
110
72
|
return slots;
|
|
111
73
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
export const PIE_SPOTLIGHT_DIM = 0.1;
|
|
124
|
-
/** The pie chart's out-of-the-box look. */
|
|
125
|
-
export const DEFAULT_PIE_CHART_THEME = {
|
|
126
|
-
sliceFills: DEFAULT_SERIES_FILLS,
|
|
127
|
-
ring: {
|
|
128
|
-
gap: 6,
|
|
129
|
-
// A donut rather than a solid pie by default: the hole is the largest
|
|
130
|
-
// uninterrupted area the chart owns and the one place a conclusion can be
|
|
131
|
-
// set. `0` here would give that away before anyone had asked for it.
|
|
132
|
-
holeRadius: 0.6,
|
|
133
|
-
startAngle: 0,
|
|
134
|
-
selectedGrow: 1.08,
|
|
135
|
-
stroke: [],
|
|
136
|
-
shadow: [],
|
|
74
|
+
/** The groups of a pie's `style`: no grid, as nothing is ruled. */
|
|
75
|
+
export const PIE_STYLE_GROUPS = {
|
|
76
|
+
colors: CHART_COLORS,
|
|
77
|
+
text: CHART_TEXT,
|
|
78
|
+
marks: {
|
|
79
|
+
/** Hole radius as a fraction of the outer radius: 0 is a pie, about 0.6 a donut. */
|
|
80
|
+
innerRadius: Types.number(0, { min: 0, max: 0.9, step: 0.05 }),
|
|
81
|
+
/** Channel between neighbouring wedges, px. */
|
|
82
|
+
sliceGap: Types.number(3, { min: 0, max: 40, step: 1, unit: "px" }),
|
|
83
|
+
/** Rounding of each wedge corner, px. */
|
|
84
|
+
sliceRadius: Types.number(4, { min: 0, max: 60, step: 1, unit: "px" }),
|
|
137
85
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
// Inside labels sit on the wedge's paint, which is a mid-tone from the
|
|
142
|
-
// palette — so they lead with the panel colour rather than the axis ink.
|
|
143
|
-
insideStyle: { ...LABEL_TEXT_STYLE, fontWeight: 800, fill: "#15130e" },
|
|
144
|
-
leaderStroke: { weight: 2, fill: CHART_PALETTE.markerColor },
|
|
86
|
+
labels: {
|
|
87
|
+
/** Read as the chart is built: inside the wedge, outside on a leader, or none. */
|
|
88
|
+
labelPlacement: Types.oneOf(["inside", "outside", "none"], { animatable: false }),
|
|
145
89
|
},
|
|
146
|
-
|
|
147
|
-
labelStyle: {
|
|
148
|
-
fontSize: 46,
|
|
149
|
-
fontWeight: 800,
|
|
150
|
-
textAlign: "center",
|
|
151
|
-
fill: CHART_PALETTE.markerColor,
|
|
152
|
-
},
|
|
153
|
-
captionStyle: {
|
|
154
|
-
fontSize: 22,
|
|
155
|
-
fontWeight: 500,
|
|
156
|
-
textAlign: "center",
|
|
157
|
-
fill: CHART_PALETTE.markerColor,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
legend: DEFAULT_LEGEND,
|
|
161
|
-
spotlight: { dimOpacity: PIE_SPOTLIGHT_DIM },
|
|
90
|
+
legend: CHART_LEGEND,
|
|
162
91
|
};
|
|
163
|
-
function
|
|
164
|
-
return
|
|
165
|
-
gap: ring?.gap ?? previous.gap,
|
|
166
|
-
holeRadius: ring?.holeRadius ?? previous.holeRadius,
|
|
167
|
-
startAngle: ring?.startAngle ?? previous.startAngle,
|
|
168
|
-
selectedGrow: ring?.selectedGrow ?? previous.selectedGrow,
|
|
169
|
-
stroke: strokeOps.resolve(ring?.stroke ?? previous.stroke),
|
|
170
|
-
shadow: shadowOps.resolve(ring?.shadow ?? previous.shadow),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
function lerpRingConfig(from, to, t) {
|
|
174
|
-
return {
|
|
175
|
-
gap: lerpNumber(from.gap, to.gap, t),
|
|
176
|
-
holeRadius: lerpNumber(from.holeRadius, to.holeRadius, t),
|
|
177
|
-
startAngle: lerpNumber(from.startAngle, to.startAngle, t),
|
|
178
|
-
selectedGrow: lerpNumber(from.selectedGrow, to.selectedGrow, t),
|
|
179
|
-
stroke: strokeOps.lerp(from.stroke, to.stroke, t),
|
|
180
|
-
shadow: shadowOps.lerp(from.shadow, to.shadow, t),
|
|
181
|
-
};
|
|
92
|
+
export function legendOf(style) {
|
|
93
|
+
return legendConfigOf(style);
|
|
182
94
|
}
|
|
183
|
-
function
|
|
184
|
-
return {
|
|
185
|
-
textStyle: textOps.resolveStyle(label?.textStyle, previous.textStyle),
|
|
186
|
-
percentStyle: textOps.resolveStyle(label?.percentStyle, previous.percentStyle),
|
|
187
|
-
insideStyle: textOps.resolveStyle(label?.insideStyle, previous.insideStyle),
|
|
188
|
-
leaderStroke: strokeOps.resolve(label?.leaderStroke ?? previous.leaderStroke),
|
|
189
|
-
};
|
|
95
|
+
function face(style) {
|
|
96
|
+
return style.fontFamily ? { fontFamily: style.fontFamily } : {};
|
|
190
97
|
}
|
|
191
|
-
function
|
|
192
|
-
return {
|
|
193
|
-
textStyle: textOps.lerpStyle(from.textStyle, to.textStyle, t),
|
|
194
|
-
percentStyle: textOps.lerpStyle(from.percentStyle, to.percentStyle, t),
|
|
195
|
-
insideStyle: textOps.lerpStyle(from.insideStyle, to.insideStyle, t),
|
|
196
|
-
leaderStroke: strokeOps.lerp(from.leaderStroke, to.leaderStroke, t),
|
|
197
|
-
};
|
|
98
|
+
export function ringConfigOf(style) {
|
|
99
|
+
return { gap: style.sliceGap, holeRadius: style.innerRadius, startAngle: 0, selectedGrow: 1.08, cornerRadius: style.sliceRadius };
|
|
198
100
|
}
|
|
199
|
-
function
|
|
101
|
+
export function labelConfigOf(style) {
|
|
102
|
+
const base = { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign: "center", fill: style.muted };
|
|
103
|
+
const bold = Math.min(900, style.fontWeight + 200);
|
|
200
104
|
return {
|
|
201
|
-
|
|
202
|
-
|
|
105
|
+
textStyle: base,
|
|
106
|
+
percentStyle: { ...base, fontWeight: bold, fill: style.foreground },
|
|
107
|
+
insideStyle: { ...base, fontSize: Math.round(style.fontSize * 1.9), fontWeight: bold, fill: "#111113" },
|
|
108
|
+
leaderStroke: { weight: 2, fill: style.muted },
|
|
203
109
|
};
|
|
204
110
|
}
|
|
205
|
-
function
|
|
111
|
+
export function centerConfigOf(style) {
|
|
206
112
|
return {
|
|
207
|
-
labelStyle:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
* {@link PieChartTheme} onto `previous` (falling back to
|
|
214
|
-
* {@link DEFAULT_PIE_CHART_THEME} on first resolution), fully resolving every
|
|
215
|
-
* leaf so the tween below always has resolved data to interpolate.
|
|
216
|
-
*/
|
|
217
|
-
export function resolvePieChartTheme(theme, previous) {
|
|
218
|
-
const base = previous ?? DEFAULT_PIE_CHART_THEME;
|
|
219
|
-
return {
|
|
220
|
-
sliceFills: resolveSeriesFills(theme?.sliceFills, base.sliceFills),
|
|
221
|
-
ring: resolveRingConfig(theme?.ring, base.ring),
|
|
222
|
-
label: resolveLabelConfig(theme?.label, base.label),
|
|
223
|
-
center: resolveCenterConfig(theme?.center, base.center),
|
|
224
|
-
legend: resolveLegendConfig(theme?.legend, base.legend),
|
|
225
|
-
spotlight: {
|
|
226
|
-
dimOpacity: theme?.spotlight?.dimOpacity ?? base.spotlight.dimOpacity,
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
/** {@link PieChart}'s `theme` property tween — leaf by leaf. */
|
|
231
|
-
export function lerpPieChartTheme(from, to, t) {
|
|
232
|
-
return {
|
|
233
|
-
// A palette is a list of independent paints rather than one value, so it
|
|
234
|
-
// interpolates pairwise by index; one that grows or shrinks holds the longer
|
|
235
|
-
// side's tail, exactly as the cartesian charts' palettes do.
|
|
236
|
-
sliceFills: lerpSeriesFills(from.sliceFills, to.sliceFills, t),
|
|
237
|
-
ring: lerpRingConfig(from.ring, to.ring, t),
|
|
238
|
-
label: lerpLabelConfig(from.label, to.label, t),
|
|
239
|
-
center: lerpCenterConfig(from.center, to.center, t),
|
|
240
|
-
legend: lerpLegendConfig(from.legend, to.legend, t),
|
|
241
|
-
spotlight: {
|
|
242
|
-
dimOpacity: lerpNumber(from.spotlight.dimOpacity, to.spotlight.dimOpacity, t),
|
|
113
|
+
labelStyle: {
|
|
114
|
+
...face(style),
|
|
115
|
+
fontSize: Math.round(style.fontSize * 1.8),
|
|
116
|
+
fontWeight: Math.min(900, style.fontWeight + 300),
|
|
117
|
+
textAlign: "center",
|
|
118
|
+
fill: style.foreground,
|
|
243
119
|
},
|
|
120
|
+
captionStyle: { ...face(style), fontSize: Math.round(style.fontSize * 0.8), fontWeight: style.fontWeight, textAlign: "center", fill: style.muted },
|
|
244
121
|
};
|
|
245
122
|
}
|
|
246
123
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/pie-chart/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,GASR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,GAAG,EACH,mBAAmB,EACnB,kBAAkB,EAClB,IAAI,GAGL,MAAM,eAAe,CAAA;AAoBtB;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAkB,EAClB,QAAgB,EAChB,KAAa,EACb,OAAe;IAEf,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3B,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC;QAC7B,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;QACtB,IAAI,EACF,OAAO,CAAC,MAAM,G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,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3C,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/C,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,SAAS,EAAE;YACT,UAAU,EAAE,UAAU,CACpB,IAAI,CAAC,SAAS,CAAC,UAAU,EACzB,EAAE,CAAC,SAAS,CAAC,UAAU,EACvB,CAAC,CACF;SACF;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * Types and pure helpers specific to the {@link PieChart} family: how rows\n * become slices, how slices become arcs on a ring, where the labels around it\n * end up, and the theme all of that is drawn from.\n *\n * The one chart in the family that draws **one mark per row** rather than one\n * per column, which is why almost nothing about its geometry is shared: there is\n * no scale, no axis and no baseline, only a circle divided by share. What it\n * *does* share — the legend, the theme leaf resolvers, the palette, the\n * percentage format — comes from `../kit/shared.ts`.\n *\n * Kept renderer-agnostic (no `Node` imports) so a host's inspector mapping\n * can build a partial {@link PieChartTheme} without\n * pulling the node classes in.\n */\n\nimport {\n lerpNumber,\n shadowOps,\n strokeOps,\n textOps,\n type DataRecord,\n type Fill,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n type Vector2,\n} from \"@motionscript/sdk\"\n\nimport {\n CHART_PALETTE,\n DEFAULT_LEGEND,\n DEFAULT_SERIES_FILLS,\n lerpLegendConfig,\n lerpSeriesFills,\n num,\n resolveLegendConfig,\n resolveSeriesFills,\n text,\n type LegendConfig,\n type LegendTheme,\n} from \"../kit/shared\"\n\n/**\n * One **resolved** slice of a {@link PieChart}: its caption, its magnitude, and\n * the paint its wedge and legend swatch take.\n *\n * This is what the ring and the legend consume, not what a scene authors: the\n * chart takes tabular `data` plus two field names and resolves it into these, so\n * the parts stay unaware of where a slice's caption, magnitude and paint came\n * from.\n */\nexport interface PieSlice {\n /** Legend caption and label text for this slice. */\n category: string\n /** This slice's magnitude. Its wedge covers `value / (sum of all values)`. */\n value: number\n /** Wedge and swatch paint. */\n fill: Fill\n}\n\n/**\n * Resolve tabular rows into slices: one per row, captioned by the `category`\n * column, sized by the `value` column, painted from `palette` by row order\n * (cycling when the palette is shorter than the data).\n *\n * Paint comes from the palette rather than from the rows because a pie draws one\n * mark per *row* — unlike the line and bar charts, where a colour belongs to a\n * series (a whole column) and rides on the series entry instead. Keeping it out\n * of the rows is what lets a pie be fed straight from a CSV of plain numbers.\n */\nexport function resolvePieSlices(\n data: DataRecord[],\n category: string,\n value: string,\n palette: Fill[]\n): PieSlice[] {\n return data.map((row, i) => ({\n category: text(row, category),\n value: num(row, value),\n fill:\n palette.length > 0 ? palette[i % palette.length] : (\"white\" as Fill),\n }))\n}\n\n/** What a {@link PieChart}'s labels say. */\nexport type PieLabelMode =\n /**\n * The category and its percentage, two lines. Their order flips with the\n * placement: a **leader** label reads category over percentage, an **inside**\n * label reads the percentage big over a small category caption — inside a\n * wedge the reader already knows which slice they're on, so the magnitude is\n * the thing being read.\n */\n | \"both\"\n /** The category only. */\n | \"category\"\n /** The percentage only — the pick when a legend already names the categories. */\n | \"percent\"\n /** No labels and no leader lines at all. */\n | \"none\"\n\n/**\n * Where a slice's label sits.\n *\n * `\"inside\"` drops the leader line entirely and centres the label in the wedge's\n * own band, which costs no gutter — so the ring draws bigger — and costs the eye\n * no round trip. `\"leader\"` is the classic treatment, and what a sliver too\n * narrow to hold text needs.\n */\nexport type PieLabelPlacement = \"inside\" | \"leader\" | \"none\"\n\n/** Degrees → radians. */\nexport const DEG = Math.PI / 180\n\n/** A slice's plotted value: negatives and non-finite values count as 0. */\nexport function sliceValue(slice: PieSlice): number {\n return slice.value > 0 && Number.isFinite(slice.value) ? slice.value : 0\n}\n\n/** Sum of every slice's plotted value — the denominator every share is taken against. */\nexport function sliceTotal(slices: PieSlice[]): number {\n let sum = 0\n for (const slice of slices) sum += sliceValue(slice)\n return sum\n}\n\n/**\n * The point at radius `r` and angle `a` on a ring centred on the origin, in the\n * node's centred, **y-up** space. Angles run **clockwise from 12 o'clock**:\n * `a = 0` points straight up (+y), and increasing `a` sweeps toward +x then −y.\n */\nexport function ringPoint(r: number, a: number): Vector2 {\n return { x: r * Math.sin(a), y: r * Math.cos(a) }\n}\n\n/** One slice's resolved angular span on the ring. */\nexport interface PieArc {\n /** Index of the slice in the source list. */\n index: number\n /** Start angle, radians clockwise from 12 o'clock. */\n a0: number\n /** End angle, radians clockwise from 12 o'clock. */\n a1: number\n /** Bisector angle — where this slice's label and pop-out point. */\n mid: number\n /** This slice's share of the total, in `[0, 1]`. */\n fraction: number\n}\n\n/**\n * Resolve slices into per-slice arcs: each covers exactly its share of the\n * circle, walking clockwise from `startDegrees` (0 = 12 o'clock), with the arcs\n * abutting. Zero/negative slices are skipped entirely; an all-zero list yields\n * no arcs.\n *\n * Arcs are the *undivided* shares — the gap between neighbours is not carved out\n * here, because a fixed angular gap reads as a wedge: wide at the rim, pinched\n * shut at the hole. It's applied when the wedge is drawn instead, as a\n * constant-width inset off both ends of every arc, so a slice still covers its\n * true percentage of the circle.\n */\nexport function pieArcs(slices: PieSlice[], startDegrees: number): PieArc[] {\n const total = sliceTotal(slices)\n if (total <= 0) return []\n\n const arcs: PieArc[] = []\n let cursor = startDegrees * DEG\n slices.forEach((slice, index) => {\n const value = sliceValue(slice)\n if (value <= 0) return\n const fraction = value / total\n const a0 = cursor\n const a1 = a0 + fraction * Math.PI * 2\n cursor = a1\n arcs.push({ index, a0, a1, mid: (a0 + a1) / 2, fraction })\n })\n return arcs\n}\n\n/** A label competing for vertical space in one of the two label columns. */\nexport interface LabelSlot {\n /** Where the label would sit if nothing else were in the way. */\n ideal: number\n /** Where it ends up once the column has been de-conflicted. Written by {@link relaxLabels}. */\n y: number\n}\n\n/**\n * Spread one column of labels so no two overlap, keeping each as close to its\n * `ideal` y as possible and the whole column inside `[bottom, top]`.\n *\n * Two passes, the standard treatment. Walking top-to-bottom, each label takes\n * the highest slot at or below its ideal that still clears the label above it by\n * `minGap`; if that pushes the tail past `bottom`, a reverse pass lifts it back\n * up. When there are more labels than the column can hold, the reverse pass wins\n * and the crowding is shared evenly rather than dumped off the bottom edge.\n *\n * Mutates each slot's `y` and returns `slots` re-ordered top-to-bottom.\n */\nexport function relaxLabels<T extends LabelSlot>(\n slots: T[],\n minGap: number,\n top: number,\n bottom: number\n): T[] {\n slots.sort((a, b) => b.ideal - a.ideal)\n\n let ceiling = top\n for (const slot of slots) {\n slot.y = Math.min(slot.ideal, ceiling)\n ceiling = slot.y - minGap\n }\n\n let floor = bottom\n for (let i = slots.length - 1; i >= 0; i--) {\n slots[i].y = Math.max(slots[i].y, floor)\n floor = slots[i].y + minGap\n }\n\n return slots\n}\n\n// ---- Theme ---------------------------------------------------------------\n\n/** The ring's geometry and paint — everything about the wedges but their colour. */\nexport interface RingConfig {\n /**\n * Width of the channel between adjacent slices, in px, held constant all the\n * way across the band — the same clearance at the hole as at the rim. (An\n * angular gap would splay open toward the rim instead.)\n */\n gap: number\n /**\n * Radius of the hole punched through the middle. Below 1 it reads as a\n * fraction of the ring's outer radius (`0.6` leaves a band 40% of the radius\n * thick); 1 and up as an explicit pixel radius; `0` fills the middle in,\n * drawing solid pie wedges.\n */\n holeRadius: number\n /** Angle in degrees where the first slice begins, clockwise from 12 o'clock. */\n startAngle: number\n /**\n * How far out a selected slice's rim reaches, as a **multiple of the ring's\n * outer radius**. Being relative, the emphasis scales with the chart instead\n * of shrinking on a big one and swamping a small one. Clamped to `[1, 1.6]`.\n */\n selectedGrow: number\n /** Optional outline on every wedge. */\n stroke: Stroke\n /** Optional drop shadow on every wedge. */\n shadow: Shadow\n}\n\n/** How the ring's labels are set, and the leader lines that point at them. */\nexport interface LabelConfig {\n /** The category caption on a label. */\n textStyle: TextStyle\n /** The percentage on a label. */\n percentStyle: TextStyle\n /**\n * Ink for a label set **inside** its wedge, both lines. Separate because an\n * inside label sits on the wedge's own paint rather than on the background, so\n * it usually wants the opposite end of the value range from everything else.\n */\n insideStyle: TextStyle\n /** The leader line running from a wedge out to its label. */\n leaderStroke: Stroke\n}\n\n/** The summary set in the ring's hole. */\nexport interface CenterConfig {\n labelStyle: TextStyle\n captionStyle: TextStyle\n}\n\n/** A {@link PieChart}'s full, resolved visual theme. */\nexport interface PieChartConfig {\n /** Wedge and swatch paint, cycled by **row** index (`i % length`). */\n sliceFills: Fill[]\n ring: RingConfig\n label: LabelConfig\n center: CenterConfig\n legend: LegendConfig\n /** How far everything outside the selection fades while any slice is selected. */\n spotlight: { dimOpacity: number }\n}\n\n/** Author-facing partial theme — every branch optional and deep-merged. */\nexport type PieChartTheme = {\n sliceFills?: Fill[]\n ring?: Partial<RingConfig>\n label?: Partial<LabelConfig>\n center?: Partial<CenterConfig>\n legend?: LegendTheme\n spotlight?: Partial<PieChartConfig[\"spotlight\"]>\n}\n\nconst LABEL_TEXT_STYLE: TextStyle = {\n fontSize: 26,\n fontWeight: 600,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\n\n/**\n * Opacity the other slices fade to under a selection. Fainter than the line and\n * bar charts' `SPOTLIGHT_DIM`: a ring's slices touch, so at that a selected\n * slice barely separates from its neighbours.\n */\nexport const PIE_SPOTLIGHT_DIM = 0.1\n\n/** The pie chart's out-of-the-box look. */\nexport const DEFAULT_PIE_CHART_THEME: PieChartConfig = {\n sliceFills: DEFAULT_SERIES_FILLS,\n ring: {\n gap: 6,\n // A donut rather than a solid pie by default: the hole is the largest\n // uninterrupted area the chart owns and the one place a conclusion can be\n // set. `0` here would give that away before anyone had asked for it.\n holeRadius: 0.6,\n startAngle: 0,\n selectedGrow: 1.08,\n stroke: [],\n shadow: [],\n },\n label: {\n textStyle: LABEL_TEXT_STYLE,\n percentStyle: { ...LABEL_TEXT_STYLE, fontWeight: 700 },\n // Inside labels sit on the wedge's paint, which is a mid-tone from the\n // palette — so they lead with the panel colour rather than the axis ink.\n insideStyle: { ...LABEL_TEXT_STYLE, fontWeight: 800, fill: \"#15130e\" },\n leaderStroke: { weight: 2, fill: CHART_PALETTE.markerColor },\n },\n center: {\n labelStyle: {\n fontSize: 46,\n fontWeight: 800,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n },\n captionStyle: {\n fontSize: 22,\n fontWeight: 500,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n },\n },\n legend: DEFAULT_LEGEND,\n spotlight: { dimOpacity: PIE_SPOTLIGHT_DIM },\n}\n\nfunction resolveRingConfig(\n ring: Partial<RingConfig> | undefined,\n previous: RingConfig\n): RingConfig {\n return {\n gap: ring?.gap ?? previous.gap,\n holeRadius: ring?.holeRadius ?? previous.holeRadius,\n startAngle: ring?.startAngle ?? previous.startAngle,\n selectedGrow: ring?.selectedGrow ?? previous.selectedGrow,\n stroke: strokeOps.resolve(ring?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(ring?.shadow ?? previous.shadow),\n }\n}\n\nfunction lerpRingConfig(\n from: RingConfig,\n to: RingConfig,\n t: number\n): RingConfig {\n return {\n gap: lerpNumber(from.gap, to.gap, t),\n holeRadius: lerpNumber(from.holeRadius, to.holeRadius, t),\n startAngle: lerpNumber(from.startAngle, to.startAngle, t),\n selectedGrow: lerpNumber(from.selectedGrow, to.selectedGrow, t),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\nfunction resolveLabelConfig(\n label: Partial<LabelConfig> | undefined,\n previous: LabelConfig\n): LabelConfig {\n return {\n textStyle: textOps.resolveStyle(label?.textStyle, previous.textStyle),\n percentStyle: textOps.resolveStyle(\n label?.percentStyle,\n previous.percentStyle\n ),\n insideStyle: textOps.resolveStyle(label?.insideStyle, previous.insideStyle),\n leaderStroke: strokeOps.resolve(\n label?.leaderStroke ?? previous.leaderStroke\n ),\n }\n}\n\nfunction lerpLabelConfig(\n from: LabelConfig,\n to: LabelConfig,\n t: number\n): LabelConfig {\n return {\n textStyle: textOps.lerpStyle(from.textStyle, to.textStyle, t),\n percentStyle: textOps.lerpStyle(from.percentStyle, to.percentStyle, t),\n insideStyle: textOps.lerpStyle(from.insideStyle, to.insideStyle, t),\n leaderStroke: strokeOps.lerp(\n from.leaderStroke as StrokeResolved[],\n to.leaderStroke as StrokeResolved[],\n t\n ),\n }\n}\n\nfunction resolveCenterConfig(\n center: Partial<CenterConfig> | undefined,\n previous: CenterConfig\n): CenterConfig {\n return {\n labelStyle: textOps.resolveStyle(center?.labelStyle, previous.labelStyle),\n captionStyle: textOps.resolveStyle(\n center?.captionStyle,\n previous.captionStyle\n ),\n }\n}\n\nfunction lerpCenterConfig(\n from: CenterConfig,\n to: CenterConfig,\n t: number\n): CenterConfig {\n return {\n labelStyle: textOps.lerpStyle(from.labelStyle, to.labelStyle, t),\n captionStyle: textOps.lerpStyle(from.captionStyle, to.captionStyle, t),\n }\n}\n\n/**\n * {@link PieChart}'s `theme` property mapper: merges the author's partial\n * {@link PieChartTheme} onto `previous` (falling back to\n * {@link DEFAULT_PIE_CHART_THEME} on first resolution), fully resolving every\n * leaf so the tween below always has resolved data to interpolate.\n */\nexport function resolvePieChartTheme(\n theme: PieChartTheme | undefined,\n previous?: PieChartConfig\n): PieChartConfig {\n const base = previous ?? DEFAULT_PIE_CHART_THEME\n return {\n sliceFills: resolveSeriesFills(theme?.sliceFills, base.sliceFills),\n ring: resolveRingConfig(theme?.ring, base.ring),\n label: resolveLabelConfig(theme?.label, base.label),\n center: resolveCenterConfig(theme?.center, base.center),\n legend: resolveLegendConfig(theme?.legend, base.legend),\n spotlight: {\n dimOpacity: theme?.spotlight?.dimOpacity ?? base.spotlight.dimOpacity,\n },\n }\n}\n\n/** {@link PieChart}'s `theme` property tween — leaf by leaf. */\nexport function lerpPieChartTheme(\n from: PieChartConfig,\n to: PieChartConfig,\n t: number\n): PieChartConfig {\n return {\n // A palette is a list of independent paints rather than one value, so it\n // interpolates pairwise by index; one that grows or shrinks holds the longer\n // side's tail, exactly as the cartesian charts' palettes do.\n sliceFills: lerpSeriesFills(from.sliceFills, to.sliceFills, t),\n ring: lerpRingConfig(from.ring, to.ring, t),\n label: lerpLabelConfig(from.label, to.label, t),\n center: lerpCenterConfig(from.center, to.center, t),\n legend: lerpLegendConfig(from.legend, to.legend, t),\n spotlight: {\n dimOpacity: lerpNumber(\n from.spotlight.dimOpacity,\n to.spotlight.dimOpacity,\n t\n ),\n },\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/pie-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA8E,MAAM,mBAAmB,CAAA;AAErH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,GAEf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAqB,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAoC,MAAM,cAAc,CAAA;AAEjH,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAoC,CAAA;AAE7F;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAwC,EAAE,QAAgB,EAAE,KAAa,EAAE,OAAwB;IAClI,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3B,QAAQ,EAAE,IAAI,CAAC,GAAY,EAAE,QAAQ,CAAC;QACtC,KAAK,EAAE,GAAG,CAAC,GAAY,EAAE,KAAK,CAAC;QAC/B,IAAI,EAAE,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AAI,EAAE,KAAK,CAAC,KAAK,EAAE;KACnJ,CAAA;AACH,CAAC","sourcesContent":["import { Types, type Fill, type TextStyle, type Stroke, type FillResolved as _FillResolved } from \"@motionscript/sdk\"\n\nimport {\n CHART_COLORS,\n CHART_LEGEND,\n CHART_TEXT,\n legendConfigOf,\n type ChartStyleBase,\n} from \"../kit/style\"\nimport { num, text, type LegendConfig } from \"../kit/shared\"\nimport { DEG, PIE_SPOTLIGHT_DIM, ringPoint, selectionFade, type CenterConfig, type PieSlice } from \"../kit/polar\"\n\nexport { DEG, PIE_SPOTLIGHT_DIM, ringPoint, selectionFade, type CenterConfig, type PieSlice }\n\n/**\n * One slice per row, painted from `palette` by row order (cycling). Paint comes\n * from the palette, not the rows, because a pie's mark is a row where a line's\n * colour belongs to a column; that lets a pie be fed a CSV of plain numbers.\n */\nexport function resolvePieSlices(data: readonly Record<string, unknown>[], category: string, value: string, palette: readonly Fill[]): PieSlice[] {\n return data.map((row, i) => ({\n category: text(row as never, category),\n value: num(row as never, value),\n fill: palette.length > 0 ? palette[i % palette.length] : (\"white\" as Fill),\n }))\n}\n\n/** What a {@link PieChart}'s labels say. */\nexport type PieLabelMode =\n /** Two lines, whose order flips with placement: an outside label reads category over percentage, an inside label reads the percentage big over a small category. */\n | \"both\"\n | \"category\"\n | \"percent\"\n /** No labels and no leader lines. */\n | \"none\"\n\n/** `\"inside\"` centres the label in the wedge's band with no leader or gutter, so the ring draws bigger; `\"outside\"` sets it on a leader, which a sliver too narrow for text needs. */\nexport type PieLabelPlacement = \"inside\" | \"outside\" | \"none\"\n\n\n/** A slice's plotted value: negatives and non-finite values count as 0. */\nexport function sliceValue(slice: PieSlice): number {\n return slice.value > 0 && Number.isFinite(slice.value) ? slice.value : 0\n}\n\n/** Sum of every slice's plotted value, the denominator of every share. */\nexport function sliceTotal(slices: PieSlice[]): number {\n let sum = 0\n for (const slice of slices) sum += sliceValue(slice)\n return sum\n}\n\n/** One slice's resolved angular span on the ring. */\nexport interface PieArc {\n /** Index of the slice in the source list. */\n index: number\n /** Radians clockwise from 12 o'clock. */\n a0: number\n a1: number\n /** Where the slice's label and pop-out point. */\n mid: number\n /** Share of the total, `[0, 1]`. */\n fraction: number\n}\n\n/**\n * One arc per positive slice, walking clockwise from `startDegrees` and abutting.\n * Arcs are the undivided shares: a fixed angular gap would pinch shut at the\n * hole, so the gap is applied when the wedge is drawn, as a constant-width inset\n * off both ends.\n */\nexport function pieArcs(slices: PieSlice[], startDegrees: number): PieArc[] {\n const total = sliceTotal(slices)\n if (total <= 0) return []\n\n const arcs: PieArc[] = []\n let cursor = startDegrees * DEG\n slices.forEach((slice, index) => {\n const value = sliceValue(slice)\n if (value <= 0) return\n const fraction = value / total\n const a0 = cursor\n const a1 = a0 + fraction * Math.PI * 2\n cursor = a1\n arcs.push({ index, a0, a1, mid: (a0 + a1) / 2, fraction })\n })\n return arcs\n}\n\ninterface LabelSlot {\n /** Where the label would sit if nothing else were in the way. */\n ideal: number\n /** Written by {@link relaxLabels}. */\n y: number\n}\n\n/**\n * Spread one column of labels so none overlap, each near its `ideal` y and all\n * inside `[bottom, top]`. A top-down pass clears each label from the one above\n * by `minGap`; a reverse pass lifts a tail pushed past `bottom`. When the column\n * cannot hold them all, the reverse pass wins and the crowding is shared evenly.\n * Mutates each `y` and returns `slots` ordered top to bottom.\n */\nexport function relaxLabels<T extends LabelSlot>(slots: T[], minGap: number, top: number, bottom: number): T[] {\n slots.sort((a, b) => b.ideal - a.ideal)\n\n let ceiling = top\n for (const slot of slots) {\n slot.y = Math.min(slot.ideal, ceiling)\n ceiling = slot.y - minGap\n }\n\n let floor = bottom\n for (let i = slots.length - 1; i >= 0; i--) {\n slots[i].y = Math.max(slots[i].y, floor)\n floor = slots[i].y + minGap\n }\n\n return slots\n}\n\n/** The ring's geometry: everything about the wedges but their colour. */\nexport interface RingConfig {\n /** Channel between adjacent slices in px, constant across the band (an angular gap would splay open toward the rim). */\n gap: number\n /** Below 1 a fraction of the outer radius (`0.6` leaves a band 40% thick); 1 and up a pixel radius; `0` draws solid wedges. */\n holeRadius: number\n /** Degrees clockwise from 12 o'clock where the first slice begins. */\n startAngle: number\n /** How far a selected slice's rim reaches, as a multiple of the outer radius so the emphasis scales with the chart. Clamped to `[1, 1.6]`. */\n selectedGrow: number\n /** Rounding of each wedge corner, px. */\n cornerRadius: number\n}\n\n/** How the ring's labels are set, and the leader lines that point at them. */\nexport interface LabelConfig {\n /** The category caption outside the ring. */\n textStyle: TextStyle\n /** The percentage outside the ring. */\n percentStyle: TextStyle\n /** Both lines of a label inside its wedge; its fill is set per wedge, for contrast against the paint. */\n insideStyle: TextStyle\n /** Runs from a wedge out to its label. */\n leaderStroke: Stroke\n}\n\n/** What a pie's `style` resolves to. */\nexport interface PieStyle extends ChartStyleBase {\n readonly innerRadius: number\n readonly sliceGap: number\n readonly sliceRadius: number\n readonly labelPlacement: PieLabelPlacement\n}\n\n/** The groups of a pie's `style`: no grid, as nothing is ruled. */\nexport const PIE_STYLE_GROUPS = {\n colors: CHART_COLORS,\n text: CHART_TEXT,\n marks: {\n /** Hole radius as a fraction of the outer radius: 0 is a pie, about 0.6 a donut. */\n innerRadius: Types.number(0, { min: 0, max: 0.9, step: 0.05 }),\n /** Channel between neighbouring wedges, px. */\n sliceGap: Types.number(3, { min: 0, max: 40, step: 1, unit: \"px\" }),\n /** Rounding of each wedge corner, px. */\n sliceRadius: Types.number(4, { min: 0, max: 60, step: 1, unit: \"px\" }),\n },\n labels: {\n /** Read as the chart is built: inside the wedge, outside on a leader, or none. */\n labelPlacement: Types.oneOf([\"inside\", \"outside\", \"none\"] as const, { animatable: false }),\n },\n legend: CHART_LEGEND,\n}\n\nexport function legendOf(style: PieStyle): LegendConfig {\n return legendConfigOf(style)\n}\n\nfunction face(style: PieStyle): Pick<TextStyle, \"fontFamily\"> {\n return style.fontFamily ? { fontFamily: style.fontFamily } : {}\n}\n\nexport function ringConfigOf(style: PieStyle): RingConfig {\n return { gap: style.sliceGap, holeRadius: style.innerRadius, startAngle: 0, selectedGrow: 1.08, cornerRadius: style.sliceRadius }\n}\n\nexport function labelConfigOf(style: PieStyle): LabelConfig {\n const base: TextStyle = { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign: \"center\", fill: style.muted }\n const bold = Math.min(900, style.fontWeight + 200)\n return {\n textStyle: base,\n percentStyle: { ...base, fontWeight: bold, fill: style.foreground },\n insideStyle: { ...base, fontSize: Math.round(style.fontSize * 1.9), fontWeight: bold, fill: \"#111113\" },\n leaderStroke: { weight: 2, fill: style.muted },\n }\n}\n\nexport function centerConfigOf(style: PieStyle): CenterConfig {\n return {\n labelStyle: {\n ...face(style),\n fontSize: Math.round(style.fontSize * 1.8),\n fontWeight: Math.min(900, style.fontWeight + 300),\n textAlign: \"center\",\n fill: style.foreground,\n },\n captionStyle: { ...face(style), fontSize: Math.round(style.fontSize * 0.8), fontWeight: style.fontWeight, textAlign: \"center\", fill: style.muted },\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { RadarChart, radarFractions, radarScale, type RadarValues } from "./radar-chart.js";
|
|
2
|
+
export { RadarGrid } from "./radar-grid.js";
|
|
3
|
+
export { RadarSeries, seriesVertices } from "./radar-series.js";
|
|
4
|
+
export { RADAR_GRID, RADAR_MARKS, fitRadius, niceCeil, spokeDirection } from "./shared.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/radar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { RadarChart, radarFractions, radarScale } from "./radar-chart.js";
|
|
2
|
+
export { RadarGrid } from "./radar-grid.js";
|
|
3
|
+
export { RadarSeries, seriesVertices } from "./radar-series.js";
|
|
4
|
+
export { RADAR_GRID, RADAR_MARKS, fitRadius, niceCeil, spokeDirection } from "./shared.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/radar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAA;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA","sourcesContent":["export { RadarChart, radarFractions, radarScale, type RadarValues } from \"./radar-chart\"\nexport { RadarGrid } from \"./radar-grid\"\nexport { RadarSeries, seriesVertices } from \"./radar-series\"\nexport { RADAR_GRID, RADAR_MARKS, fitRadius, niceCeil, spokeDirection } from \"./shared\"\n"]}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps as _Node2DProps, type Fill as _Fill, type FillResolved as _FillResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
|
+
import { type ChartSeries } from "../kit/shared.js";
|
|
3
|
+
/** What a radar chart plots, as its entries hold it. */
|
|
4
|
+
export interface RadarValues {
|
|
5
|
+
readonly data: DataRecord[];
|
|
6
|
+
readonly categoryField: string;
|
|
7
|
+
readonly series: ChartSeries[];
|
|
8
|
+
readonly min: number;
|
|
9
|
+
readonly max: number;
|
|
10
|
+
}
|
|
11
|
+
/** The scale the web is drawn to, whether `max` was given or left to the data. */
|
|
12
|
+
export declare function radarScale(state: RadarValues): {
|
|
13
|
+
min: number;
|
|
14
|
+
max: number;
|
|
15
|
+
};
|
|
16
|
+
/** Series `index`'s values as fractions of the rim, in spoke order. */
|
|
17
|
+
export declare function radarFractions(state: RadarValues, index: number): number[];
|
|
18
|
+
/**
|
|
19
|
+
* A radar (spider) chart: one spoke per data row, one closed polygon per
|
|
20
|
+
* series, over a web of rings. Composed of a {@link RadarGrid}, a
|
|
21
|
+
* {@link RadarSeries} per series, the category labels and a {@link ChartLegend}.
|
|
22
|
+
*
|
|
23
|
+
* Resting state is the finished chart; `enter` arms every part on its first
|
|
24
|
+
* frame. `max` of 0 (or one not above `min`) is the largest value rounded up.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RadarChart: import("@motionscript/sdk").Component<"radarChart", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
27
|
+
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
28
|
+
/** The column that names each spoke. */
|
|
29
|
+
readonly categoryField: "";
|
|
30
|
+
readonly series: import("@motionscript/sdk").Type<ChartSeries[], ChartSeries[], false>;
|
|
31
|
+
/** The value at the centre of the web. */
|
|
32
|
+
readonly min: 0;
|
|
33
|
+
/** The value at the rim; 0 rounds the largest value up. */
|
|
34
|
+
readonly max: 0;
|
|
35
|
+
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
36
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
37
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
38
|
+
} & {
|
|
39
|
+
gridShape: import("@motionscript/sdk").Type<"circle" | "polygon", "circle" | "polygon", false>;
|
|
40
|
+
gridLevels: import("@motionscript/sdk").Type<number, number, false>;
|
|
41
|
+
gridStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
42
|
+
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
43
|
+
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
44
|
+
} & {
|
|
45
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
46
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
47
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
48
|
+
} & {
|
|
49
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
50
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
51
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
52
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
53
|
+
} & {
|
|
54
|
+
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
55
|
+
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
56
|
+
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
57
|
+
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
58
|
+
}>, import("@motionscript/sdk").StyleValues<{
|
|
59
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
60
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
61
|
+
} & {
|
|
62
|
+
gridShape: import("@motionscript/sdk").Type<"circle" | "polygon", "circle" | "polygon", false>;
|
|
63
|
+
gridLevels: import("@motionscript/sdk").Type<number, number, false>;
|
|
64
|
+
gridStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
65
|
+
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
66
|
+
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
67
|
+
} & {
|
|
68
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
69
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
70
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
71
|
+
} & {
|
|
72
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
73
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
74
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
75
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
76
|
+
} & {
|
|
77
|
+
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
78
|
+
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
79
|
+
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
80
|
+
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
81
|
+
}>, false>;
|
|
82
|
+
}>, {
|
|
83
|
+
readonly enter: {};
|
|
84
|
+
readonly showSeries: {
|
|
85
|
+
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
86
|
+
};
|
|
87
|
+
readonly hideSeries: {
|
|
88
|
+
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
89
|
+
};
|
|
90
|
+
readonly spotlightSeries: {
|
|
91
|
+
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
92
|
+
};
|
|
93
|
+
}, readonly [], Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
94
|
+
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
95
|
+
/** The column that names each spoke. */
|
|
96
|
+
readonly categoryField: "";
|
|
97
|
+
readonly series: import("@motionscript/sdk").Type<ChartSeries[], ChartSeries[], false>;
|
|
98
|
+
/** The value at the centre of the web. */
|
|
99
|
+
readonly min: 0;
|
|
100
|
+
/** The value at the rim; 0 rounds the largest value up. */
|
|
101
|
+
readonly max: 0;
|
|
102
|
+
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
103
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
104
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
105
|
+
} & {
|
|
106
|
+
gridShape: import("@motionscript/sdk").Type<"circle" | "polygon", "circle" | "polygon", false>;
|
|
107
|
+
gridLevels: import("@motionscript/sdk").Type<number, number, false>;
|
|
108
|
+
gridStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
109
|
+
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
110
|
+
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
111
|
+
} & {
|
|
112
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
113
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
114
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
115
|
+
} & {
|
|
116
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
117
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
118
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
119
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
120
|
+
} & {
|
|
121
|
+
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
122
|
+
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
123
|
+
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
124
|
+
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
125
|
+
}>, import("@motionscript/sdk").StyleValues<{
|
|
126
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
127
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
128
|
+
} & {
|
|
129
|
+
gridShape: import("@motionscript/sdk").Type<"circle" | "polygon", "circle" | "polygon", false>;
|
|
130
|
+
gridLevels: import("@motionscript/sdk").Type<number, number, false>;
|
|
131
|
+
gridStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
132
|
+
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
133
|
+
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
134
|
+
} & {
|
|
135
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
136
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
137
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
138
|
+
} & {
|
|
139
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
140
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
141
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
142
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
143
|
+
} & {
|
|
144
|
+
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
145
|
+
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
146
|
+
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
147
|
+
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
148
|
+
}>, false>;
|
|
149
|
+
}>, readonly [], import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
150
|
+
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
151
|
+
/** The column that names each spoke. */
|
|
152
|
+
readonly categoryField: "";
|
|
153
|
+
readonly series: import("@motionscript/sdk").Type<ChartSeries[], ChartSeries[], false>;
|
|
154
|
+
/** The value at the centre of the web. */
|
|
155
|
+
readonly min: 0;
|
|
156
|
+
/** The value at the rim; 0 rounds the largest value up. */
|
|
157
|
+
readonly max: 0;
|
|
158
|
+
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
159
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
160
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
161
|
+
} & {
|
|
162
|
+
gridShape: import("@motionscript/sdk").Type<"circle" | "polygon", "circle" | "polygon", false>;
|
|
163
|
+
gridLevels: import("@motionscript/sdk").Type<number, number, false>;
|
|
164
|
+
gridStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
165
|
+
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
166
|
+
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
167
|
+
} & {
|
|
168
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
169
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
170
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
171
|
+
} & {
|
|
172
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
173
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
174
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
175
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
176
|
+
} & {
|
|
177
|
+
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
178
|
+
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
179
|
+
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
180
|
+
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
181
|
+
}>, import("@motionscript/sdk").StyleValues<{
|
|
182
|
+
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
183
|
+
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
184
|
+
} & {
|
|
185
|
+
gridShape: import("@motionscript/sdk").Type<"circle" | "polygon", "circle" | "polygon", false>;
|
|
186
|
+
gridLevels: import("@motionscript/sdk").Type<number, number, false>;
|
|
187
|
+
gridStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
188
|
+
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
189
|
+
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
190
|
+
} & {
|
|
191
|
+
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
192
|
+
fontSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
193
|
+
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
194
|
+
} & {
|
|
195
|
+
palette: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
196
|
+
foreground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
197
|
+
muted: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
198
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
199
|
+
} & {
|
|
200
|
+
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
201
|
+
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
202
|
+
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
203
|
+
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
204
|
+
}>, false>;
|
|
205
|
+
}>, {
|
|
206
|
+
readonly enter: {};
|
|
207
|
+
readonly showSeries: {
|
|
208
|
+
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
209
|
+
};
|
|
210
|
+
readonly hideSeries: {
|
|
211
|
+
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
212
|
+
};
|
|
213
|
+
readonly spotlightSeries: {
|
|
214
|
+
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
215
|
+
};
|
|
216
|
+
}, Node2D<_Node2DProps>>>>;
|
|
217
|
+
export type RadarChart = NodeOf<typeof RadarChart>;
|
|
218
|
+
//# sourceMappingURL=radar-chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radar-chart.d.ts","sourceRoot":"","sources":["../../src/radar-chart/radar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,UAAU,EACf,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EAGvC,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAyB/D,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAA;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAA;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,KAAK,EAAE,WA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