@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizontal-axis.d.ts","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAON,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"horizontal-axis.d.ts","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAON,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAExE,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,8EAA8E;IAC9E,KAAK,EAAE,KAAK,CAAC;IACb,0DAA0D;IAC1D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,oFAAoF;IACpF,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAKD,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEpD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,SAAQ,MAAM,CAAC,mBAAmB,CAAC;IACP,KAAK,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IAEjD;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,WAAW,CAAgB;IAErC,+EAA+E;IAC/E,OAAO,CAAC,WAAW,CAAc;IACjC,uDAAuD;IACvD,OAAO,CAAC,SAAS,CAAqB;IAEtC,iFAAiF;IACjF,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,CAAC,OAAO;IAIf,uEAAuE;IACvE,OAAO,CAAC,MAAM;gBAOF,KAAK,CAAC,EAAE,UAAU,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAkDnE;;;OAGG;IACH,GAAG,CAAC,KAAK,SAAQ,GAAG,IAAI;IAKxB;;;;;;;;;;;OAWG;IAEH,KAAK,CACH,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,GAC7E,QAAQ;CA4BZ"}
|
|
@@ -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, Text, easeOut, property, insetsOps, textOps, } from "@motionscript/
|
|
7
|
+
import { command, Node2D, Rect, Text, easeOut, property, insetsOps, textOps, } from "@motionscript/sdk";
|
|
8
8
|
import { DEFAULT_X_AXIS, enterBudget, formatMarker, } from "../kit/shared.js";
|
|
9
|
-
import { at, compose } from "@motionscript/
|
|
9
|
+
import { at, compose } from "@motionscript/sdk/component";
|
|
10
10
|
/** How far a marker starts above its slot when it enters, in px. */
|
|
11
11
|
const SLIDE = 24;
|
|
12
12
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizontal-axis.js","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,GAIR,MAAM,oBAAoB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AE,GAAG,EAAE,CAAC,EAAc,EAAE,CAAC;+CAA2B;AACxB;IAA9C,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;4CAA0B;AAC7B;IAAlC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;6CAAuB;AA6GjD;IADC,OAAO,EAAE;2CA8BT","sourcesContent":["import {\n command,\n Node2D,\n Rect,\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_X_AXIS,\n enterBudget,\n formatMarker,\n type AxisConfig,\n type Range,\n} from \"../kit/shared\";\nimport { at, compose, type Seekable } from \"@motionscript/core/component\"\n\nexport interface HorizontalAxisProps extends Node2DProps {\n /** `[min, max]` of the horizontal scale the markers are positioned within. */\n range: Range;\n /** Tick values (in data units) to draw along the axis. */\n markers: number[];\n /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */\n axis: AxisConfig;\n /**\n * Caption drawn centred in the gutter beneath the marker row. Empty string\n * (the default) hides it.\n */\n label: string;\n}\n\n/** How far a marker starts above its slot when it enters, in px. */\nconst SLIDE = 24;\n\n/** How a tick value is captioned — see {@link HorizontalAxis.labelFor}. */\nexport type MarkerLabel = (value: number) => string;\n\n/**\n * The horizontal axis of a {@link LineChart}: a **row of {@link Text} nodes**,\n * one per marker value, running left-to-right. Pure layout — the mirror of the\n * kit's `VerticalAxis`, including its bound (not snapshotted) marker text and\n * positions, and its landed resting state.\n *\n * Markers are always placed **by value** across the range, whatever they say:\n * `2026-03` sits three months along, not three slots along. That is what keeps\n * it distinct from a bar chart's bottom axis, which centres a caption on each\n * slot and has no scale at all — the two only look alike. What the values are\n * captioned *as* is the chart's to decide; see {@link labelFor}.\n *\n * {@link enter} staggers the markers in **left-to-right**: each starts lifted a\n * little above its slot and transparent, then fades and slides down into place.\n */\nexport class HorizontalAxis extends Node2D<HorizontalAxisProps> {\n @property({ default: () => [0, 1] as Range }) declare range: Range;\n @property({ default: () => [] as number[] }) declare markers: number[];\n @property({ default: DEFAULT_X_AXIS }) declare axis: AxisConfig;\n @property({ default: \"\" }) declare label: string;\n\n /**\n * How a tick value is captioned. Defaults to the numeric formatting the\n * vertical axis uses; a chart whose x column names months or categories\n * replaces it (see `x-scale.ts`).\n *\n * A plain field rather than a `@property`, because it is a **policy, not a\n * value**: there is nothing to tween between two formatters, and a signal\n * holding a function is a signal every `set`/`to` on this node would have to\n * know not to touch. Read inside each marker's `text` binding, so replacing it\n * before the first frame is enough — which is when the chart does it.\n */\n labelFor: MarkerLabel = formatMarker;\n\n /** One text node per marker, ordered left → right, for the staggered enter. */\n private markerNodes: Text[] = [];\n /** The caption node, or null when `label` is empty. */\n private labelNode: Text | null = null;\n\n /** The live tick values, left → right — re-read every frame, not snapshotted. */\n private get sortedMarkers(): number[] {\n return [...this.markers].sort((a, b) => a - b);\n }\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 left 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<HorizontalAxis, HorizontalAxisProps>) {\n super(props);\n\n const tickPad = insetsOps.resolve(this.axis.tickPadding).top;\n const titlePad = insetsOps.resolve(this.axis.titlePadding).top;\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 x: () => {\n const width = this.layoutBounds.width;\n const centred = (this.fracAt(i) - 0.5) * width;\n // Held inside the axis's right edge, which is also the *chart's*: the\n // last marker is centred on the last grid line, so half of `2026-06`\n // — or of `3300` — would be drawn outside the node's box and outside\n // the rectangle the editor draws around it. Only the right edge is\n // held, because the left one has the vertical axis's whole gutter\n // beyond it, and a marker overhanging into that is inside the chart.\n const limit = width / 2 - marker.layoutBounds.width / 2;\n return Math.min(centred, limit);\n },\n });\n return marker;\n });\n\n const children: Node2D[] = [\n new Rect({\n width: \"fill\",\n height: \"hug\",\n padding: { top: tickPad },\n children: this.markerNodes,\n }),\n ];\n if (this.label !== \"\") {\n this.labelNode = new Text({\n ...textOps.styleProps(this.axis.titleStyle),\n text: this.label,\n });\n children.push(this.labelNode);\n }\n\n this.add(\n new Rect({ flow: \"vertical\", gap: titlePad, height: \"hug\", width: \"fill\", children }),\n );\n }\n\n /**\n * Primes every marker (and the caption) at its pre-entrance state: lifted\n * above its slot and transparent. Idempotent — see {@link VerticalAxis.arm}.\n */\n arm(slide = SLIDE): void {\n for (const marker of this.markerNodes) marker.set({ opacity: 0, y: slide });\n this.labelNode?.set({ opacity: 0, y: slide });\n }\n\n /**\n * Stagger the markers in left to right, then slide the caption in after them.\n *\n * A {@link Seekable} rather than a generator. The offsets were always static —\n * `i * step` per marker — but expressed as `wait` inside a generator they only\n * existed while it ran, so knowing what the axis looked like partway through\n * meant running it from zero. Placed explicitly, the same stagger can be asked\n * for a time, which is what lets a chart scene scrub in constant time.\n *\n * `duration` is the **whole** entrance — see {@link VerticalAxis.enter} and\n * {@link enterBudget}.\n */\n @command()\n enter(\n args: CommandArgs<{ stagger?: number; slide?: number }> & { duration: number },\n ): Seekable {\n const { stagger, slide = SLIDE } = args.data ?? {};\n const duration = args.duration;\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 duration,\n nodes.length,\n this.labelNode !== null,\n stagger,\n );\n\n this.arm(slide);\n\n // Left marker leads: markerNodes is already left → right.\n const markers = nodes.map((node, i) =>\n at(i * step, node.to({ data: { opacity: 1, y: 0 }, duration: per, easing })),\n );\n const lastMarkerEnds = nodes.length === 0 ? 0 : (nodes.length - 1) * step + per;\n\n return compose([\n ...markers,\n ...(this.labelNode\n ? [at(lastMarkerEnds, this.labelNode.to({ data: { opacity: 1, y: 0 }, duration: caption, easing }))]\n : []),\n ]);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"horizontal-axis.js","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,OAAO,EACP,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,OAAO,GAIR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,cAAc,EACd,WAAW,EACX,YAAY,GAGb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,OAAO,EAAiB,MAAM,6BAA6B,CAAA;AAgBxE,oEAAoE;AACpE,MAAM,KAAK,GAAG,EAAE,CAAC;AAKjB;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,cAAe,SAAQ,MAA2B;IAM7D;;;;;;;;;;OAUG;IACH,QAAQ,GAAgB,YAAY,CAAC;IAErC,+EAA+E;IACvE,WAAW,GAAW,EAAE,CAAC;IACjC,uDAAuD;IAC/C,SAAS,GAAgB,IAAI,CAAC;IAEtC,iFAAiF;IACjF,IAAY,aAAa;QACvB,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjD,CAAC;IAEO,OAAO,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,uEAAuE;IAC/D,MAAM,CAAC,KAAa;QAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QAC9B,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B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,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;gBACpG,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAC;IACL,CAAC;CACF;AA9IuD;IAArD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAU,EAAE,CAAC;6CAAsB;AACd;IAApD,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,EAAc,EAAE,CAAC;+CAA2B;AACxB;IAA9C,QAAQ,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;4CAA0B;AAC7B;IAAlC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;6CAAuB;AA6GjD;IADC,OAAO,EAAE;2CA8BT","sourcesContent":["import {\r\n command,\r\n Node2D,\r\n Rect,\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_X_AXIS,\r\n enterBudget,\r\n formatMarker,\r\n type AxisConfig,\r\n type Range,\r\n} from \"../kit/shared\";\r\nimport { at, compose, type Seekable } from \"@motionscript/sdk/component\"\r\n\r\nexport interface HorizontalAxisProps extends Node2DProps {\r\n /** `[min, max]` of the horizontal scale the markers are positioned within. */\r\n range: Range;\r\n /** Tick values (in data units) to draw along the axis. */\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 * Caption drawn centred in the gutter beneath the marker row. Empty string\r\n * (the default) hides it.\r\n */\r\n label: string;\r\n}\r\n\r\n/** How far a marker starts above its slot when it enters, in px. */\r\nconst SLIDE = 24;\r\n\r\n/** How a tick value is captioned — see {@link HorizontalAxis.labelFor}. */\r\nexport type MarkerLabel = (value: number) => string;\r\n\r\n/**\r\n * The horizontal axis of a {@link LineChart}: a **row of {@link Text} nodes**,\r\n * one per marker value, running left-to-right. Pure layout — the mirror of the\r\n * kit's `VerticalAxis`, including its bound (not snapshotted) marker text and\r\n * positions, and its landed resting state.\r\n *\r\n * Markers are always placed **by value** across the range, whatever they say:\r\n * `2026-03` sits three months along, not three slots along. That is what keeps\r\n * it distinct from a bar chart's bottom axis, which centres a caption on each\r\n * slot and has no scale at all — the two only look alike. What the values are\r\n * captioned *as* is the chart's to decide; see {@link labelFor}.\r\n *\r\n * {@link enter} staggers the markers in **left-to-right**: each starts lifted a\r\n * little above its slot and transparent, then fades and slides down into place.\r\n */\r\nexport class HorizontalAxis extends Node2D<HorizontalAxisProps> {\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_X_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 numeric formatting the\r\n * vertical axis uses; a chart whose x column names months or categories\r\n * replaces it (see `x-scale.ts`).\r\n *\r\n * A plain field rather than a `@property`, because it is a **policy, not a\r\n * value**: there is nothing to tween between two formatters, and a signal\r\n * holding a function is a signal every `set`/`to` on this node would have to\r\n * know not to touch. Read inside each marker's `text` binding, so replacing it\r\n * before the first frame is enough — which is when the chart does it.\r\n */\r\n labelFor: MarkerLabel = formatMarker;\r\n\r\n /** One text node per marker, ordered left → right, for the staggered enter. */\r\n private markerNodes: Text[] = [];\r\n /** The caption node, or null when `label` is empty. */\r\n private labelNode: Text | null = null;\r\n\r\n /** The live tick values, left → right — re-read every frame, not snapshotted. */\r\n private get sortedMarkers(): number[] {\r\n return [...this.markers].sort((a, b) => a - b);\r\n }\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 left 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<HorizontalAxis, HorizontalAxisProps>) {\r\n super(props);\r\n\r\n const tickPad = insetsOps.resolve(this.axis.tickPadding).top;\r\n const titlePad = insetsOps.resolve(this.axis.titlePadding).top;\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 x: () => {\r\n const width = this.layoutBounds.width;\r\n const centred = (this.fracAt(i) - 0.5) * width;\r\n // Held inside the axis's right edge, which is also the *chart's*: the\r\n // last marker is centred on the last grid line, so half of `2026-06`\r\n // — or of `3300` — would be drawn outside the node's box and outside\r\n // the rectangle the editor draws around it. Only the right edge is\r\n // held, because the left one has the vertical axis's whole gutter\r\n // beyond it, and a marker overhanging into that is inside the chart.\r\n const limit = width / 2 - marker.layoutBounds.width / 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 new Rect({\r\n width: \"fill\",\r\n height: \"hug\",\r\n padding: { top: tickPad },\r\n children: this.markerNodes,\r\n }),\r\n ];\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 children.push(this.labelNode);\r\n }\r\n\r\n this.add(\r\n new Rect({ flow: \"vertical\", gap: titlePad, height: \"hug\", width: \"fill\", children }),\r\n );\r\n }\r\n\r\n /**\r\n * Primes every marker (and the caption) at its pre-entrance state: lifted\r\n * above its slot and transparent. Idempotent — see {@link VerticalAxis.arm}.\r\n */\r\n arm(slide = SLIDE): void {\r\n for (const marker of this.markerNodes) marker.set({ opacity: 0, y: slide });\r\n this.labelNode?.set({ opacity: 0, y: slide });\r\n }\r\n\r\n /**\r\n * Stagger the markers in left to right, then slide the caption in after them.\r\n *\r\n * A {@link Seekable} rather than a generator. The offsets were always static —\r\n * `i * step` per marker — but expressed as `wait` inside a generator they only\r\n * existed while it ran, so knowing what the axis looked like partway through\r\n * meant running it from zero. Placed explicitly, the same stagger can be asked\r\n * for a time, which is what lets a chart scene scrub in constant time.\r\n *\r\n * `duration` is the **whole** entrance — see {@link VerticalAxis.enter} and\r\n * {@link enterBudget}.\r\n */\r\n @command()\r\n enter(\r\n args: CommandArgs<{ stagger?: number; slide?: number }> & { duration: number },\r\n ): Seekable {\r\n const { stagger, slide = SLIDE } = args.data ?? {};\r\n const duration = args.duration;\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 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 // Left marker leads: markerNodes is already left → right.\r\n const markers = nodes.map((node, i) =>\r\n at(i * step, node.to({ data: { opacity: 1, y: 0 }, duration: per, easing })),\r\n );\r\n const lastMarkerEnds = nodes.length === 0 ? 0 : (nodes.length - 1) * step + per;\r\n\r\n return compose([\r\n ...markers,\r\n ...(this.labelNode\r\n ? [at(lastMarkerEnds, this.labelNode.to({ data: { opacity: 1, y: 0 }, duration: caption, easing }))]\r\n : []),\r\n ]);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/line-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,OAAO,GACR,MAAM,UAAU,CAAA;AASjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA","sourcesContent":["/**\n * The line chart: a cartesian plot with a traced polyline, spotlit regions and\n * a staggered entrance.\n *\n * {@link LineChart} composes the parts below plus the shared ones in the kit\n * (the plot panel, the value axis, the legend); each part is exported too, so\n * another node type can reuse one on its own.\n *\n * These files are what `ms add line-chart` copies. Everything they reach for\n * that is *not* here comes from the kit and stays a dependency — see\n * `../engine.ts` for why that line is where it is.\n */\nexport { LineChart } from \"./line-chart\"\nexport type { LineChartProps } from \"./line-chart\"\nexport { ChartRegion } from \"./chart-region\"\nexport { ChartLine } from \"./chart-line\"\nexport { HorizontalAxis } from \"./horizontal-axis\"\nexport {\n DEFAULT_CHART_THEME,\n EMPTY_REGION_BOX,\n clipPolylineToBox,\n hasRegion,\n lerpChartTheme,\n resolveChartTheme,\n resolveRegionBox,\n resolveYScale,\n seriesPoints,\n yExtent,\n} from \"./shared\"\nexport type {\n ChartConfig,\n ChartTheme,\n LineSeries,\n PlotRegion,\n RegionBox,\n RegionConfig,\n} from \"./shared\"\nexport { formatInstant, parseInstant, resolveXScale } from \"./x-scale\"\nexport type { XScale, XScaleKind } from \"./x-scale\"\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/line-chart/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,OAAO,GACR,MAAM,UAAU,CAAA;AASjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA","sourcesContent":["/**\r\n * The line chart: a cartesian plot with a traced polyline, spotlit regions and\r\n * a staggered entrance.\r\n *\r\n * {@link LineChart} composes the parts below plus the shared ones in the kit\r\n * (the plot panel, the value axis, the legend); each part is exported too, so\r\n * another node type can reuse one on its own.\r\n *\r\n * These files are what `ms add line-chart` copies. Everything they reach for\r\n * that is *not* here comes from the kit and stays a dependency — see\r\n * `../engine.ts` for why that line is where it is.\r\n */\r\nexport { LineChart } from \"./line-chart\"\r\nexport type { LineChartProps } from \"./line-chart\"\r\nexport { ChartRegion } from \"./chart-region\"\r\nexport { ChartLine } from \"./chart-line\"\r\nexport { HorizontalAxis } from \"./horizontal-axis\"\r\nexport {\r\n DEFAULT_CHART_THEME,\r\n EMPTY_REGION_BOX,\r\n clipPolylineToBox,\r\n hasRegion,\r\n lerpChartTheme,\r\n resolveChartTheme,\r\n resolveRegionBox,\r\n resolveYScale,\r\n seriesPoints,\r\n yExtent,\r\n} from \"./shared\"\r\nexport type {\r\n ChartConfig,\r\n ChartTheme,\r\n LineSeries,\r\n PlotRegion,\r\n RegionBox,\r\n RegionConfig,\r\n} from \"./shared\"\r\nexport { formatInstant, parseInstant, resolveXScale } from \"./x-scale\"\r\nexport type { XScale, XScaleKind } from \"./x-scale\"\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Node2D, type Command, type CommandArgs, type DataRecord, type NodeConfig, type Node2DProps } from "@motionscript/
|
|
1
|
+
import { Node2D, type Command, type CommandArgs, type DataRecord, type NodeConfig, type Node2DProps } from "@motionscript/sdk";
|
|
2
2
|
import { type AxisDomainConfig } from "../kit/shared.js";
|
|
3
3
|
import { type ChartTheme, type LineSeries, type PlotRegion } from "./shared.js";
|
|
4
|
-
import { type Seekable } from "@motionscript/core/component";
|
|
5
4
|
export interface LineChartProps extends Node2DProps {
|
|
6
5
|
/** One row per sample — a plain record of field name to value. */
|
|
7
6
|
data: DataRecord[];
|
|
@@ -44,6 +43,11 @@ type RegionState = {
|
|
|
44
43
|
region: PlotRegion | null;
|
|
45
44
|
regionReveal: number;
|
|
46
45
|
};
|
|
46
|
+
/** The axis domains {@link LineChart.zoomTo} and {@link LineChart.resetZoom} move. */
|
|
47
|
+
type AxisState = {
|
|
48
|
+
xAxis: AxisDomainConfig;
|
|
49
|
+
yAxis: AxisDomainConfig;
|
|
50
|
+
};
|
|
47
51
|
/**
|
|
48
52
|
* A multi-series line chart, composed from five independent parts rather than
|
|
49
53
|
* one monolithic draw:
|
|
@@ -64,7 +68,7 @@ type RegionState = {
|
|
|
64
68
|
* exactly on their markers.
|
|
65
69
|
*
|
|
66
70
|
* **Resting state is the finished chart.** Unlike the standalone component this
|
|
67
|
-
* was ported from, nothing is built hidden:
|
|
71
|
+
* was ported from, nothing is built hidden: an editor paints a node's Initial
|
|
68
72
|
* state on a paused canvas, and a chart that only appeared once a command had
|
|
69
73
|
* run would be edited blind. {@link enter} arms every part back to its
|
|
70
74
|
* pre-entrance state before animating, so the entrance itself is unchanged.
|
|
@@ -229,7 +233,7 @@ export declare class LineChart extends Node2D<LineChartProps> {
|
|
|
229
233
|
*/
|
|
230
234
|
enter(args: CommandArgs<Record<string, never>> & {
|
|
231
235
|
duration: number;
|
|
232
|
-
}):
|
|
236
|
+
}): Command<Record<string, never>>;
|
|
233
237
|
/**
|
|
234
238
|
* Spotlight a rectangular slice of the plot given in **data units**: dashed
|
|
235
239
|
* rules draw themselves onto each bounded edge while every series fades
|
|
@@ -300,14 +304,14 @@ export declare class LineChart extends Node2D<LineChartProps> {
|
|
|
300
304
|
region: PlotRegion;
|
|
301
305
|
}> & {
|
|
302
306
|
duration?: number;
|
|
303
|
-
}):
|
|
307
|
+
}): Command<AxisState>;
|
|
304
308
|
/**
|
|
305
309
|
* Pull back out to the domain the chart was authored with — the mirror of
|
|
306
310
|
* {@link zoomTo}, and a no-op if it was never zoomed.
|
|
307
311
|
*/
|
|
308
312
|
resetZoom(args?: CommandArgs<Record<string, never>> & {
|
|
309
313
|
duration?: number;
|
|
310
|
-
}):
|
|
314
|
+
}): Command<AxisState>;
|
|
311
315
|
/**
|
|
312
316
|
* Show series `index`: **trace** its line in left-to-right — the same draw as
|
|
313
317
|
* {@link enter}, not an opacity fade — in lockstep with its legend entry
|
|
@@ -322,7 +326,7 @@ export declare class LineChart extends Node2D<LineChartProps> {
|
|
|
322
326
|
seriesIndex: number;
|
|
323
327
|
}> & {
|
|
324
328
|
duration?: number;
|
|
325
|
-
}):
|
|
329
|
+
}): Command<Record<string, never>>;
|
|
326
330
|
/**
|
|
327
331
|
* Hide series `index`: **retrace** its line back out (`progress` 1 → 0) as its
|
|
328
332
|
* legend entry shrinks away — the mirror of {@link showSeries}.
|
|
@@ -331,7 +335,7 @@ export declare class LineChart extends Node2D<LineChartProps> {
|
|
|
331
335
|
seriesIndex: number;
|
|
332
336
|
}> & {
|
|
333
337
|
duration?: number;
|
|
334
|
-
}):
|
|
338
|
+
}): Command<Record<string, never>>;
|
|
335
339
|
/**
|
|
336
340
|
* Fade out all other series — each line **and its legend entry** — to focus
|
|
337
341
|
* attention on `index`, which comes back to full. The legend dims in place
|
|
@@ -341,7 +345,19 @@ export declare class LineChart extends Node2D<LineChartProps> {
|
|
|
341
345
|
seriesIndex: number;
|
|
342
346
|
}> & {
|
|
343
347
|
duration?: number;
|
|
344
|
-
}):
|
|
348
|
+
}): Command<Record<string, never>>;
|
|
349
|
+
/**
|
|
350
|
+
* Move props to new values; a restated axis `range` or `ticks` tweens from the
|
|
351
|
+
* domain as drawn, so an auto axis (the default) rescales continuously instead
|
|
352
|
+
* of cutting at the midpoint of the move.
|
|
353
|
+
*/
|
|
354
|
+
to<D extends Partial<LineChartProps> = Partial<LineChartProps>>(args: CommandArgs<D> & {
|
|
355
|
+
duration: number;
|
|
356
|
+
}): Command<LineChartProps>;
|
|
357
|
+
/** Both axes as drawn, so an auto range or tick row is read back as itself. */
|
|
358
|
+
private _domains;
|
|
359
|
+
/** From a resolved `from`: the axis tween steps an auto side at the midpoint, which is a cut. */
|
|
360
|
+
private _tweenAxes;
|
|
345
361
|
}
|
|
346
362
|
export {};
|
|
347
363
|
//# sourceMappingURL=line-chart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/line-chart/line-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAIN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/line-chart/line-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAIN,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,KAAK,WAAW,EAEjB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAUL,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAA;AAItB,OAAO,EAQL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EAEhB,MAAM,UAAU,CAAA;AAIjB,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,kEAAkE;IAClE,IAAI,EAAE,UAAU,EAAE,CAAA;IAClB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAA;IACd,oFAAoF;IACpF,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB,oEAAoE;IACpE,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB,oEAAoE;IACpE,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACxB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC1B;;;;OAIG;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G;IACjG,OAAO,CAAC,UAAU;CAenB"}
|
|
@@ -5,19 +5,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
var LineChart_1;
|
|
8
|
-
import { command, node, Node2D, Rect, easeOut, property, } from "@motionscript/
|
|
8
|
+
import { command, node, Node2D, Rect, easeOut, property, } from "@motionscript/sdk";
|
|
9
9
|
import { ChartBorder } from "../kit/chart-border.js";
|
|
10
10
|
import { ChartCanvas } from "../kit/chart-canvas.js";
|
|
11
11
|
import { ChartLegend } from "../kit/chart-legend.js";
|
|
12
12
|
import { VerticalAxis } from "../kit/vertical-axis.js";
|
|
13
|
-
import { SPOTLIGHT_DIM, formatMarker, lerpAxisDomain, markerValues, resolveAxisDomain, resolveSeriesFill, resolveSeriesStroke, } from "../kit/shared.js";
|
|
14
|
-
import { formatNumber } from "@motionscript/core/component";
|
|
13
|
+
import { SPOTLIGHT_DIM, formatMarker, axisTweenTarget, lerpAxisDomain, markerStep, markerValues, resolveAxisDomain, resolveSeriesFill, resolveSeriesStroke, } from "../kit/shared.js";
|
|
15
14
|
import { ChartLine } from "./chart-line.js";
|
|
16
15
|
import { ChartRegion } from "./chart-region.js";
|
|
17
16
|
import { HorizontalAxis } from "./horizontal-axis.js";
|
|
18
17
|
import { DEFAULT_CHART_THEME, lerpChartTheme, resolveChartTheme, resolveRegionBox, resolveYScale, seriesPoints, } from "./shared.js";
|
|
19
18
|
import { resolveXScale } from "./x-scale.js";
|
|
20
|
-
import { hold, sequence as sequenceOf, together } from "@motionscript/
|
|
19
|
+
import { asCommand, formatNumber, hold, sequence as sequenceOf, together } from "@motionscript/sdk/component";
|
|
21
20
|
/**
|
|
22
21
|
* Headroom above the plot, in px.
|
|
23
22
|
*
|
|
@@ -65,7 +64,7 @@ const LEGEND_SHARE = 0.15;
|
|
|
65
64
|
* exactly on their markers.
|
|
66
65
|
*
|
|
67
66
|
* **Resting state is the finished chart.** Unlike the standalone component this
|
|
68
|
-
* was ported from, nothing is built hidden:
|
|
67
|
+
* was ported from, nothing is built hidden: an editor paints a node's Initial
|
|
69
68
|
* state on a paused canvas, and a chart that only appeared once a command had
|
|
70
69
|
* run would be edited blind. {@link enter} arms every part back to its
|
|
71
70
|
* pre-entrance state before animating, so the entrance itself is unchanged.
|
|
@@ -237,7 +236,7 @@ let LineChart = class LineChart extends Node2D {
|
|
|
237
236
|
});
|
|
238
237
|
// The y axis is always numbers, so its format is simply the pattern.
|
|
239
238
|
this.vAxis.labelFor = (value) => this.yAxis.format === undefined
|
|
240
|
-
? formatMarker(value)
|
|
239
|
+
? formatMarker(value, markerStep(this.resolvedYMarkers))
|
|
241
240
|
: formatNumber(value, this.yAxis.format);
|
|
242
241
|
this.hAxis = new HorizontalAxis({
|
|
243
242
|
range: () => this.xScale,
|
|
@@ -385,17 +384,21 @@ let LineChart = class LineChart extends Node2D {
|
|
|
385
384
|
// own node (the axes, the lines, the legend), which is why these compose as
|
|
386
385
|
// steppers rather than as merged props.
|
|
387
386
|
const axes = together(this.vAxis.enter({ data: { slide: 24 }, duration: body * AXES_SHARE, easing }), this.hAxis.enter({ data: { slide: 24 }, duration: body * AXES_SHARE, easing }));
|
|
388
|
-
|
|
387
|
+
//
|
|
388
|
+
// A beat with nothing to do (a chart without a legend, or without series)
|
|
389
|
+
// still takes its share: the shares sum to the whole, and the beats after it
|
|
390
|
+
// land where they were laid out for.
|
|
391
|
+
const lines = together(hold(body * LINES_SHARE), ...this.lines.map((line) => line.enter({ duration: body * LINES_SHARE, easing })));
|
|
389
392
|
const legend = this.legend
|
|
390
|
-
?
|
|
391
|
-
:
|
|
392
|
-
const phases = sequenceOf(axes, lines,
|
|
393
|
-
return revealing
|
|
393
|
+
? this.legend.to({ data: { opacity: 1, y: 0 }, duration: body * LEGEND_SHARE, easing })
|
|
394
|
+
: hold(body * LEGEND_SHARE);
|
|
395
|
+
const phases = sequenceOf(axes, lines, legend);
|
|
396
|
+
return asCommand(revealing
|
|
394
397
|
? sequenceOf(phases,
|
|
395
398
|
// Typed to what it writes rather than to `LineChartProps`: `regionReveal`
|
|
396
399
|
// is a signal of the chart's own, not part of its authored props.
|
|
397
400
|
this.command((t) => ({ regionReveal: t }), duration * 0.25, easing))
|
|
398
|
-
: phases;
|
|
401
|
+
: phases, duration);
|
|
399
402
|
}
|
|
400
403
|
// ---- Region spotlight --------------------------------------------------
|
|
401
404
|
/**
|
|
@@ -448,7 +451,7 @@ let LineChart = class LineChart extends Node2D {
|
|
|
448
451
|
const easing = args.easing ?? easeOut();
|
|
449
452
|
const from = this.regionReveal;
|
|
450
453
|
if (from === 0) {
|
|
451
|
-
// Nothing to retract, but the call still takes its slot: in
|
|
454
|
+
// Nothing to retract, but the call still takes its slot: in an editor a
|
|
452
455
|
// command's duration is what the timeline lays out and what parallel
|
|
453
456
|
// siblings are timed against, so a no-op that took no frames would pull
|
|
454
457
|
// everything after it forward. Same reason for `zoomTo`/`resetZoom` below.
|
|
@@ -508,28 +511,14 @@ let LineChart = class LineChart extends Node2D {
|
|
|
508
511
|
const duration = args.duration ?? 0.8;
|
|
509
512
|
const easing = args.easing ?? easeOut();
|
|
510
513
|
if (!region.x && !region.y)
|
|
511
|
-
return
|
|
512
|
-
//
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
this.
|
|
516
|
-
x: {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
ticks: this.resolvedXMarkers,
|
|
520
|
-
},
|
|
521
|
-
y: {
|
|
522
|
-
label: this.yAxis.label,
|
|
523
|
-
range: this.yScale,
|
|
524
|
-
ticks: this.resolvedYMarkers,
|
|
525
|
-
},
|
|
526
|
-
};
|
|
527
|
-
const next = {};
|
|
528
|
-
if (region.x)
|
|
529
|
-
next.xAxis = LineChart_1.rescale(region.x, this.resolvedXMarkers);
|
|
530
|
-
if (region.y)
|
|
531
|
-
next.yAxis = LineChart_1.rescale(region.y, this.resolvedYMarkers);
|
|
532
|
-
return this.to({ data: next, duration, easing });
|
|
514
|
+
return this.command(() => ({}), duration);
|
|
515
|
+
// Captured *before* the first zoom moves it.
|
|
516
|
+
const from = this._domains();
|
|
517
|
+
this.home ??= from;
|
|
518
|
+
return this._tweenAxes(from, {
|
|
519
|
+
...(region.x && { x: { ...from.x, ...LineChart_1.rescale(region.x, from.x.ticks) } }),
|
|
520
|
+
...(region.y && { y: { ...from.y, ...LineChart_1.rescale(region.y, from.y.ticks) } }),
|
|
521
|
+
}, duration, easing);
|
|
533
522
|
}
|
|
534
523
|
/**
|
|
535
524
|
* Pull back out to the domain the chart was authored with — the mirror of
|
|
@@ -540,13 +529,13 @@ let LineChart = class LineChart extends Node2D {
|
|
|
540
529
|
const easing = args.easing ?? easeOut();
|
|
541
530
|
const home = this.home;
|
|
542
531
|
if (!home)
|
|
543
|
-
return
|
|
532
|
+
return this.command(() => ({}), duration);
|
|
544
533
|
// Cleared here rather than once the move lands. Nothing reads `home` while
|
|
545
534
|
// it runs, and a value has no "after" to clear it in — what matters is that
|
|
546
535
|
// the *next* `zoomTo` captures wherever the chart genuinely rests by then,
|
|
547
536
|
// and both this and its capture happen as the command list is walked.
|
|
548
537
|
this.home = null;
|
|
549
|
-
return this.
|
|
538
|
+
return this._tweenAxes(this._domains(), home, duration, easing);
|
|
550
539
|
}
|
|
551
540
|
// ---- Per-series -------------------------------------------------------
|
|
552
541
|
/**
|
|
@@ -565,8 +554,8 @@ let LineChart = class LineChart extends Node2D {
|
|
|
565
554
|
const easing = args.easing ?? easeOut();
|
|
566
555
|
const line = this.lines[index];
|
|
567
556
|
if (!line)
|
|
568
|
-
return hold(duration);
|
|
569
|
-
return together(line.enterFrom(0, duration, easing), ...(this.legend ? [this.legend.showSeries({ data: { index }, duration, easing })] : []));
|
|
557
|
+
return asCommand(hold(duration));
|
|
558
|
+
return asCommand(together(line.enterFrom(0, duration, easing), ...(this.legend ? [this.legend.showSeries({ data: { index }, duration, easing })] : [])), duration);
|
|
570
559
|
}
|
|
571
560
|
/**
|
|
572
561
|
* Hide series `index`: **retrace** its line back out (`progress` 1 → 0) as its
|
|
@@ -578,8 +567,8 @@ let LineChart = class LineChart extends Node2D {
|
|
|
578
567
|
const easing = args.easing ?? easeOut();
|
|
579
568
|
const line = this.lines[index];
|
|
580
569
|
if (!line)
|
|
581
|
-
return hold(duration);
|
|
582
|
-
return together(line.enterFrom(1, duration, easing, 0), ...(this.legend ? [this.legend.hideSeries({ data: { index }, duration, easing })] : []));
|
|
570
|
+
return asCommand(hold(duration));
|
|
571
|
+
return asCommand(together(line.enterFrom(1, duration, easing, 0), ...(this.legend ? [this.legend.hideSeries({ data: { index }, duration, easing })] : [])), duration);
|
|
583
572
|
}
|
|
584
573
|
/**
|
|
585
574
|
* Fade out all other series — each line **and its legend entry** — to focus
|
|
@@ -590,9 +579,43 @@ let LineChart = class LineChart extends Node2D {
|
|
|
590
579
|
const index = args.data?.seriesIndex ?? 0;
|
|
591
580
|
const duration = args.duration ?? 0.35;
|
|
592
581
|
const easing = args.easing ?? easeOut();
|
|
593
|
-
return together(...this.lines.map((line, i) => line.to({ data: { opacity: i === index ? 1 : SPOTLIGHT_DIM }, duration, easing })), ...(this.legend
|
|
582
|
+
return asCommand(together(...this.lines.map((line, i) => line.to({ data: { opacity: i === index ? 1 : SPOTLIGHT_DIM }, duration, easing })), ...(this.legend
|
|
594
583
|
? [this.legend.spotlightSeries({ data: { index }, duration, easing })]
|
|
595
|
-
: []));
|
|
584
|
+
: [])), duration);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Move props to new values; a restated axis `range` or `ticks` tweens from the
|
|
588
|
+
* domain as drawn, so an auto axis (the default) rescales continuously instead
|
|
589
|
+
* of cutting at the midpoint of the move.
|
|
590
|
+
*/
|
|
591
|
+
to(args) {
|
|
592
|
+
const data = (args.data ?? {});
|
|
593
|
+
const drawn = this._domains();
|
|
594
|
+
const x = axisTweenTarget(drawn.x, data.xAxis);
|
|
595
|
+
const y = axisTweenTarget(drawn.y, data.yAxis);
|
|
596
|
+
if (!x && !y)
|
|
597
|
+
return super.to(args);
|
|
598
|
+
const { xAxis, yAxis, ...rest } = data;
|
|
599
|
+
const axes = this._tweenAxes(drawn, { ...(x && { x }), ...(y && { y }) }, args.duration, args.easing ?? easeOut());
|
|
600
|
+
// An axis that only restated its caption or format still takes the plain tween.
|
|
601
|
+
const remaining = { ...rest, ...(!x && xAxis && { xAxis }), ...(!y && yAxis && { yAxis }) };
|
|
602
|
+
if (Object.keys(remaining).length === 0)
|
|
603
|
+
return axes;
|
|
604
|
+
return asCommand(together(super.to({ ...args, data: remaining }), axes), args.duration);
|
|
605
|
+
}
|
|
606
|
+
/** Both axes as drawn, so an auto range or tick row is read back as itself. */
|
|
607
|
+
_domains() {
|
|
608
|
+
return {
|
|
609
|
+
x: { ...this.xAxis, range: this.xScale, ticks: this.resolvedXMarkers },
|
|
610
|
+
y: { ...this.yAxis, range: this.yScale, ticks: this.resolvedYMarkers },
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
/** From a resolved `from`: the axis tween steps an auto side at the midpoint, which is a cut. */
|
|
614
|
+
_tweenAxes(from, to, duration, easing) {
|
|
615
|
+
return this.command((t) => ({
|
|
616
|
+
...(to.x && { xAxis: lerpAxisDomain(from.x, to.x, t) }),
|
|
617
|
+
...(to.y && { yAxis: lerpAxisDomain(from.y, to.y, t) }),
|
|
618
|
+
}), duration, easing);
|
|
596
619
|
}
|
|
597
620
|
};
|
|
598
621
|
__decorate([
|