@motionscript/charts 0.1.0-alpha.0 → 0.1.0-alpha.10
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 +105 -0
- package/NOTICE +49 -0
- package/README.md +99 -0
- package/dist/bar-chart/bar-chart.d.ts +133 -228
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +386 -565
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +35 -41
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +93 -115
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +50 -70
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +155 -210
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -2
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +1 -1
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +7 -7
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +7 -7
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-TJNHLQGV.js +2 -0
- package/dist/browser/chunks/chunk-TJNHLQGV.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 +10 -8
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +10 -8
- package/dist/engine.js.map +1 -1
- package/dist/kit/cartesian.d.ts +44 -0
- package/dist/kit/cartesian.d.ts.map +1 -0
- package/dist/kit/cartesian.js +59 -0
- package/dist/kit/cartesian.js.map +1 -0
- package/dist/kit/chart-border.d.ts +10 -11
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +15 -32
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +32 -21
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +33 -90
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +123 -85
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +137 -186
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +17 -0
- package/dist/kit/entries.d.ts.map +1 -0
- package/dist/kit/entries.js +19 -0
- package/dist/kit/entries.js.map +1 -0
- package/dist/kit/motion.d.ts +48 -0
- package/dist/kit/motion.d.ts.map +1 -0
- package/dist/kit/motion.js +63 -0
- package/dist/kit/motion.js.map +1 -0
- package/dist/kit/paints.d.ts +10 -0
- package/dist/kit/paints.d.ts.map +1 -0
- package/dist/kit/paints.js +12 -0
- package/dist/kit/paints.js.map +1 -0
- package/dist/kit/shared.d.ts +61 -10
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +108 -13
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +48 -61
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +97 -132
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +60 -77
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +100 -121
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +32 -33
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +31 -65
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +58 -64
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +94 -123
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +3 -3
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +2 -2
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +156 -303
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +410 -638
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +7 -7
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +23 -8
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +4 -11
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +16 -5
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +6 -9
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +7 -9
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +2 -2
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -1
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +108 -126
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +202 -271
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +84 -31
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +93 -107
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +160 -122
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +333 -361
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +12 -6
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +14 -8
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +7 -4
- package/src/bar-chart/bar-chart.ts +424 -686
- package/src/bar-chart/category-axis.ts +96 -111
- package/src/bar-chart/chart-bars.ts +178 -201
- package/src/bar-chart/index.ts +2 -2
- package/src/bar-chart/shared.ts +7 -7
- package/src/engine.ts +10 -8
- package/src/kit/cartesian.ts +81 -0
- package/src/kit/chart-border.ts +23 -34
- package/src/kit/chart-canvas.ts +45 -80
- package/src/kit/chart-legend.ts +185 -206
- package/src/kit/entries.ts +20 -0
- package/src/kit/motion.ts +90 -0
- package/src/kit/paints.ts +15 -0
- package/src/kit/shared.ts +120 -13
- package/src/kit/vertical-axis.ts +111 -141
- package/src/line-chart/chart-line.ts +103 -155
- package/src/line-chart/chart-region.ts +36 -81
- package/src/line-chart/horizontal-axis.ts +102 -153
- package/src/line-chart/index.ts +3 -3
- package/src/line-chart/line-chart.ts +463 -759
- package/src/line-chart/shared.ts +22 -8
- package/src/line-chart/x-scale.ts +20 -5
- package/src/nodes.ts +8 -10
- package/src/pie-chart/index.ts +2 -2
- package/src/pie-chart/pie-chart.ts +225 -303
- package/src/pie-chart/pie-legend.ts +125 -115
- package/src/pie-chart/pie-ring.ts +388 -443
- package/src/pie-chart/shared.ts +14 -8
- package/dist/browser/chunks/chunk-ZMBOBHYL.js +0 -2
- package/dist/browser/chunks/chunk-ZMBOBHYL.js.map +0 -7
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Graphics2D, Node2D, fillOps, strokeOps, property, } from "@motionscript/core";
|
|
1
|
+
import { Graphics2D, Types, component2d, fillOps, strokeOps, } from "@motionscript/sdk";
|
|
2
|
+
import { fresh } from "../kit/entries.js";
|
|
3
|
+
import { loadPaints } from "../kit/paints.js";
|
|
8
4
|
import { DEFAULT_CHART_THEME, EMPTY_REGION_BOX, hasRegion, } from "./shared.js";
|
|
9
|
-
import { declarePaints } from "@motionscript/core/component";
|
|
10
5
|
/**
|
|
11
6
|
* The **region call-out** of a {@link LineChart}: a washed rectangle over the
|
|
12
7
|
* plot with a dashed rule down each edge the author actually bounded. Sized and
|
|
13
|
-
* positioned entirely from the pre-mapped
|
|
14
|
-
* than its own
|
|
8
|
+
* positioned entirely from the pre-mapped `box` rather
|
|
9
|
+
* than its own box — the region already carries the plot geometry.
|
|
15
10
|
*
|
|
16
11
|
* It draws only the *marking*; fading the series outside the region is
|
|
17
12
|
* {@link ChartLine}'s job (it clips its own polyline against the same box), so
|
|
@@ -21,20 +16,24 @@ import { declarePaints } from "@motionscript/core/component";
|
|
|
21
16
|
* plot height, so its top and bottom edges are the plot's own border, not a data
|
|
22
17
|
* bound — drawing dashes there would assert a limit the author didn't set.
|
|
23
18
|
*/
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
export const ChartRegion = component2d({
|
|
20
|
+
key: "chartRegion",
|
|
21
|
+
state: {
|
|
22
|
+
/** The highlighted slice, already resolved into this node's local pixel space (origin at centre, y-up) by the parent {@link LineChart}. A degenerate box draws nothing. */
|
|
23
|
+
box: fresh(() => EMPTY_REGION_BOX),
|
|
24
|
+
/** Dashed rule marking each *bounded* edge of the box. */
|
|
25
|
+
stroke: Types.custom(DEFAULT_CHART_THEME.region.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),
|
|
26
|
+
/** Wash filling the box, under the series lines. */
|
|
27
|
+
fill: Types.custom(DEFAULT_CHART_THEME.region.fill, { resolve: fillOps.resolve, lerp: fillOps.lerp }),
|
|
28
|
+
/** Reveal of the annotation in `[0, 1]`, driven by the chart's own `regionReveal` so the rules and the series' dimming move as one. */
|
|
29
|
+
reveal: 0,
|
|
30
|
+
},
|
|
31
|
+
load: (loader, state) => loadPaints(loader, { fills: [state.fill], strokes: [state.stroke] }),
|
|
32
|
+
render: (ctx, state) => {
|
|
33
|
+
const box = state.box;
|
|
35
34
|
if (!hasRegion(box))
|
|
36
35
|
return;
|
|
37
|
-
const r = Math.max(0, Math.min(1,
|
|
36
|
+
const r = Math.max(0, Math.min(1, state.reveal));
|
|
38
37
|
if (r <= 0)
|
|
39
38
|
return;
|
|
40
39
|
const width = box.right - box.left;
|
|
@@ -42,60 +41,27 @@ export class ChartRegion extends Node2D {
|
|
|
42
41
|
const cx = (box.left + box.right) / 2;
|
|
43
42
|
const cy = (box.bottom + box.top) / 2;
|
|
44
43
|
// Wash first, so the rules sit over their own tint.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ctx.draw(new Graphics2D()
|
|
48
|
-
.rect({ x: cx, y: cy, width, height })
|
|
49
|
-
.fill(this.fill)
|
|
50
|
-
.opacity(r));
|
|
44
|
+
if (state.fill.length > 0) {
|
|
45
|
+
ctx.draw(new Graphics2D().rect({ x: cx, y: cy, width, height }).fill(state.fill).opacity(r));
|
|
51
46
|
}
|
|
52
47
|
// One rule per bounded edge, growing from the region's centre outward as
|
|
53
48
|
// `reveal` climbs — the same "trace it in" beat as the series lines.
|
|
54
|
-
|
|
55
|
-
if (stroke.length === 0)
|
|
49
|
+
if (state.stroke.length === 0)
|
|
56
50
|
return;
|
|
57
51
|
// One `draw` per rule rather than four line ops under a single paint:
|
|
58
52
|
// shapes chained before a `stroke()` are combined into one surface, and
|
|
59
53
|
// stroking a union of disjoint open paths doesn't paint.
|
|
60
|
-
const rule = (points) => ctx.draw(new Graphics2D().line({ points }).stroke(
|
|
54
|
+
const rule = (points) => ctx.draw(new Graphics2D().line({ points }).stroke(state.stroke).opacity(r));
|
|
61
55
|
if (box.xBounded) {
|
|
62
56
|
const half = (height / 2) * r;
|
|
63
|
-
for (const x of [box.left, box.right])
|
|
64
|
-
rule([
|
|
65
|
-
{ x, y: cy - half },
|
|
66
|
-
{ x, y: cy + half },
|
|
67
|
-
]);
|
|
68
|
-
}
|
|
57
|
+
for (const x of [box.left, box.right])
|
|
58
|
+
rule([{ x, y: cy - half }, { x, y: cy + half }]);
|
|
69
59
|
}
|
|
70
60
|
if (box.yBounded) {
|
|
71
61
|
const half = (width / 2) * r;
|
|
72
|
-
for (const y of [box.bottom, box.top])
|
|
73
|
-
rule([
|
|
74
|
-
{ x: cx - half, y },
|
|
75
|
-
{ x: cx + half, y },
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
62
|
+
for (const y of [box.bottom, box.top])
|
|
63
|
+
rule([{ x: cx - half, y }, { x: cx + half, y }]);
|
|
78
64
|
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
__decorate([
|
|
82
|
-
property({ default: () => EMPTY_REGION_BOX })
|
|
83
|
-
], ChartRegion.prototype, "box", void 0);
|
|
84
|
-
__decorate([
|
|
85
|
-
property({
|
|
86
|
-
default: DEFAULT_CHART_THEME.region.stroke,
|
|
87
|
-
mapper: strokeOps.resolve,
|
|
88
|
-
tween: strokeOps.lerp,
|
|
89
|
-
})
|
|
90
|
-
], ChartRegion.prototype, "stroke", void 0);
|
|
91
|
-
__decorate([
|
|
92
|
-
property({
|
|
93
|
-
default: DEFAULT_CHART_THEME.region.fill,
|
|
94
|
-
mapper: fillOps.resolve,
|
|
95
|
-
tween: fillOps.lerp,
|
|
96
|
-
})
|
|
97
|
-
], ChartRegion.prototype, "fill", void 0);
|
|
98
|
-
__decorate([
|
|
99
|
-
property({ default: 0 })
|
|
100
|
-
], ChartRegion.prototype, "reveal", void 0);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
101
67
|
//# sourceMappingURL=chart-region.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-region.js","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chart-region.js","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n Graphics2D,\n Types,\n component2d,\n fillOps,\n strokeOps,\n type Fill,\n type FillResolved,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` through the sdk, not core.\n type Node2D as _Node2D,\n type Stroke,\n type StrokeResolved,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"../kit/entries\"\nimport { loadPaints } from \"../kit/paints\"\nimport {\n DEFAULT_CHART_THEME,\n EMPTY_REGION_BOX,\n hasRegion,\n type RegionBox,\n} from \"./shared\"\n\n/**\n * The **region call-out** of a {@link LineChart}: a washed rectangle over the\n * plot with a dashed rule down each edge the author actually bounded. Sized and\n * positioned entirely from the pre-mapped `box` rather\n * than its own box — the region already carries the plot geometry.\n *\n * It draws only the *marking*; fading the series outside the region is\n * {@link ChartLine}'s job (it clips its own polyline against the same box), so\n * the two can't disagree about where the boundary is.\n *\n * Only bounded edges get a rule: a region given just an `x` range spans the full\n * plot height, so its top and bottom edges are the plot's own border, not a data\n * bound — drawing dashes there would assert a limit the author didn't set.\n */\nexport const ChartRegion = component2d({\n key: \"chartRegion\",\n state: {\n /** The highlighted slice, already resolved into this node's local pixel space (origin at centre, y-up) by the parent {@link LineChart}. A degenerate box draws nothing. */\n box: fresh<RegionBox>(() => EMPTY_REGION_BOX),\n /** Dashed rule marking each *bounded* edge of the box. */\n stroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_CHART_THEME.region.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n /** Wash filling the box, under the series lines. */\n fill: Types.custom<Fill, FillResolved[]>(DEFAULT_CHART_THEME.region.fill, { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n /** Reveal of the annotation in `[0, 1]`, driven by the chart's own `regionReveal` so the rules and the series' dimming move as one. */\n reveal: 0,\n },\n load: (loader, state) => loadPaints(loader, { fills: [state.fill], strokes: [state.stroke] }),\n render: (ctx, state) => {\n const box = state.box\n if (!hasRegion(box)) return\n\n const r = Math.max(0, Math.min(1, state.reveal))\n if (r <= 0) return\n\n const width = box.right - box.left\n const height = box.top - box.bottom\n const cx = (box.left + box.right) / 2\n const cy = (box.bottom + box.top) / 2\n\n // Wash first, so the rules sit over their own tint.\n if (state.fill.length > 0) {\n ctx.draw(new Graphics2D().rect({ x: cx, y: cy, width, height }).fill(state.fill).opacity(r))\n }\n\n // One rule per bounded edge, growing from the region's centre outward as\n // `reveal` climbs — the same \"trace it in\" beat as the series lines.\n if (state.stroke.length === 0) return\n\n // One `draw` per rule rather than four line ops under a single paint:\n // shapes chained before a `stroke()` are combined into one surface, and\n // stroking a union of disjoint open paths doesn't paint.\n const rule = (points: { x: number; y: number }[]) =>\n ctx.draw(new Graphics2D().line({ points }).stroke(state.stroke).opacity(r))\n\n if (box.xBounded) {\n const half = (height / 2) * r\n for (const x of [box.left, box.right]) rule([{ x, y: cy - half }, { x, y: cy + half }])\n }\n if (box.yBounded) {\n const half = (width / 2) * r\n for (const y of [box.bottom, box.top]) rule([{ x: cx - half, y }, { x: cx + half, y }])\n }\n },\n})\n\nexport type ChartRegion = NodeOf<typeof ChartRegion>\n"]}
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type NodeOf, type Node2D } from "@motionscript/sdk";
|
|
2
|
+
import { type Arrival } from "../kit/motion.js";
|
|
2
3
|
import { type AxisConfig, type Range } from "../kit/shared.js";
|
|
3
|
-
import { type Seekable } from "@motionscript/core/component";
|
|
4
|
-
export interface HorizontalAxisProps extends Node2DProps {
|
|
5
|
-
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
6
|
-
range: Range;
|
|
7
|
-
/** Tick values (in data units) to draw along the axis. */
|
|
8
|
-
markers: number[];
|
|
9
|
-
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
10
|
-
axis: AxisConfig;
|
|
11
|
-
/**
|
|
12
|
-
* Caption drawn centred in the gutter beneath the marker row. Empty string
|
|
13
|
-
* (the default) hides it.
|
|
14
|
-
*/
|
|
15
|
-
label: string;
|
|
16
|
-
}
|
|
17
|
-
/** How a tick value is captioned — see {@link HorizontalAxis.labelFor}. */
|
|
18
|
-
export type MarkerLabel = (value: number) => string;
|
|
19
4
|
/**
|
|
20
5
|
* The horizontal axis of a {@link LineChart}: a **row of {@link Text} nodes**,
|
|
21
6
|
* one per marker value, running left-to-right. Pure layout — the mirror of the
|
|
@@ -26,60 +11,69 @@ export type MarkerLabel = (value: number) => string;
|
|
|
26
11
|
* `2026-03` sits three months along, not three slots along. That is what keeps
|
|
27
12
|
* it distinct from a bar chart's bottom axis, which centres a caption on each
|
|
28
13
|
* slot and has no scale at all — the two only look alike. What the values are
|
|
29
|
-
* captioned *as* is the chart's to decide
|
|
14
|
+
* captioned *as* is the chart's to decide, in `captions`.
|
|
30
15
|
*
|
|
31
|
-
*
|
|
16
|
+
* `enter` staggers the markers in **left-to-right**: each starts lifted a
|
|
32
17
|
* little above its slot and transparent, then fades and slides down into place.
|
|
33
18
|
*/
|
|
34
|
-
export declare
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
axis
|
|
38
|
-
|
|
19
|
+
export declare const HorizontalAxis: import("@motionscript/sdk").Component<"horizontalAxis", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
20
|
+
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
21
|
+
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
22
|
+
/** Tick values (in data units) to draw along the axis. */
|
|
23
|
+
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
39
24
|
/**
|
|
40
|
-
* How
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* A plain field rather than a `@property`, because it is a **policy, not a
|
|
45
|
-
* value**: there is nothing to tween between two formatters, and a signal
|
|
46
|
-
* holding a function is a signal every `set`/`to` on this node would have to
|
|
47
|
-
* know not to touch. Read inside each marker's `text` binding, so replacing it
|
|
48
|
-
* before the first frame is enough — which is when the chart does it.
|
|
25
|
+
* How each marker is captioned, one per entry of `markers` and in its order.
|
|
26
|
+
* Empty (the default), or short, captions a marker with its bare numeric
|
|
27
|
+
* reading; a chart whose x column names months or categories writes those.
|
|
49
28
|
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
29
|
+
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
30
|
+
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
31
|
+
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
32
|
+
/** Caption drawn centred in the gutter beneath the marker row; empty (the default) hides it. */
|
|
33
|
+
readonly label: "";
|
|
34
|
+
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
35
|
+
}>, {
|
|
36
|
+
readonly enter: {
|
|
37
|
+
readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
38
|
+
readonly slide: import("@motionscript/sdk").Type<number, number, false>;
|
|
39
|
+
};
|
|
40
|
+
}, null, Node2D<import("@motionscript/core").Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
41
|
+
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
42
|
+
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
43
|
+
/** Tick values (in data units) to draw along the axis. */
|
|
44
|
+
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
61
45
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
46
|
+
* How each marker is captioned, one per entry of `markers` and in its order.
|
|
47
|
+
* Empty (the default), or short, captions a marker with its bare numeric
|
|
48
|
+
* reading; a chart whose x column names months or categories writes those.
|
|
64
49
|
*/
|
|
65
|
-
|
|
50
|
+
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
51
|
+
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
52
|
+
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
53
|
+
/** Caption drawn centred in the gutter beneath the marker row; empty (the default) hides it. */
|
|
54
|
+
readonly label: "";
|
|
55
|
+
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
56
|
+
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
57
|
+
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
58
|
+
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
59
|
+
/** Tick values (in data units) to draw along the axis. */
|
|
60
|
+
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
66
61
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* `i * step` per marker — but expressed as `wait` inside a generator they only
|
|
71
|
-
* existed while it ran, so knowing what the axis looked like partway through
|
|
72
|
-
* meant running it from zero. Placed explicitly, the same stagger can be asked
|
|
73
|
-
* for a time, which is what lets a chart scene scrub in constant time.
|
|
74
|
-
*
|
|
75
|
-
* `duration` is the **whole** entrance — see {@link VerticalAxis.enter} and
|
|
76
|
-
* {@link enterBudget}.
|
|
62
|
+
* How each marker is captioned, one per entry of `markers` and in its order.
|
|
63
|
+
* Empty (the default), or short, captions a marker with its bare numeric
|
|
64
|
+
* reading; a chart whose x column names months or categories writes those.
|
|
77
65
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
66
|
+
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
67
|
+
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
68
|
+
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
69
|
+
/** Caption drawn centred in the gutter beneath the marker row; empty (the default) hides it. */
|
|
70
|
+
readonly label: "";
|
|
71
|
+
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
72
|
+
}>, {
|
|
73
|
+
readonly enter: {
|
|
74
|
+
readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
75
|
+
readonly slide: import("@motionscript/sdk").Type<number, number, false>;
|
|
76
|
+
};
|
|
77
|
+
}, Node2D<import("@motionscript/core").Node2DProps>>>>;
|
|
78
|
+
export type HorizontalAxis = NodeOf<typeof HorizontalAxis>;
|
|
85
79
|
//# sourceMappingURL=horizontal-axis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizontal-axis.d.ts","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"horizontal-axis.d.ts","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,MAAM,EACX,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAA8D,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAMvB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc;IAGvB,8EAA8E;;IAE9E,0DAA0D;;IAE1D;;;;OAIG;;IAEH,oFAAoF;;IAEpF,gGAAgG;;;;;;;;;IAZhG,8EAA8E;;IAE9E,0DAA0D;;IAE1D;;;;OAIG;;IAEH,oFAAoF;;IAEpF,gGAAgG;;;;IAZhG,8EAA8E;;IAE9E,0DAA0D;;IAE1D;;;;OAIG;;IAEH,oFAAoF;;IAEpF,gGAAgG;;;;;;;;sDA8FlG,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import { command, Node2D, Rect, Text, easeOut, property, insetsOps, textOps, } from "@motionscript/core";
|
|
8
|
-
import { DEFAULT_X_AXIS, enterBudget, formatMarker, } from "../kit/shared.js";
|
|
9
|
-
import { at, compose } from "@motionscript/core/component";
|
|
1
|
+
import { Rect, Text, Types, component2d, insetsOps, textOps, } from "@motionscript/sdk";
|
|
2
|
+
import { asParts, fresh } from "../kit/entries.js";
|
|
3
|
+
import { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase } from "../kit/motion.js";
|
|
4
|
+
import { DEFAULT_X_AXIS, enterBudget, } from "../kit/shared.js";
|
|
5
|
+
import { markerCaption } from "../kit/vertical-axis.js";
|
|
10
6
|
/** How far a marker starts above its slot when it enters, in px. */
|
|
11
7
|
const SLIDE = 24;
|
|
12
8
|
/**
|
|
@@ -19,57 +15,57 @@ const SLIDE = 24;
|
|
|
19
15
|
* `2026-03` sits three months along, not three slots along. That is what keeps
|
|
20
16
|
* it distinct from a bar chart's bottom axis, which centres a caption on each
|
|
21
17
|
* slot and has no scale at all — the two only look alike. What the values are
|
|
22
|
-
* captioned *as* is the chart's to decide
|
|
18
|
+
* captioned *as* is the chart's to decide, in `captions`.
|
|
23
19
|
*
|
|
24
|
-
*
|
|
20
|
+
* `enter` staggers the markers in **left-to-right**: each starts lifted a
|
|
25
21
|
* little above its slot and transparent, then fades and slides down into place.
|
|
26
22
|
*/
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
23
|
+
export const HorizontalAxis = component2d({
|
|
24
|
+
key: "horizontalAxis",
|
|
25
|
+
state: {
|
|
26
|
+
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
27
|
+
range: fresh(() => [0, 1]),
|
|
28
|
+
/** Tick values (in data units) to draw along the axis. */
|
|
29
|
+
markers: fresh(() => []),
|
|
30
|
+
/**
|
|
31
|
+
* How each marker is captioned, one per entry of `markers` and in its order.
|
|
32
|
+
* Empty (the default), or short, captions a marker with its bare numeric
|
|
33
|
+
* reading; a chart whose x column names months or categories writes those.
|
|
34
|
+
*/
|
|
35
|
+
captions: fresh(() => []),
|
|
36
|
+
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
37
|
+
axis: Types.custom(DEFAULT_X_AXIS),
|
|
38
|
+
/** Caption drawn centred in the gutter beneath the marker row; empty (the default) hides it. */
|
|
39
|
+
label: "",
|
|
40
|
+
arrivals: arrivalsEntry(),
|
|
41
|
+
},
|
|
42
|
+
// A plain node filled its parent; one made of its markers would hug them.
|
|
43
|
+
defaults: { width: "fill", height: "fill" },
|
|
44
|
+
children: (state) => {
|
|
45
|
+
const tickPad = insetsOps.resolve(state.axis.tickPadding).top;
|
|
46
|
+
const titlePad = insetsOps.resolve(state.axis.titlePadding).top;
|
|
47
|
+
const column = [];
|
|
48
|
+
// The column's parent is the axis: its box is what the markers are placed in.
|
|
49
|
+
const box = () => column[0]?.parent?.layoutBounds ?? { width: 0, height: 0 };
|
|
50
|
+
/** The live tick values, left → right — re-read every frame, not snapshotted. */
|
|
51
|
+
const sorted = () => [...state.markers].sort((a, b) => a - b);
|
|
52
|
+
/** Tick `i`'s fraction across the live `range`, 0 at the left edge. */
|
|
53
|
+
const fracAt = (value) => {
|
|
54
|
+
if (value === undefined)
|
|
55
|
+
return 0;
|
|
56
|
+
const [min, max] = state.range;
|
|
57
|
+
return max <= min ? 0 : (value - min) / (max - min);
|
|
58
|
+
};
|
|
59
|
+
const markers = state.markers.map((_, i) => {
|
|
64
60
|
const marker = new Text({
|
|
65
|
-
...textOps.styleProps(
|
|
61
|
+
...textOps.styleProps(state.axis.labelStyle),
|
|
66
62
|
text: () => {
|
|
67
|
-
const
|
|
68
|
-
return
|
|
63
|
+
const value = sorted()[i];
|
|
64
|
+
return value === undefined ? "" : markerCaption(state, value);
|
|
69
65
|
},
|
|
70
66
|
x: () => {
|
|
71
|
-
const width =
|
|
72
|
-
const centred = (
|
|
67
|
+
const width = box().width;
|
|
68
|
+
const centred = (fracAt(sorted()[i]) - 0.5) * width;
|
|
73
69
|
// Held inside the axis's right edge, which is also the *chart's*: the
|
|
74
70
|
// last marker is centred on the last grid line, so half of `2026-06`
|
|
75
71
|
// — or of `3300` — would be drawn outside the node's box and outside
|
|
@@ -79,80 +75,55 @@ export class HorizontalAxis extends Node2D {
|
|
|
79
75
|
const limit = width / 2 - marker.layoutBounds.width / 2;
|
|
80
76
|
return Math.min(centred, limit);
|
|
81
77
|
},
|
|
78
|
+
opacity: () => arrivalOf(state.arrivals, i).opacity,
|
|
79
|
+
y: () => arrivalOf(state.arrivals, i).shift,
|
|
82
80
|
});
|
|
83
81
|
return marker;
|
|
84
82
|
});
|
|
85
83
|
const children = [
|
|
86
|
-
new Rect({
|
|
87
|
-
width: "fill",
|
|
88
|
-
height: "hug",
|
|
89
|
-
padding: { top: tickPad },
|
|
90
|
-
children: this.markerNodes,
|
|
91
|
-
}),
|
|
84
|
+
new Rect({ width: "fill", height: "hug", padding: { top: tickPad }, children: markers }),
|
|
92
85
|
];
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
...textOps.styleProps(
|
|
96
|
-
text:
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
if (state.label !== "") {
|
|
87
|
+
children.push(new Text({
|
|
88
|
+
...textOps.styleProps(state.axis.titleStyle),
|
|
89
|
+
text: state.label,
|
|
90
|
+
opacity: () => arrivalOf(state.arrivals, "label").opacity,
|
|
91
|
+
y: () => arrivalOf(state.arrivals, "label").shift,
|
|
92
|
+
}));
|
|
99
93
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return compose([
|
|
136
|
-
...markers,
|
|
137
|
-
...(this.labelNode
|
|
138
|
-
? [at(lastMarkerEnds, this.labelNode.to({ data: { opacity: 1, y: 0 }, duration: caption, easing }))]
|
|
139
|
-
: []),
|
|
140
|
-
]);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
__decorate([
|
|
144
|
-
property({ default: () => [0, 1] })
|
|
145
|
-
], HorizontalAxis.prototype, "range", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
property({ default: () => [] })
|
|
148
|
-
], HorizontalAxis.prototype, "markers", void 0);
|
|
149
|
-
__decorate([
|
|
150
|
-
property({ default: DEFAULT_X_AXIS })
|
|
151
|
-
], HorizontalAxis.prototype, "axis", void 0);
|
|
152
|
-
__decorate([
|
|
153
|
-
property({ default: "" })
|
|
154
|
-
], HorizontalAxis.prototype, "label", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
command()
|
|
157
|
-
], HorizontalAxis.prototype, "enter", null);
|
|
94
|
+
column.push(new Rect({ flow: "vertical", gap: titlePad, height: "hug", width: "fill", children }));
|
|
95
|
+
return asParts(column);
|
|
96
|
+
},
|
|
97
|
+
commands: {
|
|
98
|
+
/**
|
|
99
|
+
* Stagger the markers in left to right, then slide the caption in after
|
|
100
|
+
* them. Its first frame arms them all: lifted by `slide` and transparent.
|
|
101
|
+
*
|
|
102
|
+
* The timeline's duration is the **whole** entrance — see
|
|
103
|
+
* `VerticalAxis.enter` and {@link enterBudget}.
|
|
104
|
+
*/
|
|
105
|
+
enter: {
|
|
106
|
+
args: {
|
|
107
|
+
stagger: Types.custom(undefined),
|
|
108
|
+
slide: Types.number(SLIDE),
|
|
109
|
+
},
|
|
110
|
+
run: (timeline, state) => {
|
|
111
|
+
const { stagger, slide } = timeline.args;
|
|
112
|
+
const count = state.markers.length;
|
|
113
|
+
const captioned = state.label !== "";
|
|
114
|
+
const from = { opacity: 0, shift: slide };
|
|
115
|
+
const keys = [...state.markers.keys(), ...(captioned ? ["label"] : [])];
|
|
116
|
+
const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }));
|
|
117
|
+
if (count === 0)
|
|
118
|
+
return arm;
|
|
119
|
+
const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger);
|
|
120
|
+
const ease = frameEase(timeline);
|
|
121
|
+
// Left marker leads: the row is already left → right.
|
|
122
|
+
const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }));
|
|
123
|
+
const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, "label", from, ease) }] : [];
|
|
124
|
+
return timeline.together([arm, beats(timeline, [...markers, ...label])]);
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
});
|
|
158
129
|
//# sourceMappingURL=horizontal-axis.js.map
|