@motionscript/charts 0.1.1-alpha.0 → 0.1.1-alpha.2
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 +34 -0
- package/README.md +109 -28
- package/dist/bar-chart/bar-chart.d.ts +265 -39
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +219 -171
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +12 -7
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +56 -42
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +76 -52
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +105 -89
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +4 -4
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +2 -2
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +41 -65
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +73 -117
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-7XCRX6GE.js +2 -0
- package/dist/browser/chunks/chunk-7XCRX6GE.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +5 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +5 -2
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.d.ts +51 -15
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +81 -29
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +32 -24
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +52 -46
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +8 -4
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +30 -20
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/{line-chart → kit}/horizontal-axis.d.ts +31 -6
- package/dist/kit/horizontal-axis.d.ts.map +1 -0
- package/dist/{line-chart → kit}/horizontal-axis.js +23 -24
- package/dist/kit/horizontal-axis.js.map +1 -0
- package/dist/kit/motion.d.ts +5 -0
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +8 -0
- package/dist/kit/motion.js.map +1 -1
- package/dist/{pie-chart → kit}/pie-legend.d.ts +3 -3
- package/dist/kit/pie-legend.d.ts.map +1 -0
- package/dist/{pie-chart → kit}/pie-legend.js +11 -10
- package/dist/kit/pie-legend.js.map +1 -0
- package/dist/kit/polar.d.ts +31 -0
- package/dist/kit/polar.d.ts.map +1 -0
- package/dist/kit/polar.js +33 -0
- package/dist/kit/polar.js.map +1 -0
- package/dist/kit/shared.d.ts +11 -50
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +58 -141
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/style.d.ts +517 -0
- package/dist/kit/style.d.ts.map +1 -0
- package/dist/kit/style.js +292 -0
- package/dist/kit/style.js.map +1 -0
- package/dist/kit/vertical-axis.d.ts +22 -2
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +56 -43
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +95 -3
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +165 -53
- 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 +7 -8
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/index.d.ts +5 -6
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +3 -4
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +281 -18
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +284 -134
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +51 -34
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +175 -83
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +2 -0
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +15 -0
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +3 -1
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +9 -1
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +2 -3
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -2
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +114 -18
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +38 -24
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +16 -5
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +89 -55
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +61 -62
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +44 -123
- package/dist/pie-chart/shared.js.map +1 -1
- package/dist/radar-chart/index.d.ts +5 -0
- package/dist/radar-chart/index.d.ts.map +1 -0
- package/dist/radar-chart/index.js +5 -0
- package/dist/radar-chart/index.js.map +1 -0
- package/dist/radar-chart/radar-chart.d.ts +212 -0
- package/dist/radar-chart/radar-chart.d.ts.map +1 -0
- package/dist/radar-chart/radar-chart.js +224 -0
- package/dist/radar-chart/radar-chart.js.map +1 -0
- package/dist/radar-chart/radar-grid.d.ts +49 -0
- package/dist/radar-chart/radar-grid.d.ts.map +1 -0
- package/dist/radar-chart/radar-grid.js +63 -0
- package/dist/radar-chart/radar-grid.js.map +1 -0
- package/dist/radar-chart/radar-series.d.ts +59 -0
- package/dist/radar-chart/radar-series.d.ts.map +1 -0
- package/dist/radar-chart/radar-series.js +71 -0
- package/dist/radar-chart/radar-series.js.map +1 -0
- package/dist/radar-chart/shared.d.ts +78 -0
- package/dist/radar-chart/shared.d.ts.map +1 -0
- package/dist/radar-chart/shared.js +129 -0
- package/dist/radar-chart/shared.js.map +1 -0
- package/dist/radial-chart/index.d.ts +6 -0
- package/dist/radial-chart/index.d.ts.map +1 -0
- package/dist/radial-chart/index.js +4 -0
- package/dist/radial-chart/index.js.map +1 -0
- package/dist/radial-chart/radial-chart.d.ts +210 -0
- package/dist/radial-chart/radial-chart.d.ts.map +1 -0
- package/dist/radial-chart/radial-chart.js +175 -0
- package/dist/radial-chart/radial-chart.js.map +1 -0
- package/dist/radial-chart/radial-rings.d.ts +121 -0
- package/dist/radial-chart/radial-rings.d.ts.map +1 -0
- package/dist/radial-chart/radial-rings.js +273 -0
- package/dist/radial-chart/radial-rings.js.map +1 -0
- package/dist/radial-chart/shared.d.ts +77 -0
- package/dist/radial-chart/shared.d.ts.map +1 -0
- package/dist/radial-chart/shared.js +78 -0
- package/dist/radial-chart/shared.js.map +1 -0
- package/package.json +4 -4
- package/registry.json +21 -6
- package/src/bar-chart/bar-chart.ts +263 -179
- package/src/bar-chart/category-axis.ts +46 -40
- package/src/bar-chart/chart-bars.ts +136 -117
- package/src/bar-chart/index.ts +7 -10
- package/src/bar-chart/shared.ts +88 -233
- package/src/engine.ts +5 -2
- package/src/index.ts +2 -0
- package/src/kit/cartesian.ts +121 -40
- package/src/kit/chart-canvas.ts +49 -54
- package/src/kit/chart-legend.ts +28 -20
- package/src/kit/horizontal-axis.ts +114 -0
- package/src/kit/motion.ts +7 -0
- package/src/{pie-chart → kit}/pie-legend.ts +12 -11
- package/src/kit/polar.ts +54 -0
- package/src/kit/shared.ts +55 -277
- package/src/kit/style.ts +353 -0
- package/src/kit/vertical-axis.ts +67 -48
- package/src/line-chart/chart-line.ts +176 -54
- package/src/line-chart/chart-region.ts +6 -10
- package/src/line-chart/index.ts +14 -10
- package/src/line-chart/line-chart.ts +353 -151
- package/src/line-chart/shared.ts +193 -174
- package/src/line-chart/x-scale.ts +13 -0
- package/src/nodes.ts +9 -1
- package/src/pie-chart/index.ts +2 -23
- package/src/pie-chart/pie-chart.ts +54 -35
- package/src/pie-chart/pie-ring.ts +92 -71
- package/src/pie-chart/shared.ts +80 -270
- package/src/radar-chart/index.ts +4 -0
- package/src/radar-chart/radar-chart.ts +290 -0
- package/src/radar-chart/radar-grid.ts +83 -0
- package/src/radar-chart/radar-series.ts +88 -0
- package/src/radar-chart/shared.ts +153 -0
- package/src/radial-chart/index.ts +5 -0
- package/src/radial-chart/radial-chart.ts +212 -0
- package/src/radial-chart/radial-rings.ts +328 -0
- package/src/radial-chart/shared.ts +126 -0
- package/dist/browser/chunks/chunk-4SMRCU24.js +0 -2
- package/dist/browser/chunks/chunk-4SMRCU24.js.map +0 -7
- package/dist/kit/chart-border.d.ts +0 -18
- package/dist/kit/chart-border.d.ts.map +0 -1
- package/dist/kit/chart-border.js +0 -23
- package/dist/kit/chart-border.js.map +0 -1
- package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
- package/dist/line-chart/horizontal-axis.js.map +0 -1
- package/dist/pie-chart/pie-legend.d.ts.map +0 -1
- package/dist/pie-chart/pie-legend.js.map +0 -1
- package/src/kit/chart-border.ts +0 -36
- package/src/line-chart/horizontal-axis.ts +0 -122
|
@@ -1,98 +1,122 @@
|
|
|
1
|
-
import { type Fill, type FillResolved, type NodeOf, type Node2D
|
|
1
|
+
import { type Fill, type FillResolved, type NodeOf, type Node2D, type Node2DProps as _Node2DProps, type RectCornerRadius as _RectCornerRadius, type RectCornerStyle as _RectCornerStyle, type TextStyle, type CornerRadiusResolved, type CornerStyleResolved } from "@motionscript/sdk";
|
|
2
2
|
/**
|
|
3
|
-
* One drawn
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* One drawn bar in the plot's centred pixel space (origin at the centre, y-up),
|
|
4
|
+
* mapped by the parent {@link BarChart}: `center` and `thickness` across the
|
|
5
|
+
* category slot, `from` and `to` along the value axis (y for a column, x for a
|
|
6
|
+
* horizontal bar). Two ends rather than a base and a length, like `BarSpan`:
|
|
7
|
+
* one shape fits grouped, stacked and negative.
|
|
7
8
|
*/
|
|
8
9
|
export interface BarGeometry {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** Pixel y of the base: the baseline when grouped, the running stack top when stacked. */
|
|
10
|
+
center: number;
|
|
11
|
+
thickness: number;
|
|
12
|
+
/** The base: the baseline when grouped, the running stack end when stacked. */
|
|
13
13
|
from: number;
|
|
14
|
-
/**
|
|
14
|
+
/** The far end at full growth. */
|
|
15
15
|
to: number;
|
|
16
|
-
/** Whether the far end takes the
|
|
16
|
+
/** Whether the far end takes the far corners (the stack's last segment on its side). */
|
|
17
17
|
round: boolean;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/** The
|
|
21
|
-
caption
|
|
18
|
+
/** Whether the base takes the base corners (it stands on the baseline: every grouped bar, a stack's first segment). */
|
|
19
|
+
grounded?: boolean;
|
|
20
|
+
/** The figure printed by the bar; empty for none. */
|
|
21
|
+
caption: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* One series of a {@link BarChart}: its
|
|
25
|
-
*
|
|
24
|
+
* One series of a {@link BarChart}: its bar in every category plus the printed
|
|
25
|
+
* figures. A node per series, like `ChartLine`, so `showSeries` and
|
|
26
26
|
* `spotlightSeries` mean the same on both: enable the node or tween its opacity.
|
|
27
27
|
* Positions come from the parent, which owns the slot arithmetic.
|
|
28
|
-
*
|
|
29
|
-
* The figures are {@link Text} children, so they take the theme's type style,
|
|
30
|
-
* are measured by layout, and hide with the series.
|
|
31
28
|
*/
|
|
32
29
|
export declare const ChartBars: import("@motionscript/sdk").Component<"chartBars", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
33
30
|
readonly bars: import("@motionscript/sdk").Type<BarGeometry[], BarGeometry[], false>;
|
|
34
|
-
/** Pixel
|
|
31
|
+
/** Pixel position of value 0 along the value axis, where every bar grows from. */
|
|
35
32
|
readonly baseline: 0;
|
|
33
|
+
/** Bars grow along x from a category column rather than along y from a row. */
|
|
34
|
+
readonly horizontal: false;
|
|
36
35
|
readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
|
|
37
|
-
|
|
38
|
-
readonly
|
|
39
|
-
readonly
|
|
36
|
+
/** As for a bar standing up from the baseline: `topLeft`/`topRight` round its far end, the bottom pair its base. */
|
|
37
|
+
readonly cornerRadius: import("@motionscript/sdk").Type<_RectCornerRadius, CornerRadiusResolved, false>;
|
|
38
|
+
readonly cornerStyle: import("@motionscript/sdk").Type<_RectCornerStyle, CornerStyleResolved, false>;
|
|
40
39
|
/**
|
|
41
|
-
* Rise of every
|
|
42
|
-
*
|
|
43
|
-
* mid-animation and a negative
|
|
40
|
+
* Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
|
|
41
|
+
* every segment travels by the same factor, so a stack stays flush
|
|
42
|
+
* mid-animation and a negative bar grows the other way.
|
|
44
43
|
*/
|
|
45
44
|
readonly growth: 1;
|
|
46
|
-
/** Per-
|
|
45
|
+
/** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
|
|
47
46
|
readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
48
|
-
|
|
47
|
+
/** Read as built: whether each bar prints its figure, and where. */
|
|
48
|
+
readonly values: import("@motionscript/sdk").Type<"end" | "inside" | "none", "end" | "inside" | "none", false>;
|
|
49
49
|
readonly valueStyle: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
50
|
-
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the
|
|
50
|
+
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
|
|
51
51
|
readonly enabled: true;
|
|
52
52
|
}>, {
|
|
53
53
|
readonly enter: unknown;
|
|
54
|
-
}, null,
|
|
54
|
+
}, null, Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
55
55
|
readonly bars: import("@motionscript/sdk").Type<BarGeometry[], BarGeometry[], false>;
|
|
56
|
-
/** Pixel
|
|
56
|
+
/** Pixel position of value 0 along the value axis, where every bar grows from. */
|
|
57
57
|
readonly baseline: 0;
|
|
58
|
+
/** Bars grow along x from a category column rather than along y from a row. */
|
|
59
|
+
readonly horizontal: false;
|
|
58
60
|
readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
|
|
59
|
-
|
|
60
|
-
readonly
|
|
61
|
-
readonly
|
|
61
|
+
/** As for a bar standing up from the baseline: `topLeft`/`topRight` round its far end, the bottom pair its base. */
|
|
62
|
+
readonly cornerRadius: import("@motionscript/sdk").Type<_RectCornerRadius, CornerRadiusResolved, false>;
|
|
63
|
+
readonly cornerStyle: import("@motionscript/sdk").Type<_RectCornerStyle, CornerStyleResolved, false>;
|
|
62
64
|
/**
|
|
63
|
-
* Rise of every
|
|
64
|
-
*
|
|
65
|
-
* mid-animation and a negative
|
|
65
|
+
* Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
|
|
66
|
+
* every segment travels by the same factor, so a stack stays flush
|
|
67
|
+
* mid-animation and a negative bar grows the other way.
|
|
66
68
|
*/
|
|
67
69
|
readonly growth: 1;
|
|
68
|
-
/** Per-
|
|
70
|
+
/** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
|
|
69
71
|
readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
70
|
-
|
|
72
|
+
/** Read as built: whether each bar prints its figure, and where. */
|
|
73
|
+
readonly values: import("@motionscript/sdk").Type<"end" | "inside" | "none", "end" | "inside" | "none", false>;
|
|
71
74
|
readonly valueStyle: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
72
|
-
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the
|
|
75
|
+
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
|
|
73
76
|
readonly enabled: true;
|
|
74
77
|
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
75
78
|
readonly bars: import("@motionscript/sdk").Type<BarGeometry[], BarGeometry[], false>;
|
|
76
|
-
/** Pixel
|
|
79
|
+
/** Pixel position of value 0 along the value axis, where every bar grows from. */
|
|
77
80
|
readonly baseline: 0;
|
|
81
|
+
/** Bars grow along x from a category column rather than along y from a row. */
|
|
82
|
+
readonly horizontal: false;
|
|
78
83
|
readonly fill: import("@motionscript/sdk").Type<Fill, FillResolved[], false>;
|
|
79
|
-
|
|
80
|
-
readonly
|
|
81
|
-
readonly
|
|
84
|
+
/** As for a bar standing up from the baseline: `topLeft`/`topRight` round its far end, the bottom pair its base. */
|
|
85
|
+
readonly cornerRadius: import("@motionscript/sdk").Type<_RectCornerRadius, CornerRadiusResolved, false>;
|
|
86
|
+
readonly cornerStyle: import("@motionscript/sdk").Type<_RectCornerStyle, CornerStyleResolved, false>;
|
|
82
87
|
/**
|
|
83
|
-
* Rise of every
|
|
84
|
-
*
|
|
85
|
-
* mid-animation and a negative
|
|
88
|
+
* Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
|
|
89
|
+
* every segment travels by the same factor, so a stack stays flush
|
|
90
|
+
* mid-animation and a negative bar grows the other way.
|
|
86
91
|
*/
|
|
87
92
|
readonly growth: 1;
|
|
88
|
-
/** Per-
|
|
93
|
+
/** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
|
|
89
94
|
readonly dims: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
90
|
-
|
|
95
|
+
/** Read as built: whether each bar prints its figure, and where. */
|
|
96
|
+
readonly values: import("@motionscript/sdk").Type<"end" | "inside" | "none", "end" | "inside" | "none", false>;
|
|
91
97
|
readonly valueStyle: import("@motionscript/sdk").Type<TextStyle, TextStyle, false>;
|
|
92
|
-
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the
|
|
98
|
+
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
|
|
93
99
|
readonly enabled: true;
|
|
94
100
|
}>, {
|
|
95
101
|
readonly enter: unknown;
|
|
96
|
-
},
|
|
102
|
+
}, Node2D<_Node2DProps>>>>;
|
|
97
103
|
export type ChartBars = NodeOf<typeof ChartBars>;
|
|
104
|
+
type Corners<T> = {
|
|
105
|
+
topLeft: T;
|
|
106
|
+
topRight: T;
|
|
107
|
+
bottomRight: T;
|
|
108
|
+
bottomLeft: T;
|
|
109
|
+
};
|
|
110
|
+
/** Bar `bar`'s rect corners: the far pair only where its stack ends, the base pair only on the baseline, each held inside the bar. */
|
|
111
|
+
export declare function barCorners(state: {
|
|
112
|
+
readonly cornerRadius: CornerRadiusResolved;
|
|
113
|
+
readonly cornerStyle: CornerStyleResolved;
|
|
114
|
+
readonly horizontal: boolean;
|
|
115
|
+
}, bar: BarGeometry, forward: boolean, length: number): {
|
|
116
|
+
cornerRadius: Corners<number>;
|
|
117
|
+
cornerStyle: CornerStyleResolved;
|
|
118
|
+
};
|
|
119
|
+
/** A figure as the bar prints it when the chart gives no caption. */
|
|
120
|
+
export declare function barCaption(value: number): string;
|
|
121
|
+
export {};
|
|
98
122
|
//# sourceMappingURL=chart-bars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-bars.d.ts","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chart-bars.d.ts","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,gBAAgB,IAAI,iBAAiB,EAC1C,KAAK,eAAe,IAAI,gBAAgB,EACxC,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAA;AAS1B;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAA;IACZ,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,wFAAwF;IACxF,KAAK,EAAE,OAAO,CAAA;IACd,uHAAuH;IACvH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAA;CAChB;AAoDD;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;IAIlB,kFAAkF;;IAElF,+EAA+E;;;IAG/E,oHAAoH;;;IAGpH;;;;OAIG;;IAEH,oGAAoG;;IAEpG,oEAAoE;;;IAGpE,mGAAmG;;;;;;IAnBnG,kFAAkF;;IAElF,+EAA+E;;;IAG/E,oHAAoH;;;IAGpH;;;;OAIG;;IAEH,oGAAoG;;IAEpG,oEAAoE;;;IAGpE,mGAAmG;;;;IAnBnG,kFAAkF;;IAElF,+EAA+E;;;IAG/E,oHAAoH;;;IAGpH;;;;OAIG;;IAEH,oGAAoG;;IAEpG,oEAAoE;;;IAGpE,mGAAmG;;;;0BA0DrG,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAA;AAEhD,KAAK,OAAO,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC;IAAC,WAAW,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,CAAC,CAAA;CAAE,CAAA;AAc5E,sIAAsI;AACtI,wBAAgB,UAAU,CACxB,KAAK,EAAE;IAAE,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAAE,EAC/H,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACb;IAAE,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,CAarE;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import { Graphics2D, Text, Types, clamp, component2d, fillOps,
|
|
2
|
-
import {
|
|
1
|
+
import { Graphics2D, Text, Types, clamp, component2d, fillOps, } from "@motionscript/sdk";
|
|
2
|
+
import { boundText } from "../kit/cartesian.js";
|
|
3
|
+
import { asParts, fresh } from "../kit/entries.js";
|
|
3
4
|
import { frameEase } from "../kit/motion.js";
|
|
4
5
|
import { loadPaints } from "../kit/paints.js";
|
|
5
6
|
import { formatMarker } from "../kit/shared.js";
|
|
6
|
-
import {
|
|
7
|
-
/**
|
|
8
|
-
const
|
|
9
|
-
/**
|
|
10
|
-
const VALUE_FIT = 1.6;
|
|
11
|
-
/** Fallback type size when the theme's value style leaves it unset or autofit. */
|
|
12
|
-
const VALUE_SIZE = 24;
|
|
13
|
-
/**
|
|
14
|
-
* Column `i`'s dimming: the category spotlight, then the series switch. Captions
|
|
15
|
-
* read this because they are child nodes, which a `render` guard would leave on
|
|
16
|
-
* screen over a series that is not there.
|
|
17
|
-
*/
|
|
7
|
+
import { inkOn } from "./shared.js";
|
|
8
|
+
/** A figure inside a bar needs this much room around it, in multiples of the type size. */
|
|
9
|
+
const INSIDE_ROOM = 0.6;
|
|
10
|
+
/** Bar `i`'s dimming: the category spotlight, then the series switch. */
|
|
18
11
|
function dimAt(s, index) {
|
|
19
12
|
if (!s.enabled)
|
|
20
13
|
return 0;
|
|
21
14
|
return clamp(s.dims[index] ?? 1, 0, 1);
|
|
22
15
|
}
|
|
16
|
+
/** Bar `i`'s two ends as grown so far, along the value axis. */
|
|
23
17
|
function endsAt(s, index) {
|
|
24
18
|
const bar = s.bars[index];
|
|
25
19
|
if (!bar)
|
|
@@ -27,90 +21,89 @@ function endsAt(s, index) {
|
|
|
27
21
|
const g = clamp(s.growth, 0, 1);
|
|
28
22
|
return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g };
|
|
29
23
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
return typeof size === "number" ? size : VALUE_SIZE;
|
|
33
|
-
}
|
|
34
|
-
function insideAt(s, index) {
|
|
35
|
-
const bar = s.bars[index];
|
|
36
|
-
return bar !== undefined && Math.abs(bar.from - s.baseline) > 0.5;
|
|
24
|
+
function sizeOf(style) {
|
|
25
|
+
return typeof style.fontSize === "number" ? style.fontSize : 24;
|
|
37
26
|
}
|
|
38
|
-
/**
|
|
39
|
-
function
|
|
40
|
-
const bar = s.bars[index];
|
|
41
|
-
if (!bar || bar.value === 0)
|
|
42
|
-
return "";
|
|
43
|
-
// An interior segment prints inside itself and must hold a line of type; a grouped column prints past its end.
|
|
44
|
-
if (insideAt(s, index)) {
|
|
45
|
-
const ends = endsAt(s, index);
|
|
46
|
-
if (!ends)
|
|
47
|
-
return "";
|
|
48
|
-
if (Math.abs(ends.end - ends.base) < valueSize(s) * VALUE_FIT)
|
|
49
|
-
return "";
|
|
50
|
-
}
|
|
51
|
-
return bar.caption ?? formatMarker(bar.value);
|
|
52
|
-
}
|
|
53
|
-
function captionY(s, index) {
|
|
27
|
+
/** Where bar `i`'s figure sits along the value axis: past its end, or in its middle. */
|
|
28
|
+
function captionAlong(s, index, extent) {
|
|
54
29
|
const ends = endsAt(s, index);
|
|
55
30
|
if (!ends)
|
|
56
31
|
return 0;
|
|
57
|
-
if (
|
|
32
|
+
if (s.values === "inside")
|
|
58
33
|
return (ends.base + ends.end) / 2;
|
|
59
|
-
// Text is centred on `y`: clear the end by the gap plus half a line, on the side the column reached.
|
|
60
34
|
const direction = ends.end >= ends.base ? 1 : -1;
|
|
61
|
-
return ends.end + direction * (
|
|
35
|
+
return ends.end + direction * (sizeOf(s.valueStyle) * 0.4 + extent / 2);
|
|
36
|
+
}
|
|
37
|
+
/** Whether bar `i` has room for a figure `extent` long inside it. */
|
|
38
|
+
function fitsInside(s, index, extent, across) {
|
|
39
|
+
const bar = s.bars[index];
|
|
40
|
+
const ends = endsAt(s, index);
|
|
41
|
+
if (!bar || !ends)
|
|
42
|
+
return false;
|
|
43
|
+
const room = sizeOf(s.valueStyle) * INSIDE_ROOM;
|
|
44
|
+
return Math.abs(ends.end - ends.base) >= extent + room && bar.thickness >= across;
|
|
62
45
|
}
|
|
63
46
|
/**
|
|
64
|
-
* One series of a {@link BarChart}: its
|
|
65
|
-
*
|
|
47
|
+
* One series of a {@link BarChart}: its bar in every category plus the printed
|
|
48
|
+
* figures. A node per series, like `ChartLine`, so `showSeries` and
|
|
66
49
|
* `spotlightSeries` mean the same on both: enable the node or tween its opacity.
|
|
67
50
|
* Positions come from the parent, which owns the slot arithmetic.
|
|
68
|
-
*
|
|
69
|
-
* The figures are {@link Text} children, so they take the theme's type style,
|
|
70
|
-
* are measured by layout, and hide with the series.
|
|
71
51
|
*/
|
|
72
52
|
export const ChartBars = component2d({
|
|
73
53
|
key: "chartBars",
|
|
74
54
|
state: {
|
|
75
55
|
bars: fresh(() => []),
|
|
76
|
-
/** Pixel
|
|
56
|
+
/** Pixel position of value 0 along the value axis, where every bar grows from. */
|
|
77
57
|
baseline: 0,
|
|
58
|
+
/** Bars grow along x from a category column rather than along y from a row. */
|
|
59
|
+
horizontal: false,
|
|
78
60
|
fill: Types.custom([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
/** As for a bar standing up from the baseline: `topLeft`/`topRight` round its far end, the bottom pair its base. */
|
|
62
|
+
cornerRadius: Types.cornerRadius(8),
|
|
63
|
+
cornerStyle: Types.cornerStyle("rounded"),
|
|
82
64
|
/**
|
|
83
|
-
* Rise of every
|
|
84
|
-
*
|
|
85
|
-
* mid-animation and a negative
|
|
65
|
+
* Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:
|
|
66
|
+
* every segment travels by the same factor, so a stack stays flush
|
|
67
|
+
* mid-animation and a negative bar grows the other way.
|
|
86
68
|
*/
|
|
87
69
|
growth: 1,
|
|
88
|
-
/** Per-
|
|
70
|
+
/** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */
|
|
89
71
|
dims: fresh(() => []),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
/** Read as built: whether each bar prints its figure, and where. */
|
|
73
|
+
values: Types.custom("none"),
|
|
74
|
+
valueStyle: Types.custom({ fontSize: 24, fill: "white" }),
|
|
75
|
+
/** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */
|
|
93
76
|
enabled: true,
|
|
94
77
|
},
|
|
95
78
|
// A node made of its figures would otherwise hug them.
|
|
96
79
|
defaults: { width: "fill", height: "fill" },
|
|
97
|
-
// One
|
|
98
|
-
// and bound to the live geometry so it travels with its
|
|
80
|
+
// One figure per bar, built once (the row count is fixed at construction)
|
|
81
|
+
// and bound to the live geometry so it travels with its bar.
|
|
99
82
|
children: (state) => {
|
|
100
|
-
if (
|
|
83
|
+
if (state.values === "none")
|
|
101
84
|
return [];
|
|
102
|
-
return state.bars.map((_, i) =>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
85
|
+
return asParts(state.bars.map((_, i) => {
|
|
86
|
+
const caption = new Text({
|
|
87
|
+
...boundText(() => ({ ...state.valueStyle, ...(state.values === "inside" && { fill: inkOn(state.fill) }) })),
|
|
88
|
+
text: () => state.bars[i]?.caption ?? "",
|
|
89
|
+
x: () => (state.horizontal ? captionAlong(state, i, caption.layoutBounds.width) : (state.bars[i]?.center ?? 0)),
|
|
90
|
+
y: () => (state.horizontal ? (state.bars[i]?.center ?? 0) : captionAlong(state, i, caption.layoutBounds.height)),
|
|
91
|
+
opacity: () => {
|
|
92
|
+
const box = caption.layoutBounds;
|
|
93
|
+
const along = state.horizontal ? box.width : box.height;
|
|
94
|
+
const across = state.horizontal ? box.height : box.width;
|
|
95
|
+
if (state.values === "inside" && !fitsInside(state, i, along, across))
|
|
96
|
+
return 0;
|
|
97
|
+
// A figure past the end rises in with its bar's last stretch.
|
|
98
|
+
return dimAt(state, i) * clamp((state.growth - 0.6) / 0.4, 0, 1);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
return caption;
|
|
108
102
|
}));
|
|
109
103
|
},
|
|
110
|
-
|
|
111
|
-
load: (loader, state) => loadPaints(loader, { fills: [state.fill], shadows: [state.barShadow], strokes: [state.barStroke] }),
|
|
104
|
+
load: (loader, state) => loadPaints(loader, { fills: [state.fill] }),
|
|
112
105
|
commands: {
|
|
113
|
-
/** Raise every
|
|
106
|
+
/** Raise every bar from the baseline (`growth` 0 to 1). The resting state is the finished one; the chart arms it back to 0. */
|
|
114
107
|
enter: (timeline) => {
|
|
115
108
|
const ease = frameEase(timeline);
|
|
116
109
|
return timeline.animate((t) => ({ growth: ease(t) }));
|
|
@@ -121,33 +114,56 @@ export const ChartBars = component2d({
|
|
|
121
114
|
for (let i = 0; i < state.bars.length; i++) {
|
|
122
115
|
const bar = state.bars[i];
|
|
123
116
|
const ends = endsAt(state, i);
|
|
124
|
-
if (!ends || bar.
|
|
117
|
+
if (!ends || bar.thickness <= 0)
|
|
125
118
|
continue;
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
// A segment inside a stack reaches a pixel under the next, so no seam of background shows between them.
|
|
120
|
+
const seam = bar.round ? 0 : 1;
|
|
121
|
+
const length = Math.abs(ends.end - ends.base) + seam;
|
|
122
|
+
if (length <= seam)
|
|
128
123
|
continue;
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
y:
|
|
135
|
-
width: bar.
|
|
136
|
-
|
|
137
|
-
// Corner keys are visual (y-up): a column reaching up rounds `top*`, one reaching down `bottom*`. Only the far end rounds.
|
|
138
|
-
cornerRadius: radius > 0
|
|
139
|
-
? ends.end >= ends.base
|
|
140
|
-
? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 }
|
|
141
|
-
: { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 }
|
|
142
|
-
: 0,
|
|
143
|
-
});
|
|
144
|
-
rect.shadow(state.barShadow);
|
|
145
|
-
rect.fill(state.fill);
|
|
146
|
-
rect.stroke(state.barStroke);
|
|
124
|
+
const forward = ends.end >= ends.base;
|
|
125
|
+
const mid = (ends.base + ends.end) / 2 + (forward ? seam : -seam) / 2;
|
|
126
|
+
const corners = barCorners(state, bar, forward, length);
|
|
127
|
+
// One `Graphics2D` per bar: opacity belongs to the command list, and the spotlight dims single bars.
|
|
128
|
+
const g = new Graphics2D().rect(state.horizontal
|
|
129
|
+
? { x: mid, y: bar.center, width: length, height: bar.thickness, ...corners }
|
|
130
|
+
: { x: bar.center, y: mid, width: bar.thickness, height: length, ...corners });
|
|
131
|
+
g.fill(state.fill);
|
|
147
132
|
ctx.draw(g.opacity(dimAt(state, i)));
|
|
148
133
|
}
|
|
149
134
|
}
|
|
150
135
|
ctx.children();
|
|
151
136
|
},
|
|
152
137
|
});
|
|
138
|
+
/**
|
|
139
|
+
* Turns corners written for a bar standing up into the drawn bar's visual
|
|
140
|
+
* (y-up) corners: mirrored for a bar below zero, turned a quarter clockwise
|
|
141
|
+
* for one growing right, and both for one growing left.
|
|
142
|
+
*/
|
|
143
|
+
function orient(c, horizontal, forward) {
|
|
144
|
+
if (!horizontal)
|
|
145
|
+
return forward ? c : { topLeft: c.bottomLeft, topRight: c.bottomRight, bottomRight: c.topRight, bottomLeft: c.topLeft };
|
|
146
|
+
return forward
|
|
147
|
+
? { topLeft: c.bottomLeft, topRight: c.topLeft, bottomRight: c.topRight, bottomLeft: c.bottomRight }
|
|
148
|
+
: { topLeft: c.topLeft, topRight: c.bottomLeft, bottomRight: c.bottomRight, bottomLeft: c.topRight };
|
|
149
|
+
}
|
|
150
|
+
/** Bar `bar`'s rect corners: the far pair only where its stack ends, the base pair only on the baseline, each held inside the bar. */
|
|
151
|
+
export function barCorners(state, bar, forward, length) {
|
|
152
|
+
const grounded = bar.grounded ?? true;
|
|
153
|
+
const r = state.cornerRadius;
|
|
154
|
+
const ends = (bar.round ? 1 : 0) + (grounded ? 1 : 0);
|
|
155
|
+
const cap = Math.max(0, Math.min(bar.thickness / 2, ends > 1 ? length / 2 : length));
|
|
156
|
+
const fit = (v, on) => (on ? Math.max(0, Math.min(v, cap)) : 0);
|
|
157
|
+
const upright = {
|
|
158
|
+
topLeft: fit(r.topLeft, bar.round),
|
|
159
|
+
topRight: fit(r.topRight, bar.round),
|
|
160
|
+
bottomRight: fit(r.bottomRight, grounded),
|
|
161
|
+
bottomLeft: fit(r.bottomLeft, grounded),
|
|
162
|
+
};
|
|
163
|
+
return { cornerRadius: orient(upright, state.horizontal, forward), cornerStyle: orient(state.cornerStyle, state.horizontal, forward) };
|
|
164
|
+
}
|
|
165
|
+
/** A figure as the bar prints it when the chart gives no caption. */
|
|
166
|
+
export function barCaption(value) {
|
|
167
|
+
return value === 0 ? "" : formatMarker(value);
|
|
168
|
+
}
|
|
153
169
|
//# sourceMappingURL=chart-bars.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B,CAAC,EAAE,GAAG,CAAC,CAAC;oBACR,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;oBAC7B,KAAK,EAAE,GAAG,CAAC,KAAK;oBAChB,MAAM;oBACN,2HAA2H;oBAC3H,YAAY,EACV,MAAM,GAAG,CAAC;wBACR,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI;4BACrB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE;4BACtE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE;wBACxE,CAAC,CAAC,CAAC;iBACR,CAAC,CAAA;gBACF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBACrB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;gBAC5B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,QAAQ,EAAE,CAAA;IAChB,CAAC;CACF,CAAC,CAAA","sourcesContent":["import {\n Graphics2D,\n Text,\n Types,\n clamp,\n component2d,\n fillOps,\n shadowOps,\n strokeOps,\n textOps,\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 Shadow,\n type ShadowResolved,\n type Stroke,\n type StrokeResolved,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"../kit/entries\"\nimport { frameEase } from \"../kit/motion\"\nimport { loadPaints } from \"../kit/paints\"\nimport { formatMarker } from \"../kit/shared\"\nimport { DEFAULT_BAR_CHART_THEME } from \"./shared\"\n\n/**\n * One drawn column in the plot's centred pixel space (origin at the centre,\n * y-up), mapped by the parent {@link BarChart}. `from`/`to` are the two ends\n * rather than a base and a height, like {@link BarSpan}: one shape fits grouped,\n * stacked and negative.\n */\nexport interface BarGeometry {\n /** Centre x. */\n x: number\n width: number\n /** Pixel y of the base: the baseline when grouped, the running stack top when stacked. */\n from: number\n /** Pixel y of the far end at full growth. */\n to: number\n /** Whether the far end takes the corner radius (the stack's cap). */\n round: boolean\n /** The value plotted, for the printed figure. */\n value: number\n /** The printed figure, written as the value axis writes its ticks; absent, the bare marker reading of `value`. */\n caption?: string\n}\n\n/** Gap between a grouped column's end and the figure printed over it, in px. */\nconst VALUE_GAP = 10\n/** A segment shorter than this many multiples of the type size prints no figure. */\nconst VALUE_FIT = 1.6\n/** Fallback type size when the theme's value style leaves it unset or autofit. */\nconst VALUE_SIZE = 24\n\ninterface Columns {\n readonly bars: readonly BarGeometry[]\n readonly baseline: number\n readonly growth: number\n readonly dims: readonly number[]\n readonly enabled: boolean\n readonly valueStyle: TextStyle\n}\n\n/**\n * Column `i`'s dimming: the category spotlight, then the series switch. Captions\n * read this because they are child nodes, which a `render` guard would leave on\n * screen over a series that is not there.\n */\nfunction dimAt(s: Columns, index: number): number {\n if (!s.enabled) return 0\n return clamp(s.dims[index] ?? 1, 0, 1)\n}\n\nfunction endsAt(s: Columns, index: number): { base: number; end: number } | null {\n const bar = s.bars[index]\n if (!bar) return null\n const g = clamp(s.growth, 0, 1)\n return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g }\n}\n\nfunction valueSize(s: Columns): number {\n const size = s.valueStyle.fontSize\n return typeof size === \"number\" ? size : VALUE_SIZE\n}\n\nfunction insideAt(s: Columns, index: number): boolean {\n const bar = s.bars[index]\n return bar !== undefined && Math.abs(bar.from - s.baseline) > 0.5\n}\n\n/** Column `i`'s figure, or `\"\"` where there is no room. Blanking rather than dropping the node keeps captions index-aligned, so a rescale into more room prints again. */\nfunction captionAt(s: Columns, index: number): string {\n const bar = s.bars[index]\n if (!bar || bar.value === 0) return \"\"\n // An interior segment prints inside itself and must hold a line of type; a grouped column prints past its end.\n if (insideAt(s, index)) {\n const ends = endsAt(s, index)\n if (!ends) return \"\"\n if (Math.abs(ends.end - ends.base) < valueSize(s) * VALUE_FIT) return \"\"\n }\n return bar.caption ?? formatMarker(bar.value)\n}\n\nfunction captionY(s: Columns, index: number): number {\n const ends = endsAt(s, index)\n if (!ends) return 0\n if (insideAt(s, index)) return (ends.base + ends.end) / 2\n // Text is centred on `y`: clear the end by the gap plus half a line, on the side the column reached.\n const direction = ends.end >= ends.base ? 1 : -1\n return ends.end + direction * (VALUE_GAP + valueSize(s) / 2)\n}\n\n/**\n * One series of a {@link BarChart}: its column in every category plus the\n * printed figures. A node per series, like `ChartLine`, so `showSeries` and\n * `spotlightSeries` mean the same on both: enable the node or tween its opacity.\n * Positions come from the parent, which owns the slot arithmetic.\n *\n * The figures are {@link Text} children, so they take the theme's type style,\n * are measured by layout, and hide with the series.\n */\nexport const ChartBars = component2d({\n key: \"chartBars\",\n state: {\n bars: fresh<BarGeometry[]>(() => []),\n /** Pixel y of value 0, where every column grows from. */\n baseline: 0,\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n barStroke: Types.custom<Stroke, StrokeResolved[]>(DEFAULT_BAR_CHART_THEME.bar.stroke, { resolve: strokeOps.resolve, lerp: strokeOps.lerp }),\n barShadow: Types.custom<Shadow, ShadowResolved[]>(DEFAULT_BAR_CHART_THEME.bar.shadow, { resolve: shadowOps.resolve, lerp: shadowOps.lerp }),\n cornerRadius: DEFAULT_BAR_CHART_THEME.bar.cornerRadius,\n /**\n * Rise of every column in `[0, 1]` about the baseline, not each column's own\n * base: every segment travels by the same factor, so a stack stays flush\n * mid-animation and a negative column grows down.\n */\n growth: 1,\n /** Per-column opacity by row index, how the category spotlight reaches one column. Missing reads as 1. */\n dims: fresh<number[]>(() => []),\n showValues: false,\n valueStyle: Types.custom<TextStyle>(DEFAULT_BAR_CHART_THEME.valueStyle),\n /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the columns and their figures. */\n enabled: true,\n },\n // A node made of its figures would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n // One caption per column, built once (the row count is fixed at construction)\n // and bound to the live geometry so it travels with its column.\n children: (state) => {\n if (!state.showValues) return []\n return state.bars.map((_, i) =>\n Text({\n ...textOps.styleProps(state.valueStyle),\n text: () => captionAt(state, i),\n x: () => state.bars[i]?.x ?? 0,\n y: () => captionY(state, i),\n opacity: () => dimAt(state, i),\n })\n )\n },\n // The stroke and shadow sit past the conventional slots, so they are named here.\n load: (loader, state) =>\n loadPaints(loader, { fills: [state.fill], shadows: [state.barShadow], strokes: [state.barStroke] }),\n commands: {\n /** Raise every column from the baseline (`growth` 0 to 1). The resting state is the finished one; the chart arms it back to 0. */\n enter: (timeline) => {\n const ease = frameEase(timeline)\n return timeline.animate((t) => ({ growth: ease(t) }))\n },\n },\n render: (ctx, state) => {\n if (state.enabled) {\n for (let i = 0; i < state.bars.length; i++) {\n const bar = state.bars[i]\n const ends = endsAt(state, i)\n if (!ends || bar.width <= 0) continue\n const height = Math.abs(ends.end - ends.base)\n if (height <= 0) continue\n\n const radius = bar.round ? Math.min(state.cornerRadius, height) : 0\n // One `Graphics2D` per column: opacity belongs to the command list, and the spotlight dims single columns.\n const g = new Graphics2D()\n const rect = g.rect({\n x: bar.x,\n y: (ends.base + ends.end) / 2,\n width: bar.width,\n height,\n // Corner keys are visual (y-up): a column reaching up rounds `top*`, one reaching down `bottom*`. Only the far end rounds.\n cornerRadius:\n radius > 0\n ? ends.end >= ends.base\n ? { topLeft: radius, topRight: radius, bottomLeft: 0, bottomRight: 0 }\n : { bottomLeft: radius, bottomRight: radius, topLeft: 0, topRight: 0 }\n : 0,\n })\n rect.shadow(state.barShadow)\n rect.fill(state.fill)\n rect.stroke(state.barStroke)\n ctx.draw(g.opacity(dimAt(state, i)))\n }\n }\n ctx.children()\n },\n})\n\nexport type ChartBars = NodeOf<typeof ChartBars>\n"]}
|
|
1
|
+
{"version":3,"file":"chart-bars.js","sourceRoot":"","sources":["../../src/bar-chart/chart-bars.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,OAAO,GAYR,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAwBhC,2FAA2F;AAC3F,MAAM,WAAW,GAAG,GAAG,CAAA;AAavB,yEAAyE;AACzE,SAAS,KAAK,CAAC,CAAO,EAAE,KAAa;IACnC,IAAI,CAAC,CAAC,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IACxB,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,gEAAgE;AAChE,SAAS,MAAM,CAAC,CAAO,EAAE,KAAa;IACpC,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CA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CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["import {\n Graphics2D,\n Text,\n Types,\n clamp,\n component2d,\n fillOps,\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,\n type Node2DProps as _Node2DProps,\n type RectCornerRadius as _RectCornerRadius,\n type RectCornerStyle as _RectCornerStyle,\n type TextStyle,\n type CornerRadiusResolved,\n type CornerStyleResolved,\n} from \"@motionscript/sdk\"\n\nimport { boundText } from \"../kit/cartesian\"\nimport { asParts, fresh } from \"../kit/entries\"\nimport { frameEase } from \"../kit/motion\"\nimport { loadPaints } from \"../kit/paints\"\nimport { formatMarker } from \"../kit/shared\"\nimport { inkOn } from \"./shared\"\n\n/**\n * One drawn bar in the plot's centred pixel space (origin at the centre, y-up),\n * mapped by the parent {@link BarChart}: `center` and `thickness` across the\n * category slot, `from` and `to` along the value axis (y for a column, x for a\n * horizontal bar). Two ends rather than a base and a length, like `BarSpan`:\n * one shape fits grouped, stacked and negative.\n */\nexport interface BarGeometry {\n center: number\n thickness: number\n /** The base: the baseline when grouped, the running stack end when stacked. */\n from: number\n /** The far end at full growth. */\n to: number\n /** Whether the far end takes the far corners (the stack's last segment on its side). */\n round: boolean\n /** Whether the base takes the base corners (it stands on the baseline: every grouped bar, a stack's first segment). */\n grounded?: boolean\n /** The figure printed by the bar; empty for none. */\n caption: string\n}\n\n/** A figure inside a bar needs this much room around it, in multiples of the type size. */\nconst INSIDE_ROOM = 0.6\n\ninterface Bars {\n readonly bars: readonly BarGeometry[]\n readonly baseline: number\n readonly horizontal: boolean\n readonly growth: number\n readonly dims: readonly number[]\n readonly enabled: boolean\n readonly values: \"none\" | \"end\" | \"inside\"\n readonly valueStyle: TextStyle\n}\n\n/** Bar `i`'s dimming: the category spotlight, then the series switch. */\nfunction dimAt(s: Bars, index: number): number {\n if (!s.enabled) return 0\n return clamp(s.dims[index] ?? 1, 0, 1)\n}\n\n/** Bar `i`'s two ends as grown so far, along the value axis. */\nfunction endsAt(s: Bars, index: number): { base: number; end: number } | null {\n const bar = s.bars[index]\n if (!bar) return null\n const g = clamp(s.growth, 0, 1)\n return { base: s.baseline + (bar.from - s.baseline) * g, end: s.baseline + (bar.to - s.baseline) * g }\n}\n\nfunction sizeOf(style: TextStyle): number {\n return typeof style.fontSize === \"number\" ? style.fontSize : 24\n}\n\n/** Where bar `i`'s figure sits along the value axis: past its end, or in its middle. */\nfunction captionAlong(s: Bars, index: number, extent: number): number {\n const ends = endsAt(s, index)\n if (!ends) return 0\n if (s.values === \"inside\") return (ends.base + ends.end) / 2\n const direction = ends.end >= ends.base ? 1 : -1\n return ends.end + direction * (sizeOf(s.valueStyle) * 0.4 + extent / 2)\n}\n\n/** Whether bar `i` has room for a figure `extent` long inside it. */\nfunction fitsInside(s: Bars, index: number, extent: number, across: number): boolean {\n const bar = s.bars[index]\n const ends = endsAt(s, index)\n if (!bar || !ends) return false\n const room = sizeOf(s.valueStyle) * INSIDE_ROOM\n return Math.abs(ends.end - ends.base) >= extent + room && bar.thickness >= across\n}\n\n/**\n * One series of a {@link BarChart}: its bar in every category plus the printed\n * figures. A node per series, like `ChartLine`, so `showSeries` and\n * `spotlightSeries` mean the same on both: enable the node or tween its opacity.\n * Positions come from the parent, which owns the slot arithmetic.\n */\nexport const ChartBars = component2d({\n key: \"chartBars\",\n state: {\n bars: fresh<BarGeometry[]>(() => []),\n /** Pixel position of value 0 along the value axis, where every bar grows from. */\n baseline: 0,\n /** Bars grow along x from a category column rather than along y from a row. */\n horizontal: false,\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n /** As for a bar standing up from the baseline: `topLeft`/`topRight` round its far end, the bottom pair its base. */\n cornerRadius: Types.cornerRadius(8),\n cornerStyle: Types.cornerStyle(\"rounded\"),\n /**\n * Rise of every bar in `[0, 1]` about the baseline, not each bar's own base:\n * every segment travels by the same factor, so a stack stays flush\n * mid-animation and a negative bar grows the other way.\n */\n growth: 1,\n /** Per-bar opacity by row index, how the category spotlight reaches one bar. Missing reads as 1. */\n dims: fresh<number[]>(() => []),\n /** Read as built: whether each bar prints its figure, and where. */\n values: Types.custom<\"none\" | \"end\" | \"inside\">(\"none\"),\n valueStyle: Types.custom<TextStyle>({ fontSize: 24, fill: \"white\" }),\n /** The wholesale switch behind `showSeries`/`hideSeries`; off skips the bars and their figures. */\n enabled: true,\n },\n // A node made of its figures would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n // One figure per bar, built once (the row count is fixed at construction)\n // and bound to the live geometry so it travels with its bar.\n children: (state) => {\n if (state.values === \"none\") return []\n return asParts(state.bars.map((_, i) => {\n const caption: Node2D = new Text({\n ...boundText(() => ({ ...state.valueStyle, ...(state.values === \"inside\" && { fill: inkOn(state.fill) }) })),\n text: () => state.bars[i]?.caption ?? \"\",\n x: () => (state.horizontal ? captionAlong(state, i, caption.layoutBounds.width) : (state.bars[i]?.center ?? 0)),\n y: () => (state.horizontal ? (state.bars[i]?.center ?? 0) : captionAlong(state, i, caption.layoutBounds.height)),\n opacity: () => {\n const box = caption.layoutBounds\n const along = state.horizontal ? box.width : box.height\n const across = state.horizontal ? box.height : box.width\n if (state.values === \"inside\" && !fitsInside(state, i, along, across)) return 0\n // A figure past the end rises in with its bar's last stretch.\n return dimAt(state, i) * clamp((state.growth - 0.6) / 0.4, 0, 1)\n },\n }) as unknown as Node2D\n return caption\n }))\n },\n load: (loader, state) => loadPaints(loader, { fills: [state.fill] }),\n commands: {\n /** Raise every bar from the baseline (`growth` 0 to 1). The resting state is the finished one; the chart arms it back to 0. */\n enter: (timeline) => {\n const ease = frameEase(timeline)\n return timeline.animate((t) => ({ growth: ease(t) }))\n },\n },\n render: (ctx, state) => {\n if (state.enabled) {\n for (let i = 0; i < state.bars.length; i++) {\n const bar = state.bars[i]\n const ends = endsAt(state, i)\n if (!ends || bar.thickness <= 0) continue\n // A segment inside a stack reaches a pixel under the next, so no seam of background shows between them.\n const seam = bar.round ? 0 : 1\n const length = Math.abs(ends.end - ends.base) + seam\n if (length <= seam) continue\n const forward = ends.end >= ends.base\n const mid = (ends.base + ends.end) / 2 + (forward ? seam : -seam) / 2\n const corners = barCorners(state, bar, forward, length)\n // One `Graphics2D` per bar: opacity belongs to the command list, and the spotlight dims single bars.\n const g = new Graphics2D().rect(state.horizontal\n ? { x: mid, y: bar.center, width: length, height: bar.thickness, ...corners }\n : { x: bar.center, y: mid, width: bar.thickness, height: length, ...corners })\n g.fill(state.fill)\n ctx.draw(g.opacity(dimAt(state, i)))\n }\n }\n ctx.children()\n },\n})\n\nexport type ChartBars = NodeOf<typeof ChartBars>\n\ntype Corners<T> = { topLeft: T; topRight: T; bottomRight: T; bottomLeft: T }\n\n/**\n * Turns corners written for a bar standing up into the drawn bar's visual\n * (y-up) corners: mirrored for a bar below zero, turned a quarter clockwise\n * for one growing right, and both for one growing left.\n */\nfunction orient<T>(c: Corners<T>, horizontal: boolean, forward: boolean): Corners<T> {\n if (!horizontal) return forward ? c : { topLeft: c.bottomLeft, topRight: c.bottomRight, bottomRight: c.topRight, bottomLeft: c.topLeft }\n return forward\n ? { topLeft: c.bottomLeft, topRight: c.topLeft, bottomRight: c.topRight, bottomLeft: c.bottomRight }\n : { topLeft: c.topLeft, topRight: c.bottomLeft, bottomRight: c.bottomRight, bottomLeft: c.topRight }\n}\n\n/** Bar `bar`'s rect corners: the far pair only where its stack ends, the base pair only on the baseline, each held inside the bar. */\nexport function barCorners(\n state: { readonly cornerRadius: CornerRadiusResolved; readonly cornerStyle: CornerStyleResolved; readonly horizontal: boolean },\n bar: BarGeometry,\n forward: boolean,\n length: number\n): { cornerRadius: Corners<number>; cornerStyle: CornerStyleResolved } {\n const grounded = bar.grounded ?? true\n const r = state.cornerRadius\n const ends = (bar.round ? 1 : 0) + (grounded ? 1 : 0)\n const cap = Math.max(0, Math.min(bar.thickness / 2, ends > 1 ? length / 2 : length))\n const fit = (v: number, on: boolean) => (on ? Math.max(0, Math.min(v, cap)) : 0)\n const upright: Corners<number> = {\n topLeft: fit(r.topLeft, bar.round),\n topRight: fit(r.topRight, bar.round),\n bottomRight: fit(r.bottomRight, grounded),\n bottomLeft: fit(r.bottomLeft, grounded),\n }\n return { cornerRadius: orient(upright, state.horizontal, forward), cornerStyle: orient(state.cornerStyle, state.horizontal, forward) }\n}\n\n/** A figure as the bar prints it when the chart gives no caption. */\nexport function barCaption(value: number): string {\n return value === 0 ? \"\" : formatMarker(value)\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { BarChart, barChartDomain } from "./bar-chart.js";
|
|
2
|
-
export type { BarChartDomain, BarChartValues } from "./bar-chart.js";
|
|
2
|
+
export type { BarChartDomain, BarChartStyle, BarChartValues } from "./bar-chart.js";
|
|
3
3
|
export { ChartBars } from "./chart-bars.js";
|
|
4
4
|
export type { BarGeometry } from "./chart-bars.js";
|
|
5
|
-
export { CategoryAxis } from "./category-axis.js";
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
5
|
+
export { CategoryAxis, slotCentre } from "./category-axis.js";
|
|
6
|
+
export { BAR_LABELS, BAR_MARKS, barCategories, barSpans, barValueExtent, inkOn, resolveBarScale, } from "./shared.js";
|
|
7
|
+
export type { BarOrientation, BarSeries, BarSpan, BarStack, } from "./shared.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,QAAQ,EACR,cAAc,EACd,KAAK,EACL,eAAe,GAChB,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,cAAc,EACd,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,UAAU,CAAA"}
|
package/dist/bar-chart/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BarChart, barChartDomain } from "./bar-chart.js";
|
|
2
2
|
export { ChartBars } from "./chart-bars.js";
|
|
3
|
-
export { CategoryAxis } from "./category-axis.js";
|
|
4
|
-
export {
|
|
3
|
+
export { CategoryAxis, slotCentre } from "./category-axis.js";
|
|
4
|
+
export { BAR_LABELS, BAR_MARKS, barCategories, barSpans, barValueExtent, inkOn, resolveBarScale, } from "./shared.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bar-chart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EACL,UAAU,EACV,SAAS,EACT,aAAa,EACb,QAAQ,EACR,cAAc,EACd,KAAK,EACL,eAAe,GAChB,MAAM,UAAU,CAAA","sourcesContent":["export { BarChart, barChartDomain } from \"./bar-chart\"\nexport type { BarChartDomain, BarChartStyle, BarChartValues } from \"./bar-chart\"\nexport { ChartBars } from \"./chart-bars\"\nexport type { BarGeometry } from \"./chart-bars\"\nexport { CategoryAxis, slotCentre } from \"./category-axis\"\nexport {\n BAR_LABELS,\n BAR_MARKS,\n barCategories,\n barSpans,\n barValueExtent,\n inkOn,\n resolveBarScale,\n} from \"./shared\"\nexport type {\n BarOrientation,\n BarSeries,\n BarSpan,\n BarStack,\n} from \"./shared\"\n"]}
|