@motionscript/charts 0.1.0-alpha.0 → 0.1.0-alpha.5
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 +59 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +85 -0
- package/dist/bar-chart/bar-chart.d.ts +33 -19
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +68 -64
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +2 -2
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +2 -2
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +1 -1
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +2 -2
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +4 -4
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +4 -4
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-5ZPBV6BU.js +2 -0
- package/dist/browser/chunks/chunk-5ZPBV6BU.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 +4 -3
- package/dist/engine.d.ts +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +1 -1
- package/dist/engine.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/chart-border.d.ts +1 -1
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +2 -2
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +1 -1
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +2 -2
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +6 -27
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +33 -57
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/shared.d.ts +31 -8
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +67 -11
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +2 -2
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +2 -2
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +3 -3
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +2 -2
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +1 -1
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +2 -2
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +2 -2
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +2 -2
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +25 -9
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +66 -43
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +4 -4
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +20 -5
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +2 -2
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +2 -2
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +16 -10
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +15 -16
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +2 -2
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +6 -6
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +14 -5
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +45 -15
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +4 -4
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +4 -4
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +6 -4
- package/registry.json +23 -23
- package/src/bar-chart/bar-chart.ts +820 -804
- package/src/bar-chart/category-axis.ts +177 -177
- package/src/bar-chart/chart-bars.ts +310 -310
- package/src/bar-chart/index.ts +31 -31
- package/src/bar-chart/shared.ts +354 -354
- package/src/engine.ts +26 -26
- package/src/index.ts +5 -5
- package/src/kit/chart-border.ts +61 -61
- package/src/kit/chart-canvas.ts +157 -157
- package/src/kit/chart-legend.ts +245 -250
- package/src/kit/shared.ts +733 -675
- package/src/kit/vertical-axis.ts +224 -224
- package/src/line-chart/chart-line.ts +208 -208
- package/src/line-chart/chart-region.ts +135 -135
- package/src/line-chart/horizontal-axis.ts +202 -202
- package/src/line-chart/index.ts +39 -39
- package/src/line-chart/line-chart.ts +961 -894
- package/src/line-chart/shared.ts +473 -459
- package/src/line-chart/x-scale.ts +367 -367
- package/src/nodes.ts +20 -20
- package/src/pie-chart/index.ts +37 -37
- package/src/pie-chart/pie-chart.ts +383 -374
- package/src/pie-chart/pie-legend.ts +159 -159
- package/src/pie-chart/pie-ring.ts +935 -903
- package/src/pie-chart/shared.ts +490 -490
- package/dist/browser/chunks/chunk-ZMBOBHYL.js +0 -2
- package/dist/browser/chunks/chunk-ZMBOBHYL.js.map +0 -7
package/dist/kit/shared.js
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
* that three times would mean three answers to "how does a chart round its axis"
|
|
13
13
|
* within one app.
|
|
14
14
|
*
|
|
15
|
-
* Kept renderer-agnostic (no `Node` imports) so
|
|
16
|
-
* mappings can build a partial theme without pulling the node classes in
|
|
17
|
-
* same way `line-chart-props.ts` always has.
|
|
15
|
+
* Kept renderer-agnostic (no `Node` imports) so a host's own inspector
|
|
16
|
+
* mappings can build a partial theme without pulling the node classes in.
|
|
18
17
|
*
|
|
19
18
|
* **Two conventions run through every resolver and lerp below**, inherited from
|
|
20
19
|
* the shape system's `resolveStroke`/`resolveShadow`:
|
|
@@ -28,7 +27,7 @@
|
|
|
28
27
|
* defaulting the missing side to 0 would animate a font weight down to nothing
|
|
29
28
|
* on the way to "unset".
|
|
30
29
|
*/
|
|
31
|
-
import { fillOps, lerpNumber, shadowOps, strokeOps, insetsOps, textOps, } from "@motionscript/
|
|
30
|
+
import { fillOps, lerpNumber, shadowOps, strokeOps, insetsOps, textOps, } from "@motionscript/sdk";
|
|
32
31
|
/**
|
|
33
32
|
* An axis domain's @property mapper: merges the author's partial input onto
|
|
34
33
|
* `previous`, so a later partial `.set({ yAxis: {...} })` patches
|
|
@@ -74,6 +73,29 @@ function lerpOptionalTicks(from, to, t) {
|
|
|
74
73
|
}
|
|
75
74
|
return out;
|
|
76
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Where a generic `to()` of an axis domain should land, given the domain as it
|
|
78
|
+
* is *drawn* (`drawn`, with `range` and `ticks` resolved off the data), or
|
|
79
|
+
* `undefined` when the request states neither a `range` nor `ticks` and the
|
|
80
|
+
* plain property tween will do.
|
|
81
|
+
*
|
|
82
|
+
* The stored domain of an auto axis has no `range` and no `ticks`, and
|
|
83
|
+
* {@link lerpAxisDomain} steps an unset side at the midpoint, so tweening the
|
|
84
|
+
* stored value from an auto axis is a cut. The charts therefore tween between
|
|
85
|
+
* resolved domains, as their zoom does; this builds the destination. A `range`
|
|
86
|
+
* given without `ticks` keeps the tick *count* the axis already draws, so each
|
|
87
|
+
* marker slides from its old value to its new one instead of the row popping.
|
|
88
|
+
*/
|
|
89
|
+
export function axisTweenTarget(drawn, requested) {
|
|
90
|
+
if (requested?.range === undefined && requested?.ticks === undefined)
|
|
91
|
+
return undefined;
|
|
92
|
+
const target = resolveAxisDomain(requested, drawn);
|
|
93
|
+
if (requested.ticks === undefined && requested.range !== undefined) {
|
|
94
|
+
const count = Math.max(2, drawn.ticks?.length ?? 2);
|
|
95
|
+
target.ticks = markerValues(requested.range, count - 1);
|
|
96
|
+
}
|
|
97
|
+
return target;
|
|
98
|
+
}
|
|
77
99
|
/**
|
|
78
100
|
* The low-level colour tokens the default themes are built from — a dark plot
|
|
79
101
|
* panel with warm-grey axis furniture.
|
|
@@ -109,7 +131,8 @@ export function clampUnit(value) {
|
|
|
109
131
|
}
|
|
110
132
|
// ---- Row readers ---------------------------------------------------------
|
|
111
133
|
/**
|
|
112
|
-
* Read a numeric field off a row, defaulting missing
|
|
134
|
+
* Read a numeric field off a row, defaulting missing, non-numeric and non-finite
|
|
135
|
+
* values to 0.
|
|
113
136
|
*
|
|
114
137
|
* A column left as strings silently plots as 0, which is why the CSV parser's
|
|
115
138
|
* numeric auto-coercion matters — a quoted or unit-suffixed column won't plot
|
|
@@ -119,7 +142,9 @@ export function num(row, field) {
|
|
|
119
142
|
if (field === undefined)
|
|
120
143
|
return 0;
|
|
121
144
|
const v = row[field];
|
|
122
|
-
|
|
145
|
+
// A `NaN` or infinite cell is no more a measurement than a missing one: read
|
|
146
|
+
// as 0, it cannot poison the scale and turn every point into `NaN`.
|
|
147
|
+
return typeof v === "number" && Number.isFinite(v) ? v : 0;
|
|
123
148
|
}
|
|
124
149
|
/**
|
|
125
150
|
* Read a field off a row as its caption — the counterpart to {@link num} for
|
|
@@ -376,11 +401,42 @@ export function resolvePalettePaint(palette, override, index) {
|
|
|
376
401
|
return palette[index % palette.length];
|
|
377
402
|
}
|
|
378
403
|
// ---- Scales and formatting -----------------------------------------------
|
|
379
|
-
/**
|
|
380
|
-
|
|
404
|
+
/**
|
|
405
|
+
* Format a marker value: integers plain, otherwise trimmed to one decimal, or to
|
|
406
|
+
* as many as the axis's tick `step` needs to tell neighbouring ticks apart.
|
|
407
|
+
*
|
|
408
|
+
* One decimal is the floor, so a step of 0.1 or more reads exactly as it always
|
|
409
|
+
* has; a finer step (a unit axis ticked every 0.05) gets two, instead of five
|
|
410
|
+
* ticks captioned `0.1 0.1 0.2 0.2 0.3`. Trailing zeros are dropped either way.
|
|
411
|
+
*/
|
|
412
|
+
export function formatMarker(value, step) {
|
|
381
413
|
if (Number.isInteger(value))
|
|
382
414
|
return String(value);
|
|
383
|
-
|
|
415
|
+
const decimals = Math.max(1, step === undefined ? 1 : decimalsFor(step));
|
|
416
|
+
return value.toFixed(decimals).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
417
|
+
}
|
|
418
|
+
/** Decimal places needed to write `step` exactly, capped at six. */
|
|
419
|
+
function decimalsFor(step) {
|
|
420
|
+
if (!(step > 0) || !Number.isFinite(step))
|
|
421
|
+
return 1;
|
|
422
|
+
for (let d = 0; d <= 6; d++) {
|
|
423
|
+
const scaled = step * 10 ** d;
|
|
424
|
+
if (Math.abs(scaled - Math.round(scaled)) < 1e-6 * Math.max(1, scaled))
|
|
425
|
+
return d;
|
|
426
|
+
}
|
|
427
|
+
// An irrational-looking step (a third): as many places as separate the ticks.
|
|
428
|
+
return Math.min(6, Math.max(1, Math.ceil(-Math.log10(step)) + 1));
|
|
429
|
+
}
|
|
430
|
+
/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */
|
|
431
|
+
export function markerStep(markers) {
|
|
432
|
+
const sorted = [...markers].filter(Number.isFinite).sort((a, b) => a - b);
|
|
433
|
+
let step;
|
|
434
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
435
|
+
const gap = sorted[i] - sorted[i - 1];
|
|
436
|
+
if (gap > 1e-12 && (step === undefined || gap < step))
|
|
437
|
+
step = gap;
|
|
438
|
+
}
|
|
439
|
+
return step;
|
|
384
440
|
}
|
|
385
441
|
/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */
|
|
386
442
|
export function formatPercent(fraction) {
|
|
@@ -395,7 +451,7 @@ export function markerValues([min, max], markerCount) {
|
|
|
395
451
|
return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i);
|
|
396
452
|
}
|
|
397
453
|
// Lifted into the engine, because a graph and a diagram want them too — see
|
|
398
|
-
// `@motionscript/
|
|
454
|
+
// `@motionscript/sdk/component`. Re-exported so a chart, and anything that
|
|
399
455
|
// copied one, still reaches them where it always did.
|
|
400
|
-
export { niceStep, enterBudget } from "@motionscript/
|
|
456
|
+
export { niceStep, enterBudget } from "@motionscript/sdk/component";
|
|
401
457
|
//# sourceMappingURL=shared.js.map
|
package/dist/kit/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,GAWR,MAAM,oBAAoB,CAAA;AAuD3B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoC,EACpC,QAA2B;IAE3B,OAAO;QACL,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC7C,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM;KAC3C,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,U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C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AAC7E,CAAC;AAED,4EAA4E;AAC5E,4EAA4E;AAC5E,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA","sourcesContent":["/**\n * The vocabulary every chart node shares: what a *series* is, how an axis is\n * scaled and formatted, and the theme leaves each chart's own theme is assembled\n * from.\n *\n * This module exists because the three chart types are three ways of drawing the\n * same table. A line chart, a bar chart and a pie chart disagree about almost\n * everything visible — polylines against columns against wedges — and agree\n * about almost everything underneath: a series is a column with a caption and a\n * paint, a marker is a number formatted one way, a legend is a swatch beside a\n * label, and a theme is a tree of paints with one mapper and one tween. Writing\n * that three times would mean three answers to \"how does a chart round its axis\"\n * within one app.\n *\n * Kept renderer-agnostic (no `Node` imports) so the studio's own inspector\n * mappings can build a partial theme without pulling the node classes in, the\n * same way `line-chart-props.ts` always has.\n *\n * **Two conventions run through every resolver and lerp below**, inherited from\n * the shape system's `resolveStroke`/`resolveShadow`:\n *\n * - A **mapper** merges the author's loose, partial input onto a `previous`\n * resolved value and resolves every leaf, so the tween always has resolved\n * data to interpolate. It is idempotent.\n * - A **tween** interpolates two resolved values leaf by leaf. Categorical\n * fields (`fontFamily`, `textAlign`) and fields that are `undefined` on either\n * side **step at the midpoint**, because there is no meaningful in-between and\n * defaulting the missing side to 0 would animate a font weight down to nothing\n * on the way to \"unset\".\n */\n\nimport {\n fillOps,\n lerpNumber,\n shadowOps,\n strokeOps,\n insetsOps,\n textOps,\n type DataRecord,\n type Fill,\n type FillResolved,\n type Insets,\n type InsetsResolved,\n type Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n} from \"@motionscript/core\"\n\n/**\n * One series of a chart: a column of the table, captioned and painted.\n *\n * `field` names the column carrying this series' values. What that becomes is\n * the chart's business — a traced polyline, a column of bars, a wedge — but the\n * three questions asked of it are the same everywhere: which column, what to\n * call it, what to paint it, and whether it is currently drawn.\n *\n * `fill` is an **override**: omit it and the series takes the theme palette's\n * entry for its own index, which is what makes a chart nobody has themed come\n * out in five distinct colours rather than five identical ones.\n */\nexport interface ChartSeries {\n /** Key into each data row for this series' value. */\n field: string\n /** Legend caption for this series. */\n label: string\n /**\n * Paint override for this series' mark and its legend swatch. Omit to take\n * the theme palette's entry for this series' index.\n */\n fill?: Fill\n /** Whether the series shows by default. Defaults to `true`. */\n enabled?: boolean\n}\n\n/** A `[min, max]` numeric range in data units. */\nexport type Range = [min: number, max: number]\n\n/**\n * One axis's *data* domain — what it shows — as opposed to {@link AxisConfig},\n * which is how it's *styled*. Every field is optional: `range`/`ticks` derive\n * from the plotted data when omitted, and `label` defaults to `\"\"`.\n */\nexport interface AxisDomainConfig {\n /** Caption drawn alongside the axis. Pass `\"\"` (the default) to hide it. */\n label?: string\n /** `[min, max]` of the scale. Derived from the data bounds when omitted. */\n range?: Range\n /** Tick values (in data units). Derived (five evenly-spaced) when omitted. */\n ticks?: number[]\n /**\n * How a tick value is written down — a `number-format` pattern such as\n * `#,##0.00` or `$#,##0`.\n *\n * Here rather than in {@link AxisConfig} because it is a statement about the\n * *numbers*, not about the ink they are set in: `$` on a revenue axis says\n * what the column holds, and it has to survive a re-theme. It sits beside\n * `range` and `ticks` for the same reason those do.\n */\n format?: string\n}\n\n/**\n * An axis domain's @property mapper: merges the author's partial input onto\n * `previous`, so a later partial `.set({ yAxis: {...} })` patches\n * `label`/`range`/`ticks` independently. `range`/`ticks` staying `undefined`\n * after the merge is the auto-derive signal the scale getters read.\n */\nexport function resolveAxisDomain(\n domain: AxisDomainConfig | undefined,\n previous?: AxisDomainConfig\n): AxisDomainConfig {\n return {\n label: domain?.label ?? previous?.label ?? \"\",\n range: domain?.range ?? previous?.range,\n ticks: domain?.ticks ?? previous?.ticks,\n format: domain?.format ?? previous?.format,\n }\n}\n\n/**\n * An axis domain's @property tween: interpolates `range`/`ticks` numerically\n * (pairwise by index for `ticks`), so a `to` command that restates a range\n * rescales the plot smoothly. `label`, and either field when one side is in\n * auto-derive mode, step at the midpoint.\n */\nexport function lerpAxisDomain(\n from: AxisDomainConfig,\n to: AxisDomainConfig,\n t: number\n): AxisDomainConfig {\n return {\n label: t < 0.5 ? from.label : to.label,\n range: lerpOptionalRange(from.range, to.range, t),\n ticks: lerpOptionalTicks(from.ticks, to.ticks, t),\n // Steps at the midpoint with the caption, for the same reason: there is no\n // halfway between `$#,##0` and `0.0%`.\n format: t < 0.5 ? from.format : to.format,\n }\n}\n\nfunction lerpOptionalRange(\n from: Range | undefined,\n to: Range | undefined,\n t: number\n): Range | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n return [lerpNumber(from[0], to[0], t), lerpNumber(from[1], to[1], t)]\n}\n\nfunction lerpOptionalTicks(\n from: number[] | undefined,\n to: number[] | undefined,\n t: number\n): number[] | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n const n = Math.max(from.length, to.length)\n const out: number[] = []\n for (let i = 0; i < n; i++) {\n out.push(lerpNumber(from[i] ?? to[i], to[i] ?? from[i], t))\n }\n return out\n}\n\n/**\n * The low-level colour tokens the default themes are built from — a dark plot\n * panel with warm-grey axis furniture.\n */\nexport const CHART_PALETTE = {\n /** Fill of the plot panel behind the marks. */\n plotFill: \"#15130e\",\n /** Colour of the plot's thick border. */\n borderColor: \"#4a4036\",\n /** Colour of the faint grid lines spanning the plot. */\n gridColor: \"#2c2820\",\n /** Colour of the numeric axis markers, axis captions, and legend labels. */\n markerColor: \"#8a7f70\",\n /** Colour of a spotlit region's dashed rules and its wash. */\n regionColor: \"#d99a3a\",\n} as const\n\n/** The out-of-the-box series palette, cycled by series index. */\nexport const DEFAULT_SERIES_COLORS = [\n \"#d9603b\",\n \"#8194ad\",\n \"#e0a93b\",\n \"#5e9d6b\",\n \"#9ec85a\",\n] as const\n\n/**\n * Opacity an *un*-spotlighted series fades to — its mark and its legend entry\n * alike, so the two dim together.\n */\nexport const SPOTLIGHT_DIM = 0.2\n\n/** Clamp a number into `[0, 1]` — the range every reveal signal here runs in. */\nexport function clampUnit(value: number): number {\n return value < 0 ? 0 : value > 1 ? 1 : value\n}\n\n// ---- Row readers ---------------------------------------------------------\n\n/**\n * Read a numeric field off a row, defaulting missing/non-numeric values to 0.\n *\n * A column left as strings silently plots as 0, which is why the CSV parser's\n * numeric auto-coercion matters — a quoted or unit-suffixed column won't plot\n * until it's coerced.\n */\nexport function num(row: DataRecord, field: string | undefined): number {\n if (field === undefined) return 0\n const v = row[field]\n return typeof v === \"number\" ? v : 0\n}\n\n/**\n * Read a field off a row as its caption — the counterpart to {@link num} for\n * the columns a chart *names* things by rather than measures them by (a bar's\n * category, a wedge's slice). A missing cell reads as empty rather than as the\n * string `\"undefined\"`.\n */\nexport function text(row: DataRecord, field: string | undefined): string {\n if (field === undefined || field === \"\") return \"\"\n const v = row[field]\n return v === undefined || v === null ? \"\" : String(v)\n}\n\n/**\n * Every column that holds numbers across `data`, in header order, skipping the\n * names in `exclude` (typically the category column).\n *\n * A column counts as numeric only if every non-empty cell in it is a number, so\n * a stray text cell leaves the column out rather than plotting zeros. This is\n * what lets a chart plot \"every other column\" without the author naming twenty\n * fields.\n */\nexport function numericFields(\n data: DataRecord[],\n exclude: string[] = []\n): string[] {\n if (data.length === 0) return []\n const skip = new Set(exclude)\n const seen = new Set<string>()\n const order: string[] = []\n for (const row of data)\n for (const key of Object.keys(row))\n if (!skip.has(key) && !seen.has(key)) {\n seen.add(key)\n order.push(key)\n }\n\n return order.filter((key) => {\n let sawValue = false\n for (const row of data) {\n const v = row[key]\n if (v === undefined || v === \"\") continue\n if (typeof v !== \"number\") return false\n sawValue = true\n }\n return sawValue\n })\n}\n\n// ---- Theme branches ------------------------------------------------------\n\n/** One axis's (x or y) style vocabulary. */\nexport interface AxisConfig {\n /** Style of each marker along the axis. */\n labelStyle: TextStyle\n /** Style of the axis caption. */\n titleStyle: TextStyle\n /**\n * This axis's direction of the plot's internal grid — weight+fill honoured,\n * dash/cap/join ignored (grid lines are drawn as filled rects).\n */\n lineStyle: Stroke\n /**\n * Gap between the plot and the marker row. Only the side facing the plot is\n * read — `.top` for a horizontal axis, `.right` for a vertical one.\n */\n tickPadding: Insets\n /** Gap between the marker row and the caption, read the same side. */\n titlePadding: Insets\n}\n\n/** A legend's per-series colour swatch — a rounded chip, not the caption. */\nexport interface LegendMarkerConfig {\n width: number\n height: number\n borderRadius: number\n stroke: Stroke\n shadow: Shadow\n}\n\n/** A legend's visual theme. */\nexport interface LegendConfig {\n padding: Insets\n /** Caption style — only the swatch carries the series colour. */\n textStyle: TextStyle\n /** Gap between legend entries. */\n itemGap: number\n markerStyle: LegendMarkerConfig\n}\n\n/** The plot panel a cartesian chart draws its marks over. */\nexport interface PlotAreaConfig {\n stroke: Stroke\n fill: Fill\n shadow: Shadow\n}\n\nconst AXIS_LABEL_STYLE: TextStyle = {\n fontSize: 24,\n fontWeight: 700,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_TITLE_STYLE: TextStyle = {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_LINE_STYLE: Stroke = { weight: 2, fill: CHART_PALETTE.gridColor }\n\n/** The default styling of a horizontal (marker row beneath the plot) axis. */\nexport const DEFAULT_X_AXIS: AxisConfig = {\n labelStyle: AXIS_LABEL_STYLE,\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 20,\n titlePadding: 4,\n}\n\n/** The default styling of a vertical (marker column beside the plot) axis. */\nexport const DEFAULT_Y_AXIS: AxisConfig = {\n labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: \"right\" },\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 40,\n titlePadding: 24,\n}\n\n/**\n * The default plot panel: **unpainted**, framed. A chart reads against the\n * stage rather than punching a panel into it, which is the look the family was\n * designed at.\n */\nexport const DEFAULT_PLOT_AREA: PlotAreaConfig = {\n fill: [],\n stroke: { weight: 6, fill: CHART_PALETTE.borderColor },\n shadow: [],\n}\n\n/** The default legend styling, shared by every chart that draws one. */\nexport const DEFAULT_LEGEND: LegendConfig = {\n padding: 0,\n textStyle: {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"left\",\n fill: CHART_PALETTE.markerColor,\n },\n itemGap: 44,\n markerStyle: {\n width: 60,\n height: 24,\n borderRadius: 6,\n stroke: [],\n shadow: [],\n },\n}\n\n/** The default per-series stroke palette — {@link DEFAULT_SERIES_COLORS}, drawn 4px. */\nexport const DEFAULT_SERIES_STROKES: Stroke[] = DEFAULT_SERIES_COLORS.map(\n (fill) => ({ weight: 4, fill })\n)\n\n/** The default per-series fill palette — the same colours, as solid paint. */\nexport const DEFAULT_SERIES_FILLS: Fill[] = DEFAULT_SERIES_COLORS.map(\n (fill) => fill\n)\n\n// ---- Theme branch resolvers ----------------------------------------------\n// Each chart type assembles its own theme out of these, so \"the axis furniture\"\n// means one thing across the family and each chart still declares only the\n// branches it actually draws.\n\nexport function resolveAxisConfig(\n axis: Partial<AxisConfig> | undefined,\n previous: AxisConfig\n): AxisConfig {\n return {\n labelStyle: textOps.resolveStyle(axis?.labelStyle, previous.labelStyle),\n titleStyle: textOps.resolveStyle(axis?.titleStyle, previous.titleStyle),\n lineStyle: strokeOps.resolve(axis?.lineStyle ?? previous.lineStyle),\n tickPadding: insetsOps.resolve(\n axis?.tickPadding ?? previous.tickPadding,\n previous.tickPadding as InsetsResolved\n ),\n titlePadding: insetsOps.resolve(\n axis?.titlePadding ?? previous.titlePadding,\n previous.titlePadding as InsetsResolved\n ),\n }\n}\n\nexport function lerpAxisConfig(\n from: AxisConfig,\n to: AxisConfig,\n t: number\n): AxisConfig {\n return {\n labelStyle: textOps.lerpStyle(from.labelStyle, to.labelStyle, t),\n titleStyle: textOps.lerpStyle(from.titleStyle, to.titleStyle, t),\n lineStyle: strokeOps.lerp(\n from.lineStyle as StrokeResolved[],\n to.lineStyle as StrokeResolved[],\n t\n ),\n tickPadding: insetsOps.lerp(\n from.tickPadding as InsetsResolved,\n to.tickPadding as InsetsResolved,\n t\n ),\n titlePadding: insetsOps.lerp(\n from.titlePadding as InsetsResolved,\n to.titlePadding as InsetsResolved,\n t\n ),\n }\n}\n\nexport function resolvePlotArea(\n plotArea: Partial<PlotAreaConfig> | undefined,\n previous: PlotAreaConfig\n): PlotAreaConfig {\n return {\n fill: fillOps.resolve(plotArea?.fill ?? previous.fill),\n stroke: strokeOps.resolve(plotArea?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(plotArea?.shadow ?? previous.shadow),\n }\n}\n\nexport function lerpPlotArea(\n from: PlotAreaConfig,\n to: PlotAreaConfig,\n t: number\n): PlotAreaConfig {\n return {\n fill: fillOps.lerp(\n from.fill as FillResolved[],\n to.fill as FillResolved[],\n t\n ),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\nfunction resolveLegendMarkerConfig(\n marker: Partial<LegendMarkerConfig> | undefined,\n previous: LegendMarkerConfig\n): LegendMarkerConfig {\n return {\n width: marker?.width ?? previous.width,\n height: marker?.height ?? previous.height,\n borderRadius: marker?.borderRadius ?? previous.borderRadius,\n stroke: strokeOps.resolve(marker?.stroke ?? previous.stroke),\n shadow: shadowOps.resolve(marker?.shadow ?? previous.shadow),\n }\n}\n\nfunction lerpLegendMarkerConfig(\n from: LegendMarkerConfig,\n to: LegendMarkerConfig,\n t: number\n): LegendMarkerConfig {\n return {\n width: lerpNumber(from.width, to.width, t),\n height: lerpNumber(from.height, to.height, t),\n borderRadius: lerpNumber(from.borderRadius, to.borderRadius, t),\n stroke: strokeOps.lerp(\n from.stroke as StrokeResolved[],\n to.stroke as StrokeResolved[],\n t\n ),\n shadow: shadowOps.lerp(\n from.shadow as ShadowResolved[],\n to.shadow as ShadowResolved[],\n t\n ),\n }\n}\n\n/** A legend theme as the author may state it — every branch optional. */\nexport type LegendTheme = Partial<Omit<LegendConfig, \"markerStyle\">> & {\n markerStyle?: Partial<LegendMarkerConfig>\n}\n\nexport function resolveLegendConfig(\n legend: LegendTheme | undefined,\n previous: LegendConfig\n): LegendConfig {\n return {\n padding: insetsOps.resolve(\n legend?.padding ?? previous.padding,\n previous.padding as InsetsResolved\n ),\n textStyle: textOps.resolveStyle(legend?.textStyle, previous.textStyle),\n itemGap: legend?.itemGap ?? previous.itemGap,\n markerStyle: resolveLegendMarkerConfig(\n legend?.markerStyle,\n previous.markerStyle\n ),\n }\n}\n\nexport function lerpLegendConfig(\n from: LegendConfig,\n to: LegendConfig,\n t: number\n): LegendConfig {\n return {\n padding: insetsOps.lerp(\n from.padding as InsetsResolved,\n to.padding as InsetsResolved,\n t\n ),\n textStyle: textOps.lerpStyle(from.textStyle, to.textStyle, t),\n itemGap: lerpNumber(from.itemGap, to.itemGap, t),\n markerStyle: lerpLegendMarkerConfig(from.markerStyle, to.markerStyle, t),\n }\n}\n\n/** A whole-palette override replaces the previous palette outright. */\nexport function resolveSeriesStrokes(\n styles: Stroke[] | undefined,\n previous: Stroke[]\n): Stroke[] {\n return (styles ?? previous).map((s) => strokeOps.resolve(s))\n}\n\n/** Pairwise by index; a palette that grows/shrinks holds the longer side's tail. */\nexport function lerpSeriesStrokes(\n from: Stroke[],\n to: Stroke[],\n t: number\n): Stroke[] {\n const n = Math.max(from.length, to.length)\n const out: Stroke[] = []\n for (let i = 0; i < n; i++) {\n const a = (from[i] ?? to[i]) as StrokeResolved[]\n const b = (to[i] ?? from[i]) as StrokeResolved[]\n out.push(strokeOps.lerp(a, b, t))\n }\n return out\n}\n\n/** The fill-palette twin of {@link resolveSeriesStrokes}, for filled marks. */\nexport function resolveSeriesFills(\n fills: Fill[] | undefined,\n previous: Fill[]\n): Fill[] {\n return (fills ?? previous).map((f) => fillOps.resolve(f))\n}\n\n/** The fill-palette twin of {@link lerpSeriesStrokes}. */\nexport function lerpSeriesFills(from: Fill[], to: Fill[], t: number): Fill[] {\n const n = Math.max(from.length, to.length)\n const out: Fill[] = []\n for (let i = 0; i < n; i++) {\n const a = (from[i] ?? to[i]) as FillResolved[]\n const b = (to[i] ?? from[i]) as FillResolved[]\n out.push(fillOps.lerp(a, b, t))\n }\n return out\n}\n\n// ---- Per-series paint ----------------------------------------------------\n\n/**\n * The effective stroke for series `index`: the palette's entry at\n * `index % palette.length`, with the series' own `fill`, if set, overriding just\n * the last (topmost) layer's colour.\n */\nexport function resolveSeriesStroke(\n palette: Stroke[],\n series: ChartSeries,\n index: number\n): Stroke {\n const entry: Stroke =\n palette.length > 0\n ? palette[index % palette.length]\n : { weight: 4, fill: \"white\" }\n if (series.fill == null) return entry\n const layers = strokeOps.resolve(entry)\n if (layers.length === 0) return { weight: 4, fill: series.fill }\n const next = [...layers]\n next[next.length - 1] = {\n ...next[next.length - 1],\n fill: fillOps.resolve(series.fill),\n }\n return next\n}\n\n/**\n * The effective *colour* for series `index` — the same colour\n * {@link resolveSeriesStroke} draws its line in — for contexts (a legend\n * swatch) that only need the fill.\n */\nexport function resolveSeriesFill(\n palette: Stroke[],\n series: ChartSeries,\n index: number\n): Fill {\n const layers = strokeOps.resolve(resolveSeriesStroke(palette, series, index))\n return layers[layers.length - 1]?.fill ?? \"white\"\n}\n\n/**\n * The effective paint for mark `index` of a **filled** chart (a bar, a wedge):\n * the series' own `fill` when it carries one, else the palette's entry for its\n * index, cycled.\n *\n * The stroke twin above has to reach inside a stroke to swap one layer's colour;\n * a filled mark has no such geometry wrapped around its paint, so an override is\n * simply the whole answer.\n */\nexport function resolvePalettePaint(\n palette: Fill[],\n override: Fill | undefined,\n index: number\n): Fill {\n if (override != null) return override\n if (palette.length === 0) return \"white\"\n return palette[index % palette.length]\n}\n\n// ---- Scales and formatting -----------------------------------------------\n\n\n/** Format a marker value: integers plain, otherwise trimmed to one decimal. */\nexport function formatMarker(value: number): string {\n if (Number.isInteger(value)) return String(value)\n return value.toFixed(1).replace(/\\.0$/, \"\")\n}\n\n/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */\nexport function formatPercent(fraction: number): string {\n const pct = fraction * 100\n if (Number.isInteger(pct)) return `${pct}%`\n return `${pct.toFixed(1).replace(/\\.0$/, \"\")}%`\n}\n\n/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */\nexport function markerValues([min, max]: Range, markerCount: number): number[] {\n const n = Math.max(2, Math.round(markerCount))\n return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i)\n}\n\n// Lifted into the engine, because a graph and a diagram want them too — see\n// `@motionscript/core/component`. Re-exported so a chart, and anything that\n// copied one, still reaches them where it always did.\nexport { niceStep, enterBudget } from \"@motionscript/core/component\"\n"]}
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,GAWR,MAAM,mBAAmB,CAAA;AAuD1B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoC,EACpC,QAA2B;IAE3B,OAAO;QACL,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC7C,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,QAAQ,EAAE,KAAK;QACvC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM;KAC3C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,CAAA;AAC7E,CAAC;AAED,4EAA4E;AAC5E,2EAA2E;AAC3E,sDAAsD;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA","sourcesContent":["/**\r\n * The vocabulary every chart node shares: what a *series* is, how an axis is\r\n * scaled and formatted, and the theme leaves each chart's own theme is assembled\r\n * from.\r\n *\r\n * This module exists because the three chart types are three ways of drawing the\r\n * same table. A line chart, a bar chart and a pie chart disagree about almost\r\n * everything visible — polylines against columns against wedges — and agree\r\n * about almost everything underneath: a series is a column with a caption and a\r\n * paint, a marker is a number formatted one way, a legend is a swatch beside a\r\n * label, and a theme is a tree of paints with one mapper and one tween. Writing\r\n * that three times would mean three answers to \"how does a chart round its axis\"\r\n * within one app.\r\n *\r\n * Kept renderer-agnostic (no `Node` imports) so a host's own inspector\r\n * mappings can build a partial theme without pulling the node classes in.\r\n *\r\n * **Two conventions run through every resolver and lerp below**, inherited from\r\n * the shape system's `resolveStroke`/`resolveShadow`:\r\n *\r\n * - A **mapper** merges the author's loose, partial input onto a `previous`\r\n * resolved value and resolves every leaf, so the tween always has resolved\r\n * data to interpolate. It is idempotent.\r\n * - A **tween** interpolates two resolved values leaf by leaf. Categorical\r\n * fields (`fontFamily`, `textAlign`) and fields that are `undefined` on either\r\n * side **step at the midpoint**, because there is no meaningful in-between and\r\n * defaulting the missing side to 0 would animate a font weight down to nothing\r\n * on the way to \"unset\".\r\n */\r\n\r\nimport {\r\n fillOps,\r\n lerpNumber,\r\n shadowOps,\r\n strokeOps,\r\n insetsOps,\r\n textOps,\r\n type DataRecord,\r\n type Fill,\r\n type FillResolved,\r\n type Insets,\r\n type InsetsResolved,\r\n type Shadow,\r\n type ShadowResolved,\r\n type Stroke,\r\n type StrokeResolved,\r\n type TextStyle,\r\n} from \"@motionscript/sdk\"\r\n\r\n/**\r\n * One series of a chart: a column of the table, captioned and painted.\r\n *\r\n * `field` names the column carrying this series' values. What that becomes is\r\n * the chart's business — a traced polyline, a column of bars, a wedge — but the\r\n * three questions asked of it are the same everywhere: which column, what to\r\n * call it, what to paint it, and whether it is currently drawn.\r\n *\r\n * `fill` is an **override**: omit it and the series takes the theme palette's\r\n * entry for its own index, which is what makes a chart nobody has themed come\r\n * out in five distinct colours rather than five identical ones.\r\n */\r\nexport interface ChartSeries {\r\n /** Key into each data row for this series' value. */\r\n field: string\r\n /** Legend caption for this series. */\r\n label: string\r\n /**\r\n * Paint override for this series' mark and its legend swatch. Omit to take\r\n * the theme palette's entry for this series' index.\r\n */\r\n fill?: Fill\r\n /** Whether the series shows by default. Defaults to `true`. */\r\n enabled?: boolean\r\n}\r\n\r\n/** A `[min, max]` numeric range in data units. */\r\nexport type Range = [min: number, max: number]\r\n\r\n/**\r\n * One axis's *data* domain — what it shows — as opposed to {@link AxisConfig},\r\n * which is how it's *styled*. Every field is optional: `range`/`ticks` derive\r\n * from the plotted data when omitted, and `label` defaults to `\"\"`.\r\n */\r\nexport interface AxisDomainConfig {\r\n /** Caption drawn alongside the axis. Pass `\"\"` (the default) to hide it. */\r\n label?: string\r\n /** `[min, max]` of the scale. Derived from the data bounds when omitted. */\r\n range?: Range\r\n /** Tick values (in data units). Derived (five evenly-spaced) when omitted. */\r\n ticks?: number[]\r\n /**\r\n * How a tick value is written down — a `number-format` pattern such as\r\n * `#,##0.00` or `$#,##0`.\r\n *\r\n * Here rather than in {@link AxisConfig} because it is a statement about the\r\n * *numbers*, not about the ink they are set in: `$` on a revenue axis says\r\n * what the column holds, and it has to survive a re-theme. It sits beside\r\n * `range` and `ticks` for the same reason those do.\r\n */\r\n format?: string\r\n}\r\n\r\n/**\r\n * An axis domain's @property mapper: merges the author's partial input onto\r\n * `previous`, so a later partial `.set({ yAxis: {...} })` patches\r\n * `label`/`range`/`ticks` independently. `range`/`ticks` staying `undefined`\r\n * after the merge is the auto-derive signal the scale getters read.\r\n */\r\nexport function resolveAxisDomain(\r\n domain: AxisDomainConfig | undefined,\r\n previous?: AxisDomainConfig\r\n): AxisDomainConfig {\r\n return {\r\n label: domain?.label ?? previous?.label ?? \"\",\r\n range: domain?.range ?? previous?.range,\r\n ticks: domain?.ticks ?? previous?.ticks,\r\n format: domain?.format ?? previous?.format,\r\n }\r\n}\r\n\r\n/**\r\n * An axis domain's @property tween: interpolates `range`/`ticks` numerically\r\n * (pairwise by index for `ticks`), so a `to` command that restates a range\r\n * rescales the plot smoothly. `label`, and either field when one side is in\r\n * auto-derive mode, step at the midpoint.\r\n */\r\nexport function lerpAxisDomain(\r\n from: AxisDomainConfig,\r\n to: AxisDomainConfig,\r\n t: number\r\n): AxisDomainConfig {\r\n return {\r\n label: t < 0.5 ? from.label : to.label,\r\n range: lerpOptionalRange(from.range, to.range, t),\r\n ticks: lerpOptionalTicks(from.ticks, to.ticks, t),\r\n // Steps at the midpoint with the caption, for the same reason: there is no\r\n // halfway between `$#,##0` and `0.0%`.\r\n format: t < 0.5 ? from.format : to.format,\r\n }\r\n}\r\n\r\nfunction lerpOptionalRange(\r\n from: Range | undefined,\r\n to: Range | undefined,\r\n t: number\r\n): Range | undefined {\r\n if (!from || !to) return t < 0.5 ? from : to\r\n return [lerpNumber(from[0], to[0], t), lerpNumber(from[1], to[1], t)]\r\n}\r\n\r\nfunction lerpOptionalTicks(\r\n from: number[] | undefined,\r\n to: number[] | undefined,\r\n t: number\r\n): number[] | undefined {\r\n if (!from || !to) return t < 0.5 ? from : to\r\n const n = Math.max(from.length, to.length)\r\n const out: number[] = []\r\n for (let i = 0; i < n; i++) {\r\n out.push(lerpNumber(from[i] ?? to[i], to[i] ?? from[i], t))\r\n }\r\n return out\r\n}\r\n\r\n/**\r\n * Where a generic `to()` of an axis domain should land, given the domain as it\r\n * is *drawn* (`drawn`, with `range` and `ticks` resolved off the data), or\r\n * `undefined` when the request states neither a `range` nor `ticks` and the\r\n * plain property tween will do.\r\n *\r\n * The stored domain of an auto axis has no `range` and no `ticks`, and\r\n * {@link lerpAxisDomain} steps an unset side at the midpoint, so tweening the\r\n * stored value from an auto axis is a cut. The charts therefore tween between\r\n * resolved domains, as their zoom does; this builds the destination. A `range`\r\n * given without `ticks` keeps the tick *count* the axis already draws, so each\r\n * marker slides from its old value to its new one instead of the row popping.\r\n */\r\nexport function axisTweenTarget(\r\n drawn: AxisDomainConfig,\r\n requested: AxisDomainConfig | undefined\r\n): AxisDomainConfig | undefined {\r\n if (requested?.range === undefined && requested?.ticks === undefined) return undefined\r\n const target = resolveAxisDomain(requested, drawn)\r\n if (requested.ticks === undefined && requested.range !== undefined) {\r\n const count = Math.max(2, drawn.ticks?.length ?? 2)\r\n target.ticks = markerValues(requested.range, count - 1)\r\n }\r\n return target\r\n}\r\n\r\n/**\r\n * The low-level colour tokens the default themes are built from — a dark plot\r\n * panel with warm-grey axis furniture.\r\n */\r\nexport const CHART_PALETTE = {\r\n /** Fill of the plot panel behind the marks. */\r\n plotFill: \"#15130e\",\r\n /** Colour of the plot's thick border. */\r\n borderColor: \"#4a4036\",\r\n /** Colour of the faint grid lines spanning the plot. */\r\n gridColor: \"#2c2820\",\r\n /** Colour of the numeric axis markers, axis captions, and legend labels. */\r\n markerColor: \"#8a7f70\",\r\n /** Colour of a spotlit region's dashed rules and its wash. */\r\n regionColor: \"#d99a3a\",\r\n} as const\r\n\r\n/** The out-of-the-box series palette, cycled by series index. */\r\nexport const DEFAULT_SERIES_COLORS = [\r\n \"#d9603b\",\r\n \"#8194ad\",\r\n \"#e0a93b\",\r\n \"#5e9d6b\",\r\n \"#9ec85a\",\r\n] as const\r\n\r\n/**\r\n * Opacity an *un*-spotlighted series fades to — its mark and its legend entry\r\n * alike, so the two dim together.\r\n */\r\nexport const SPOTLIGHT_DIM = 0.2\r\n\r\n/** Clamp a number into `[0, 1]` — the range every reveal signal here runs in. */\r\nexport function clampUnit(value: number): number {\r\n return value < 0 ? 0 : value > 1 ? 1 : value\r\n}\r\n\r\n// ---- Row readers ---------------------------------------------------------\r\n\r\n/**\r\n * Read a numeric field off a row, defaulting missing, non-numeric and non-finite\r\n * values to 0.\r\n *\r\n * A column left as strings silently plots as 0, which is why the CSV parser's\r\n * numeric auto-coercion matters — a quoted or unit-suffixed column won't plot\r\n * until it's coerced.\r\n */\r\nexport function num(row: DataRecord, field: string | undefined): number {\r\n if (field === undefined) return 0\r\n const v = row[field]\r\n // A `NaN` or infinite cell is no more a measurement than a missing one: read\r\n // as 0, it cannot poison the scale and turn every point into `NaN`.\r\n return typeof v === \"number\" && Number.isFinite(v) ? v : 0\r\n}\r\n\r\n/**\r\n * Read a field off a row as its caption — the counterpart to {@link num} for\r\n * the columns a chart *names* things by rather than measures them by (a bar's\r\n * category, a wedge's slice). A missing cell reads as empty rather than as the\r\n * string `\"undefined\"`.\r\n */\r\nexport function text(row: DataRecord, field: string | undefined): string {\r\n if (field === undefined || field === \"\") return \"\"\r\n const v = row[field]\r\n return v === undefined || v === null ? \"\" : String(v)\r\n}\r\n\r\n/**\r\n * Every column that holds numbers across `data`, in header order, skipping the\r\n * names in `exclude` (typically the category column).\r\n *\r\n * A column counts as numeric only if every non-empty cell in it is a number, so\r\n * a stray text cell leaves the column out rather than plotting zeros. This is\r\n * what lets a chart plot \"every other column\" without the author naming twenty\r\n * fields.\r\n */\r\nexport function numericFields(\r\n data: DataRecord[],\r\n exclude: string[] = []\r\n): string[] {\r\n if (data.length === 0) return []\r\n const skip = new Set(exclude)\r\n const seen = new Set<string>()\r\n const order: string[] = []\r\n for (const row of data)\r\n for (const key of Object.keys(row))\r\n if (!skip.has(key) && !seen.has(key)) {\r\n seen.add(key)\r\n order.push(key)\r\n }\r\n\r\n return order.filter((key) => {\r\n let sawValue = false\r\n for (const row of data) {\r\n const v = row[key]\r\n if (v === undefined || v === \"\") continue\r\n if (typeof v !== \"number\") return false\r\n sawValue = true\r\n }\r\n return sawValue\r\n })\r\n}\r\n\r\n// ---- Theme branches ------------------------------------------------------\r\n\r\n/** One axis's (x or y) style vocabulary. */\r\nexport interface AxisConfig {\r\n /** Style of each marker along the axis. */\r\n labelStyle: TextStyle\r\n /** Style of the axis caption. */\r\n titleStyle: TextStyle\r\n /**\r\n * This axis's direction of the plot's internal grid — weight+fill honoured,\r\n * dash/cap/join ignored (grid lines are drawn as filled rects).\r\n */\r\n lineStyle: Stroke\r\n /**\r\n * Gap between the plot and the marker row. Only the side facing the plot is\r\n * read — `.top` for a horizontal axis, `.right` for a vertical one.\r\n */\r\n tickPadding: Insets\r\n /** Gap between the marker row and the caption, read the same side. */\r\n titlePadding: Insets\r\n}\r\n\r\n/** A legend's per-series colour swatch — a rounded chip, not the caption. */\r\nexport interface LegendMarkerConfig {\r\n width: number\r\n height: number\r\n borderRadius: number\r\n stroke: Stroke\r\n shadow: Shadow\r\n}\r\n\r\n/** A legend's visual theme. */\r\nexport interface LegendConfig {\r\n padding: Insets\r\n /** Caption style — only the swatch carries the series colour. */\r\n textStyle: TextStyle\r\n /** Gap between legend entries. */\r\n itemGap: number\r\n markerStyle: LegendMarkerConfig\r\n}\r\n\r\n/** The plot panel a cartesian chart draws its marks over. */\r\nexport interface PlotAreaConfig {\r\n stroke: Stroke\r\n fill: Fill\r\n shadow: Shadow\r\n}\r\n\r\nconst AXIS_LABEL_STYLE: TextStyle = {\r\n fontSize: 24,\r\n fontWeight: 700,\r\n textAlign: \"center\",\r\n fill: CHART_PALETTE.markerColor,\r\n}\r\nconst AXIS_TITLE_STYLE: TextStyle = {\r\n fontSize: 30,\r\n fontWeight: 600,\r\n textAlign: \"center\",\r\n fill: CHART_PALETTE.markerColor,\r\n}\r\nconst AXIS_LINE_STYLE: Stroke = { weight: 2, fill: CHART_PALETTE.gridColor }\r\n\r\n/** The default styling of a horizontal (marker row beneath the plot) axis. */\r\nexport const DEFAULT_X_AXIS: AxisConfig = {\r\n labelStyle: AXIS_LABEL_STYLE,\r\n titleStyle: AXIS_TITLE_STYLE,\r\n lineStyle: AXIS_LINE_STYLE,\r\n tickPadding: 20,\r\n titlePadding: 4,\r\n}\r\n\r\n/** The default styling of a vertical (marker column beside the plot) axis. */\r\nexport const DEFAULT_Y_AXIS: AxisConfig = {\r\n labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: \"right\" },\r\n titleStyle: AXIS_TITLE_STYLE,\r\n lineStyle: AXIS_LINE_STYLE,\r\n tickPadding: 40,\r\n titlePadding: 24,\r\n}\r\n\r\n/**\r\n * The default plot panel: **unpainted**, framed. A chart reads against the\r\n * stage rather than punching a panel into it, which is the look the family was\r\n * designed at.\r\n */\r\nexport const DEFAULT_PLOT_AREA: PlotAreaConfig = {\r\n fill: [],\r\n stroke: { weight: 6, fill: CHART_PALETTE.borderColor },\r\n shadow: [],\r\n}\r\n\r\n/** The default legend styling, shared by every chart that draws one. */\r\nexport const DEFAULT_LEGEND: LegendConfig = {\r\n padding: 0,\r\n textStyle: {\r\n fontSize: 30,\r\n fontWeight: 600,\r\n textAlign: \"left\",\r\n fill: CHART_PALETTE.markerColor,\r\n },\r\n itemGap: 44,\r\n markerStyle: {\r\n width: 60,\r\n height: 24,\r\n borderRadius: 6,\r\n stroke: [],\r\n shadow: [],\r\n },\r\n}\r\n\r\n/** The default per-series stroke palette — {@link DEFAULT_SERIES_COLORS}, drawn 4px. */\r\nexport const DEFAULT_SERIES_STROKES: Stroke[] = DEFAULT_SERIES_COLORS.map(\r\n (fill) => ({ weight: 4, fill })\r\n)\r\n\r\n/** The default per-series fill palette — the same colours, as solid paint. */\r\nexport const DEFAULT_SERIES_FILLS: Fill[] = DEFAULT_SERIES_COLORS.map(\r\n (fill) => fill\r\n)\r\n\r\n// ---- Theme branch resolvers ----------------------------------------------\r\n// Each chart type assembles its own theme out of these, so \"the axis furniture\"\r\n// means one thing across the family and each chart still declares only the\r\n// branches it actually draws.\r\n\r\nexport function resolveAxisConfig(\r\n axis: Partial<AxisConfig> | undefined,\r\n previous: AxisConfig\r\n): AxisConfig {\r\n return {\r\n labelStyle: textOps.resolveStyle(axis?.labelStyle, previous.labelStyle),\r\n titleStyle: textOps.resolveStyle(axis?.titleStyle, previous.titleStyle),\r\n lineStyle: strokeOps.resolve(axis?.lineStyle ?? previous.lineStyle),\r\n tickPadding: insetsOps.resolve(\r\n axis?.tickPadding ?? previous.tickPadding,\r\n previous.tickPadding as InsetsResolved\r\n ),\r\n titlePadding: insetsOps.resolve(\r\n axis?.titlePadding ?? previous.titlePadding,\r\n previous.titlePadding as InsetsResolved\r\n ),\r\n }\r\n}\r\n\r\nexport function lerpAxisConfig(\r\n from: AxisConfig,\r\n to: AxisConfig,\r\n t: number\r\n): AxisConfig {\r\n return {\r\n labelStyle: textOps.lerpStyle(from.labelStyle, to.labelStyle, t),\r\n titleStyle: textOps.lerpStyle(from.titleStyle, to.titleStyle, t),\r\n lineStyle: strokeOps.lerp(\r\n from.lineStyle as StrokeResolved[],\r\n to.lineStyle as StrokeResolved[],\r\n t\r\n ),\r\n tickPadding: insetsOps.lerp(\r\n from.tickPadding as InsetsResolved,\r\n to.tickPadding as InsetsResolved,\r\n t\r\n ),\r\n titlePadding: insetsOps.lerp(\r\n from.titlePadding as InsetsResolved,\r\n to.titlePadding as InsetsResolved,\r\n t\r\n ),\r\n }\r\n}\r\n\r\nexport function resolvePlotArea(\r\n plotArea: Partial<PlotAreaConfig> | undefined,\r\n previous: PlotAreaConfig\r\n): PlotAreaConfig {\r\n return {\r\n fill: fillOps.resolve(plotArea?.fill ?? previous.fill),\r\n stroke: strokeOps.resolve(plotArea?.stroke ?? previous.stroke),\r\n shadow: shadowOps.resolve(plotArea?.shadow ?? previous.shadow),\r\n }\r\n}\r\n\r\nexport function lerpPlotArea(\r\n from: PlotAreaConfig,\r\n to: PlotAreaConfig,\r\n t: number\r\n): PlotAreaConfig {\r\n return {\r\n fill: fillOps.lerp(\r\n from.fill as FillResolved[],\r\n to.fill as FillResolved[],\r\n t\r\n ),\r\n stroke: strokeOps.lerp(\r\n from.stroke as StrokeResolved[],\r\n to.stroke as StrokeResolved[],\r\n t\r\n ),\r\n shadow: shadowOps.lerp(\r\n from.shadow as ShadowResolved[],\r\n to.shadow as ShadowResolved[],\r\n t\r\n ),\r\n }\r\n}\r\n\r\nfunction resolveLegendMarkerConfig(\r\n marker: Partial<LegendMarkerConfig> | undefined,\r\n previous: LegendMarkerConfig\r\n): LegendMarkerConfig {\r\n return {\r\n width: marker?.width ?? previous.width,\r\n height: marker?.height ?? previous.height,\r\n borderRadius: marker?.borderRadius ?? previous.borderRadius,\r\n stroke: strokeOps.resolve(marker?.stroke ?? previous.stroke),\r\n shadow: shadowOps.resolve(marker?.shadow ?? previous.shadow),\r\n }\r\n}\r\n\r\nfunction lerpLegendMarkerConfig(\r\n from: LegendMarkerConfig,\r\n to: LegendMarkerConfig,\r\n t: number\r\n): LegendMarkerConfig {\r\n return {\r\n width: lerpNumber(from.width, to.width, t),\r\n height: lerpNumber(from.height, to.height, t),\r\n borderRadius: lerpNumber(from.borderRadius, to.borderRadius, t),\r\n stroke: strokeOps.lerp(\r\n from.stroke as StrokeResolved[],\r\n to.stroke as StrokeResolved[],\r\n t\r\n ),\r\n shadow: shadowOps.lerp(\r\n from.shadow as ShadowResolved[],\r\n to.shadow as ShadowResolved[],\r\n t\r\n ),\r\n }\r\n}\r\n\r\n/** A legend theme as the author may state it — every branch optional. */\r\nexport type LegendTheme = Partial<Omit<LegendConfig, \"markerStyle\">> & {\r\n markerStyle?: Partial<LegendMarkerConfig>\r\n}\r\n\r\nexport function resolveLegendConfig(\r\n legend: LegendTheme | undefined,\r\n previous: LegendConfig\r\n): LegendConfig {\r\n return {\r\n padding: insetsOps.resolve(\r\n legend?.padding ?? previous.padding,\r\n previous.padding as InsetsResolved\r\n ),\r\n textStyle: textOps.resolveStyle(legend?.textStyle, previous.textStyle),\r\n itemGap: legend?.itemGap ?? previous.itemGap,\r\n markerStyle: resolveLegendMarkerConfig(\r\n legend?.markerStyle,\r\n previous.markerStyle\r\n ),\r\n }\r\n}\r\n\r\nexport function lerpLegendConfig(\r\n from: LegendConfig,\r\n to: LegendConfig,\r\n t: number\r\n): LegendConfig {\r\n return {\r\n padding: insetsOps.lerp(\r\n from.padding as InsetsResolved,\r\n to.padding as InsetsResolved,\r\n t\r\n ),\r\n textStyle: textOps.lerpStyle(from.textStyle, to.textStyle, t),\r\n itemGap: lerpNumber(from.itemGap, to.itemGap, t),\r\n markerStyle: lerpLegendMarkerConfig(from.markerStyle, to.markerStyle, t),\r\n }\r\n}\r\n\r\n/** A whole-palette override replaces the previous palette outright. */\r\nexport function resolveSeriesStrokes(\r\n styles: Stroke[] | undefined,\r\n previous: Stroke[]\r\n): Stroke[] {\r\n return (styles ?? previous).map((s) => strokeOps.resolve(s))\r\n}\r\n\r\n/** Pairwise by index; a palette that grows/shrinks holds the longer side's tail. */\r\nexport function lerpSeriesStrokes(\r\n from: Stroke[],\r\n to: Stroke[],\r\n t: number\r\n): Stroke[] {\r\n const n = Math.max(from.length, to.length)\r\n const out: Stroke[] = []\r\n for (let i = 0; i < n; i++) {\r\n const a = (from[i] ?? to[i]) as StrokeResolved[]\r\n const b = (to[i] ?? from[i]) as StrokeResolved[]\r\n out.push(strokeOps.lerp(a, b, t))\r\n }\r\n return out\r\n}\r\n\r\n/** The fill-palette twin of {@link resolveSeriesStrokes}, for filled marks. */\r\nexport function resolveSeriesFills(\r\n fills: Fill[] | undefined,\r\n previous: Fill[]\r\n): Fill[] {\r\n return (fills ?? previous).map((f) => fillOps.resolve(f))\r\n}\r\n\r\n/** The fill-palette twin of {@link lerpSeriesStrokes}. */\r\nexport function lerpSeriesFills(from: Fill[], to: Fill[], t: number): Fill[] {\r\n const n = Math.max(from.length, to.length)\r\n const out: Fill[] = []\r\n for (let i = 0; i < n; i++) {\r\n const a = (from[i] ?? to[i]) as FillResolved[]\r\n const b = (to[i] ?? from[i]) as FillResolved[]\r\n out.push(fillOps.lerp(a, b, t))\r\n }\r\n return out\r\n}\r\n\r\n// ---- Per-series paint ----------------------------------------------------\r\n\r\n/**\r\n * The effective stroke for series `index`: the palette's entry at\r\n * `index % palette.length`, with the series' own `fill`, if set, overriding just\r\n * the last (topmost) layer's colour.\r\n */\r\nexport function resolveSeriesStroke(\r\n palette: Stroke[],\r\n series: ChartSeries,\r\n index: number\r\n): Stroke {\r\n const entry: Stroke =\r\n palette.length > 0\r\n ? palette[index % palette.length]\r\n : { weight: 4, fill: \"white\" }\r\n if (series.fill == null) return entry\r\n const layers = strokeOps.resolve(entry)\r\n if (layers.length === 0) return { weight: 4, fill: series.fill }\r\n const next = [...layers]\r\n next[next.length - 1] = {\r\n ...next[next.length - 1],\r\n fill: fillOps.resolve(series.fill),\r\n }\r\n return next\r\n}\r\n\r\n/**\r\n * The effective *colour* for series `index` — the same colour\r\n * {@link resolveSeriesStroke} draws its line in — for contexts (a legend\r\n * swatch) that only need the fill.\r\n */\r\nexport function resolveSeriesFill(\r\n palette: Stroke[],\r\n series: ChartSeries,\r\n index: number\r\n): Fill {\r\n const layers = strokeOps.resolve(resolveSeriesStroke(palette, series, index))\r\n return layers[layers.length - 1]?.fill ?? \"white\"\r\n}\r\n\r\n/**\r\n * The effective paint for mark `index` of a **filled** chart (a bar, a wedge):\r\n * the series' own `fill` when it carries one, else the palette's entry for its\r\n * index, cycled.\r\n *\r\n * The stroke twin above has to reach inside a stroke to swap one layer's colour;\r\n * a filled mark has no such geometry wrapped around its paint, so an override is\r\n * simply the whole answer.\r\n */\r\nexport function resolvePalettePaint(\r\n palette: Fill[],\r\n override: Fill | undefined,\r\n index: number\r\n): Fill {\r\n if (override != null) return override\r\n if (palette.length === 0) return \"white\"\r\n return palette[index % palette.length]\r\n}\r\n\r\n// ---- Scales and formatting -----------------------------------------------\r\n\r\n\r\n/**\r\n * Format a marker value: integers plain, otherwise trimmed to one decimal, or to\r\n * as many as the axis's tick `step` needs to tell neighbouring ticks apart.\r\n *\r\n * One decimal is the floor, so a step of 0.1 or more reads exactly as it always\r\n * has; a finer step (a unit axis ticked every 0.05) gets two, instead of five\r\n * ticks captioned `0.1 0.1 0.2 0.2 0.3`. Trailing zeros are dropped either way.\r\n */\r\nexport function formatMarker(value: number, step?: number): string {\r\n if (Number.isInteger(value)) return String(value)\r\n const decimals = Math.max(1, step === undefined ? 1 : decimalsFor(step))\r\n return value.toFixed(decimals).replace(/(\\.\\d*?)0+$/, \"$1\").replace(/\\.$/, \"\")\r\n}\r\n\r\n/** Decimal places needed to write `step` exactly, capped at six. */\r\nfunction decimalsFor(step: number): number {\r\n if (!(step > 0) || !Number.isFinite(step)) return 1\r\n for (let d = 0; d <= 6; d++) {\r\n const scaled = step * 10 ** d\r\n if (Math.abs(scaled - Math.round(scaled)) < 1e-6 * Math.max(1, scaled)) return d\r\n }\r\n // An irrational-looking step (a third): as many places as separate the ticks.\r\n return Math.min(6, Math.max(1, Math.ceil(-Math.log10(step)) + 1))\r\n}\r\n\r\n/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */\r\nexport function markerStep(markers: readonly number[]): number | undefined {\r\n const sorted = [...markers].filter(Number.isFinite).sort((a, b) => a - b)\r\n let step: number | undefined\r\n for (let i = 1; i < sorted.length; i++) {\r\n const gap = sorted[i] - sorted[i - 1]\r\n if (gap > 1e-12 && (step === undefined || gap < step)) step = gap\r\n }\r\n return step\r\n}\r\n\r\n/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */\r\nexport function formatPercent(fraction: number): string {\r\n const pct = fraction * 100\r\n if (Number.isInteger(pct)) return `${pct}%`\r\n return `${pct.toFixed(1).replace(/\\.0$/, \"\")}%`\r\n}\r\n\r\n/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */\r\nexport function markerValues([min, max]: Range, markerCount: number): number[] {\r\n const n = Math.max(2, Math.round(markerCount))\r\n return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i)\r\n}\r\n\r\n// Lifted into the engine, because a graph and a diagram want them too — see\r\n// `@motionscript/sdk/component`. Re-exported so a chart, and anything that\r\n// copied one, still reaches them where it always did.\r\nexport { niceStep, enterBudget } from \"@motionscript/sdk/component\"\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node2D, type CommandArgs, type NodeConfig, type Node2DProps } from "@motionscript/
|
|
1
|
+
import { Node2D, type CommandArgs, type NodeConfig, type Node2DProps } from "@motionscript/sdk";
|
|
2
2
|
import { type AxisConfig, type Range } from "./shared.js";
|
|
3
|
-
import { type Seekable } from "@motionscript/
|
|
3
|
+
import { type Seekable } from "@motionscript/sdk/component";
|
|
4
4
|
export interface VerticalAxisProps extends Node2DProps {
|
|
5
5
|
/** `[min, max]` of the vertical scale the markers are positioned within. */
|
|
6
6
|
range: Range;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertical-axis.d.ts","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAQN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"vertical-axis.d.ts","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAQN,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AACjB,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAExE,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,4EAA4E;IAC5E,KAAK,EAAE,KAAK,CAAA;IACZ;;;;OAIG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,oFAAoF;IACpF,IAAI,EAAE,UAAU,CAAA;IAChB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAKD,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,YAAa,SAAQ,MAAM,CAAC,iBAAiB,CAAC;IACH,KAAK,EAAE,KAAK,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;IAEhD;;;;;;;OAOG;IACH,QAAQ,EAAE,WAAW,CAAe;IAEpC,+EAA+E;IAC/E,OAAO,CAAC,WAAW,CAAa;IAChC,kFAAkF;IAClF,OAAO,CAAC,SAAS,CAAoB;IAErC,gFAAgF;IAChF,OAAO,KAAK,aAAa,GAExB;IAED;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAIf,yEAAyE;IACzE,OAAO,CAAC,MAAM;gBAOF,KAAK,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,iBAAiB,CAAC;IA0D/D;;;;OAIG;IACH,GAAG,CAAC,KAAK,SAAQ,GAAG,IAAI;IAKxB;;;;;;;;;;;;;;OAcG;IAEH,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ;CA6BhG"}
|
|
@@ -4,9 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { command, Node2D, Rect, RotatedBox, Text, easeOut, property, insetsOps, textOps, } from "@motionscript/
|
|
7
|
+
import { command, Node2D, Rect, RotatedBox, Text, easeOut, property, insetsOps, textOps, } from "@motionscript/sdk";
|
|
8
8
|
import { DEFAULT_Y_AXIS, enterBudget, formatMarker, } from "./shared.js";
|
|
9
|
-
import { at, compose } from "@motionscript/
|
|
9
|
+
import { at, compose } from "@motionscript/sdk/component";
|
|
10
10
|
/** How far a marker starts to the right of its slot when it enters, in px. */
|
|
11
11
|
const SLIDE = 24;
|
|
12
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertical-axis.js","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,GAIR,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GAGb,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,EAAE,EAAE,OAAO,EAAiB,MAAM,8BAA8B,CAAA;AAqBzE,8EAA8E;AAC9E,MAAM,KAAK,GAAG,EAAE,CAAA;AAKhB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAyB;IAMzD;;;;;;;OAOG;IACH,QAAQ,GAAgB,YAAY,CAAA;IAEpC,+EAA+E;IACvE,WAAW,GAAW,EAAE,CAAA;IAChC,kFAAkF;IAC1E,SAAS,GAAgB,IAAI,CAAA;IAErC,gFAAgF;IAChF,IAAY,aAAa;QACvB,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACK,OAAO,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED,yEAAyE;IACjE,MAAM,CAAC,KAAa;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC7B,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,CAAA;QAC7B,MAAM,CAAC,GAAG,EAAE,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EAAsE;QACtE,OAAO,OAAO,CAAC;YACb,GAAG,OAAO;YACV,GAAG,CAAC,IAAI,CAAC,SAAS;gBAChB,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;gBACpG,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAA;IACJ,CAAC;CACF;AA3JuD;IAArD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAU,EAAE,CAAC;2CAAqB;AACb;IAApD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAc,EAAE,CAAC;6CAA0B;AACvB;IAA9C,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;0CAAyB;AAC5B;IAAlC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;2CAAsB;AA2HhD;IADC,OAAO,EAAE;yCA6BT","sourcesContent":["import {\n command,\n Node2D,\n Rect,\n RotatedBox,\n Text,\n easeOut,\n property,\n insetsOps,\n textOps,\n type CommandArgs,\n type NodeConfig,\n type Node2DProps,\n} from \"@motionscript/core\"\n\nimport {\n DEFAULT_Y_AXIS,\n enterBudget,\n formatMarker,\n type AxisConfig,\n type Range,\n} from \"./shared\"\nimport { at, compose, type Seekable } from \"@motionscript/core/component\"\n\nexport interface VerticalAxisProps extends Node2DProps {\n /** `[min, max]` of the vertical scale the markers are positioned within. */\n range: Range\n /**\n * Tick values (in data units) to draw up the axis, each placed by its fraction\n * across {@link VerticalAxisProps.range}. Need not be evenly spaced or include\n * the ends.\n */\n markers: number[]\n /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */\n axis: AxisConfig\n /**\n * Rotated caption drawn in the gutter to the left of the marker column. Empty\n * string (the default) hides it — no caption node is built and no label gutter\n * is reserved.\n */\n label: string\n}\n\n/** How far a marker starts to the right of its slot when it enters, in px. */\nconst SLIDE = 24\n\n/** How a tick value is captioned — see {@link VerticalAxis.labelFor}. */\nexport type MarkerLabel = (value: number) => string\n\n/**\n * The numeric vertical axis shared by the cartesian charts: a **column of\n * {@link Text} nodes**, one per marker value, running top-to-bottom (highest\n * value at the top). Pure layout — no `Graphics` — so the markers are real text\n * nodes the scene can measure, restyle, or animate individually.\n *\n * Each marker is positioned so its centre lands exactly on its value's fraction\n * across `range` within the axis's filled height, so unevenly-spaced markers\n * land where their values fall. Both the caption and the position are *bound*,\n * not snapshotted: a chart that rescales its axes (see `LineChart.zoomTo`)\n * tweens `range`/`markers` live. Only the marker **count** is fixed at\n * construction.\n *\n * {@link enter} staggers them in **bottom-to-top**: each marker starts pushed a\n * little to the right and transparent, then fades and slides left into place.\n * The resting state is the landed one, so a chart that is never told to enter\n * still reads as a finished chart.\n */\nexport class VerticalAxis extends Node2D<VerticalAxisProps> {\n @property({ default: () => [0, 1] as Range }) declare range: Range\n @property({ default: () => [] as number[] }) declare markers: number[]\n @property({ default: DEFAULT_Y_AXIS }) declare axis: AxisConfig\n @property({ default: \"\" }) declare label: string\n\n /**\n * How a tick value is captioned. Defaults to the bare numeric reading; a\n * chart with a number format on this axis replaces it (see `number-format`).\n *\n * A plain field rather than a `@property`, for the reason the horizontal\n * axis's twin spells out: it is a policy, not a value, and there is nothing\n * to tween between two formatters.\n */\n labelFor: MarkerLabel = formatMarker\n\n /** One text node per marker, ordered top → bottom, for the staggered enter. */\n private markerNodes: Text[] = []\n /** The caption node, or null when `label` is empty. Entered after the markers. */\n private labelNode: Text | null = null\n\n /** The live tick values, top → bottom (highest first) — re-read every frame. */\n private get sortedMarkers(): number[] {\n return [...this.markers].sort((a, b) => b - a)\n }\n\n /**\n * Tick `i`'s value, or `undefined` once the live `markers` list is shorter\n * than the column of text nodes built for it — a slot with no value renders as\n * empty text rather than repeating its neighbour.\n */\n private valueAt(index: number): number | undefined {\n return this.sortedMarkers[index]\n }\n\n /** Tick `i`'s fraction across the live `range`, 0 at the bottom edge. */\n private fracAt(index: number): number {\n const v = this.valueAt(index)\n if (v === undefined) return 0\n const [min, max] = this.range\n return max <= min ? 0 : (v - min) / (max - min)\n }\n\n constructor(props?: NodeConfig<VerticalAxis, VerticalAxisProps>) {\n super(props)\n\n // Composed from plain props (range/markers/label) — no context needed, so\n // it's built here. super() applied the props, so the reads below resolve.\n const tickPad = insetsOps.resolve(this.axis.tickPadding).right\n const titlePad = insetsOps.resolve(this.axis.titlePadding).right\n\n this.markerNodes = this.markers.map((_, i) => {\n const marker: Text = new Text({\n ...textOps.styleProps(this.axis.labelStyle),\n text: () => {\n const v = this.valueAt(i)\n return v === undefined ? \"\" : this.labelFor(v)\n },\n y: () => {\n // Node2D space is y-up, so the fraction runs from the bottom.\n const height = this.layoutBounds.height\n const centred = (this.fracAt(i) - 0.5) * height\n // Held inside the axis's top edge — the backstop for a chart whose\n // headroom is smaller than its marker text is tall, which a theme with\n // much larger markers can arrange. Only the top, because what lies\n // below the axis is the chart's own horizontal axis and legend.\n const limit = height / 2 - marker.layoutBounds.height / 2\n return Math.min(centred, limit)\n },\n })\n return marker\n })\n\n const children: Node2D[] = []\n if (this.label !== \"\") {\n this.labelNode = new Text({\n ...textOps.styleProps(this.axis.titleStyle),\n text: this.label,\n })\n // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.\n children.push(\n new RotatedBox({\n angle: -90,\n width: \"hug\",\n height: \"hug\",\n children: this.labelNode,\n })\n )\n }\n children.push(\n new Rect({\n height: \"fill\",\n width: \"hug\",\n padding: { right: tickPad },\n children: this.markerNodes,\n })\n )\n\n this.add(new Rect({ flow: \"horizontal\", gap: titlePad, children }))\n }\n\n /**\n * Primes every marker (and the caption) at its pre-entrance state: shifted\n * right and transparent. Idempotent, and separate from {@link enter} so the\n * chart can arm its whole composition before the first frame is drawn.\n */\n arm(slide = SLIDE): void {\n for (const marker of this.markerNodes) marker.set({ opacity: 0, x: slide })\n this.labelNode?.set({ opacity: 0, x: slide })\n }\n\n /**\n * Stagger the markers in bottom to top, then slide the caption in from the\n * right after them.\n *\n * A {@link Seekable} rather than a generator — see the note on the horizontal\n * axis's `enter`. The offsets were always static; expressing them as `wait`\n * inside a generator is what made them reachable only by running it.\n *\n * `args.duration` is the **whole** entrance, not one marker's slide: the\n * stagger and the caption are carved out of it rather than added on top. See\n * {@link enterBudget} for why that distinction matters here.\n *\n * `args.data.stagger` is seconds between successive markers (derived when\n * omitted); `args.data.slide` is the starting rightward offset in px.\n */\n @command()\n enter(args: CommandArgs<{ stagger?: number; slide?: number }> & { duration: number }): Seekable {\n const { stagger, slide = SLIDE } = args.data ?? {}\n const easing = args.easing ?? easeOut()\n const nodes = this.markerNodes\n if (nodes.length === 0) return compose([])\n const { step, per, caption } = enterBudget(\n args.duration,\n nodes.length,\n this.labelNode !== null,\n stagger\n )\n\n this.arm(slide)\n\n // Bottom marker leads: markerNodes is top → bottom, so walk it in reverse.\n const markers = nodes.map((node, i) => {\n const order = nodes.length - 1 - i // bottom-most = 0\n return at(order * step, node.to({ data: { opacity: 1, x: 0 }, duration: per, easing }))\n })\n const lastMarkerEnds = (nodes.length - 1) * step + per\n\n // Once every marker has landed, the caption slides in from the right.\n return compose([\n ...markers,\n ...(this.labelNode\n ? [at(lastMarkerEnds, this.labelNode.to({ data: { opacity: 1, x: 0 }, duration: caption, easing }))]\n : []),\n ])\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vertical-axis.js","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,GAIR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,cAAc,EACd,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D,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAU,EAAE,CAAC;2CAAqB;AACb;IAApD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAc,EAAE,CAAC;6CAA0B;AACvB;IAA9C,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;0CAAyB;AAC5B;IAAlC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;2CAAsB;AA2HhD;IADC,OAAO,EAAE;yCA6BT","sourcesContent":["import {\r\n command,\r\n Node2D,\r\n Rect,\r\n RotatedBox,\r\n Text,\r\n easeOut,\r\n property,\r\n insetsOps,\r\n textOps,\r\n type CommandArgs,\r\n type NodeConfig,\r\n type Node2DProps,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport {\r\n DEFAULT_Y_AXIS,\r\n enterBudget,\r\n formatMarker,\r\n type AxisConfig,\r\n type Range,\r\n} from \"./shared\"\r\nimport { at, compose, type Seekable } from \"@motionscript/sdk/component\"\r\n\r\nexport interface VerticalAxisProps extends Node2DProps {\r\n /** `[min, max]` of the vertical scale the markers are positioned within. */\r\n range: Range\r\n /**\r\n * Tick values (in data units) to draw up the axis, each placed by its fraction\r\n * across {@link VerticalAxisProps.range}. Need not be evenly spaced or include\r\n * the ends.\r\n */\r\n markers: number[]\r\n /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */\r\n axis: AxisConfig\r\n /**\r\n * Rotated caption drawn in the gutter to the left of the marker column. Empty\r\n * string (the default) hides it — no caption node is built and no label gutter\r\n * is reserved.\r\n */\r\n label: string\r\n}\r\n\r\n/** How far a marker starts to the right of its slot when it enters, in px. */\r\nconst SLIDE = 24\r\n\r\n/** How a tick value is captioned — see {@link VerticalAxis.labelFor}. */\r\nexport type MarkerLabel = (value: number) => string\r\n\r\n/**\r\n * The numeric vertical axis shared by the cartesian charts: a **column of\r\n * {@link Text} nodes**, one per marker value, running top-to-bottom (highest\r\n * value at the top). Pure layout — no `Graphics` — so the markers are real text\r\n * nodes the scene can measure, restyle, or animate individually.\r\n *\r\n * Each marker is positioned so its centre lands exactly on its value's fraction\r\n * across `range` within the axis's filled height, so unevenly-spaced markers\r\n * land where their values fall. Both the caption and the position are *bound*,\r\n * not snapshotted: a chart that rescales its axes (see `LineChart.zoomTo`)\r\n * tweens `range`/`markers` live. Only the marker **count** is fixed at\r\n * construction.\r\n *\r\n * {@link enter} staggers them in **bottom-to-top**: each marker starts pushed a\r\n * little to the right and transparent, then fades and slides left into place.\r\n * The resting state is the landed one, so a chart that is never told to enter\r\n * still reads as a finished chart.\r\n */\r\nexport class VerticalAxis extends Node2D<VerticalAxisProps> {\r\n @property({ default: () => [0, 1] as Range }) declare range: Range\r\n @property({ default: () => [] as number[] }) declare markers: number[]\r\n @property({ default: DEFAULT_Y_AXIS }) declare axis: AxisConfig\r\n @property({ default: \"\" }) declare label: string\r\n\r\n /**\r\n * How a tick value is captioned. Defaults to the bare numeric reading; a\r\n * chart with a number format on this axis replaces it (see `number-format`).\r\n *\r\n * A plain field rather than a `@property`, for the reason the horizontal\r\n * axis's twin spells out: it is a policy, not a value, and there is nothing\r\n * to tween between two formatters.\r\n */\r\n labelFor: MarkerLabel = formatMarker\r\n\r\n /** One text node per marker, ordered top → bottom, for the staggered enter. */\r\n private markerNodes: Text[] = []\r\n /** The caption node, or null when `label` is empty. Entered after the markers. */\r\n private labelNode: Text | null = null\r\n\r\n /** The live tick values, top → bottom (highest first) — re-read every frame. */\r\n private get sortedMarkers(): number[] {\r\n return [...this.markers].sort((a, b) => b - a)\r\n }\r\n\r\n /**\r\n * Tick `i`'s value, or `undefined` once the live `markers` list is shorter\r\n * than the column of text nodes built for it — a slot with no value renders as\r\n * empty text rather than repeating its neighbour.\r\n */\r\n private valueAt(index: number): number | undefined {\r\n return this.sortedMarkers[index]\r\n }\r\n\r\n /** Tick `i`'s fraction across the live `range`, 0 at the bottom edge. */\r\n private fracAt(index: number): number {\r\n const v = this.valueAt(index)\r\n if (v === undefined) return 0\r\n const [min, max] = this.range\r\n return max <= min ? 0 : (v - min) / (max - min)\r\n }\r\n\r\n constructor(props?: NodeConfig<VerticalAxis, VerticalAxisProps>) {\r\n super(props)\r\n\r\n // Composed from plain props (range/markers/label) — no context needed, so\r\n // it's built here. super() applied the props, so the reads below resolve.\r\n const tickPad = insetsOps.resolve(this.axis.tickPadding).right\r\n const titlePad = insetsOps.resolve(this.axis.titlePadding).right\r\n\r\n this.markerNodes = this.markers.map((_, i) => {\r\n const marker: Text = new Text({\r\n ...textOps.styleProps(this.axis.labelStyle),\r\n text: () => {\r\n const v = this.valueAt(i)\r\n return v === undefined ? \"\" : this.labelFor(v)\r\n },\r\n y: () => {\r\n // Node2D space is y-up, so the fraction runs from the bottom.\r\n const height = this.layoutBounds.height\r\n const centred = (this.fracAt(i) - 0.5) * height\r\n // Held inside the axis's top edge — the backstop for a chart whose\r\n // headroom is smaller than its marker text is tall, which a theme with\r\n // much larger markers can arrange. Only the top, because what lies\r\n // below the axis is the chart's own horizontal axis and legend.\r\n const limit = height / 2 - marker.layoutBounds.height / 2\r\n return Math.min(centred, limit)\r\n },\r\n })\r\n return marker\r\n })\r\n\r\n const children: Node2D[] = []\r\n if (this.label !== \"\") {\r\n this.labelNode = new Text({\r\n ...textOps.styleProps(this.axis.titleStyle),\r\n text: this.label,\r\n })\r\n // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.\r\n children.push(\r\n new RotatedBox({\r\n angle: -90,\r\n width: \"hug\",\r\n height: \"hug\",\r\n children: this.labelNode,\r\n })\r\n )\r\n }\r\n children.push(\r\n new Rect({\r\n height: \"fill\",\r\n width: \"hug\",\r\n padding: { right: tickPad },\r\n children: this.markerNodes,\r\n })\r\n )\r\n\r\n this.add(new Rect({ flow: \"horizontal\", gap: titlePad, children }))\r\n }\r\n\r\n /**\r\n * Primes every marker (and the caption) at its pre-entrance state: shifted\r\n * right and transparent. Idempotent, and separate from {@link enter} so the\r\n * chart can arm its whole composition before the first frame is drawn.\r\n */\r\n arm(slide = SLIDE): void {\r\n for (const marker of this.markerNodes) marker.set({ opacity: 0, x: slide })\r\n this.labelNode?.set({ opacity: 0, x: slide })\r\n }\r\n\r\n /**\r\n * Stagger the markers in bottom to top, then slide the caption in from the\r\n * right after them.\r\n *\r\n * A {@link Seekable} rather than a generator — see the note on the horizontal\r\n * axis's `enter`. The offsets were always static; expressing them as `wait`\r\n * inside a generator is what made them reachable only by running it.\r\n *\r\n * `args.duration` is the **whole** entrance, not one marker's slide: the\r\n * stagger and the caption are carved out of it rather than added on top. See\r\n * {@link enterBudget} for why that distinction matters here.\r\n *\r\n * `args.data.stagger` is seconds between successive markers (derived when\r\n * omitted); `args.data.slide` is the starting rightward offset in px.\r\n */\r\n @command()\r\n enter(args: CommandArgs<{ stagger?: number; slide?: number }> & { duration: number }): Seekable {\r\n const { stagger, slide = SLIDE } = args.data ?? {}\r\n const easing = args.easing ?? easeOut()\r\n const nodes = this.markerNodes\r\n if (nodes.length === 0) return compose([])\r\n const { step, per, caption } = enterBudget(\r\n args.duration,\r\n nodes.length,\r\n this.labelNode !== null,\r\n stagger\r\n )\r\n\r\n this.arm(slide)\r\n\r\n // Bottom marker leads: markerNodes is top → bottom, so walk it in reverse.\r\n const markers = nodes.map((node, i) => {\r\n const order = nodes.length - 1 - i // bottom-most = 0\r\n return at(order * step, node.to({ data: { opacity: 1, x: 0 }, duration: per, easing }))\r\n })\r\n const lastMarkerEnds = (nodes.length - 1) * step + per\r\n\r\n // Once every marker has landed, the caption slides in from the right.\r\n return compose([\r\n ...markers,\r\n ...(this.labelNode\r\n ? [at(lastMarkerEnds, this.labelNode.to({ data: { opacity: 1, x: 0 }, duration: caption, easing }))]\r\n : []),\r\n ])\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AssetScope, Node2D, type Command, type CommandArgs, type EasingFunction, type Node2DProps, type RenderContext2D, type Stroke, type Vector2 } from "@motionscript/
|
|
1
|
+
import { type AssetScope, Node2D, type Command, type CommandArgs, type EasingFunction, type Node2DProps, type RenderContext2D, type Stroke, type Vector2 } from "@motionscript/sdk";
|
|
2
2
|
import { type RegionBox } from "./shared.js";
|
|
3
3
|
export interface ChartLineProps extends Node2DProps {
|
|
4
4
|
/**
|
|
@@ -12,8 +12,8 @@ export interface ChartLineProps extends Node2DProps {
|
|
|
12
12
|
* Reveal of the line in `[0, 1]`: 0 hides it, 1 traces it fully from its left
|
|
13
13
|
* end to its right.
|
|
14
14
|
*
|
|
15
|
-
* Defaults to **1**, unlike the standalone chart this was ported from: in
|
|
16
|
-
*
|
|
15
|
+
* Defaults to **1**, unlike the standalone chart this was ported from: in an
|
|
16
|
+
* editor a node's resting state is what the paused editor canvas paints, so a
|
|
17
17
|
* chart that only appeared once a command had run would edit blind. {@link
|
|
18
18
|
* enter} drives it from 0 regardless of where it rests, so the animation is
|
|
19
19
|
* unchanged.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-line.d.ts","sourceRoot":"","sources":["../../src/line-chart/chart-line.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,MAAM,EAKN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EAEX,KAAK,OAAO,EACb,MAAM,
|
|
1
|
+
{"version":3,"file":"chart-line.d.ts","sourceRoot":"","sources":["../../src/line-chart/chart-line.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,MAAM,EAKN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EAEX,KAAK,OAAO,EACb,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,UAAU,CAAA;AAGjB,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD;;;OAGG;IACH,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAA;IACd;;;;;;;;;OASG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;;;OAIG;IACH,SAAS,EAAE,SAAS,CAAA;IACpB,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,MAAM,CAAC,cAAc,CAAC;IACG,MAAM,EAAE,OAAO,EAAE,CAAA;IAE/D,MAAM,EAAE,MAAM,CAAA;IACY,QAAQ,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IACE,SAAS,EAAE,SAAS,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAEhE;;;OAGG;IACM,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAKhD,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAuChD;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IA+BnB;;;;;;;;;OASG;IAEH,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/F;;;;;;;;;;;OAWG;IACH,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,cAA0B,EAClC,EAAE,SAAI,GACL,OAAO,CAAC,cAAc,CAAC;CAY3B"}
|
|
@@ -4,10 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Graphics2D, Node2D, command, easeOut, strokeOps, property, } from "@motionscript/
|
|
7
|
+
import { Graphics2D, Node2D, command, easeOut, strokeOps, property, } from "@motionscript/sdk";
|
|
8
8
|
import { SPOTLIGHT_DIM } from "../kit/shared.js";
|
|
9
9
|
import { EMPTY_REGION_BOX, clipPolylineToBox, hasRegion, } from "./shared.js";
|
|
10
|
-
import { declarePaints } from "@motionscript/
|
|
10
|
+
import { declarePaints } from "@motionscript/sdk/component";
|
|
11
11
|
/**
|
|
12
12
|
* A single series line of a {@link LineChart}: one rounded polyline traced
|
|
13
13
|
* through pre-mapped pixel `points`, drawn as one {@link Graphics2D} command list.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-line.js","sourceRoot":"","sources":["../../src/line-chart/chart-line.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,GAST,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,GAEV,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAoC5D;;;;;;;GAOG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAsB;IASnD;;;OAGG;IACM,aAAa,CAAC,MAAkB;QACvC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QAC3B,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC7B,CAAC;IAES,UAAU,CAAC,GAAoB;QACvC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;QACvB,IAAI,GAAG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;YACvC,yEAAyE;YACzE,iEAAiE;YACjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,CAAC,EAAE,CAAA;QAC5C,CAAC,EACD,QAAQ,EACR,MAAM,CACP,CAAA;IACH,CAAC;CACF;AAzIuD;IAArD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAe,EAAE,CAAC;yCAA0B;AAE/D;IADP,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;yCACtD;AACY;IAAjC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;2CAAyB;AACb;IAApC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAyB;AACE;IAAtD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;4CAA6B;AAC7B;IAA7C,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;6CAA2B;AAkGhE;IADC,OAAO,EAAE;sCAGT","sourcesContent":["import {\n type AssetScope,\n Graphics2D,\n Node2D,\n command,\n easeOut,\n strokeOps,\n property,\n type Command,\n type CommandArgs,\n type EasingFunction,\n type Node2DProps,\n type RenderContext2D,\n type Stroke,\n type StrokeResolved,\n type Vector2,\n} from \"@motionscript/core\"\n\nimport { SPOTLIGHT_DIM } from \"../kit/shared\"\nimport {\n EMPTY_REGION_BOX,\n clipPolylineToBox,\n hasRegion,\n type RegionBox,\n} from \"./shared\"\nimport { declarePaints } from \"@motionscript/core/component\"\n\nexport interface ChartLineProps extends Node2DProps {\n /**\n * The series polyline, already mapped into this node's local pixel space\n * (origin at centre, y-up) by the parent {@link LineChart}. Ordered along x.\n */\n points: Vector2[]\n /** Line colour + weight (+ optional dash/cap/join) — the per-series stroke. */\n stroke: Stroke\n /**\n * Reveal of the line in `[0, 1]`: 0 hides it, 1 traces it fully from its left\n * end to its right.\n *\n * Defaults to **1**, unlike the standalone chart this was ported from: in the\n * studio a node's resting state is what the paused editor canvas paints, so a\n * chart that only appeared once a command had run would edit blind. {@link\n * enter} drives it from 0 regardless of where it rests, so the animation is\n * unchanged.\n */\n progress: number\n /**\n * Whether this line is drawn at all. `false` hides it outright — the switch\n * the chart flips alongside its legend's per-series toggle.\n */\n enabled: boolean\n /**\n * A slice of the plot to spotlight, in this node's own pixel space. When set\n * to a real box, the stretches of the line *outside* it drop to\n * {@link ChartLineProps.dimOpacity} while the stretches inside stay full.\n */\n spotlight: RegionBox\n /** Opacity the out-of-region stretches fade to. */\n dimOpacity: number\n}\n\n/**\n * A single series line of a {@link LineChart}: one rounded polyline traced\n * through pre-mapped pixel `points`, drawn as one {@link Graphics2D} command list.\n * Sized and positioned by the parent, which shares the plot's coordinate frame.\n *\n * Two signals drive it: {@link ChartLineProps.progress} traces the line in\n * (animated by {@link enter}) and `enabled` shows or hides it wholesale.\n */\nexport class ChartLine extends Node2D<ChartLineProps> {\n @property({ default: () => [] as Vector2[] }) declare points: Vector2[]\n @property({ default: [], mapper: strokeOps.resolve, tween: strokeOps.lerp })\n declare stroke: Stroke\n @property({ default: 1 }) declare progress: number\n @property({ default: true }) declare enabled: boolean\n @property({ default: () => EMPTY_REGION_BOX }) declare spotlight: RegionBox\n @property({ default: SPOTLIGHT_DIM }) declare dimOpacity: number\n\n /**\n * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the\n * paint props it carries — see {@link declarePaints}.\n */\n override declareAssets(assets: AssetScope): void {\n super.declareAssets(assets)\n declarePaints(this, assets)\n }\n\n protected renderSelf(ctx: RenderContext2D): void {\n if (!this.enabled) return\n const pts = this.points\n if (pts.length < 2) return\n\n const p = Math.max(0, Math.min(1, this.progress))\n if (p <= 0) return\n\n const drawn = this.tracePoints(pts, p)\n if (drawn.length < 2) return\n const stroke = this.stroke as StrokeResolved[]\n const radius = (stroke[0]?.weight ?? 0) * 2 // round the joins\n\n const box = this.spotlight\n if (!hasRegion(box)) {\n ctx.draw(new Graphics2D().line({ points: drawn, radius }).stroke(stroke))\n return\n }\n\n // Spotlit: the whole line goes down to `dimOpacity`, then the stretches\n // inside the region are re-drawn over it at full strength. Two passes rather\n // than one dim + one bright *complementary* pair, so the bright run has\n // continuous geometry through the region and its joins round the way an\n // unspotlit line's do — and so the boundary lands exactly on the region edge.\n ctx.draw(\n new Graphics2D()\n .line({ points: drawn, radius })\n .stroke(stroke)\n .opacity(Math.max(0, Math.min(1, this.dimOpacity)))\n )\n\n // One `draw` per run: shapes chained before a `stroke()` are combined into a\n // single surface, and stroking a union of disjoint open paths doesn't paint\n // — so a line that leaves the region and comes back would lose both halves.\n for (const run of clipPolylineToBox(drawn, box)) {\n ctx.draw(new Graphics2D().line({ points: run, radius }).stroke(stroke))\n }\n }\n\n /**\n * The prefix of `pts` revealed at fraction `p ∈ [0, 1]`, measuring the reveal\n * by *cumulative arc length* so the line traces at a steady pace regardless of\n * uneven point spacing. Returns the whole-point prefix plus one interpolated\n * point partway along the active segment.\n */\n private tracePoints(pts: Vector2[], p: number): Vector2[] {\n if (p >= 1 || pts.length < 2) return pts\n if (p <= 0) return []\n\n const segLen: number[] = []\n let total = 0\n for (let i = 1; i < pts.length; i++) {\n const d = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y)\n segLen.push(d)\n total += d\n }\n if (total === 0) return pts\n\n let target = total * p\n const out: Vector2[] = [pts[0]]\n for (let i = 0; i < segLen.length; i++) {\n if (target >= segLen[i]) {\n out.push(pts[i + 1])\n target -= segLen[i]\n } else {\n const t = segLen[i] === 0 ? 0 : target / segLen[i]\n out.push({\n x: pts[i].x + (pts[i + 1].x - pts[i].x) * t,\n y: pts[i].y + (pts[i + 1].y - pts[i].y) * t,\n })\n break\n }\n }\n return out\n }\n\n /**\n * Trace the line in from its left end to its right over `duration` seconds.\n * Drives `progress` `0 → 1`.\n *\n * A `Command` rather than a generator, so the trace can be *evaluated* at a\n * time instead of run to one — which is what lets a scene containing this\n * chart be scrubbed in constant time. It no longer needs to prime `progress`\n * to 0 first: the value at `t` is a function of `t`, so a repeat call re-traces\n * by definition rather than by having reset something.\n */\n @command()\n enter(args: CommandArgs<Record<string, never>> & { duration: number }): Command<ChartLineProps> {\n return this.enterFrom(0, args.duration, args.easing ?? easeOut())\n }\n\n /**\n * The trace, with both ends stated: `progress` runs `from` → `to`.\n *\n * What {@link LineChart.showSeries} and `hideSeries` are both made of — they\n * are the same motion in opposite directions, and expressing them as one thing\n * with endpoints is what stops the pair drifting apart.\n *\n * `enabled` rides along in the same value rather than being set before or after\n * the command. A line is drawable for every `t` the trace covers and undrawn\n * outside it, which is what makes arriving at a time backwards show what\n * arriving forwards does — a flag flipped by a side effect would not.\n */\n enterFrom(\n from: number,\n duration: number,\n easing: EasingFunction = easeOut(),\n to = 1\n ): Command<ChartLineProps> {\n return this.command<ChartLineProps>(\n (t) => {\n const progress = from + (to - from) * t\n // Hidden only once it has fully retraced, so the last frame of a hide is\n // the empty plot rather than a line that vanished a frame early.\n return { progress, enabled: progress > 0 }\n },\n duration,\n easing\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart-line.js","sourceRoot":"","sources":["../../src/line-chart/chart-line.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,UAAU,EACV,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,GAST,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,GAEV,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAoC3D;;;;;;;GAOG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAsB;IASnD;;;OAGG;IACM,aAAa,CAAC,MAAkB;QACvC,KAAK,CAAC,aAAa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,SAAS,CACP,IAAY,EACZ,QAAgB,EAChB,SAAyB,OAAO,EAAE,EAClC,EAAE,GAAG,CAAC;QAEN,OAAO,IAAI,CAAC,OAAO,CACjB,CAAC,CAAC,EAAE,EAAE;YACJ,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;YACvC,yEAAyE;YACzE,iEAAiE;YACjE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAG,CAAC,EAAE,CAAA;QAC5C,CAAC,EACD,QAAQ,EACR,MAAM,CACP,CAAA;IACH,CAAC;CACF;AAzIuD;IAArD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAe,EAAE,CAAC;yCAA0B;AAE/D;IADP,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;yCACtD;AACY;IAAjC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;2CAAyB;AACb;IAApC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAyB;AACE;IAAtD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;4CAA6B;AAC7B;IAA7C,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;6CAA2B;AAkGhE;IADC,OAAO,EAAE;sCAGT","sourcesContent":["import {\r\n type AssetScope,\r\n Graphics2D,\r\n Node2D,\r\n command,\r\n easeOut,\r\n strokeOps,\r\n property,\r\n type Command,\r\n type CommandArgs,\r\n type EasingFunction,\r\n type Node2DProps,\r\n type RenderContext2D,\r\n type Stroke,\r\n type StrokeResolved,\r\n type Vector2,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport { SPOTLIGHT_DIM } from \"../kit/shared\"\r\nimport {\r\n EMPTY_REGION_BOX,\r\n clipPolylineToBox,\r\n hasRegion,\r\n type RegionBox,\r\n} from \"./shared\"\r\nimport { declarePaints } from \"@motionscript/sdk/component\"\r\n\r\nexport interface ChartLineProps extends Node2DProps {\r\n /**\r\n * The series polyline, already mapped into this node's local pixel space\r\n * (origin at centre, y-up) by the parent {@link LineChart}. Ordered along x.\r\n */\r\n points: Vector2[]\r\n /** Line colour + weight (+ optional dash/cap/join) — the per-series stroke. */\r\n stroke: Stroke\r\n /**\r\n * Reveal of the line in `[0, 1]`: 0 hides it, 1 traces it fully from its left\r\n * end to its right.\r\n *\r\n * Defaults to **1**, unlike the standalone chart this was ported from: in an\r\n * editor a node's resting state is what the paused editor canvas paints, so a\r\n * chart that only appeared once a command had run would edit blind. {@link\r\n * enter} drives it from 0 regardless of where it rests, so the animation is\r\n * unchanged.\r\n */\r\n progress: number\r\n /**\r\n * Whether this line is drawn at all. `false` hides it outright — the switch\r\n * the chart flips alongside its legend's per-series toggle.\r\n */\r\n enabled: boolean\r\n /**\r\n * A slice of the plot to spotlight, in this node's own pixel space. When set\r\n * to a real box, the stretches of the line *outside* it drop to\r\n * {@link ChartLineProps.dimOpacity} while the stretches inside stay full.\r\n */\r\n spotlight: RegionBox\r\n /** Opacity the out-of-region stretches fade to. */\r\n dimOpacity: number\r\n}\r\n\r\n/**\r\n * A single series line of a {@link LineChart}: one rounded polyline traced\r\n * through pre-mapped pixel `points`, drawn as one {@link Graphics2D} command list.\r\n * Sized and positioned by the parent, which shares the plot's coordinate frame.\r\n *\r\n * Two signals drive it: {@link ChartLineProps.progress} traces the line in\r\n * (animated by {@link enter}) and `enabled` shows or hides it wholesale.\r\n */\r\nexport class ChartLine extends Node2D<ChartLineProps> {\r\n @property({ default: () => [] as Vector2[] }) declare points: Vector2[]\r\n @property({ default: [], mapper: strokeOps.resolve, tween: strokeOps.lerp })\r\n declare stroke: Stroke\r\n @property({ default: 1 }) declare progress: number\r\n @property({ default: true }) declare enabled: boolean\r\n @property({ default: () => EMPTY_REGION_BOX }) declare spotlight: RegionBox\r\n @property({ default: SPOTLIGHT_DIM }) declare dimOpacity: number\r\n\r\n /**\r\n * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the\r\n * paint props it carries — see {@link declarePaints}.\r\n */\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets)\r\n declarePaints(this, assets)\r\n }\r\n\r\n protected renderSelf(ctx: RenderContext2D): void {\r\n if (!this.enabled) return\r\n const pts = this.points\r\n if (pts.length < 2) return\r\n\r\n const p = Math.max(0, Math.min(1, this.progress))\r\n if (p <= 0) return\r\n\r\n const drawn = this.tracePoints(pts, p)\r\n if (drawn.length < 2) return\r\n const stroke = this.stroke as StrokeResolved[]\r\n const radius = (stroke[0]?.weight ?? 0) * 2 // round the joins\r\n\r\n const box = this.spotlight\r\n if (!hasRegion(box)) {\r\n ctx.draw(new Graphics2D().line({ points: drawn, radius }).stroke(stroke))\r\n return\r\n }\r\n\r\n // Spotlit: the whole line goes down to `dimOpacity`, then the stretches\r\n // inside the region are re-drawn over it at full strength. Two passes rather\r\n // than one dim + one bright *complementary* pair, so the bright run has\r\n // continuous geometry through the region and its joins round the way an\r\n // unspotlit line's do — and so the boundary lands exactly on the region edge.\r\n ctx.draw(\r\n new Graphics2D()\r\n .line({ points: drawn, radius })\r\n .stroke(stroke)\r\n .opacity(Math.max(0, Math.min(1, this.dimOpacity)))\r\n )\r\n\r\n // One `draw` per run: shapes chained before a `stroke()` are combined into a\r\n // single surface, and stroking a union of disjoint open paths doesn't paint\r\n // — so a line that leaves the region and comes back would lose both halves.\r\n for (const run of clipPolylineToBox(drawn, box)) {\r\n ctx.draw(new Graphics2D().line({ points: run, radius }).stroke(stroke))\r\n }\r\n }\r\n\r\n /**\r\n * The prefix of `pts` revealed at fraction `p ∈ [0, 1]`, measuring the reveal\r\n * by *cumulative arc length* so the line traces at a steady pace regardless of\r\n * uneven point spacing. Returns the whole-point prefix plus one interpolated\r\n * point partway along the active segment.\r\n */\r\n private tracePoints(pts: Vector2[], p: number): Vector2[] {\r\n if (p >= 1 || pts.length < 2) return pts\r\n if (p <= 0) return []\r\n\r\n const segLen: number[] = []\r\n let total = 0\r\n for (let i = 1; i < pts.length; i++) {\r\n const d = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y)\r\n segLen.push(d)\r\n total += d\r\n }\r\n if (total === 0) return pts\r\n\r\n let target = total * p\r\n const out: Vector2[] = [pts[0]]\r\n for (let i = 0; i < segLen.length; i++) {\r\n if (target >= segLen[i]) {\r\n out.push(pts[i + 1])\r\n target -= segLen[i]\r\n } else {\r\n const t = segLen[i] === 0 ? 0 : target / segLen[i]\r\n out.push({\r\n x: pts[i].x + (pts[i + 1].x - pts[i].x) * t,\r\n y: pts[i].y + (pts[i + 1].y - pts[i].y) * t,\r\n })\r\n break\r\n }\r\n }\r\n return out\r\n }\r\n\r\n /**\r\n * Trace the line in from its left end to its right over `duration` seconds.\r\n * Drives `progress` `0 → 1`.\r\n *\r\n * A `Command` rather than a generator, so the trace can be *evaluated* at a\r\n * time instead of run to one — which is what lets a scene containing this\r\n * chart be scrubbed in constant time. It no longer needs to prime `progress`\r\n * to 0 first: the value at `t` is a function of `t`, so a repeat call re-traces\r\n * by definition rather than by having reset something.\r\n */\r\n @command()\r\n enter(args: CommandArgs<Record<string, never>> & { duration: number }): Command<ChartLineProps> {\r\n return this.enterFrom(0, args.duration, args.easing ?? easeOut())\r\n }\r\n\r\n /**\r\n * The trace, with both ends stated: `progress` runs `from` → `to`.\r\n *\r\n * What {@link LineChart.showSeries} and `hideSeries` are both made of — they\r\n * are the same motion in opposite directions, and expressing them as one thing\r\n * with endpoints is what stops the pair drifting apart.\r\n *\r\n * `enabled` rides along in the same value rather than being set before or after\r\n * the command. A line is drawable for every `t` the trace covers and undrawn\r\n * outside it, which is what makes arriving at a time backwards show what\r\n * arriving forwards does — a flag flipped by a side effect would not.\r\n */\r\n enterFrom(\r\n from: number,\r\n duration: number,\r\n easing: EasingFunction = easeOut(),\r\n to = 1\r\n ): Command<ChartLineProps> {\r\n return this.command<ChartLineProps>(\r\n (t) => {\r\n const progress = from + (to - from) * t\r\n // Hidden only once it has fully retraced, so the last frame of a hide is\r\n // the empty plot rather than a line that vanished a frame early.\r\n return { progress, enabled: progress > 0 }\r\n },\r\n duration,\r\n easing\r\n )\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AssetScope, Node2D, type Fill, type Node2DProps, type RenderContext2D, type Stroke } from "@motionscript/
|
|
1
|
+
import { type AssetScope, Node2D, type Fill, type Node2DProps, type RenderContext2D, type Stroke } from "@motionscript/sdk";
|
|
2
2
|
import { type RegionBox } from "./shared.js";
|
|
3
3
|
export interface ChartRegionProps extends Node2DProps {
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-region.d.ts","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,MAAM,EAIN,KAAK,IAAI,EAET,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EAEZ,MAAM,
|
|
1
|
+
{"version":3,"file":"chart-region.d.ts","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAEf,MAAM,EAIN,KAAK,IAAI,EAET,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,UAAU,CAAA;AAGjB,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD;;;;OAIG;IACH,GAAG,EAAE,SAAS,CAAA;IACd,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAA;IACd,oDAAoD;IACpD,IAAI,EAAE,IAAI,CAAA;IACV;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAY,SAAQ,MAAM,CAAC,gBAAgB,CAAC;IACA,GAAG,EAAE,SAAS,CAAA;IAM7D,MAAM,EAAE,MAAM,CAAA;IAMd,IAAI,EAAE,IAAI,CAAA;IACgB,MAAM,EAAE,MAAM,CAAA;IAEhD;;;OAGG;IACM,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAKhD,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;CAqDjD"}
|
|
@@ -4,9 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Graphics2D, Node2D, fillOps, strokeOps, property, } from "@motionscript/
|
|
7
|
+
import { Graphics2D, Node2D, fillOps, strokeOps, property, } from "@motionscript/sdk";
|
|
8
8
|
import { DEFAULT_CHART_THEME, EMPTY_REGION_BOX, hasRegion, } from "./shared.js";
|
|
9
|
-
import { declarePaints } from "@motionscript/
|
|
9
|
+
import { declarePaints } from "@motionscript/sdk/component";
|
|
10
10
|
/**
|
|
11
11
|
* The **region call-out** of a {@link LineChart}: a washed rectangle over the
|
|
12
12
|
* plot with a dashed rule down each edge the author actually bounded. Sized and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-region.js","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,UAAU,EACV,MAAM,EACN,OAAO,EACP,SAAS,EACT,QAAQ,GAOT,MAAM,
|
|
1
|
+
{"version":3,"file":"chart-region.js","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAEL,UA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CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE;oBACnB,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE;iBACpB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA7EwD;IAAtD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;wCAAuB;AAM7D;IALP,QAAQ,CAAC;QACR,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM;QAC1C,MAAM,EAAE,SAAS,CAAC,OAAO;QACzB,KAAK,EAAE,SAAS,CAAC,IAAI;KACtB,CAAC;2CACoB;AAMd;IALP,QAAQ,CAAC;QACR,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,IAAI;QACxC,MAAM,EAAE,OAAO,CAAC,OAAO;QACvB,KAAK,EAAE,OAAO,CAAC,IAAI;KACpB,CAAC;yCACgB;AACgB;IAAjC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;2CAAuB","sourcesContent":["import {\r\n type AssetScope,\r\n Graphics2D,\r\n Node2D,\r\n fillOps,\r\n strokeOps,\r\n property,\r\n type Fill,\r\n type FillResolved,\r\n type Node2DProps,\r\n type RenderContext2D,\r\n type Stroke,\r\n type StrokeResolved,\r\n} from \"@motionscript/sdk\"\r\n\r\nimport {\r\n DEFAULT_CHART_THEME,\r\n EMPTY_REGION_BOX,\r\n hasRegion,\r\n type RegionBox,\r\n} from \"./shared\"\r\nimport { declarePaints } from \"@motionscript/sdk/component\"\r\n\r\nexport interface ChartRegionProps extends Node2DProps {\r\n /**\r\n * The highlighted slice, already resolved into this node's local pixel space\r\n * (origin at centre, y-up) by the parent {@link LineChart}. A degenerate box\r\n * draws nothing.\r\n */\r\n box: RegionBox\r\n /** Dashed rule marking each *bounded* edge of the box. */\r\n stroke: Stroke\r\n /** Wash filling the box, under the series lines. */\r\n fill: Fill\r\n /**\r\n * Reveal of the annotation in `[0, 1]`: 0 hides it, 1 draws it fully. Driven\r\n * by the chart's own `regionReveal`, so the rules and the series' dimming move\r\n * as one.\r\n */\r\n reveal: number\r\n}\r\n\r\n/**\r\n * The **region call-out** of a {@link LineChart}: a washed rectangle over the\r\n * plot with a dashed rule down each edge the author actually bounded. Sized and\r\n * positioned entirely from the pre-mapped {@link ChartRegionProps.box} rather\r\n * than its own `layoutBounds` — the box already carries the plot geometry.\r\n *\r\n * It draws only the *marking*; fading the series outside the region is\r\n * {@link ChartLine}'s job (it clips its own polyline against the same box), so\r\n * the two can't disagree about where the boundary is.\r\n *\r\n * Only bounded edges get a rule: a region given just an `x` range spans the full\r\n * plot height, so its top and bottom edges are the plot's own border, not a data\r\n * bound — drawing dashes there would assert a limit the author didn't set.\r\n */\r\nexport class ChartRegion extends Node2D<ChartRegionProps> {\r\n @property({ default: () => EMPTY_REGION_BOX }) declare box: RegionBox\r\n @property({\r\n default: DEFAULT_CHART_THEME.region.stroke,\r\n mapper: strokeOps.resolve,\r\n tween: strokeOps.lerp,\r\n })\r\n declare stroke: Stroke\r\n @property({\r\n default: DEFAULT_CHART_THEME.region.fill,\r\n mapper: fillOps.resolve,\r\n tween: fillOps.lerp,\r\n })\r\n declare fill: Fill\r\n @property({ default: 0 }) declare reveal: number\r\n\r\n /**\r\n * This node extends `Node2D` rather than `ShapeNode`, so nothing declares the\r\n * paint props it carries — see {@link declarePaints}.\r\n */\r\n override declareAssets(assets: AssetScope): void {\r\n super.declareAssets(assets)\r\n declarePaints(this, assets)\r\n }\r\n\r\n protected renderSelf(ctx: RenderContext2D): void {\r\n const box = this.box\r\n if (!hasRegion(box)) return\r\n\r\n const r = Math.max(0, Math.min(1, this.reveal))\r\n if (r <= 0) return\r\n\r\n const width = box.right - box.left\r\n const height = box.top - box.bottom\r\n const cx = (box.left + box.right) / 2\r\n const cy = (box.bottom + box.top) / 2\r\n\r\n // Wash first, so the rules sit over their own tint.\r\n const layers = this.fill as FillResolved[]\r\n if (layers.length > 0) {\r\n ctx.draw(\r\n new Graphics2D()\r\n .rect({ x: cx, y: cy, width, height })\r\n .fill(this.fill)\r\n .opacity(r)\r\n )\r\n }\r\n\r\n // One rule per bounded edge, growing from the region's centre outward as\r\n // `reveal` climbs — the same \"trace it in\" beat as the series lines.\r\n const stroke = this.stroke as StrokeResolved[]\r\n if (stroke.length === 0) return\r\n\r\n // One `draw` per rule rather than four line ops under a single paint:\r\n // shapes chained before a `stroke()` are combined into one surface, and\r\n // stroking a union of disjoint open paths doesn't paint.\r\n const rule = (points: { x: number; y: number }[]) =>\r\n ctx.draw(new Graphics2D().line({ points }).stroke(this.stroke).opacity(r))\r\n\r\n if (box.xBounded) {\r\n const half = (height / 2) * r\r\n for (const x of [box.left, box.right]) {\r\n rule([\r\n { x, y: cy - half },\r\n { x, y: cy + half },\r\n ])\r\n }\r\n }\r\n if (box.yBounded) {\r\n const half = (width / 2) * r\r\n for (const y of [box.bottom, box.top]) {\r\n rule([\r\n { x: cx - half, y },\r\n { x: cx + half, y },\r\n ])\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Node2D, type CommandArgs, type NodeConfig, type Node2DProps } from "@motionscript/
|
|
1
|
+
import { Node2D, type CommandArgs, type NodeConfig, type Node2DProps } from "@motionscript/sdk";
|
|
2
2
|
import { type AxisConfig, type Range } from "../kit/shared.js";
|
|
3
|
-
import { type Seekable } from "@motionscript/
|
|
3
|
+
import { type Seekable } from "@motionscript/sdk/component";
|
|
4
4
|
export interface HorizontalAxisProps extends Node2DProps {
|
|
5
5
|
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
6
6
|
range: Range;
|