@motionscript/charts 0.1.0 → 0.1.1-alpha.0
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 +19 -0
- package/dist/bar-chart/bar-chart.d.ts +22 -93
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +48 -121
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +11 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +15 -38
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +43 -74
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +31 -59
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -10
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +0 -7
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +27 -90
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +15 -54
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-4SMRCU24.js +2 -0
- package/dist/browser/chunks/chunk-4SMRCU24.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +4 -16
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +4 -16
- package/dist/engine.js.map +1 -1
- package/dist/kit/cartesian.d.ts +8 -28
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +7 -19
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-border.d.ts +9 -18
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +4 -9
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +25 -36
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +13 -13
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +14 -61
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +17 -65
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +2 -0
- package/dist/kit/entries.d.ts.map +1 -1
- package/dist/kit/entries.js +2 -0
- package/dist/kit/entries.js.map +1 -1
- package/dist/kit/motion.d.ts +11 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +7 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/kit/shared.d.ts +60 -175
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +40 -157
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +16 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +17 -42
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +16 -41
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +14 -43
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -27
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +8 -22
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +16 -43
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +13 -42
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +1 -13
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +0 -12
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +23 -109
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +45 -141
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +33 -107
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +28 -81
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +14 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +29 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +0 -12
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -12
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +1 -12
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +0 -9
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +37 -71
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +31 -65
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +11 -26
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +14 -39
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +50 -192
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +75 -247
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +45 -131
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +29 -72
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +51 -165
- package/src/bar-chart/category-axis.ts +16 -57
- package/src/bar-chart/chart-bars.ts +43 -120
- package/src/bar-chart/index.ts +2 -10
- package/src/bar-chart/shared.ts +29 -97
- package/src/engine.ts +4 -16
- package/src/kit/cartesian.ts +11 -26
- package/src/kit/chart-border.ts +6 -20
- package/src/kit/chart-canvas.ts +15 -40
- package/src/kit/chart-legend.ts +17 -86
- package/src/kit/entries.ts +4 -1
- package/src/kit/motion.ts +11 -2
- package/src/kit/shared.ts +58 -219
- package/src/kit/vertical-axis.ts +18 -71
- package/src/line-chart/chart-line.ts +16 -44
- package/src/line-chart/chart-region.ts +10 -23
- package/src/line-chart/horizontal-axis.ts +13 -42
- package/src/line-chart/index.ts +1 -13
- package/src/line-chart/line-chart.ts +50 -184
- package/src/line-chart/shared.ts +51 -145
- package/src/line-chart/x-scale.ts +31 -121
- package/src/nodes.ts +0 -12
- package/src/pie-chart/index.ts +1 -12
- package/src/pie-chart/pie-chart.ts +34 -102
- package/src/pie-chart/pie-legend.ts +14 -55
- package/src/pie-chart/pie-ring.ts +80 -307
- package/src/pie-chart/shared.ts +50 -139
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-region.js","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,
|
|
1
|
+
{"version":3,"file":"chart-region.js","sourceRoot":"","sources":["../../src/line-chart/chart-region.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,KAAK,EACL,WAAW,EACX,OAAO,EACP,SAAS,GASV,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,GAEV,MAAM,UAAU,CAAA;AAEjB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC;IACrC,GAAG,EAAE,aAAa;IAClB,KAAK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C,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC;gBAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QACzF,CAAC;IACH,CAAC;CACF,CAAC,CAAA","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` and its props through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\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 call-out of a {@link LineChart}: a washed rectangle with a dashed rule on\n * each bounded edge, drawn from the pre-mapped `box`. Dimming the series outside\n * is {@link ChartLine}'s job, clipped against the same box so the two agree on\n * the boundary. An unbounded edge is the plot's own border, and a rule there\n * would assert a limit the author did not set.\n */\nexport const ChartRegion = component2d({\n key: \"chartRegion\",\n state: {\n /** In this node's pixel space (origin at centre, y-up), mapped by the parent. A degenerate box draws nothing. */\n box: fresh<RegionBox>(() => EMPTY_REGION_BOX),\n stroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_CHART_THEME.region.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n fill: Types.custom<Fill, FillResolved[]>(DEFAULT_CHART_THEME.region.fill, { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n /** Driven by the chart's `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 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 if (state.stroke.length === 0) return\n\n // One `draw` per rule: stroking a union of disjoint open paths paints nothing.\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,35 +1,20 @@
|
|
|
1
|
-
import { type NodeOf, type Node2D } from "@motionscript/sdk";
|
|
1
|
+
import { type NodeOf, type Node2D, type Node2DProps as _Node2DProps } from "@motionscript/sdk";
|
|
2
2
|
import { type Arrival } from "../kit/motion.js";
|
|
3
3
|
import { type AxisConfig, type Range } from "../kit/shared.js";
|
|
4
4
|
/**
|
|
5
|
-
* The horizontal axis of a {@link LineChart}: a
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Markers are always placed **by value** across the range, whatever they say:
|
|
11
|
-
* `2026-03` sits three months along, not three slots along. That is what keeps
|
|
12
|
-
* it distinct from a bar chart's bottom axis, which centres a caption on each
|
|
13
|
-
* slot and has no scale at all — the two only look alike. What the values are
|
|
14
|
-
* captioned *as* is the chart's to decide, in `captions`.
|
|
15
|
-
*
|
|
16
|
-
* `enter` staggers the markers in **left-to-right**: each starts lifted a
|
|
17
|
-
* little above its slot and transparent, then fades and slides down into place.
|
|
5
|
+
* The horizontal axis of a {@link LineChart}: a row of {@link Text} markers, the
|
|
6
|
+
* mirror of `VerticalAxis` (bound text and positions, landed resting state).
|
|
7
|
+
* Markers are placed by value across the range, whatever they say: `2026-03`
|
|
8
|
+
* sits three months along, not three slots along, unlike a bar chart's axis.
|
|
18
9
|
*/
|
|
19
10
|
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
11
|
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
22
|
-
/** Tick values
|
|
12
|
+
/** Tick values in data units. */
|
|
23
13
|
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
24
|
-
/**
|
|
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.
|
|
28
|
-
*/
|
|
14
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
29
15
|
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
30
|
-
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
31
16
|
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
32
|
-
/** Caption
|
|
17
|
+
/** Caption centred beneath the markers; empty hides it. */
|
|
33
18
|
readonly label: "";
|
|
34
19
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
35
20
|
}>, {
|
|
@@ -37,36 +22,24 @@ export declare const HorizontalAxis: import("@motionscript/sdk").Component<"hori
|
|
|
37
22
|
readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
38
23
|
readonly slide: import("@motionscript/sdk").Type<number, number, false>;
|
|
39
24
|
};
|
|
40
|
-
}, null, Node2D<
|
|
41
|
-
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
25
|
+
}, null, Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
42
26
|
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
43
|
-
/** Tick values
|
|
27
|
+
/** Tick values in data units. */
|
|
44
28
|
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
45
|
-
/**
|
|
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.
|
|
49
|
-
*/
|
|
29
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
50
30
|
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
51
|
-
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
52
31
|
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
53
|
-
/** Caption
|
|
32
|
+
/** Caption centred beneath the markers; empty hides it. */
|
|
54
33
|
readonly label: "";
|
|
55
34
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
56
35
|
}>, 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
36
|
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
59
|
-
/** Tick values
|
|
37
|
+
/** Tick values in data units. */
|
|
60
38
|
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
61
|
-
/**
|
|
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.
|
|
65
|
-
*/
|
|
39
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
66
40
|
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
67
|
-
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
68
41
|
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
69
|
-
/** Caption
|
|
42
|
+
/** Caption centred beneath the markers; empty hides it. */
|
|
70
43
|
readonly label: "";
|
|
71
44
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
72
45
|
}>, {
|
|
@@ -74,6 +47,6 @@ export declare const HorizontalAxis: import("@motionscript/sdk").Component<"hori
|
|
|
74
47
|
readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
75
48
|
readonly slide: import("@motionscript/sdk").Type<number, number, false>;
|
|
76
49
|
};
|
|
77
|
-
}, Node2D<
|
|
50
|
+
}, Node2D<_Node2DProps>>>>;
|
|
78
51
|
export type HorizontalAxis = NodeOf<typeof HorizontalAxis>;
|
|
79
52
|
//# 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,EAOL,KAAK,MAAM,EACX,KAAK,MAAM,
|
|
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,EACX,KAAK,WAAW,IAAI,YAAY,EACjC,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAA8D,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AAKvB;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;IAIvB,iCAAiC;;IAEjC,0FAA0F;;;IAG1F,2DAA2D;;;;;;;;;;IAL3D,iCAAiC;;IAEjC,0FAA0F;;;IAG1F,2DAA2D;;;;;IAL3D,iCAAiC;;IAEjC,0FAA0F;;;IAG1F,2DAA2D;;;;;;;;0BAgF7D,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -1,55 +1,38 @@
|
|
|
1
1
|
import { Rect, Text, Types, component2d, insetsOps, textOps, } from "@motionscript/sdk";
|
|
2
|
+
import { enterBudget } from "@motionscript/sdk/component";
|
|
2
3
|
import { asParts, fresh } from "../kit/entries.js";
|
|
3
4
|
import { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase } from "../kit/motion.js";
|
|
4
|
-
import { DEFAULT_X_AXIS,
|
|
5
|
+
import { DEFAULT_X_AXIS, } from "../kit/shared.js";
|
|
5
6
|
import { markerCaption } from "../kit/vertical-axis.js";
|
|
6
|
-
/** How far a marker starts above its slot when it enters, in px. */
|
|
7
7
|
const SLIDE = 24;
|
|
8
8
|
/**
|
|
9
|
-
* The horizontal axis of a {@link LineChart}: a
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Markers are always placed **by value** across the range, whatever they say:
|
|
15
|
-
* `2026-03` sits three months along, not three slots along. That is what keeps
|
|
16
|
-
* it distinct from a bar chart's bottom axis, which centres a caption on each
|
|
17
|
-
* slot and has no scale at all — the two only look alike. What the values are
|
|
18
|
-
* captioned *as* is the chart's to decide, in `captions`.
|
|
19
|
-
*
|
|
20
|
-
* `enter` staggers the markers in **left-to-right**: each starts lifted a
|
|
21
|
-
* little above its slot and transparent, then fades and slides down into place.
|
|
9
|
+
* The horizontal axis of a {@link LineChart}: a row of {@link Text} markers, the
|
|
10
|
+
* mirror of `VerticalAxis` (bound text and positions, landed resting state).
|
|
11
|
+
* Markers are placed by value across the range, whatever they say: `2026-03`
|
|
12
|
+
* sits three months along, not three slots along, unlike a bar chart's axis.
|
|
22
13
|
*/
|
|
23
14
|
export const HorizontalAxis = component2d({
|
|
24
15
|
key: "horizontalAxis",
|
|
25
16
|
state: {
|
|
26
|
-
/** `[min, max]` of the horizontal scale the markers are positioned within. */
|
|
27
17
|
range: fresh(() => [0, 1]),
|
|
28
|
-
/** Tick values
|
|
18
|
+
/** Tick values in data units. */
|
|
29
19
|
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
|
-
*/
|
|
20
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
35
21
|
captions: fresh(() => []),
|
|
36
|
-
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
37
22
|
axis: Types.custom(DEFAULT_X_AXIS),
|
|
38
|
-
/** Caption
|
|
23
|
+
/** Caption centred beneath the markers; empty hides it. */
|
|
39
24
|
label: "",
|
|
40
25
|
arrivals: arrivalsEntry(),
|
|
41
26
|
},
|
|
42
|
-
// A
|
|
27
|
+
// A node made of markers would otherwise hug them.
|
|
43
28
|
defaults: { width: "fill", height: "fill" },
|
|
44
29
|
children: (state) => {
|
|
45
30
|
const tickPad = insetsOps.resolve(state.axis.tickPadding).top;
|
|
46
31
|
const titlePad = insetsOps.resolve(state.axis.titlePadding).top;
|
|
47
32
|
const column = [];
|
|
48
|
-
// The column's parent is the axis
|
|
33
|
+
// The column's parent is the axis, whose box the markers are placed in.
|
|
49
34
|
const box = () => column[0]?.parent?.layoutBounds ?? { width: 0, height: 0 };
|
|
50
|
-
/** The live tick values, left → right — re-read every frame, not snapshotted. */
|
|
51
35
|
const sorted = () => [...state.markers].sort((a, b) => a - b);
|
|
52
|
-
/** Tick `i`'s fraction across the live `range`, 0 at the left edge. */
|
|
53
36
|
const fracAt = (value) => {
|
|
54
37
|
if (value === undefined)
|
|
55
38
|
return 0;
|
|
@@ -66,12 +49,7 @@ export const HorizontalAxis = component2d({
|
|
|
66
49
|
x: () => {
|
|
67
50
|
const width = box().width;
|
|
68
51
|
const centred = (fracAt(sorted()[i]) - 0.5) * width;
|
|
69
|
-
// Held inside the
|
|
70
|
-
// last marker is centred on the last grid line, so half of `2026-06`
|
|
71
|
-
// — or of `3300` — would be drawn outside the node's box and outside
|
|
72
|
-
// the rectangle the editor draws around it. Only the right edge is
|
|
73
|
-
// held, because the left one has the vertical axis's whole gutter
|
|
74
|
-
// beyond it, and a marker overhanging into that is inside the chart.
|
|
52
|
+
// Held inside the right edge, the chart's own: the last marker is centred on the last grid line, so half of it would fall outside the box. The left edge has the vertical axis's gutter beyond it.
|
|
75
53
|
const limit = width / 2 - marker.layoutBounds.width / 2;
|
|
76
54
|
return Math.min(centred, limit);
|
|
77
55
|
},
|
|
@@ -95,13 +73,7 @@ export const HorizontalAxis = component2d({
|
|
|
95
73
|
return asParts(column);
|
|
96
74
|
},
|
|
97
75
|
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
|
-
*/
|
|
76
|
+
/** Stagger markers in left to right, then the caption. The duration is the whole entrance ({@link enterBudget}). */
|
|
105
77
|
enter: {
|
|
106
78
|
args: {
|
|
107
79
|
stagger: Types.custom(undefined),
|
|
@@ -118,7 +90,6 @@ export const HorizontalAxis = component2d({
|
|
|
118
90
|
return arm;
|
|
119
91
|
const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger);
|
|
120
92
|
const ease = frameEase(timeline);
|
|
121
|
-
// Left marker leads: the row is already left → right.
|
|
122
93
|
const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }));
|
|
123
94
|
const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, "label", from, ease) }] : [];
|
|
124
95
|
return timeline.together([arm, beats(timeline, [...markers, ...label])]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizontal-axis.js","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,GAGR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAC;AACzG,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,oEAAoE;AACpE,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;IACxC,GAAG,EAAE,gBAAgB;IACrB,KAAK,EAAE;QACL,8EAA8E;QAC9E,KAAK,EAAE,KAAK,CAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,0DAA0D;QAC1D,OAAO,EAAE,KAAK,CAAW,GAAG,EAAE,CAAC,EAAE,CAAC;QAClC;;;;WAIG;QACH,QAAQ,EAAE,KAAK,CAAW,GAAG,EAAE,CAAC,EAAE,CAAC;QACnC,oFAAoF;QACpF,IAAI,EAAE,KAAK,CAAC,MAAM,CAAa,cAAc,CAAC;QAC9C,gGAAgG;QAChG,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,aAAa,EAAE;KAC1B;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AK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC;SACF;KACF;CACF,CAAC,CAAC","sourcesContent":["import {\n Rect,\n Text,\n Types,\n component2d,\n insetsOps,\n textOps,\n type NodeOf,\n type Node2D,\n} from \"@motionscript/sdk\";\n\nimport { asParts, fresh } from \"../kit/entries\";\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"../kit/motion\";\nimport {\n DEFAULT_X_AXIS,\n enterBudget,\n type AxisConfig,\n type Range,\n} from \"../kit/shared\";\nimport { markerCaption } from \"../kit/vertical-axis\";\n\n/** How far a marker starts above its slot when it enters, in px. */\nconst SLIDE = 24;\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, in `captions`.\n *\n * `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 const HorizontalAxis = component2d({\n key: \"horizontalAxis\",\n state: {\n /** `[min, max]` of the horizontal scale the markers are positioned within. */\n range: fresh<Range>(() => [0, 1]),\n /** Tick values (in data units) to draw along the axis. */\n markers: fresh<number[]>(() => []),\n /**\n * How each marker is captioned, one per entry of `markers` and in its order.\n * Empty (the default), or short, captions a marker with its bare numeric\n * reading; a chart whose x column names months or categories writes those.\n */\n captions: fresh<string[]>(() => []),\n /** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */\n axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),\n /** Caption drawn centred in the gutter beneath the marker row; empty (the default) hides it. */\n label: \"\",\n arrivals: arrivalsEntry(),\n },\n // A plain node filled its parent; one made of its markers would hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const tickPad = insetsOps.resolve(state.axis.tickPadding).top;\n const titlePad = insetsOps.resolve(state.axis.titlePadding).top;\n\n const column: Node2D[] = [];\n // The column's parent is the axis: its box is what the markers are placed in.\n const box = () => (column[0]?.parent as Node2D | null | undefined)?.layoutBounds ?? { width: 0, height: 0 };\n /** The live tick values, left → right — re-read every frame, not snapshotted. */\n const sorted = () => [...state.markers].sort((a, b) => a - b);\n /** Tick `i`'s fraction across the live `range`, 0 at the left edge. */\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0;\n const [min, max] = state.range;\n return max <= min ? 0 : (value - min) / (max - min);\n };\n\n const markers = state.markers.map((_, i) => {\n const marker: Node2D = new Text({\n ...textOps.styleProps(state.axis.labelStyle),\n text: () => {\n const value = sorted()[i];\n return value === undefined ? \"\" : markerCaption(state, value);\n },\n x: () => {\n const width = box().width;\n const centred = (fracAt(sorted()[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 opacity: () => arrivalOf(state.arrivals, i).opacity,\n y: () => arrivalOf(state.arrivals, i).shift,\n });\n return marker;\n });\n\n const children: Node2D[] = [\n new Rect({ width: \"fill\", height: \"hug\", padding: { top: tickPad }, children: markers }),\n ];\n if (state.label !== \"\") {\n children.push(\n new Text({\n ...textOps.styleProps(state.axis.titleStyle),\n text: state.label,\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\n y: () => arrivalOf(state.arrivals, \"label\").shift,\n }),\n );\n }\n\n column.push(new Rect({ flow: \"vertical\", gap: titlePad, height: \"hug\", width: \"fill\", children }));\n return asParts(column);\n },\n commands: {\n /**\n * Stagger the markers in left to right, then slide the caption in after\n * them. Its first frame arms them all: lifted by `slide` and transparent.\n *\n * The timeline's duration is the **whole** entrance — see\n * `VerticalAxis.enter` and {@link enterBudget}.\n */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args;\n const count = state.markers.length;\n const captioned = state.label !== \"\";\n const from: Arrival = { opacity: 0, shift: slide };\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])];\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }));\n if (count === 0) return arm;\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger);\n const ease = frameEase(timeline);\n // Left marker leads: the row is already left → right.\n const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }));\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : [];\n return timeline.together([arm, beats(timeline, [...markers, ...label])]);\n },\n },\n },\n});\n\nexport type HorizontalAxis = NodeOf<typeof HorizontalAxis>;\n"]}
|
|
1
|
+
{"version":3,"file":"horizontal-axis.js","sourceRoot":"","sources":["../../src/line-chart/horizontal-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,GAIR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAC;AACzG,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM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AAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpI,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,CAAC;SACF;KACF;CACF,CAAC,CAAC","sourcesContent":["import {\n Rect,\n Text,\n Types,\n component2d,\n insetsOps,\n textOps,\n type NodeOf,\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\";\nimport { enterBudget } from \"@motionscript/sdk/component\";\n\nimport { asParts, fresh } from \"../kit/entries\";\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"../kit/motion\";\nimport {\n DEFAULT_X_AXIS,\n type AxisConfig,\n type Range,\n} from \"../kit/shared\";\nimport { markerCaption } from \"../kit/vertical-axis\";\n\nconst SLIDE = 24;\n\n/**\n * The horizontal axis of a {@link LineChart}: a row of {@link Text} markers, the\n * mirror of `VerticalAxis` (bound text and positions, landed resting state).\n * Markers are placed by value across the range, whatever they say: `2026-03`\n * sits three months along, not three slots along, unlike a bar chart's axis.\n */\nexport const HorizontalAxis = component2d({\n key: \"horizontalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n /** Tick values in data units. */\n markers: fresh<number[]>(() => []),\n /** One caption per marker in its order; a missing one reads as the bare numeric value. */\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),\n /** Caption centred beneath the markers; empty hides it. */\n label: \"\",\n arrivals: arrivalsEntry(),\n },\n // A node made of markers would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const tickPad = insetsOps.resolve(state.axis.tickPadding).top;\n const titlePad = insetsOps.resolve(state.axis.titlePadding).top;\n\n const column: Node2D[] = [];\n // The column's parent is the axis, whose box the markers are placed in.\n const box = () => (column[0]?.parent as Node2D | null | undefined)?.layoutBounds ?? { width: 0, height: 0 };\n const sorted = () => [...state.markers].sort((a, b) => a - b);\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0;\n const [min, max] = state.range;\n return max <= min ? 0 : (value - min) / (max - min);\n };\n\n const markers = state.markers.map((_, i) => {\n const marker: Node2D = new Text({\n ...textOps.styleProps(state.axis.labelStyle),\n text: () => {\n const value = sorted()[i];\n return value === undefined ? \"\" : markerCaption(state, value);\n },\n x: () => {\n const width = box().width;\n const centred = (fracAt(sorted()[i]) - 0.5) * width;\n // Held inside the right edge, the chart's own: the last marker is centred on the last grid line, so half of it would fall outside the box. The left edge has the vertical axis's gutter beyond it.\n const limit = width / 2 - marker.layoutBounds.width / 2;\n return Math.min(centred, limit);\n },\n opacity: () => arrivalOf(state.arrivals, i).opacity,\n y: () => arrivalOf(state.arrivals, i).shift,\n });\n return marker;\n });\n\n const children: Node2D[] = [\n new Rect({ width: \"fill\", height: \"hug\", padding: { top: tickPad }, children: markers }),\n ];\n if (state.label !== \"\") {\n children.push(\n new Text({\n ...textOps.styleProps(state.axis.titleStyle),\n text: state.label,\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\n y: () => arrivalOf(state.arrivals, \"label\").shift,\n }),\n );\n }\n\n column.push(new Rect({ flow: \"vertical\", gap: titlePad, height: \"hug\", width: \"fill\", children }));\n return asParts(column);\n },\n commands: {\n /** Stagger markers in left to right, then the caption. The duration is the whole entrance ({@link enterBudget}). */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args;\n const count = state.markers.length;\n const captioned = state.label !== \"\";\n const from: Arrival = { opacity: 0, shift: slide };\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])];\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }));\n if (count === 0) return arm;\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger);\n const ease = frameEase(timeline);\n const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }));\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : [];\n return timeline.together([arm, beats(timeline, [...markers, ...label])]);\n },\n },\n },\n});\n\nexport type HorizontalAxis = NodeOf<typeof HorizontalAxis>;\n"]}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The line chart: a cartesian plot with a traced polyline, spotlit regions and
|
|
3
|
-
* a staggered entrance.
|
|
4
|
-
*
|
|
5
|
-
* {@link LineChart} composes the parts below plus the shared ones in the kit
|
|
6
|
-
* (the plot panel, the value axis, the legend); each part is exported too, so
|
|
7
|
-
* another node type can reuse one on its own.
|
|
8
|
-
*
|
|
9
|
-
* These files are what a copy of the line chart takes (`registry.json`). Everything they reach for
|
|
10
|
-
* that is *not* here comes from the kit and stays a dependency — see
|
|
11
|
-
* `../engine.ts` for why that line is where it is.
|
|
12
|
-
*/
|
|
13
1
|
export { LineChart, lineChartDomains } from "./line-chart.js";
|
|
14
|
-
export type { LineChartDomains,
|
|
2
|
+
export type { LineChartDomains, LineChartValues } from "./line-chart.js";
|
|
15
3
|
export { ChartRegion } from "./chart-region.js";
|
|
16
4
|
export { ChartLine } from "./chart-line.js";
|
|
17
5
|
export { HorizontalAxis } from "./horizontal-axis.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/line-chart/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/line-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC1D,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACrE,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;AACjB,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,GACb,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACtE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/line-chart/index.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The line chart: a cartesian plot with a traced polyline, spotlit regions and
|
|
3
|
-
* a staggered entrance.
|
|
4
|
-
*
|
|
5
|
-
* {@link LineChart} composes the parts below plus the shared ones in the kit
|
|
6
|
-
* (the plot panel, the value axis, the legend); each part is exported too, so
|
|
7
|
-
* another node type can reuse one on its own.
|
|
8
|
-
*
|
|
9
|
-
* These files are what a copy of the line chart takes (`registry.json`). Everything they reach for
|
|
10
|
-
* that is *not* here comes from the kit and stays a dependency — see
|
|
11
|
-
* `../engine.ts` for why that line is where it is.
|
|
12
|
-
*/
|
|
13
1
|
export { LineChart, lineChartDomains } from "./line-chart.js";
|
|
14
2
|
export { ChartRegion } from "./chart-region.js";
|
|
15
3
|
export { ChartLine } from "./chart-line.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/line-chart/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/line-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE1D,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":["export { LineChart, lineChartDomains } from \"./line-chart\"\nexport type { LineChartDomains, LineChartValues } 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,46 +1,10 @@
|
|
|
1
|
-
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
|
|
2
|
-
import { type AxisDomainConfig, type
|
|
1
|
+
import { type DataRecord, type NodeOf, type Node2D, type Node2DProps as _Node2DProps } from "@motionscript/sdk";
|
|
2
|
+
import { type AxisDomainConfig, type ResolvedAxisDomain } from "../kit/shared.js";
|
|
3
3
|
import { type ChartConfig, type ChartTheme, type LineSeries, type PlotRegion } from "./shared.js";
|
|
4
|
-
export interface LineChartProps extends Node2DProps {
|
|
5
|
-
/** One row per sample — a plain record of field name to value. */
|
|
6
|
-
data: DataRecord[];
|
|
7
|
-
/**
|
|
8
|
-
* Key into each row for its x value, shared by every series. Named `xField`
|
|
9
|
-
* rather than `x` because every node already has an `x` — its position.
|
|
10
|
-
*/
|
|
11
|
-
xField: string;
|
|
12
|
-
/** One polyline per entry: which field it plots, its legend `label`, its `fill`. */
|
|
13
|
-
series: LineSeries[];
|
|
14
|
-
/** X-axis data domain: caption, scale range, and tick placement. */
|
|
15
|
-
xAxis?: AxisDomainConfig;
|
|
16
|
-
/** Y-axis data domain: caption, scale range, and tick placement. */
|
|
17
|
-
yAxis?: AxisDomainConfig;
|
|
18
|
-
/**
|
|
19
|
-
* A slice of the plot to spotlight, in **data units**. Dashed rules mark the
|
|
20
|
-
* bounded edges and every series fades outside the box — see
|
|
21
|
-
* `spotlightRegion`, which animates the same thing. `null` (the default) is no
|
|
22
|
-
* region.
|
|
23
|
-
*/
|
|
24
|
-
region?: PlotRegion | null;
|
|
25
|
-
/**
|
|
26
|
-
* The chart's visual theme — series palette, axis text/grid/gutters, plot
|
|
27
|
-
* panel paint, and legend styling. Every branch is optional and deep-merged
|
|
28
|
-
* onto {@link DEFAULT_CHART_THEME}, so pass only what you want to override.
|
|
29
|
-
*/
|
|
30
|
-
theme?: ChartTheme;
|
|
31
|
-
/** Whether the legend row below the plot is drawn at all. */
|
|
32
|
-
showLegend?: boolean;
|
|
33
|
-
}
|
|
34
4
|
/** Both axes' domains with their ranges and ticks resolved. */
|
|
35
5
|
export interface LineChartDomains {
|
|
36
|
-
readonly x:
|
|
37
|
-
|
|
38
|
-
readonly ticks: number[];
|
|
39
|
-
};
|
|
40
|
-
readonly y: AxisDomainConfig & {
|
|
41
|
-
readonly range: Range;
|
|
42
|
-
readonly ticks: number[];
|
|
43
|
-
};
|
|
6
|
+
readonly x: ResolvedAxisDomain;
|
|
7
|
+
readonly y: ResolvedAxisDomain;
|
|
44
8
|
}
|
|
45
9
|
/** What a line chart plots, as its entries hold it. */
|
|
46
10
|
export interface LineChartValues {
|
|
@@ -50,34 +14,17 @@ export interface LineChartValues {
|
|
|
50
14
|
readonly xAxis: AxisDomainConfig;
|
|
51
15
|
readonly yAxis: AxisDomainConfig;
|
|
52
16
|
}
|
|
53
|
-
/** Both axes as
|
|
17
|
+
/** Both axes as drawn now. */
|
|
54
18
|
export declare function lineChartDomains(s: LineChartValues): LineChartDomains;
|
|
55
19
|
/**
|
|
56
|
-
* A multi-series line chart
|
|
57
|
-
* one
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* - {@link VerticalAxis} / {@link HorizontalAxis} — columns/rows of real text
|
|
61
|
-
* markers that stagger in, each carrying its own axis caption.
|
|
62
|
-
* - {@link ChartRegion} — the optional call-out marking a spotlit slice of the
|
|
63
|
-
* plot: dashed rules on its bounded edges, and every series faded outside it.
|
|
64
|
-
* - {@link ChartLine} (one per series) — the traced polylines over the canvas.
|
|
65
|
-
* - {@link ChartLegend} — a row of entries below the chart, one per series.
|
|
66
|
-
*
|
|
67
|
-
* Every part reads the chart's entries through bindings, and the lines, the
|
|
68
|
-
* region and the grid all map against the plot panel's own laid-out box, so
|
|
69
|
-
* points land exactly on their markers and the chart re-flows if its box
|
|
70
|
-
* changes.
|
|
71
|
-
*
|
|
72
|
-
* **Resting state is the finished chart**: an editor paints a node's Initial
|
|
73
|
-
* state on a paused canvas. `enter` arms every part on its first frame.
|
|
20
|
+
* A multi-series line chart composed of {@link ChartCanvas}, {@link VerticalAxis} /
|
|
21
|
+
* {@link HorizontalAxis}, {@link ChartRegion}, one {@link ChartLine} per series and
|
|
22
|
+
* {@link ChartLegend}. Every part reads the chart's entries through bindings and
|
|
23
|
+
* maps against the plot panel's own laid-out box.
|
|
74
24
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* region resolves against the live scales, so it travels with a zoom. A `to` of
|
|
79
|
-
* an axis `range` or `ticks` tweens from the domain as drawn (see
|
|
80
|
-
* {@link lerpAxisEntry}), so an auto axis rescales continuously.
|
|
25
|
+
* Resting state is the finished chart; `enter` arms every part on its first
|
|
26
|
+
* frame. A `to` of an axis `range` or `ticks` tweens from the domain as drawn
|
|
27
|
+
* (see {@link lerpAxisEntry}), so an auto axis rescales continuously.
|
|
81
28
|
*/
|
|
82
29
|
export declare const LineChart: import("@motionscript/sdk").Component<"lineChart", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
83
30
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
@@ -86,24 +33,13 @@ export declare const LineChart: import("@motionscript/sdk").Component<"lineChart
|
|
|
86
33
|
readonly xAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
|
|
87
34
|
readonly yAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
|
|
88
35
|
readonly theme: import("@motionscript/sdk").Type<ChartTheme, ChartConfig, false>;
|
|
89
|
-
/**
|
|
90
|
-
* The spotlit slice of the plot in data units, or `null` for none. The box
|
|
91
|
-
* snaps; the animation is {@link regionReveal} drawing the rules on.
|
|
92
|
-
*/
|
|
36
|
+
/** The spotlit slice in data units, or `null`. The box snaps; {@link regionReveal} animates it. */
|
|
93
37
|
readonly region: import("@motionscript/sdk").Type<PlotRegion | null, PlotRegion | null, false>;
|
|
94
|
-
/**
|
|
95
|
-
* How far the `region` call-out is drawn in, `[0, 1]`: the rules grow out and
|
|
96
|
-
* the wash fades up as it climbs, while every line's out-of-region stretch
|
|
97
|
-
* fades to the theme's `region.dimOpacity`.
|
|
98
|
-
*/
|
|
38
|
+
/** How far the `region` call-out is drawn in, `[0, 1]`: rules grow, wash fades up, out-of-region stretches fade to `region.dimOpacity`. */
|
|
99
39
|
readonly regionReveal: 0;
|
|
100
40
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
101
41
|
readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
102
|
-
/**
|
|
103
|
-
* The domain `zoomTo` first left, so `resetZoom` restores the chart as it
|
|
104
|
-
* stood, auto-derived ticks included. Cleared by `resetZoom`, so the next zoom
|
|
105
|
-
* remembers wherever the chart rests then.
|
|
106
|
-
*/
|
|
42
|
+
/** The domain `zoomTo` first left, so `resetZoom` restores it, auto-derived ticks included. */
|
|
107
43
|
readonly home: import("@motionscript/sdk").Type<LineChartDomains | null, LineChartDomains | null, false>;
|
|
108
44
|
}>, {
|
|
109
45
|
readonly enter: {};
|
|
@@ -124,31 +60,20 @@ export declare const LineChart: import("@motionscript/sdk").Component<"lineChart
|
|
|
124
60
|
readonly spotlightSeries: {
|
|
125
61
|
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
126
62
|
};
|
|
127
|
-
}, readonly [], Node2D<
|
|
63
|
+
}, readonly [], Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
128
64
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
129
65
|
readonly xField: "";
|
|
130
66
|
readonly series: import("@motionscript/sdk").Type<import("../index.js").ChartSeries[], import("../index.js").ChartSeries[], false>;
|
|
131
67
|
readonly xAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
|
|
132
68
|
readonly yAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
|
|
133
69
|
readonly theme: import("@motionscript/sdk").Type<ChartTheme, ChartConfig, false>;
|
|
134
|
-
/**
|
|
135
|
-
* The spotlit slice of the plot in data units, or `null` for none. The box
|
|
136
|
-
* snaps; the animation is {@link regionReveal} drawing the rules on.
|
|
137
|
-
*/
|
|
70
|
+
/** The spotlit slice in data units, or `null`. The box snaps; {@link regionReveal} animates it. */
|
|
138
71
|
readonly region: import("@motionscript/sdk").Type<PlotRegion | null, PlotRegion | null, false>;
|
|
139
|
-
/**
|
|
140
|
-
* How far the `region` call-out is drawn in, `[0, 1]`: the rules grow out and
|
|
141
|
-
* the wash fades up as it climbs, while every line's out-of-region stretch
|
|
142
|
-
* fades to the theme's `region.dimOpacity`.
|
|
143
|
-
*/
|
|
72
|
+
/** How far the `region` call-out is drawn in, `[0, 1]`: rules grow, wash fades up, out-of-region stretches fade to `region.dimOpacity`. */
|
|
144
73
|
readonly regionReveal: 0;
|
|
145
74
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
146
75
|
readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
147
|
-
/**
|
|
148
|
-
* The domain `zoomTo` first left, so `resetZoom` restores the chart as it
|
|
149
|
-
* stood, auto-derived ticks included. Cleared by `resetZoom`, so the next zoom
|
|
150
|
-
* remembers wherever the chart rests then.
|
|
151
|
-
*/
|
|
76
|
+
/** The domain `zoomTo` first left, so `resetZoom` restores it, auto-derived ticks included. */
|
|
152
77
|
readonly home: import("@motionscript/sdk").Type<LineChartDomains | null, LineChartDomains | null, false>;
|
|
153
78
|
}>, readonly [], import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
154
79
|
readonly data: import("@motionscript/sdk").Type<DataRecord[], DataRecord[], false>;
|
|
@@ -157,24 +82,13 @@ export declare const LineChart: import("@motionscript/sdk").Component<"lineChart
|
|
|
157
82
|
readonly xAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
|
|
158
83
|
readonly yAxis: import("@motionscript/sdk").Type<AxisDomainConfig, AxisDomainConfig, false>;
|
|
159
84
|
readonly theme: import("@motionscript/sdk").Type<ChartTheme, ChartConfig, false>;
|
|
160
|
-
/**
|
|
161
|
-
* The spotlit slice of the plot in data units, or `null` for none. The box
|
|
162
|
-
* snaps; the animation is {@link regionReveal} drawing the rules on.
|
|
163
|
-
*/
|
|
85
|
+
/** The spotlit slice in data units, or `null`. The box snaps; {@link regionReveal} animates it. */
|
|
164
86
|
readonly region: import("@motionscript/sdk").Type<PlotRegion | null, PlotRegion | null, false>;
|
|
165
|
-
/**
|
|
166
|
-
* How far the `region` call-out is drawn in, `[0, 1]`: the rules grow out and
|
|
167
|
-
* the wash fades up as it climbs, while every line's out-of-region stretch
|
|
168
|
-
* fades to the theme's `region.dimOpacity`.
|
|
169
|
-
*/
|
|
87
|
+
/** How far the `region` call-out is drawn in, `[0, 1]`: rules grow, wash fades up, out-of-region stretches fade to `region.dimOpacity`. */
|
|
170
88
|
readonly regionReveal: 0;
|
|
171
89
|
/** Read as the chart is built: the legend is a part the chart builds or doesn't. */
|
|
172
90
|
readonly showLegend: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
173
|
-
/**
|
|
174
|
-
* The domain `zoomTo` first left, so `resetZoom` restores the chart as it
|
|
175
|
-
* stood, auto-derived ticks included. Cleared by `resetZoom`, so the next zoom
|
|
176
|
-
* remembers wherever the chart rests then.
|
|
177
|
-
*/
|
|
91
|
+
/** The domain `zoomTo` first left, so `resetZoom` restores it, auto-derived ticks included. */
|
|
178
92
|
readonly home: import("@motionscript/sdk").Type<LineChartDomains | null, LineChartDomains | null, false>;
|
|
179
93
|
}>, {
|
|
180
94
|
readonly enter: {};
|
|
@@ -195,6 +109,6 @@ export declare const LineChart: import("@motionscript/sdk").Component<"lineChart
|
|
|
195
109
|
readonly spotlightSeries: {
|
|
196
110
|
readonly seriesIndex: import("@motionscript/sdk").Type<number, number, false>;
|
|
197
111
|
};
|
|
198
|
-
}, Node2D<
|
|
112
|
+
}, Node2D<_Node2DProps>>>>;
|
|
199
113
|
export type LineChart = NodeOf<typeof LineChart>;
|
|
200
114
|
//# 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,EAML,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../src/line-chart/line-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,IAAI,YAAY,EAGjC,MAAM,mBAAmB,CAAA;AAU1B,OAAO,EAWL,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACxB,MAAM,eAAe,CAAA;AAItB,OAAO,EAOL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EAEhB,MAAM,UAAU,CAAA;AAGjB,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,CAAC,EAAE,kBAAkB,CAAA;IAC9B,QAAQ,CAAC,CAAC,EAAE,kBAAkB,CAAA;CAC/B;AAED,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,CAAA;IAC7B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAChC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;CACjC;AA4CD,8BAA8B;AAC9B,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,GAAG,gBAAgB,CAYrE;AAoFD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS;;;;;;;IAUlB,mGAAmG;;IAEnG,2IAA2I;;IAE3I,oFAAoF;;IAEpF,+FAA+F;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAN/F,mGAAmG;;I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