@motionscript/charts 0.1.1-alpha.1 → 0.1.1-alpha.2
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 +15 -0
- package/README.md +19 -8
- package/dist/bar-chart/bar-chart.d.ts +97 -65
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +9 -5
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +29 -5
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +33 -8
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +9 -4
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +10 -5
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-7XCRX6GE.js +2 -0
- package/dist/browser/chunks/chunk-7XCRX6GE.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/kit/cartesian.d.ts +6 -4
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +5 -3
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/style.d.ts +339 -76
- package/dist/kit/style.d.ts.map +1 -1
- package/dist/kit/style.js +196 -101
- package/dist/kit/style.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +81 -57
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +9 -7
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +43 -43
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +2 -1
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +15 -8
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +21 -20
- package/dist/pie-chart/shared.js.map +1 -1
- package/dist/radar-chart/index.d.ts +1 -1
- package/dist/radar-chart/index.d.ts.map +1 -1
- package/dist/radar-chart/index.js +1 -1
- package/dist/radar-chart/index.js.map +1 -1
- package/dist/radar-chart/radar-chart.d.ts +37 -43
- package/dist/radar-chart/radar-chart.d.ts.map +1 -1
- package/dist/radar-chart/radar-chart.js +12 -12
- package/dist/radar-chart/radar-chart.js.map +1 -1
- package/dist/radar-chart/radar-grid.d.ts +7 -1
- package/dist/radar-chart/radar-grid.d.ts.map +1 -1
- package/dist/radar-chart/radar-grid.js +17 -15
- package/dist/radar-chart/radar-grid.js.map +1 -1
- package/dist/radar-chart/shared.d.ts +7 -2
- package/dist/radar-chart/shared.d.ts.map +1 -1
- package/dist/radar-chart/shared.js +6 -0
- package/dist/radar-chart/shared.js.map +1 -1
- package/dist/radial-chart/radial-chart.d.ts +37 -43
- package/dist/radial-chart/radial-chart.d.ts.map +1 -1
- package/dist/radial-chart/radial-chart.js +2 -1
- package/dist/radial-chart/radial-chart.js.map +1 -1
- package/dist/radial-chart/shared.d.ts +13 -9
- package/dist/radial-chart/shared.d.ts.map +1 -1
- package/dist/radial-chart/shared.js +15 -16
- package/dist/radial-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +17 -6
- package/src/bar-chart/chart-bars.ts +48 -9
- package/src/bar-chart/shared.ts +20 -5
- package/src/kit/cartesian.ts +10 -7
- package/src/kit/style.ts +214 -118
- package/src/line-chart/line-chart.ts +14 -8
- package/src/pie-chart/pie-chart.ts +3 -1
- package/src/pie-chart/shared.ts +30 -22
- package/src/radar-chart/index.ts +1 -1
- package/src/radar-chart/radar-chart.ts +16 -13
- package/src/radar-chart/radar-grid.ts +18 -13
- package/src/radar-chart/shared.ts +9 -2
- package/src/radial-chart/radial-chart.ts +3 -1
- package/src/radial-chart/shared.ts +30 -18
- package/dist/browser/chunks/chunk-R3Q5EE6E.js +0 -2
- package/dist/browser/chunks/chunk-R3Q5EE6E.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/pie-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAErH,OAAO,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/pie-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAErH,OAAO,EAUL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEjH,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,CAAA;AAE7F;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,IAAI,EAAE,GAAG,QAAQ,EAAE,CAMhJ;AAED,4CAA4C;AAC5C,MAAM,MAAM,YAAY;AACtB,oKAAoK;AAClK,MAAM,GACN,UAAU,GACV,SAAS;AACX,qCAAqC;GACnC,MAAM,CAAA;AAEV,sLAAsL;AACtL,MAAM,MAAM,iBA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ACpB,uCAAuC;IACvC,YAAY,EAAE,SAAS,CAAA;IACvB,yGAAyG;IACzG,WAAW,EAAE,SAAS,CAAA;IACtB,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,wCAAwC;AACxC,MAAM,WAAW,QAAS,SAAQ,cAAc;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAA;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAAA;CAC3C;AAED,mEAAmE;AACnE,eAAO,MAAM,gBAAgB;;;;;;;;;QAIzB,yBAAyB;;QAEzB,4GAA4G;;QAE5G,oFAAoF;;;;QAKpF,oFAAoF;;QAEpF,+CAA+C;;QAE/C,yCAAyC;;;;QAIzC,kFAAkF;;;;;;;CAIrF,CAAA;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAEtD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,CAExD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,WAAW,CAS1D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,YAAY,CAM5D"}
|
package/dist/pie-chart/shared.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Types } from "@motionscript/sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { CHART_BACKGROUND, CHART_FOREGROUND, CHART_LEGEND, CHART_MUTED, CHART_SERIES, LEGEND_TEXT, legendConfigOf, placedText, sizeOf, } from "../kit/style.js";
|
|
3
3
|
import { num, text } from "../kit/shared.js";
|
|
4
4
|
import { DEG, PIE_SPOTLIGHT_DIM, ringPoint, selectionFade } from "../kit/polar.js";
|
|
5
5
|
export { DEG, PIE_SPOTLIGHT_DIM, ringPoint, selectionFade };
|
|
6
6
|
/**
|
|
7
|
-
* One slice per row, painted from `
|
|
7
|
+
* One slice per row, painted from `seriesFills` by row order (cycling). Paint comes
|
|
8
8
|
* from the palette, not the rows, because a pie's mark is a row where a line's
|
|
9
9
|
* colour belongs to a column; that lets a pie be fed a CSV of plain numbers.
|
|
10
10
|
*/
|
|
@@ -73,8 +73,17 @@ export function relaxLabels(slots, minGap, top, bottom) {
|
|
|
73
73
|
}
|
|
74
74
|
/** The groups of a pie's `style`: no grid, as nothing is ruled. */
|
|
75
75
|
export const PIE_STYLE_GROUPS = {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
series: CHART_SERIES,
|
|
77
|
+
background: CHART_BACKGROUND,
|
|
78
|
+
text: {
|
|
79
|
+
/** Each slice's name. */
|
|
80
|
+
labelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),
|
|
81
|
+
/** Each slice's share or value, beside its name; inside a wedge both are set larger, inked for contrast. */
|
|
82
|
+
valueText: Types.typography({ fontSize: 28, fontWeight: 700, fill: CHART_FOREGROUND }),
|
|
83
|
+
/** The summary in the hole; its caption is set smaller, in the slice names' ink. */
|
|
84
|
+
centerText: Types.typography({ fontSize: 50, fontWeight: 800, fill: CHART_FOREGROUND }),
|
|
85
|
+
...LEGEND_TEXT,
|
|
86
|
+
},
|
|
78
87
|
marks: {
|
|
79
88
|
/** Hole radius as a fraction of the outer radius: 0 is a pie, about 0.6 a donut. */
|
|
80
89
|
innerRadius: Types.number(0, { min: 0, max: 0.9, step: 0.05 }),
|
|
@@ -92,32 +101,24 @@ export const PIE_STYLE_GROUPS = {
|
|
|
92
101
|
export function legendOf(style) {
|
|
93
102
|
return legendConfigOf(style);
|
|
94
103
|
}
|
|
95
|
-
function face(style) {
|
|
96
|
-
return style.fontFamily ? { fontFamily: style.fontFamily } : {};
|
|
97
|
-
}
|
|
98
104
|
export function ringConfigOf(style) {
|
|
99
105
|
return { gap: style.sliceGap, holeRadius: style.innerRadius, startAngle: 0, selectedGrow: 1.08, cornerRadius: style.sliceRadius };
|
|
100
106
|
}
|
|
101
107
|
export function labelConfigOf(style) {
|
|
102
|
-
const base =
|
|
103
|
-
const
|
|
108
|
+
const base = placedText(style.labelText);
|
|
109
|
+
const value = placedText(style.valueText);
|
|
104
110
|
return {
|
|
105
111
|
textStyle: base,
|
|
106
|
-
percentStyle:
|
|
107
|
-
insideStyle: { ...
|
|
108
|
-
leaderStroke: { weight: 2, fill: style.
|
|
112
|
+
percentStyle: value,
|
|
113
|
+
insideStyle: { ...value, fontSize: Math.round(sizeOf(style.valueText) * 1.9), fill: "#111113" },
|
|
114
|
+
leaderStroke: { weight: 2, fill: style.labelText.fill ?? "white" },
|
|
109
115
|
};
|
|
110
116
|
}
|
|
111
117
|
export function centerConfigOf(style) {
|
|
118
|
+
const size = sizeOf(style.centerText, 50);
|
|
112
119
|
return {
|
|
113
|
-
labelStyle:
|
|
114
|
-
|
|
115
|
-
fontSize: Math.round(style.fontSize * 1.8),
|
|
116
|
-
fontWeight: Math.min(900, style.fontWeight + 300),
|
|
117
|
-
textAlign: "center",
|
|
118
|
-
fill: style.foreground,
|
|
119
|
-
},
|
|
120
|
-
captionStyle: { ...face(style), fontSize: Math.round(style.fontSize * 0.8), fontWeight: style.fontWeight, textAlign: "center", fill: style.muted },
|
|
120
|
+
labelStyle: placedText(style.centerText),
|
|
121
|
+
captionStyle: placedText(style.labelText, "center", { fontSize: Math.round(size * 0.45) }),
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/pie-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA8E,MAAM,mBAAmB,CAAA;AAErH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,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE;KAC/C,CAAA;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,OAAO;QACL,UAAU,EAAE;YACV,GAAG,IAAI,CAAC,KAAK,CAAC;YACd,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC;YAC1C,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC;YACjD,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,KAAK,CAAC,UAAU;SACvB;QACD,YAAY,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,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"]}
|
|
1
|
+
{"version":3,"file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I;QACf,YAAY,EAAE,KAAK;QACnB,WAAW,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE;QAC/F,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,IAAI,OAAO,EAAE;KACnE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;IACzC,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC;QACxC,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;KAC3F,CAAA;AACH,CAAC","sourcesContent":["import { Types, type Fill, type TextStyle, type Stroke, type FillResolved as _FillResolved } from \"@motionscript/sdk\"\n\nimport {\n CHART_BACKGROUND,\n CHART_FOREGROUND,\n CHART_LEGEND,\n CHART_MUTED,\n CHART_SERIES,\n LEGEND_TEXT,\n legendConfigOf,\n placedText,\n sizeOf,\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 `seriesFills` 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 labelText: TextStyle\n readonly valueText: TextStyle\n readonly centerText: TextStyle\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 series: CHART_SERIES,\n background: CHART_BACKGROUND,\n text: {\n /** Each slice's name. */\n labelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),\n /** Each slice's share or value, beside its name; inside a wedge both are set larger, inked for contrast. */\n valueText: Types.typography({ fontSize: 28, fontWeight: 700, fill: CHART_FOREGROUND }),\n /** The summary in the hole; its caption is set smaller, in the slice names' ink. */\n centerText: Types.typography({ fontSize: 50, fontWeight: 800, fill: CHART_FOREGROUND }),\n ...LEGEND_TEXT,\n },\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\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 = placedText(style.labelText)\n const value = placedText(style.valueText)\n return {\n textStyle: base,\n percentStyle: value,\n insideStyle: { ...value, fontSize: Math.round(sizeOf(style.valueText) * 1.9), fill: \"#111113\" },\n leaderStroke: { weight: 2, fill: style.labelText.fill ?? \"white\" },\n }\n}\n\nexport function centerConfigOf(style: PieStyle): CenterConfig {\n const size = sizeOf(style.centerText, 50)\n return {\n labelStyle: placedText(style.centerText),\n captionStyle: placedText(style.labelText, \"center\", { fontSize: Math.round(size * 0.45) }),\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { RadarChart, radarFractions, radarScale, type RadarValues } from "./radar-chart.js";
|
|
2
2
|
export { RadarGrid } from "./radar-grid.js";
|
|
3
3
|
export { RadarSeries, seriesVertices } from "./radar-series.js";
|
|
4
|
-
export { RADAR_GRID, RADAR_MARKS, fitRadius, niceCeil, spokeDirection } from "./shared.js";
|
|
4
|
+
export { RADAR_GRID, RADAR_MARKS, RADAR_TEXT, fitRadius, niceCeil, spokeDirection } from "./shared.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { RadarChart, radarFractions, radarScale } from "./radar-chart.js";
|
|
2
2
|
export { RadarGrid } from "./radar-grid.js";
|
|
3
3
|
export { RadarSeries, seriesVertices } from "./radar-series.js";
|
|
4
|
-
export { RADAR_GRID, RADAR_MARKS, fitRadius, niceCeil, spokeDirection } from "./shared.js";
|
|
4
|
+
export { RADAR_GRID, RADAR_MARKS, RADAR_TEXT, fitRadius, niceCeil, spokeDirection } from "./shared.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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"]}
|
|
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,UAAU,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, RADAR_TEXT, fitRadius, niceCeil, spokeDirection } from \"./shared\"\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
1
|
+
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps as _Node2DProps, type TextStyle as _TextStyle, type Fill as _Fill, type FillResolved as _FillResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
2
|
import { type ChartSeries } from "../kit/shared.js";
|
|
3
3
|
/** What a radar chart plots, as its entries hold it. */
|
|
4
4
|
export interface RadarValues {
|
|
@@ -33,6 +33,9 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
33
33
|
/** The value at the rim; 0 rounds the largest value up. */
|
|
34
34
|
readonly max: 0;
|
|
35
35
|
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
36
|
+
gridBackground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
37
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
38
|
+
} & {
|
|
36
39
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
37
40
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
38
41
|
} & {
|
|
@@ -42,20 +45,19 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
42
45
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
43
46
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
44
47
|
} & {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
48
|
+
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
49
|
+
spokeText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
48
50
|
} & {
|
|
49
|
-
|
|
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>;
|
|
51
|
+
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
53
52
|
} & {
|
|
54
53
|
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
55
54
|
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
56
55
|
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
57
56
|
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
58
57
|
}>, import("@motionscript/sdk").StyleValues<{
|
|
58
|
+
gridBackground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
59
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
60
|
+
} & {
|
|
59
61
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
60
62
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
61
63
|
} & {
|
|
@@ -65,14 +67,10 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
65
67
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
66
68
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
67
69
|
} & {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
70
|
+
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
71
|
+
spokeText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
71
72
|
} & {
|
|
72
|
-
|
|
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>;
|
|
73
|
+
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
76
74
|
} & {
|
|
77
75
|
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
78
76
|
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -100,6 +98,9 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
100
98
|
/** The value at the rim; 0 rounds the largest value up. */
|
|
101
99
|
readonly max: 0;
|
|
102
100
|
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
101
|
+
gridBackground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
102
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
103
|
+
} & {
|
|
103
104
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
104
105
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
105
106
|
} & {
|
|
@@ -109,20 +110,19 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
109
110
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
110
111
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
111
112
|
} & {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
113
|
+
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
114
|
+
spokeText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
115
115
|
} & {
|
|
116
|
-
|
|
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>;
|
|
116
|
+
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
120
117
|
} & {
|
|
121
118
|
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
122
119
|
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
123
120
|
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
124
121
|
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
125
122
|
}>, import("@motionscript/sdk").StyleValues<{
|
|
123
|
+
gridBackground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
124
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
125
|
+
} & {
|
|
126
126
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
127
127
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
128
128
|
} & {
|
|
@@ -132,14 +132,10 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
132
132
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
133
133
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
134
134
|
} & {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
135
|
+
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
136
|
+
spokeText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
138
137
|
} & {
|
|
139
|
-
|
|
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>;
|
|
138
|
+
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
143
139
|
} & {
|
|
144
140
|
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
145
141
|
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -156,6 +152,9 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
156
152
|
/** The value at the rim; 0 rounds the largest value up. */
|
|
157
153
|
readonly max: 0;
|
|
158
154
|
readonly style: import("@motionscript/sdk").Type<import("@motionscript/sdk").StyleInput<{
|
|
155
|
+
gridBackground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
156
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
157
|
+
} & {
|
|
159
158
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
160
159
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
161
160
|
} & {
|
|
@@ -165,20 +164,19 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
165
164
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
166
165
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
167
166
|
} & {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
167
|
+
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
168
|
+
spokeText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
171
169
|
} & {
|
|
172
|
-
|
|
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>;
|
|
170
|
+
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
176
171
|
} & {
|
|
177
172
|
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
178
173
|
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
179
174
|
dots: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
180
175
|
dotSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
181
176
|
}>, import("@motionscript/sdk").StyleValues<{
|
|
177
|
+
gridBackground: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
178
|
+
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
179
|
+
} & {
|
|
182
180
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
183
181
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
184
182
|
} & {
|
|
@@ -188,14 +186,10 @@ export declare const RadarChart: import("@motionscript/sdk").Component<"radarCha
|
|
|
188
186
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, _StrokeResolved[], false>;
|
|
189
187
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
190
188
|
} & {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
fontWeight: import("@motionscript/sdk").Type<number, number, false>;
|
|
189
|
+
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
190
|
+
spokeText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
194
191
|
} & {
|
|
195
|
-
|
|
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>;
|
|
192
|
+
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
199
193
|
} & {
|
|
200
194
|
strokeWidth: import("@motionscript/sdk").Type<number, number, false>;
|
|
201
195
|
areaOpacity: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radar-chart.d.ts","sourceRoot":"","sources":["../../src/radar-chart/radar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"radar-chart.d.ts","sourceRoot":"","sources":["../../src/radar-chart/radar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,SAAS,IAAI,UAAU,EAC5B,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;AA4B/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,WAAW,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAE3E;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ1E;AAgCD;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU;;IAInB,wCAAwC;;;IAGxC,0CAA0C;;IAE1C,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAL3D,wCAAwC;;;IAGxC,0CAA0C;;IAE1C,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAL3D,wCAAwC;;;IAGxC,0CAA0C;;IAE1C,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAkK7D,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Rect, Text, Types, component2d, easeOut,
|
|
2
|
-
import { laidOutSize } from "../kit/cartesian.js";
|
|
1
|
+
import { Rect, Text, Types, component2d, easeOut, } from "@motionscript/sdk";
|
|
2
|
+
import { boundText, laidOutSize } from "../kit/cartesian.js";
|
|
3
3
|
import { ChartLegend } from "../kit/chart-legend.js";
|
|
4
4
|
import { SERIES_ARG, asParts, fresh } from "../kit/entries.js";
|
|
5
5
|
import { ENTER_SHARE, LEGEND_SLIDE, beats } from "../kit/motion.js";
|
|
6
6
|
import { SPOTLIGHT_DIM } from "../kit/shared.js";
|
|
7
|
-
import {
|
|
7
|
+
import { CHART_LEGEND, CHART_SERIES, CHART_STYLE_FAMILY, CHART_STYLE_PRESETS, GRID_BACKGROUND, legendConfigOf, migrateChartStyle, placedText, seriesFill, sizeOf, } from "../kit/style.js";
|
|
8
8
|
import { RadarGrid } from "./radar-grid.js";
|
|
9
9
|
import { RadarSeries } from "./radar-series.js";
|
|
10
|
-
import { RADAR_GRID, RADAR_MARKS, categoriesOf, fitRadius, fractionOf, labelAnchor, labelPoint, scaleOf, valuesOf, } from "./shared.js";
|
|
10
|
+
import { RADAR_GRID, RADAR_TEXT, RADAR_MARKS, categoriesOf, fitRadius, fractionOf, labelAnchor, labelPoint, scaleOf, valuesOf, } from "./shared.js";
|
|
11
11
|
/** The scale the web is drawn to, whether `max` was given or left to the data. */
|
|
12
12
|
export function radarScale(state) {
|
|
13
13
|
return scaleOf(valuesOf(state.data, state.series), state.min, state.max);
|
|
@@ -73,8 +73,9 @@ export const RadarChart = component2d({
|
|
|
73
73
|
/** The value at the rim; 0 rounds the largest value up. */
|
|
74
74
|
max: 0,
|
|
75
75
|
style: Types.style(CHART_STYLE_FAMILY, {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
series: CHART_SERIES,
|
|
77
|
+
background: GRID_BACKGROUND,
|
|
78
|
+
text: RADAR_TEXT,
|
|
78
79
|
grid: RADAR_GRID,
|
|
79
80
|
marks: RADAR_MARKS,
|
|
80
81
|
legend: CHART_LEGEND,
|
|
@@ -82,18 +83,20 @@ export const RadarChart = component2d({
|
|
|
82
83
|
},
|
|
83
84
|
// A node made of parts that fill would otherwise hug them.
|
|
84
85
|
defaults: { width: "fill", height: "fill" },
|
|
86
|
+
migrate: { style: migrateChartStyle("radar") },
|
|
85
87
|
allowedChildren: [],
|
|
86
88
|
children: (state) => {
|
|
87
89
|
const style = () => state.style;
|
|
88
90
|
let plot;
|
|
89
91
|
const plotSize = () => laidOutSize(plot);
|
|
90
|
-
const radius = () => fitRadius(plotSize(), categoriesOf(state.data, state.categoryField), style().
|
|
92
|
+
const radius = () => fitRadius(plotSize(), categoriesOf(state.data, state.categoryField), sizeOf(style().spokeText), style().spokeLabels);
|
|
91
93
|
const count = state.data.length;
|
|
92
94
|
const enabled = state.series.map((s) => s.enabled ?? true);
|
|
93
95
|
const grid = new RadarGrid({
|
|
94
96
|
count: () => state.data.length,
|
|
95
97
|
radius,
|
|
96
98
|
levels: () => style().gridLevels,
|
|
99
|
+
fill: () => style().gridBackground,
|
|
97
100
|
shape: () => style().gridShape,
|
|
98
101
|
stroke: () => style().gridStroke,
|
|
99
102
|
spokeStroke: () => style().spokeStroke,
|
|
@@ -117,13 +120,10 @@ export const RadarChart = component2d({
|
|
|
117
120
|
for (let i = 0; i < count; i++) {
|
|
118
121
|
const anchor = labelAnchor(i, count);
|
|
119
122
|
const align = anchor === "centerLeft" ? "left" : anchor === "centerRight" ? "right" : "center";
|
|
120
|
-
const at = () => labelPoint(i, count, radius(), style().
|
|
123
|
+
const at = () => labelPoint(i, count, radius(), sizeOf(style().spokeText));
|
|
121
124
|
labels.push(new Text({
|
|
122
|
-
...
|
|
125
|
+
...boundText(() => placedText(style().spokeText, align)),
|
|
123
126
|
text: () => categoriesOf(state.data, state.categoryField)[i] ?? "",
|
|
124
|
-
fontSize: () => style().fontSize,
|
|
125
|
-
fontWeight: () => style().fontWeight,
|
|
126
|
-
fill: () => style().muted,
|
|
127
127
|
[anchor]: at,
|
|
128
128
|
}));
|
|
129
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radar-chart.js","sourceRoot":"","sources":["../../src/radar-chart/radar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,EACP,OAAO,GAaR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO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AC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;oBACjF,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC1E,CAAC,CAAA;YACJ,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n Text,\n Types,\n component2d,\n easeOut,\n textOps,\n type ChildView,\n type DataRecord,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Size2D,\n type Vector2,\n} from \"@motionscript/sdk\"\n\nimport { laidOutSize } from \"../kit/cartesian\"\nimport { ChartLegend } from \"../kit/chart-legend\"\nimport { SERIES_ARG, asParts, fresh } from \"../kit/entries\"\nimport { ENTER_SHARE, LEGEND_SLIDE, beats, type AnyTimeline, type Beat } from \"../kit/motion\"\nimport { SPOTLIGHT_DIM, type ChartSeries } from \"../kit/shared\"\nimport {\n CHART_COLORS,\n CHART_LEGEND,\n CHART_STYLE_FAMILY,\n CHART_STYLE_PRESETS,\n CHART_TEXT,\n legendConfigOf,\n markerText,\n seriesFill,\n} from \"../kit/style\"\nimport { RadarGrid } from \"./radar-grid\"\nimport { RadarSeries } from \"./radar-series\"\nimport {\n RADAR_GRID,\n RADAR_MARKS,\n categoriesOf,\n fitRadius,\n fractionOf,\n labelAnchor,\n labelPoint,\n scaleOf,\n valuesOf,\n} from \"./shared\"\n\n/** What a radar chart plots, as its entries hold it. */\nexport interface RadarValues {\n readonly data: DataRecord[]\n readonly categoryField: string\n readonly series: ChartSeries[]\n readonly min: number\n readonly max: number\n}\n\n/** The scale the web is drawn to, whether `max` was given or left to the data. */\nexport function radarScale(state: RadarValues): { min: number; max: number } {\n return scaleOf(valuesOf(state.data, state.series), state.min, state.max)\n}\n\n/** Series `index`'s values as fractions of the rim, in spoke order. */\nexport function radarFractions(state: RadarValues, index: number): number[] {\n const series = state.series[index]\n if (!series) return []\n const scale = radarScale(state)\n return state.data.map((row) => {\n const v = row[series.field]\n return fractionOf(typeof v === \"number\" && Number.isFinite(v) ? v : 0, scale)\n })\n}\n\n/** The grid, series, label layer and legend among the children; the last row holding a grid is the one the chart built. */\nfunction partsOf(children: readonly ChildView[]) {\n for (let i = children.length - 1; i >= 0; i--) {\n const row = children[i]\n if (!Rect.is(row)) continue\n const plot = row.children.find((part) => Rect.is(part) && part.children.some(RadarGrid.is))\n if (!plot) continue\n return {\n grid: plot.children.find(RadarGrid.is)!,\n series: plot.children.filter(RadarSeries.is),\n labels: plot.children.find(Rect.is) ?? null,\n legend: row.children.find(ChartLegend.is) ?? null,\n }\n }\n return null\n}\n\nfunction toggling(timeline: AnyTimeline, children: readonly ChildView[], index: number, show: boolean) {\n const parts = partsOf(children)\n const series = parts?.series[index]\n if (!parts || !series) return timeline.wait(timeline.duration)\n return timeline.together([\n series.run(\"enter\", show ? { from: 0, to: 1 } : { from: 1, to: 0 }),\n ...(parts.legend ? [parts.legend.run(show ? \"showSeries\" : \"hideSeries\", { index })] : []),\n ])\n}\n\n/** The share of one series' growth that passes before the next starts. */\nconst STAGGER = 0.3\n\n/**\n * A radar (spider) chart: one spoke per data row, one closed polygon per\n * series, over a web of rings. Composed of a {@link RadarGrid}, a\n * {@link RadarSeries} per series, the category labels and a {@link ChartLegend}.\n *\n * Resting state is the finished chart; `enter` arms every part on its first\n * frame. `max` of 0 (or one not above `min`) is the largest value rounded up.\n */\nexport const RadarChart = component2d({\n key: \"radarChart\",\n state: {\n data: fresh<DataRecord[]>(() => [], { kind: \"dataset\" }),\n /** The column that names each spoke. */\n categoryField: \"\",\n series: fresh<ChartSeries[]>(() => [], { kind: \"series\" }),\n /** The value at the centre of the web. */\n min: 0,\n /** The value at the rim; 0 rounds the largest value up. */\n max: 0,\n style: Types.style(\n CHART_STYLE_FAMILY,\n {\n colors: CHART_COLORS,\n text: CHART_TEXT,\n grid: RADAR_GRID,\n marks: RADAR_MARKS,\n legend: CHART_LEGEND,\n },\n { presets: CHART_STYLE_PRESETS }\n ),\n },\n // A node made of parts that fill would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n allowedChildren: [],\n children: (state) => {\n const style = () => state.style\n let plot: Node2D | undefined\n const plotSize = (): Size2D => laidOutSize(plot)\n const radius = () => fitRadius(plotSize(), categoriesOf(state.data, state.categoryField), style().fontSize, style().spokeLabels)\n const count = state.data.length\n const enabled = state.series.map((s) => s.enabled ?? true)\n\n const grid = new RadarGrid({\n count: () => state.data.length,\n radius,\n levels: () => style().gridLevels,\n shape: () => style().gridShape,\n stroke: () => style().gridStroke,\n spokeStroke: () => style().spokeStroke,\n }) as unknown as Node2D\n\n const series = state.series.map(\n (s, i) =>\n new RadarSeries({\n fractions: () => radarFractions(state, i),\n radius,\n fill: () => seriesFill(style(), s, i),\n stroke: () => {\n const weight = style().strokeWidth\n return weight > 0 ? { weight, fill: seriesFill(style(), s, i), align: \"center\", join: \"round\" } : []\n },\n areaOpacity: () => style().areaOpacity,\n dots: () => style().dots,\n dotSize: () => style().dotSize,\n enabled: enabled[i],\n }) as unknown as Node2D\n )\n\n const parts: Node2D[] = [grid, ...series]\n\n if (state.style.spokeLabels) {\n const labels: Node2D[] = []\n for (let i = 0; i < count; i++) {\n const anchor = labelAnchor(i, count)\n const align = anchor === \"centerLeft\" ? \"left\" : anchor === \"centerRight\" ? \"right\" : \"center\"\n const at = (): Vector2 => labelPoint(i, count, radius(), style().fontSize)\n labels.push(\n new Text({\n ...textOps.styleProps(markerText(state.style, align)),\n text: () => categoriesOf(state.data, state.categoryField)[i] ?? \"\",\n fontSize: () => style().fontSize,\n fontWeight: () => style().fontWeight,\n fill: () => style().muted,\n [anchor]: at,\n }) as unknown as Node2D\n )\n }\n parts.push(new Rect({ width: \"fill\", height: \"fill\", children: labels }) as unknown as Node2D)\n }\n\n plot = new Rect({ width: \"fill\", height: \"fill\", children: parts }) as unknown as Node2D\n\n const row: Node2D[] = [plot]\n const position = state.style.legend\n if (position !== \"none\") {\n const side = position === \"right\"\n const config = legendConfigOf(state.style)\n const legend = new ChartLegend({\n series: state.series,\n swatches: () => state.series.map((s, i) => seriesFill(style(), s, i)),\n legend: () => legendConfigOf(style()),\n flow: side ? \"vertical\" : \"horizontal\",\n // Spacing is fixed as built; a style tween re-paints the swatches and captions only.\n gap: side ? Math.round(config.itemGap / 2) : config.itemGap,\n padding: config.padding,\n }) as unknown as Node2D\n if (position === \"top\") row.unshift(legend)\n else row.push(legend)\n }\n\n const frame = new Rect({\n flow: position === \"right\" ? \"horizontal\" : \"vertical\",\n width: \"fill\",\n height: \"fill\",\n gap: 24,\n align: \"center\",\n fill: () => style().background,\n children: row,\n })\n return asParts([frame as unknown as Node2D])\n },\n commands: {\n /** The web grows out, the polygons grow from the centre one series after another, then the labels and legend come up. */\n enter: {\n args: {},\n // Held from arrival, so it never shows finished ahead of its draw.\n entrance: true,\n easing: easeOut(),\n run: (timeline, _state, children) => {\n const parts = partsOf(children)\n if (!parts) return timeline.wait(timeline.duration)\n const duration = timeline.duration\n const web = duration * ENTER_SHARE.axes\n const marks = duration * ENTER_SHARE.marks\n const last = duration * ENTER_SHARE.legend\n const n = Math.max(1, parts.series.length)\n const each = marks / (1 + STAGGER * (n - 1))\n const { legend, labels } = parts\n const at0 = (piece: Beat[\"piece\"]): Beat => ({ at: 0, duration: 0, piece })\n // The first frame arms what every later beat moves: a beat ahead of the playhead writes nothing.\n return beats(timeline, [\n at0(parts.grid.to({ reveal: 0 })),\n ...parts.series.map((s) => at0(s.to({ progress: 0 }))),\n ...(labels ? [at0(labels.to({ opacity: 0 }))] : []),\n ...(legend ? [at0(legend.to({ opacity: 0, y: -LEGEND_SLIDE }))] : []),\n { at: 0, duration: web, piece: parts.grid.to({ reveal: 1 }) },\n ...parts.series.map((s, i) => ({ at: web + i * each * STAGGER, duration: each, piece: s.to({ progress: 1 }) })),\n ...(labels ? [{ at: web + marks * 0.6, duration: last + marks * 0.4, piece: labels.to({ opacity: 1 }) }] : []),\n ...(legend ? [{ at: web + marks, duration: last, piece: legend.to({ opacity: 1, y: 0 }) }] : []),\n ])\n },\n },\n /** Grow series `index`'s polygon back out of the centre, with its legend entry growing in. */\n showSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, _state, children) => toggling(timeline, children, timeline.args.seriesIndex, true),\n },\n /** Shrink series `index`'s polygon into the centre as its legend entry shrinks away. */\n hideSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, _state, children) => toggling(timeline, children, timeline.args.seriesIndex, false),\n },\n /** Fade every other series, polygon and legend entry, to focus on `index`. The legend dims in place, so the row does not reflow. */\n spotlightSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, _state, children) => {\n const parts = partsOf(children)\n if (!parts) return timeline.wait(timeline.duration)\n const index = timeline.args.seriesIndex\n return timeline.together([\n ...parts.series.map((s, i) => s.to({ opacity: i === index ? 1 : SPOTLIGHT_DIM })),\n ...(parts.legend ? [parts.legend.run(\"spotlightSeries\", { index })] : []),\n ])\n },\n },\n },\n})\n\nexport type RadarChart = NodeOf<typeof RadarChart>\n"]}
|
|
1
|
+
{"version":3,"file":"radar-chart.js","sourceRoot":"","sources":["../../src/radar-chart/radar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,OAAO,GAcR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,k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,CAAC,IAAI,CAAC,WAAW,CAAA;gBACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC;oBACvB,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;oBACjF,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC1E,CAAC,CAAA;YACJ,CAAC;SACF;KACF;CACF,CAAC,CAAA","sourcesContent":["import {\n Rect,\n Text,\n Types,\n component2d,\n easeOut,\n type ChildView,\n type DataRecord,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n type TextStyle as _TextStyle,\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Size2D,\n type Vector2,\n} from \"@motionscript/sdk\"\n\nimport { boundText, laidOutSize } from \"../kit/cartesian\"\nimport { ChartLegend } from \"../kit/chart-legend\"\nimport { SERIES_ARG, asParts, fresh } from \"../kit/entries\"\nimport { ENTER_SHARE, LEGEND_SLIDE, beats, type AnyTimeline, type Beat } from \"../kit/motion\"\nimport { SPOTLIGHT_DIM, type ChartSeries } from \"../kit/shared\"\nimport {\n CHART_LEGEND,\n CHART_SERIES,\n CHART_STYLE_FAMILY,\n CHART_STYLE_PRESETS,\n GRID_BACKGROUND,\n legendConfigOf,\n migrateChartStyle,\n placedText,\n seriesFill,\n sizeOf,\n} from \"../kit/style\"\nimport { RadarGrid } from \"./radar-grid\"\nimport { RadarSeries } from \"./radar-series\"\nimport {\n RADAR_GRID,\n RADAR_TEXT,\n RADAR_MARKS,\n categoriesOf,\n fitRadius,\n fractionOf,\n labelAnchor,\n labelPoint,\n scaleOf,\n valuesOf,\n} from \"./shared\"\n\n/** What a radar chart plots, as its entries hold it. */\nexport interface RadarValues {\n readonly data: DataRecord[]\n readonly categoryField: string\n readonly series: ChartSeries[]\n readonly min: number\n readonly max: number\n}\n\n/** The scale the web is drawn to, whether `max` was given or left to the data. */\nexport function radarScale(state: RadarValues): { min: number; max: number } {\n return scaleOf(valuesOf(state.data, state.series), state.min, state.max)\n}\n\n/** Series `index`'s values as fractions of the rim, in spoke order. */\nexport function radarFractions(state: RadarValues, index: number): number[] {\n const series = state.series[index]\n if (!series) return []\n const scale = radarScale(state)\n return state.data.map((row) => {\n const v = row[series.field]\n return fractionOf(typeof v === \"number\" && Number.isFinite(v) ? v : 0, scale)\n })\n}\n\n/** The grid, series, label layer and legend among the children; the last row holding a grid is the one the chart built. */\nfunction partsOf(children: readonly ChildView[]) {\n for (let i = children.length - 1; i >= 0; i--) {\n const row = children[i]\n if (!Rect.is(row)) continue\n const plot = row.children.find((part) => Rect.is(part) && part.children.some(RadarGrid.is))\n if (!plot) continue\n return {\n grid: plot.children.find(RadarGrid.is)!,\n series: plot.children.filter(RadarSeries.is),\n labels: plot.children.find(Rect.is) ?? null,\n legend: row.children.find(ChartLegend.is) ?? null,\n }\n }\n return null\n}\n\nfunction toggling(timeline: AnyTimeline, children: readonly ChildView[], index: number, show: boolean) {\n const parts = partsOf(children)\n const series = parts?.series[index]\n if (!parts || !series) return timeline.wait(timeline.duration)\n return timeline.together([\n series.run(\"enter\", show ? { from: 0, to: 1 } : { from: 1, to: 0 }),\n ...(parts.legend ? [parts.legend.run(show ? \"showSeries\" : \"hideSeries\", { index })] : []),\n ])\n}\n\n/** The share of one series' growth that passes before the next starts. */\nconst STAGGER = 0.3\n\n/**\n * A radar (spider) chart: one spoke per data row, one closed polygon per\n * series, over a web of rings. Composed of a {@link RadarGrid}, a\n * {@link RadarSeries} per series, the category labels and a {@link ChartLegend}.\n *\n * Resting state is the finished chart; `enter` arms every part on its first\n * frame. `max` of 0 (or one not above `min`) is the largest value rounded up.\n */\nexport const RadarChart = component2d({\n key: \"radarChart\",\n state: {\n data: fresh<DataRecord[]>(() => [], { kind: \"dataset\" }),\n /** The column that names each spoke. */\n categoryField: \"\",\n series: fresh<ChartSeries[]>(() => [], { kind: \"series\" }),\n /** The value at the centre of the web. */\n min: 0,\n /** The value at the rim; 0 rounds the largest value up. */\n max: 0,\n style: Types.style(\n CHART_STYLE_FAMILY,\n {\n series: CHART_SERIES,\n background: GRID_BACKGROUND,\n text: RADAR_TEXT,\n grid: RADAR_GRID,\n marks: RADAR_MARKS,\n legend: CHART_LEGEND,\n },\n { presets: CHART_STYLE_PRESETS }\n ),\n },\n // A node made of parts that fill would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n migrate: { style: migrateChartStyle(\"radar\") },\n allowedChildren: [],\n children: (state) => {\n const style = () => state.style\n let plot: Node2D | undefined\n const plotSize = (): Size2D => laidOutSize(plot)\n const radius = () => fitRadius(plotSize(), categoriesOf(state.data, state.categoryField), sizeOf(style().spokeText), style().spokeLabels)\n const count = state.data.length\n const enabled = state.series.map((s) => s.enabled ?? true)\n\n const grid = new RadarGrid({\n count: () => state.data.length,\n radius,\n levels: () => style().gridLevels,\n fill: () => style().gridBackground,\n shape: () => style().gridShape,\n stroke: () => style().gridStroke,\n spokeStroke: () => style().spokeStroke,\n }) as unknown as Node2D\n\n const series = state.series.map(\n (s, i) =>\n new RadarSeries({\n fractions: () => radarFractions(state, i),\n radius,\n fill: () => seriesFill(style(), s, i),\n stroke: () => {\n const weight = style().strokeWidth\n return weight > 0 ? { weight, fill: seriesFill(style(), s, i), align: \"center\", join: \"round\" } : []\n },\n areaOpacity: () => style().areaOpacity,\n dots: () => style().dots,\n dotSize: () => style().dotSize,\n enabled: enabled[i],\n }) as unknown as Node2D\n )\n\n const parts: Node2D[] = [grid, ...series]\n\n if (state.style.spokeLabels) {\n const labels: Node2D[] = []\n for (let i = 0; i < count; i++) {\n const anchor = labelAnchor(i, count)\n const align = anchor === \"centerLeft\" ? \"left\" : anchor === \"centerRight\" ? \"right\" : \"center\"\n const at = (): Vector2 => labelPoint(i, count, radius(), sizeOf(style().spokeText))\n labels.push(\n new Text({\n ...boundText(() => placedText(style().spokeText, align)),\n text: () => categoriesOf(state.data, state.categoryField)[i] ?? \"\",\n [anchor]: at,\n }) as unknown as Node2D\n )\n }\n parts.push(new Rect({ width: \"fill\", height: \"fill\", children: labels }) as unknown as Node2D)\n }\n\n plot = new Rect({ width: \"fill\", height: \"fill\", children: parts }) as unknown as Node2D\n\n const row: Node2D[] = [plot]\n const position = state.style.legend\n if (position !== \"none\") {\n const side = position === \"right\"\n const config = legendConfigOf(state.style)\n const legend = new ChartLegend({\n series: state.series,\n swatches: () => state.series.map((s, i) => seriesFill(style(), s, i)),\n legend: () => legendConfigOf(style()),\n flow: side ? \"vertical\" : \"horizontal\",\n // Spacing is fixed as built; a style tween re-paints the swatches and captions only.\n gap: side ? Math.round(config.itemGap / 2) : config.itemGap,\n padding: config.padding,\n }) as unknown as Node2D\n if (position === \"top\") row.unshift(legend)\n else row.push(legend)\n }\n\n const frame = new Rect({\n flow: position === \"right\" ? \"horizontal\" : \"vertical\",\n width: \"fill\",\n height: \"fill\",\n gap: 24,\n align: \"center\",\n fill: () => style().background,\n children: row,\n })\n return asParts([frame as unknown as Node2D])\n },\n commands: {\n /** The web grows out, the polygons grow from the centre one series after another, then the labels and legend come up. */\n enter: {\n args: {},\n // Held from arrival, so it never shows finished ahead of its draw.\n entrance: true,\n easing: easeOut(),\n run: (timeline, _state, children) => {\n const parts = partsOf(children)\n if (!parts) return timeline.wait(timeline.duration)\n const duration = timeline.duration\n const web = duration * ENTER_SHARE.axes\n const marks = duration * ENTER_SHARE.marks\n const last = duration * ENTER_SHARE.legend\n const n = Math.max(1, parts.series.length)\n const each = marks / (1 + STAGGER * (n - 1))\n const { legend, labels } = parts\n const at0 = (piece: Beat[\"piece\"]): Beat => ({ at: 0, duration: 0, piece })\n // The first frame arms what every later beat moves: a beat ahead of the playhead writes nothing.\n return beats(timeline, [\n at0(parts.grid.to({ reveal: 0 })),\n ...parts.series.map((s) => at0(s.to({ progress: 0 }))),\n ...(labels ? [at0(labels.to({ opacity: 0 }))] : []),\n ...(legend ? [at0(legend.to({ opacity: 0, y: -LEGEND_SLIDE }))] : []),\n { at: 0, duration: web, piece: parts.grid.to({ reveal: 1 }) },\n ...parts.series.map((s, i) => ({ at: web + i * each * STAGGER, duration: each, piece: s.to({ progress: 1 }) })),\n ...(labels ? [{ at: web + marks * 0.6, duration: last + marks * 0.4, piece: labels.to({ opacity: 1 }) }] : []),\n ...(legend ? [{ at: web + marks, duration: last, piece: legend.to({ opacity: 1, y: 0 }) }] : []),\n ])\n },\n },\n /** Grow series `index`'s polygon back out of the centre, with its legend entry growing in. */\n showSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, _state, children) => toggling(timeline, children, timeline.args.seriesIndex, true),\n },\n /** Shrink series `index`'s polygon into the centre as its legend entry shrinks away. */\n hideSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, _state, children) => toggling(timeline, children, timeline.args.seriesIndex, false),\n },\n /** Fade every other series, polygon and legend entry, to focus on `index`. The legend dims in place, so the row does not reflow. */\n spotlightSeries: {\n args: { seriesIndex: SERIES_ARG },\n easing: easeOut(),\n run: (timeline, _state, children) => {\n const parts = partsOf(children)\n if (!parts) return timeline.wait(timeline.duration)\n const index = timeline.args.seriesIndex\n return timeline.together([\n ...parts.series.map((s, i) => s.to({ opacity: i === index ? 1 : SPOTLIGHT_DIM })),\n ...(parts.legend ? [parts.legend.run(\"spotlightSeries\", { index })] : []),\n ])\n },\n },\n },\n})\n\nexport type RadarChart = NodeOf<typeof RadarChart>\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NodeOf, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Stroke, type StrokeResolved } from "@motionscript/sdk";
|
|
1
|
+
import { type Fill, type FillResolved, type NodeOf, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Stroke, type StrokeResolved } from "@motionscript/sdk";
|
|
2
2
|
import { type GridShape } from "./shared.js";
|
|
3
3
|
/**
|
|
4
4
|
* The web of a {@link RadarChart}: `levels` rings and, if asked, a spoke to each
|
|
@@ -10,6 +10,8 @@ export declare const RadarGrid: import("@motionscript/sdk").Component<"radarGrid
|
|
|
10
10
|
/** The rim, in px. */
|
|
11
11
|
readonly radius: 0;
|
|
12
12
|
readonly levels: 4;
|
|
13
|
+
/** Inside the outer ring, under the rings and spokes; empty paints nothing. */
|
|
14
|
+
readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
|
|
13
15
|
readonly shape: import("@motionscript/sdk").Type<GridShape, GridShape, false>;
|
|
14
16
|
readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
|
|
15
17
|
/** The line out to each category; empty draws none. */
|
|
@@ -21,6 +23,8 @@ export declare const RadarGrid: import("@motionscript/sdk").Component<"radarGrid
|
|
|
21
23
|
/** The rim, in px. */
|
|
22
24
|
readonly radius: 0;
|
|
23
25
|
readonly levels: 4;
|
|
26
|
+
/** Inside the outer ring, under the rings and spokes; empty paints nothing. */
|
|
27
|
+
readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
|
|
24
28
|
readonly shape: import("@motionscript/sdk").Type<GridShape, GridShape, false>;
|
|
25
29
|
readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
|
|
26
30
|
/** The line out to each category; empty draws none. */
|
|
@@ -32,6 +36,8 @@ export declare const RadarGrid: import("@motionscript/sdk").Component<"radarGrid
|
|
|
32
36
|
/** The rim, in px. */
|
|
33
37
|
readonly radius: 0;
|
|
34
38
|
readonly levels: 4;
|
|
39
|
+
/** Inside the outer ring, under the rings and spokes; empty paints nothing. */
|
|
40
|
+
readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
|
|
35
41
|
readonly shape: import("@motionscript/sdk").Type<GridShape, GridShape, false>;
|
|
36
42
|
readonly stroke: import("@motionscript/sdk").Type<Stroke, StrokeResolved[], false>;
|
|
37
43
|
/** The line out to each category; empty draws none. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radar-grid.d.ts","sourceRoot":"","sources":["../../src/radar-chart/radar-grid.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"radar-grid.d.ts","sourceRoot":"","sources":["../../src/radar-chart/radar-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,MAAM,EAEX,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,EACX,KAAK,cAAc,EAEpB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,SAAS;;IAIlB,sBAAsB;;;IAGtB,+EAA+E;;;;IAI/E,uDAAuD;;IAEvD,uFAAuF;;;;IATvF,sBAAsB;;;IAGtB,+EAA+E;;;;IAI/E,uDAAuD;;IAEvD,uFAAuF;;;;IATvF,sBAAsB;;;IAGtB,+EAA+E;;;;IAI/E,uDAAuD;;IAEvD,uFAAuF;;gCAyCzF,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAA"}
|