@motionscript/charts 0.1.1-alpha.2 → 0.1.1-alpha.3
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 +8 -0
- package/README.md +7 -9
- package/dist/bar-chart/bar-chart.d.ts +48 -48
- package/dist/bar-chart/bar-chart.js +2 -2
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +2 -1
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +2 -0
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-FJHNBNPQ.js +2 -0
- package/dist/browser/chunks/chunk-FJHNBNPQ.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/style.d.ts +25 -20
- package/dist/kit/style.d.ts.map +1 -1
- package/dist/kit/style.js +20 -18
- package/dist/kit/style.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +48 -48
- package/dist/line-chart/line-chart.js +2 -2
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +2 -1
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +2 -0
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +18 -24
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/shared.d.ts +7 -9
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +7 -10
- 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 +6 -12
- package/dist/radar-chart/radar-chart.d.ts.map +1 -1
- package/dist/radar-chart/radar-chart.js +1 -2
- package/dist/radar-chart/radar-chart.js.map +1 -1
- package/dist/radar-chart/shared.d.ts +2 -5
- package/dist/radar-chart/shared.d.ts.map +1 -1
- package/dist/radar-chart/shared.js +3 -6
- package/dist/radar-chart/shared.js.map +1 -1
- package/dist/radial-chart/radial-chart.d.ts +12 -18
- package/dist/radial-chart/radial-chart.d.ts.map +1 -1
- package/dist/radial-chart/shared.d.ts +5 -7
- package/dist/radial-chart/shared.d.ts.map +1 -1
- package/dist/radial-chart/shared.js +5 -8
- package/dist/radial-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +2 -2
- package/src/bar-chart/shared.ts +3 -0
- package/src/kit/style.ts +21 -19
- package/src/line-chart/line-chart.ts +2 -2
- package/src/line-chart/shared.ts +3 -1
- package/src/pie-chart/shared.ts +6 -10
- package/src/radar-chart/index.ts +1 -1
- package/src/radar-chart/radar-chart.ts +0 -2
- package/src/radar-chart/shared.ts +3 -7
- package/src/radial-chart/shared.ts +4 -8
- package/dist/browser/chunks/chunk-7XCRX6GE.js +0 -2
- package/dist/browser/chunks/chunk-7XCRX6GE.js.map +0 -7
|
@@ -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,GAcR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAA+B,MAAM,eAAe,CAAA;AAC7F,OAAO,EAAE,aAAa,EAAoB,MAAM,eAAe,C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,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
|
+
{"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,kBAAkB,CAAA;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,q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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_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 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,10 +1,5 @@
|
|
|
1
1
|
import { type TextStyle, type DataRecord, type Size2D, type StrokeResolved, type Stroke as _Stroke, type Vector2 } from "@motionscript/sdk";
|
|
2
2
|
import { type ChartSeries } from "../kit/shared.js";
|
|
3
|
-
/** The radar chart's text: the category names around the rim, and the legend. */
|
|
4
|
-
export declare const RADAR_TEXT: {
|
|
5
|
-
legendText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
6
|
-
spokeText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
7
|
-
};
|
|
8
3
|
export type GridShape = "polygon" | "circle";
|
|
9
4
|
/** The radar chart's own grid group: the web the polygons are drawn over. */
|
|
10
5
|
export declare const RADAR_GRID: {
|
|
@@ -18,6 +13,8 @@ export declare const RADAR_GRID: {
|
|
|
18
13
|
spokeStroke: import("@motionscript/sdk").Type<_Stroke, StrokeResolved[], false>;
|
|
19
14
|
/** Read as the chart is built: whether the category names stand around the rim. */
|
|
20
15
|
spokeLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
16
|
+
/** The category names around the rim. */
|
|
17
|
+
spokeText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
21
18
|
};
|
|
22
19
|
export declare const RADAR_MARKS: {
|
|
23
20
|
/** Outline weight of each series' polygon. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/radar-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,IAAI,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAElJ,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3D,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/radar-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,IAAI,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM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
|
|
4
|
-
/** The radar chart's text: the category names around the rim, and the legend. */
|
|
5
|
-
export const RADAR_TEXT = {
|
|
6
|
-
spokeText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),
|
|
7
|
-
...LEGEND_TEXT,
|
|
8
|
-
};
|
|
3
|
+
import { CHART_MUTED } from "../kit/style.js";
|
|
9
4
|
/** The radar chart's own grid group: the web the polygons are drawn over. */
|
|
10
5
|
export const RADAR_GRID = {
|
|
11
6
|
/** Whether the rings are straight-edged (a polygon through the spokes) or round. */
|
|
@@ -18,6 +13,8 @@ export const RADAR_GRID = {
|
|
|
18
13
|
spokeStroke: Types.stroke({ weight: 2, fill: "white/15" }),
|
|
19
14
|
/** Read as the chart is built: whether the category names stand around the rim. */
|
|
20
15
|
spokeLabels: Types.boolean(true, { animatable: false }),
|
|
16
|
+
/** The category names around the rim. */
|
|
17
|
+
spokeText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),
|
|
21
18
|
};
|
|
22
19
|
export const RADAR_MARKS = {
|
|
23
20
|
/** Outline weight of each series' polygon. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/radar-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA2G,MAAM,mBAAmB,CAAA;AAElJ,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoB,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAEvD,iFAAiF;AACjF,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACjF,GAAG,WAAW;CACf,CAAA;AAID,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,oFAAoF;IAC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7C,MAAM,CAAC,GAAG,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACrC,OAAO,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;AAC/B,CAAC","sourcesContent":["import { Types, type TextStyle, type DataRecord, type Size2D, type StrokeResolved, type Stroke as _Stroke, type Vector2 } from \"@motionscript/sdk\"\n\nimport { num, text, type ChartSeries } from \"../kit/shared\"\nimport { CHART_MUTED, LEGEND_TEXT } from \"../kit/style\"\n\n/** The radar chart's text: the category names around the rim, and the legend. */\nexport const RADAR_TEXT = {\n spokeText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),\n ...LEGEND_TEXT,\n}\n\nexport type GridShape = \"polygon\" | \"circle\"\n\n/** The radar chart's own grid group: the web the polygons are drawn over. */\nexport const RADAR_GRID = {\n /** Whether the rings are straight-edged (a polygon through the spokes) or round. */\n gridShape: Types.oneOf([\"polygon\", \"circle\"] as const),\n /** How many rings, outermost at the scale's maximum. */\n gridLevels: Types.number(4, { min: 1, max: 10, step: 1 }),\n /** The rings; empty draws none. */\n gridStroke: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** The line from the centre out to each category; empty draws none. */\n spokeStroke: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** Read as the chart is built: whether the category names stand around the rim. */\n spokeLabels: Types.boolean(true, { animatable: false }),\n}\n\nexport const RADAR_MARKS = {\n /** Outline weight of each series' polygon. */\n strokeWidth: Types.number(4, { min: 0, max: 24, step: 1, unit: \"px\" }),\n /** How strongly each polygon is filled in its series colour; 0 leaves an outline. */\n areaOpacity: Types.number(0.25, { min: 0, max: 1, step: 0.05 }),\n /** Whether a dot marks each value on its spoke. */\n dots: Types.boolean(true),\n dotSize: Types.number(10, { min: 2, max: 40, step: 1, unit: \"px\" }),\n}\n\n/** The grid and marks fields the parts read, whichever way the chart's style is spelled. */\nexport interface RadarStyle {\n readonly gridShape: GridShape\n readonly gridLevels: number\n readonly gridStroke: StrokeResolved[]\n readonly spokeStroke: StrokeResolved[]\n readonly spokeLabels: boolean\n readonly strokeWidth: number\n readonly areaOpacity: number\n readonly dots: boolean\n readonly dotSize: number\n readonly spokeText: TextStyle\n}\n\n/** Fraction of the label's font size between the rim and the label. */\nconst LABEL_PAD = 0.55\n/** Glyph width as a fraction of the font size, for fitting labels. */\nconst GLYPH = 0.58\n/** Room kept clear around the web when nothing else claims it, in px. */\nconst MARGIN = 10\n/** Below this a spoke counts as vertical, and its label centres over it. */\nconst SIDE = 0.35\n\n/** Spoke `index` of `count`, as a unit direction: 12 o'clock first, clockwise on screen, y up. */\nexport function spokeDirection(index: number, count: number): Vector2 {\n const angle = (index / Math.max(1, count)) * Math.PI * 2\n return { x: Math.sin(angle), y: Math.cos(angle) }\n}\n\n/** One category per data row. */\nexport function categoriesOf(data: readonly DataRecord[], field: string): string[] {\n return data.map((row) => text(row, field))\n}\n\n/** One list of values per series, a value per row. */\nexport function valuesOf(data: readonly DataRecord[], series: readonly ChartSeries[]): number[][] {\n return series.map((s) => data.map((row) => num(row, s.field)))\n}\n\nconst MANTISSAS = [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10]\n\n/** `value` rounded up to a tidy 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8 times a power of ten. */\nexport function niceCeil(value: number): number {\n if (!(value > 0)) return 1\n const power = 10 ** Math.floor(Math.log10(value))\n const mantissa = value / power\n const pick = MANTISSAS.find((m) => m >= mantissa - 1e-9) ?? 10\n return pick * power\n}\n\n/**\n * The scale the web is drawn to: `min` (default 0) to `max`, which when unset\n * (or not above `min`) is the largest value rounded up tidily.\n */\nexport function scaleOf(values: readonly (readonly number[])[], min: number, max: number): { min: number; max: number } {\n if (max > min) return { min, max }\n let top = min\n for (const list of values) for (const v of list) top = Math.max(top, v)\n const span = niceCeil(top - min)\n return { min, max: min + span }\n}\n\n/** Where `value` stands between the scale's ends, `0`-`1`. */\nexport function fractionOf(value: number, scale: { min: number; max: number }): number {\n const span = scale.max - scale.min\n if (span <= 0) return 0\n return Math.min(1, Math.max(0, (value - scale.min) / span))\n}\n\nexport type LabelAnchor = \"centerLeft\" | \"centerRight\" | \"bottomCenter\" | \"topCenter\"\n\n/** Which corner of a category's label touches the point beside its spoke's end. */\nexport function labelAnchor(index: number, count: number): LabelAnchor {\n const { x, y } = spokeDirection(index, count)\n if (x > SIDE) return \"centerLeft\"\n if (x < -SIDE) return \"centerRight\"\n return y >= 0 ? \"bottomCenter\" : \"topCenter\"\n}\n\nexport function labelPad(fontSize: number): number {\n return fontSize * LABEL_PAD\n}\n\n/** Rough size of a label, since the web is fitted before any text is measured. */\nexport function labelSize(caption: string, fontSize: number): Size2D {\n return { width: caption.length * fontSize * GLYPH, height: fontSize * 1.25 }\n}\n\n/**\n * The rim's radius for a box: the largest the web can be with every label\n * (when there are labels) still inside it.\n */\nexport function fitRadius(box: Size2D, categories: readonly string[], fontSize: number, labelled: boolean): number {\n let radius = Math.min(box.width, box.height) / 2 - MARGIN\n if (!labelled) return Math.max(0, radius)\n const pad = labelPad(fontSize)\n const count = categories.length\n categories.forEach((caption, i) => {\n const { x, y } = spokeDirection(i, count)\n const size = labelSize(caption, fontSize)\n const side = labelAnchor(i, count)\n // How much of the label hangs past its anchor point on each axis.\n const reachX = side === \"centerLeft\" || side === \"centerRight\" ? size.width : size.width / 2\n const reachY = side === \"bottomCenter\" || side === \"topCenter\" ? size.height : size.height / 2\n if (Math.abs(x) > 1e-6) radius = Math.min(radius, (box.width / 2 - reachX - MARGIN / 2) / Math.abs(x) - pad)\n if (Math.abs(y) > 1e-6) radius = Math.min(radius, (box.height / 2 - reachY - MARGIN / 2) / Math.abs(y) - pad)\n })\n return Math.max(0, radius)\n}\n\n/** Where spoke `index`'s label is pinned: just past the rim, centre-relative, y up. */\nexport function labelPoint(index: number, count: number, radius: number, fontSize: number): Vector2 {\n const { x, y } = spokeDirection(index, count)\n const r = radius + labelPad(f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,IAAI;YAAE,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IAC/G,CAAC,CAAC,CAAA;IACF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,KAAa,EAAE,MAAc,EAAE,QAAgB;IACvF,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC7C,MAAM,CAAC,GAAG,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACrC,OAAO,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAA;AAC/B,CAAC","sourcesContent":["import { Types, type TextStyle, type DataRecord, type Size2D, type StrokeResolved, type Stroke as _Stroke, type Vector2 } from \"@motionscript/sdk\"\n\nimport { num, text, type ChartSeries } from \"../kit/shared\"\nimport { CHART_MUTED } from \"../kit/style\"\n\nexport type GridShape = \"polygon\" | \"circle\"\n\n/** The radar chart's own grid group: the web the polygons are drawn over. */\nexport const RADAR_GRID = {\n /** Whether the rings are straight-edged (a polygon through the spokes) or round. */\n gridShape: Types.oneOf([\"polygon\", \"circle\"] as const),\n /** How many rings, outermost at the scale's maximum. */\n gridLevels: Types.number(4, { min: 1, max: 10, step: 1 }),\n /** The rings; empty draws none. */\n gridStroke: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** The line from the centre out to each category; empty draws none. */\n spokeStroke: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** Read as the chart is built: whether the category names stand around the rim. */\n spokeLabels: Types.boolean(true, { animatable: false }),\n /** The category names around the rim. */\n spokeText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),\n}\n\nexport const RADAR_MARKS = {\n /** Outline weight of each series' polygon. */\n strokeWidth: Types.number(4, { min: 0, max: 24, step: 1, unit: \"px\" }),\n /** How strongly each polygon is filled in its series colour; 0 leaves an outline. */\n areaOpacity: Types.number(0.25, { min: 0, max: 1, step: 0.05 }),\n /** Whether a dot marks each value on its spoke. */\n dots: Types.boolean(true),\n dotSize: Types.number(10, { min: 2, max: 40, step: 1, unit: \"px\" }),\n}\n\n/** The grid and marks fields the parts read, whichever way the chart's style is spelled. */\nexport interface RadarStyle {\n readonly gridShape: GridShape\n readonly gridLevels: number\n readonly gridStroke: StrokeResolved[]\n readonly spokeStroke: StrokeResolved[]\n readonly spokeLabels: boolean\n readonly strokeWidth: number\n readonly areaOpacity: number\n readonly dots: boolean\n readonly dotSize: number\n readonly spokeText: TextStyle\n}\n\n/** Fraction of the label's font size between the rim and the label. */\nconst LABEL_PAD = 0.55\n/** Glyph width as a fraction of the font size, for fitting labels. */\nconst GLYPH = 0.58\n/** Room kept clear around the web when nothing else claims it, in px. */\nconst MARGIN = 10\n/** Below this a spoke counts as vertical, and its label centres over it. */\nconst SIDE = 0.35\n\n/** Spoke `index` of `count`, as a unit direction: 12 o'clock first, clockwise on screen, y up. */\nexport function spokeDirection(index: number, count: number): Vector2 {\n const angle = (index / Math.max(1, count)) * Math.PI * 2\n return { x: Math.sin(angle), y: Math.cos(angle) }\n}\n\n/** One category per data row. */\nexport function categoriesOf(data: readonly DataRecord[], field: string): string[] {\n return data.map((row) => text(row, field))\n}\n\n/** One list of values per series, a value per row. */\nexport function valuesOf(data: readonly DataRecord[], series: readonly ChartSeries[]): number[][] {\n return series.map((s) => data.map((row) => num(row, s.field)))\n}\n\nconst MANTISSAS = [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10]\n\n/** `value` rounded up to a tidy 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8 times a power of ten. */\nexport function niceCeil(value: number): number {\n if (!(value > 0)) return 1\n const power = 10 ** Math.floor(Math.log10(value))\n const mantissa = value / power\n const pick = MANTISSAS.find((m) => m >= mantissa - 1e-9) ?? 10\n return pick * power\n}\n\n/**\n * The scale the web is drawn to: `min` (default 0) to `max`, which when unset\n * (or not above `min`) is the largest value rounded up tidily.\n */\nexport function scaleOf(values: readonly (readonly number[])[], min: number, max: number): { min: number; max: number } {\n if (max > min) return { min, max }\n let top = min\n for (const list of values) for (const v of list) top = Math.max(top, v)\n const span = niceCeil(top - min)\n return { min, max: min + span }\n}\n\n/** Where `value` stands between the scale's ends, `0`-`1`. */\nexport function fractionOf(value: number, scale: { min: number; max: number }): number {\n const span = scale.max - scale.min\n if (span <= 0) return 0\n return Math.min(1, Math.max(0, (value - scale.min) / span))\n}\n\nexport type LabelAnchor = \"centerLeft\" | \"centerRight\" | \"bottomCenter\" | \"topCenter\"\n\n/** Which corner of a category's label touches the point beside its spoke's end. */\nexport function labelAnchor(index: number, count: number): LabelAnchor {\n const { x, y } = spokeDirection(index, count)\n if (x > SIDE) return \"centerLeft\"\n if (x < -SIDE) return \"centerRight\"\n return y >= 0 ? \"bottomCenter\" : \"topCenter\"\n}\n\nexport function labelPad(fontSize: number): number {\n return fontSize * LABEL_PAD\n}\n\n/** Rough size of a label, since the web is fitted before any text is measured. */\nexport function labelSize(caption: string, fontSize: number): Size2D {\n return { width: caption.length * fontSize * GLYPH, height: fontSize * 1.25 }\n}\n\n/**\n * The rim's radius for a box: the largest the web can be with every label\n * (when there are labels) still inside it.\n */\nexport function fitRadius(box: Size2D, categories: readonly string[], fontSize: number, labelled: boolean): number {\n let radius = Math.min(box.width, box.height) / 2 - MARGIN\n if (!labelled) return Math.max(0, radius)\n const pad = labelPad(fontSize)\n const count = categories.length\n categories.forEach((caption, i) => {\n const { x, y } = spokeDirection(i, count)\n const size = labelSize(caption, fontSize)\n const side = labelAnchor(i, count)\n // How much of the label hangs past its anchor point on each axis.\n const reachX = side === \"centerLeft\" || side === \"centerRight\" ? size.width : size.width / 2\n const reachY = side === \"bottomCenter\" || side === \"topCenter\" ? size.height : size.height / 2\n if (Math.abs(x) > 1e-6) radius = Math.min(radius, (box.width / 2 - reachX - MARGIN / 2) / Math.abs(x) - pad)\n if (Math.abs(y) > 1e-6) radius = Math.min(radius, (box.height / 2 - reachY - MARGIN / 2) / Math.abs(y) - pad)\n })\n return Math.max(0, radius)\n}\n\n/** Where spoke `index`'s label is pinned: just past the rim, centre-relative, y up. */\nexport function labelPoint(index: number, count: number, radius: number, fontSize: number): Vector2 {\n const { x, y } = spokeDirection(index, count)\n const r = radius + labelPad(fontSize)\n return { x: x * r, y: y * r }\n}\n"]}
|
|
@@ -27,10 +27,7 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
27
27
|
} & {
|
|
28
28
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
29
29
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
30
|
-
} & {
|
|
31
30
|
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
32
|
-
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
33
|
-
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
34
31
|
} & {
|
|
35
32
|
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
36
33
|
} & {
|
|
@@ -42,15 +39,14 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
42
39
|
roundCaps: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
43
40
|
} & {
|
|
44
41
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
42
|
+
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
43
|
+
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
45
44
|
}>, import("@motionscript/sdk").StyleValues<{
|
|
46
45
|
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
47
46
|
} & {
|
|
48
47
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
49
48
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
50
|
-
} & {
|
|
51
49
|
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
52
|
-
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
53
|
-
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
54
50
|
} & {
|
|
55
51
|
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
56
52
|
} & {
|
|
@@ -62,6 +58,8 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
62
58
|
roundCaps: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
63
59
|
} & {
|
|
64
60
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
61
|
+
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
62
|
+
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
65
63
|
}>, false>;
|
|
66
64
|
/** Gap between the rings and the legend, in px. */
|
|
67
65
|
readonly gap: 40;
|
|
@@ -93,10 +91,7 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
93
91
|
} & {
|
|
94
92
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
95
93
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
96
|
-
} & {
|
|
97
94
|
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
98
|
-
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
99
|
-
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
100
95
|
} & {
|
|
101
96
|
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
102
97
|
} & {
|
|
@@ -108,15 +103,14 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
108
103
|
roundCaps: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
109
104
|
} & {
|
|
110
105
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
106
|
+
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
107
|
+
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
111
108
|
}>, import("@motionscript/sdk").StyleValues<{
|
|
112
109
|
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
113
110
|
} & {
|
|
114
111
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
115
112
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
116
|
-
} & {
|
|
117
113
|
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
118
|
-
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
119
|
-
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
120
114
|
} & {
|
|
121
115
|
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
122
116
|
} & {
|
|
@@ -128,6 +122,8 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
128
122
|
roundCaps: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
129
123
|
} & {
|
|
130
124
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
125
|
+
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
126
|
+
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
131
127
|
}>, false>;
|
|
132
128
|
/** Gap between the rings and the legend, in px. */
|
|
133
129
|
readonly gap: 40;
|
|
@@ -152,10 +148,7 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
152
148
|
} & {
|
|
153
149
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
154
150
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
155
|
-
} & {
|
|
156
151
|
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
157
|
-
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
158
|
-
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
159
152
|
} & {
|
|
160
153
|
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
161
154
|
} & {
|
|
@@ -167,15 +160,14 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
167
160
|
roundCaps: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
168
161
|
} & {
|
|
169
162
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
163
|
+
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
164
|
+
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
170
165
|
}>, import("@motionscript/sdk").StyleValues<{
|
|
171
166
|
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
172
167
|
} & {
|
|
173
168
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
174
169
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
175
|
-
} & {
|
|
176
170
|
legendText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
177
|
-
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
178
|
-
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
179
171
|
} & {
|
|
180
172
|
seriesFills: import("@motionscript/sdk").Type<_Fill[], _FillResolved[][], false>;
|
|
181
173
|
} & {
|
|
@@ -187,6 +179,8 @@ export declare const RadialChart: import("@motionscript/sdk").Component<"radialC
|
|
|
187
179
|
roundCaps: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
188
180
|
} & {
|
|
189
181
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
182
|
+
labelText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
183
|
+
centerText: import("@motionscript/sdk").Type<_TextStyle, _TextStyle, false>;
|
|
190
184
|
}>, false>;
|
|
191
185
|
/** Gap between the rings and the legend, in px. */
|
|
192
186
|
readonly gap: 40;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radial-chart.d.ts","sourceRoot":"","sources":["../../src/radial-chart/radial-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,EACnC,MAAM,mBAAmB,CAAA;AAQ1B,OAAO,EAQL,KAAK,WAAW,EACjB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAA;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAA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jF,mDAAmD;;IAEnD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,8GAA8G;;IAE9G,yJAAyJ;;;;IAfzJ,4DAA4D;;IAE5D,yDAAyD;;IAEzD,iFAAiF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGjF,mDAAmD;;IAEnD,mCAAmC;;IAEnC,+CAA+C;;IAE/C,8GAA8G;;IAE9G,yJAAyJ;;;;;;;;;0BAuG3J,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA"}
|
|
@@ -40,13 +40,6 @@ export declare const RADIAL_STYLE_GROUPS: {
|
|
|
40
40
|
background: {
|
|
41
41
|
background: import("@motionscript/sdk").Type<_Fill, _FillResolved[], false>;
|
|
42
42
|
};
|
|
43
|
-
text: {
|
|
44
|
-
legendText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
45
|
-
/** The category at each ring's start, and the caption under the centre. */
|
|
46
|
-
labelText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
47
|
-
/** The summary in the middle. */
|
|
48
|
-
centerText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
49
|
-
};
|
|
50
43
|
marks: {
|
|
51
44
|
/** Where the innermost ring starts, as a fraction of the outer radius. */
|
|
52
45
|
innerRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -64,10 +57,15 @@ export declare const RADIAL_STYLE_GROUPS: {
|
|
|
64
57
|
labels: {
|
|
65
58
|
/** The category written at each ring's start, set in the label text. */
|
|
66
59
|
ringLabels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
60
|
+
/** The category at each ring's start, and the caption under the centre. */
|
|
61
|
+
labelText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
62
|
+
/** The summary in the middle. */
|
|
63
|
+
centerText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
67
64
|
};
|
|
68
65
|
legend: {
|
|
69
66
|
legend: import("@motionscript/sdk").Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
70
67
|
swatch: import("@motionscript/sdk").Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
68
|
+
legendText: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
71
69
|
};
|
|
72
70
|
};
|
|
73
71
|
export declare function marksOf(style: RadialStyle): RadialMarks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/radial-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,IAAI,IAAI,KAAK,EAAE,KAAK,YAAY,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEzI,OAAO,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/radial-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,IAAI,IAAI,KAAK,EAAE,KAAK,YAAY,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEzI,OAAO,EAUL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE1D,gHAAgH;AAChH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAA;AAEhC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG,SAAS,EAAE,CAEvJ;AAED,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SA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gB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAEzD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,CAEzD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAMzD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Types, clamp } from "@motionscript/sdk";
|
|
2
|
-
import { CHART_BACKGROUND, CHART_FOREGROUND, CHART_LEGEND, CHART_MUTED, CHART_SERIES,
|
|
2
|
+
import { CHART_BACKGROUND, CHART_FOREGROUND, CHART_LEGEND, CHART_MUTED, CHART_SERIES, legendConfigOf, paletteFill, placedText, sizeOf, } from "../kit/style.js";
|
|
3
3
|
import { num, text } from "../kit/shared.js";
|
|
4
4
|
export function resolveRadialRows(data, category, value, style) {
|
|
5
5
|
return data.map((row, i) => ({ category: text(row, category), value: num(row, value), fill: paletteFill(style, i) }));
|
|
@@ -25,13 +25,6 @@ export function radialFractions(rows, max) {
|
|
|
25
25
|
export const RADIAL_STYLE_GROUPS = {
|
|
26
26
|
series: CHART_SERIES,
|
|
27
27
|
background: CHART_BACKGROUND,
|
|
28
|
-
text: {
|
|
29
|
-
/** The category at each ring's start, and the caption under the centre. */
|
|
30
|
-
labelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),
|
|
31
|
-
/** The summary in the middle. */
|
|
32
|
-
centerText: Types.typography({ fontSize: 50, fontWeight: 800, fill: CHART_FOREGROUND }),
|
|
33
|
-
...LEGEND_TEXT,
|
|
34
|
-
},
|
|
35
28
|
marks: {
|
|
36
29
|
/** Where the innermost ring starts, as a fraction of the outer radius. */
|
|
37
30
|
innerRadius: Types.number(0.3, { min: 0, max: 0.9, step: 0.05 }),
|
|
@@ -49,6 +42,10 @@ export const RADIAL_STYLE_GROUPS = {
|
|
|
49
42
|
labels: {
|
|
50
43
|
/** The category written at each ring's start, set in the label text. */
|
|
51
44
|
ringLabels: Types.boolean(false),
|
|
45
|
+
/** The category at each ring's start, and the caption under the centre. */
|
|
46
|
+
labelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),
|
|
47
|
+
/** The summary in the middle. */
|
|
48
|
+
centerText: Types.typography({ fontSize: 50, fontWeight: 800, fill: CHART_FOREGROUND }),
|
|
52
49
|
},
|
|
53
50
|
legend: CHART_LEGEND,
|
|
54
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/radial-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAA2F,MAAM,mBAAmB,CAAA;AAEzI,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/radial-chart/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAA2F,MAAM,mBAAmB,CAAA;AAEzI,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,EACV,MAAM,GAEP,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAMzC,MAAM,UAAU,iBAAiB,CAAC,IAA2B,EAAE,QAAgB,EAAE,KAAa,EAAE,KAA0C;IACxI,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACvH,CAAC;AAED,yEAAyE;AACzE,M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KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAC7B,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAkB;IACzC,OAAO,cAAc,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC5C,OAAO,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAkB;IACzC,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, clamp, type DataRecord, type TextStyle, type Fill as _Fill, 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 legendConfigOf,\n paletteFill,\n placedText,\n sizeOf,\n type ChartStyleBase,\n} from \"../kit/style\"\nimport type { LegendConfig } from \"../kit/shared\"\nimport { num, text } from \"../kit/shared\"\nimport type { CenterConfig, PieSlice } from \"../kit/polar\"\n\n/** One ring: a row's caption, magnitude and paint. The same shape as a pie's slice, so the legend is shared. */\nexport type RadialRow = PieSlice\n\nexport function resolveRadialRows(data: readonly DataRecord[], category: string, value: string, style: Pick<ChartStyleBase, \"seriesFills\">): RadialRow[] {\n return data.map((row, i) => ({ category: text(row, category), value: num(row, value), fill: paletteFill(style, i) }))\n}\n\n/** A row's plotted value: negatives and non-finite values count as 0. */\nexport function rowValue(row: RadialRow): number {\n return row.value > 0 && Number.isFinite(row.value) ? row.value : 0\n}\n\n/** What a full sweep stands for: `max` when it is positive, else the largest value (1 when every value is 0). */\nexport function radialMax(rows: readonly RadialRow[], max: number): number {\n if (max > 0 && Number.isFinite(max)) return max\n let largest = 0\n for (const row of rows) largest = Math.max(largest, rowValue(row))\n return largest > 0 ? largest : 1\n}\n\n/** The share of a full sweep each row fills, `[0, 1]`. */\nexport function radialFractions(rows: readonly RadialRow[], max: number): number[] {\n const top = radialMax(rows, max)\n return rows.map((row) => clamp(rowValue(row) / top, 0, 1))\n}\n\n/** The ring geometry and look, from `style`. */\nexport interface RadialMarks {\n innerRadius: number\n ringGap: number\n /** Degrees of a full ring. */\n sweep: number\n /** Degrees clockwise from 12 o'clock. */\n startAngle: number\n track: boolean\n roundCaps: boolean\n}\n\nexport interface RadialStyle extends ChartStyleBase {\n readonly innerRadius: number\n readonly ringGap: number\n readonly sweep: number\n readonly startAngle: number\n readonly track: _FillResolved[]\n readonly roundCaps: boolean\n readonly ringLabels: boolean\n readonly labelText: TextStyle\n readonly centerText: TextStyle\n}\n\nexport const RADIAL_STYLE_GROUPS = {\n series: CHART_SERIES,\n background: CHART_BACKGROUND,\n marks: {\n /** Where the innermost ring starts, as a fraction of the outer radius. */\n innerRadius: Types.number(0.3, { min: 0, max: 0.9, step: 0.05 }),\n /** Space between neighbouring rings, px. */\n ringGap: Types.number(8, { min: 0, max: 60, step: 1, unit: \"px\" }),\n /** Degrees a full ring spans: 360 a circle, 270 a gauge-like open ring. */\n sweep: Types.number(360, { min: 30, max: 360, step: 5, unit: \"deg\" }),\n /** Degrees clockwise from 12 o'clock where every ring begins. */\n startAngle: Types.number(0, { min: -360, max: 360, step: 5, unit: \"deg\" }),\n /** The full ring under each arc; empty draws none. */\n track: Types.fill(\"white/10\"),\n /** Round the ends of the arcs and tracks. */\n roundCaps: Types.boolean(true),\n },\n labels: {\n /** The category written at each ring's start, set in the label text. */\n ringLabels: Types.boolean(false),\n /** The category at each ring's start, and the caption under the centre. */\n labelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),\n /** The summary in the middle. */\n centerText: Types.typography({ fontSize: 50, fontWeight: 800, fill: CHART_FOREGROUND }),\n },\n legend: CHART_LEGEND,\n}\n\nexport function marksOf(style: RadialStyle): RadialMarks {\n return {\n innerRadius: style.innerRadius,\n ringGap: style.ringGap,\n sweep: style.sweep,\n startAngle: style.startAngle,\n track: style.track.length > 0,\n roundCaps: style.roundCaps,\n }\n}\n\nexport function legendOf(style: RadialStyle): LegendConfig {\n return legendConfigOf(style)\n}\n\nexport function ringLabelOf(style: RadialStyle): TextStyle {\n return placedText(style.labelText)\n}\n\nexport function centerOf(style: RadialStyle): 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/charts",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Animated data charts for Motion Script: a line chart, a bar chart and a pie chart sharing one axis, legend and theme kit.",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"license": "Apache-2.0",
|
|
51
51
|
"author": "Motionscript",
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@motionscript/sdk": "^0.1.1-alpha.
|
|
53
|
+
"@motionscript/sdk": "^0.1.1-alpha.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^25.6.2",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
62
|
"typescript-eslint": "^8.48.0",
|
|
63
63
|
"vitest": "^4.1.5",
|
|
64
|
-
"@motionscript/core": "0.1.1-alpha.
|
|
65
|
-
"@motionscript/sdk": "0.1.1-alpha.
|
|
64
|
+
"@motionscript/core": "0.1.1-alpha.3",
|
|
65
|
+
"@motionscript/sdk": "0.1.1-alpha.3"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
} from "../kit/shared"
|
|
50
50
|
import {
|
|
51
51
|
CARTESIAN_GRID,
|
|
52
|
-
|
|
52
|
+
CARTESIAN_AXES,
|
|
53
53
|
CHART_LEGEND,
|
|
54
54
|
CHART_SERIES,
|
|
55
55
|
CHART_STYLE_FAMILY,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
|
|
78
78
|
const BAR_STYLE = Types.style(
|
|
79
79
|
CHART_STYLE_FAMILY,
|
|
80
|
-
{ series: CHART_SERIES, background: GRID_BACKGROUND,
|
|
80
|
+
{ series: CHART_SERIES, background: GRID_BACKGROUND, grid: CARTESIAN_GRID, axes: CARTESIAN_AXES, marks: BAR_MARKS, labels: BAR_LABELS, legend: CHART_LEGEND },
|
|
81
81
|
{ presets: CHART_STYLE_PRESETS }
|
|
82
82
|
)
|
|
83
83
|
|
package/src/bar-chart/shared.ts
CHANGED
|
@@ -8,9 +8,11 @@ import {
|
|
|
8
8
|
type CornerStyleResolved as _CornerStyleResolved,
|
|
9
9
|
type RectCornerRadius as _RectCornerRadius,
|
|
10
10
|
type RectCornerStyle as _RectCornerStyle,
|
|
11
|
+
type TextStyle as _TextStyle,
|
|
11
12
|
} from "@motionscript/sdk"
|
|
12
13
|
|
|
13
14
|
import { niceRange, num, text, type ChartSeries, type Range } from "../kit/shared"
|
|
15
|
+
import { VALUE_TEXT } from "../kit/style"
|
|
14
16
|
|
|
15
17
|
/** One bar per row, beside its siblings in the category slot or stacked on them: {@link ChartSeries} under the name for what it draws here. */
|
|
16
18
|
export type BarSeries = ChartSeries
|
|
@@ -138,4 +140,5 @@ export const BAR_MARKS = {
|
|
|
138
140
|
export const BAR_LABELS = {
|
|
139
141
|
/** Read as the chart is built: each bar's value past its end, inside it, or none. */
|
|
140
142
|
values: Types.oneOf(["none", "end", "inside"] as const, { animatable: false }),
|
|
143
|
+
...VALUE_TEXT,
|
|
141
144
|
}
|