@motionscript/charts 0.1.0 → 0.1.1-alpha.1
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 +38 -0
- package/README.md +98 -28
- package/dist/bar-chart/bar-chart.d.ts +242 -119
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +231 -260
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +16 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +59 -68
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +60 -91
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +88 -125
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +5 -13
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +2 -9
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +40 -132
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +70 -158
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-R3Q5EE6E.js +2 -0
- package/dist/browser/chunks/chunk-R3Q5EE6E.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 +8 -17
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +8 -17
- 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 +49 -35
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +80 -42
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +37 -40
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +53 -47
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +16 -59
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +38 -76
- 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/horizontal-axis.d.ts +77 -0
- package/dist/kit/horizontal-axis.d.ts.map +1 -0
- package/dist/kit/horizontal-axis.js +99 -0
- package/dist/kit/horizontal-axis.js.map +1 -0
- package/dist/kit/motion.d.ts +16 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +15 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/{pie-chart → kit}/pie-legend.d.ts +14 -29
- package/dist/kit/pie-legend.d.ts.map +1 -0
- package/dist/kit/pie-legend.js +93 -0
- 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 +60 -214
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +91 -291
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/style.d.ts +254 -0
- package/dist/kit/style.d.ts.map +1 -0
- package/dist/kit/style.js +197 -0
- package/dist/kit/style.js.map +1 -0
- package/dist/kit/vertical-axis.d.ts +36 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +69 -81
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +107 -40
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +172 -89
- 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 +13 -28
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/index.d.ts +5 -18
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +3 -16
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +272 -119
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +309 -257
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +73 -130
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +195 -156
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +16 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +44 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +3 -13
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +9 -13
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +3 -15
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -11
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +147 -85
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +65 -86
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +65 -196
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +154 -292
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +78 -172
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +54 -177
- 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 +218 -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 +43 -0
- package/dist/radar-chart/radar-grid.d.ts.map +1 -0
- package/dist/radar-chart/radar-grid.js +61 -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 +73 -0
- package/dist/radar-chart/shared.d.ts.map +1 -0
- package/dist/radar-chart/shared.js +123 -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 +216 -0
- package/dist/radial-chart/radial-chart.d.ts.map +1 -0
- package/dist/radial-chart/radial-chart.js +174 -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 +73 -0
- package/dist/radial-chart/shared.d.ts.map +1 -0
- package/dist/radial-chart/shared.js +79 -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 +274 -315
- package/src/bar-chart/category-axis.ts +53 -88
- package/src/bar-chart/chart-bars.ts +108 -205
- package/src/bar-chart/index.ts +8 -19
- package/src/bar-chart/shared.ts +81 -309
- package/src/engine.ts +8 -17
- package/src/index.ts +2 -0
- package/src/kit/cartesian.ts +118 -55
- package/src/kit/chart-canvas.ts +50 -80
- package/src/kit/chart-legend.ts +36 -97
- package/src/kit/entries.ts +4 -1
- package/src/kit/horizontal-axis.ts +114 -0
- package/src/kit/motion.ts +18 -2
- package/src/{pie-chart → kit}/pie-legend.ts +25 -65
- package/src/kit/polar.ts +54 -0
- package/src/kit/shared.ts +104 -487
- package/src/kit/style.ts +257 -0
- package/src/kit/vertical-axis.ts +81 -115
- package/src/line-chart/chart-line.ts +185 -91
- package/src/line-chart/chart-region.ts +14 -31
- package/src/line-chart/index.ts +14 -22
- package/src/line-chart/line-chart.ts +377 -315
- package/src/line-chart/shared.ts +229 -304
- package/src/line-chart/x-scale.ts +44 -121
- package/src/nodes.ts +9 -13
- package/src/pie-chart/index.ts +3 -35
- package/src/pie-chart/pie-chart.ts +83 -134
- package/src/pie-chart/pie-ring.ts +162 -368
- package/src/pie-chart/shared.ts +92 -379
- package/src/radar-chart/index.ts +4 -0
- package/src/radar-chart/radar-chart.ts +287 -0
- package/src/radar-chart/radar-grid.ts +78 -0
- package/src/radar-chart/radar-series.ts +88 -0
- package/src/radar-chart/shared.ts +146 -0
- package/src/radial-chart/index.ts +5 -0
- package/src/radial-chart/radial-chart.ts +210 -0
- package/src/radial-chart/radial-rings.ts +328 -0
- package/src/radial-chart/shared.ts +114 -0
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
- package/dist/kit/chart-border.d.ts +0 -27
- package/dist/kit/chart-border.d.ts.map +0 -1
- package/dist/kit/chart-border.js +0 -28
- package/dist/kit/chart-border.js.map +0 -1
- package/dist/line-chart/horizontal-axis.d.ts +0 -79
- package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
- package/dist/line-chart/horizontal-axis.js +0 -129
- 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 +0 -117
- package/dist/pie-chart/pie-legend.js.map +0 -1
- package/src/kit/chart-border.ts +0 -50
- package/src/line-chart/horizontal-axis.ts +0 -151
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart family's style: one `style` entry per chart, built from the groups
|
|
3
|
+
* below, so a look saved off one chart lays onto any other (a field the other
|
|
4
|
+
* chart does not draw is dropped). A chart spreads the shared groups and adds a
|
|
5
|
+
* `marks` group of its own.
|
|
6
|
+
*/
|
|
7
|
+
import { type Fill, type StrokeResolved, type Stroke as _Stroke, type StyleInput, type TextStyle, type FillResolved as _FillResolved, type Type as _Type } from "@motionscript/sdk";
|
|
8
|
+
import type { AxisConfig, ChartSeries, LegendConfig } from "./shared.js";
|
|
9
|
+
/** The style family every chart shares; a host keys saved styles by it. */
|
|
10
|
+
export declare const CHART_STYLE_FAMILY = "chart";
|
|
11
|
+
/** The out-of-the-box series colours, cycled by series (or row) index. */
|
|
12
|
+
export declare const CHART_PALETTE_DEFAULT: readonly ["#4f8cff", "#2fbf8f", "#f5a524", "#e5547a", "#9b6cf0"];
|
|
13
|
+
export declare const CHART_COLORS: {
|
|
14
|
+
/** A colour per series (a pie's or radial's per row), cycled. */
|
|
15
|
+
palette: _Type<Fill[], _FillResolved[][], false>;
|
|
16
|
+
/** Values, legend captions, centre text. */
|
|
17
|
+
foreground: _Type<Fill, _FillResolved[], false>;
|
|
18
|
+
/** Axis markers and captions, spoke labels. */
|
|
19
|
+
muted: _Type<Fill, _FillResolved[], false>;
|
|
20
|
+
/** Behind the plot; none by default, so the chart reads against the stage. */
|
|
21
|
+
background: _Type<Fill, _FillResolved[], false>;
|
|
22
|
+
};
|
|
23
|
+
export declare const CHART_TEXT: {
|
|
24
|
+
/** Empty: the scene's default face. */
|
|
25
|
+
fontFamily: _Type<string, string, false>;
|
|
26
|
+
/** Marker and legend size at 1080p; titles and values scale from it. */
|
|
27
|
+
fontSize: _Type<number, number, false>;
|
|
28
|
+
fontWeight: _Type<number, number, false>;
|
|
29
|
+
};
|
|
30
|
+
export declare const CARTESIAN_GRID: {
|
|
31
|
+
/** The lines along the value ticks of a column chart (one per tick); empty draws none. */
|
|
32
|
+
horizontalGrid: _Type<_Stroke, StrokeResolved[], false>;
|
|
33
|
+
/** The lines under the category markers; empty draws none. */
|
|
34
|
+
verticalGrid: _Type<_Stroke, StrokeResolved[], false>;
|
|
35
|
+
/** The baseline and the value-axis rule; empty draws none. */
|
|
36
|
+
axisStroke: _Type<_Stroke, StrokeResolved[], false>;
|
|
37
|
+
/** Read as the chart is built: whether the category (x) axis row is drawn. */
|
|
38
|
+
showXAxis: _Type<boolean, boolean, false>;
|
|
39
|
+
/** Read as the chart is built: whether the value (y) axis column is drawn. */
|
|
40
|
+
showYAxis: _Type<boolean, boolean, false>;
|
|
41
|
+
};
|
|
42
|
+
export type LegendPosition = "bottom" | "top" | "right" | "none";
|
|
43
|
+
export type LegendSwatch = "square" | "circle" | "line";
|
|
44
|
+
export declare const CHART_LEGEND: {
|
|
45
|
+
/** Read as the chart is built: where the legend sits, or `none`. */
|
|
46
|
+
legend: _Type<"right" | "top" | "bottom" | "none", "right" | "top" | "bottom" | "none", false>;
|
|
47
|
+
swatch: _Type<"square" | "circle" | "line", "square" | "circle" | "line", false>;
|
|
48
|
+
};
|
|
49
|
+
/** The type fields, and the two text colours: what every text helper reads. */
|
|
50
|
+
export interface ChartTextStyle {
|
|
51
|
+
readonly foreground: Fill;
|
|
52
|
+
readonly muted: Fill;
|
|
53
|
+
readonly fontFamily: string;
|
|
54
|
+
readonly fontSize: number;
|
|
55
|
+
readonly fontWeight: number;
|
|
56
|
+
}
|
|
57
|
+
/** The fields every chart's style resolves, whichever groups it spreads. */
|
|
58
|
+
export interface ChartStyleBase extends ChartTextStyle {
|
|
59
|
+
readonly palette: readonly Fill[];
|
|
60
|
+
readonly background: Fill;
|
|
61
|
+
readonly legend: LegendPosition;
|
|
62
|
+
readonly swatch: LegendSwatch;
|
|
63
|
+
}
|
|
64
|
+
/** The cartesian grid fields, for the line and bar charts. */
|
|
65
|
+
export interface CartesianStyle extends ChartStyleBase {
|
|
66
|
+
readonly horizontalGrid: StrokeResolved[];
|
|
67
|
+
readonly verticalGrid: StrokeResolved[];
|
|
68
|
+
readonly axisStroke: StrokeResolved[];
|
|
69
|
+
readonly showXAxis: boolean;
|
|
70
|
+
readonly showYAxis: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** The rule and track fields a preset restates so its rules read on its background (a chart keeps those it draws). */
|
|
73
|
+
declare const _PRESET_RULES: {
|
|
74
|
+
horizontalGrid: _Type<_Stroke, StrokeResolved[], false>;
|
|
75
|
+
gridStroke: _Type<_Stroke, StrokeResolved[], false>;
|
|
76
|
+
spokeStroke: _Type<_Stroke, StrokeResolved[], false>;
|
|
77
|
+
track: _Type<Fill, _FillResolved[], false>;
|
|
78
|
+
};
|
|
79
|
+
/** A preset's fields: any chart's, so one preset dresses every chart. */
|
|
80
|
+
export type ChartStylePreset = StyleInput<typeof CHART_COLORS & typeof CHART_TEXT & typeof _PRESET_RULES>;
|
|
81
|
+
/** Ready-made looks, each stating every colour so applying one replaces the last. */
|
|
82
|
+
export declare const CHART_STYLE_PRESETS: {
|
|
83
|
+
midnight: {
|
|
84
|
+
palette: ("#4f8cff" | "#2fbf8f" | "#f5a524" | "#e5547a" | "#9b6cf0")[];
|
|
85
|
+
foreground: string;
|
|
86
|
+
muted: string;
|
|
87
|
+
horizontalGrid: {
|
|
88
|
+
weight: number;
|
|
89
|
+
fill: string;
|
|
90
|
+
};
|
|
91
|
+
gridStroke: {
|
|
92
|
+
weight: number;
|
|
93
|
+
fill: string;
|
|
94
|
+
};
|
|
95
|
+
spokeStroke: {
|
|
96
|
+
weight: number;
|
|
97
|
+
fill: string;
|
|
98
|
+
};
|
|
99
|
+
track: string;
|
|
100
|
+
background: never[];
|
|
101
|
+
};
|
|
102
|
+
paper: {
|
|
103
|
+
palette: string[];
|
|
104
|
+
foreground: string;
|
|
105
|
+
muted: string;
|
|
106
|
+
horizontalGrid: {
|
|
107
|
+
weight: number;
|
|
108
|
+
fill: string;
|
|
109
|
+
};
|
|
110
|
+
gridStroke: {
|
|
111
|
+
weight: number;
|
|
112
|
+
fill: string;
|
|
113
|
+
};
|
|
114
|
+
spokeStroke: {
|
|
115
|
+
weight: number;
|
|
116
|
+
fill: string;
|
|
117
|
+
};
|
|
118
|
+
track: string;
|
|
119
|
+
background: string;
|
|
120
|
+
};
|
|
121
|
+
ember: {
|
|
122
|
+
palette: string[];
|
|
123
|
+
foreground: string;
|
|
124
|
+
muted: string;
|
|
125
|
+
horizontalGrid: {
|
|
126
|
+
weight: number;
|
|
127
|
+
fill: string;
|
|
128
|
+
};
|
|
129
|
+
gridStroke: {
|
|
130
|
+
weight: number;
|
|
131
|
+
fill: string;
|
|
132
|
+
};
|
|
133
|
+
spokeStroke: {
|
|
134
|
+
weight: number;
|
|
135
|
+
fill: string;
|
|
136
|
+
};
|
|
137
|
+
track: string;
|
|
138
|
+
background: string;
|
|
139
|
+
};
|
|
140
|
+
neon: {
|
|
141
|
+
palette: string[];
|
|
142
|
+
foreground: string;
|
|
143
|
+
muted: string;
|
|
144
|
+
horizontalGrid: {
|
|
145
|
+
weight: number;
|
|
146
|
+
fill: string;
|
|
147
|
+
};
|
|
148
|
+
gridStroke: {
|
|
149
|
+
weight: number;
|
|
150
|
+
fill: string;
|
|
151
|
+
};
|
|
152
|
+
spokeStroke: {
|
|
153
|
+
weight: number;
|
|
154
|
+
fill: string;
|
|
155
|
+
};
|
|
156
|
+
track: string;
|
|
157
|
+
background: never[];
|
|
158
|
+
};
|
|
159
|
+
ocean: {
|
|
160
|
+
palette: string[];
|
|
161
|
+
foreground: string;
|
|
162
|
+
muted: string;
|
|
163
|
+
horizontalGrid: {
|
|
164
|
+
weight: number;
|
|
165
|
+
fill: string;
|
|
166
|
+
};
|
|
167
|
+
gridStroke: {
|
|
168
|
+
weight: number;
|
|
169
|
+
fill: string;
|
|
170
|
+
};
|
|
171
|
+
spokeStroke: {
|
|
172
|
+
weight: number;
|
|
173
|
+
fill: string;
|
|
174
|
+
};
|
|
175
|
+
track: string;
|
|
176
|
+
background: string;
|
|
177
|
+
};
|
|
178
|
+
sunset: {
|
|
179
|
+
palette: string[];
|
|
180
|
+
foreground: string;
|
|
181
|
+
muted: string;
|
|
182
|
+
horizontalGrid: {
|
|
183
|
+
weight: number;
|
|
184
|
+
fill: string;
|
|
185
|
+
};
|
|
186
|
+
gridStroke: {
|
|
187
|
+
weight: number;
|
|
188
|
+
fill: string;
|
|
189
|
+
};
|
|
190
|
+
spokeStroke: {
|
|
191
|
+
weight: number;
|
|
192
|
+
fill: string;
|
|
193
|
+
};
|
|
194
|
+
track: string;
|
|
195
|
+
background: never[];
|
|
196
|
+
};
|
|
197
|
+
pastel: {
|
|
198
|
+
palette: string[];
|
|
199
|
+
foreground: string;
|
|
200
|
+
muted: string;
|
|
201
|
+
horizontalGrid: {
|
|
202
|
+
weight: number;
|
|
203
|
+
fill: string;
|
|
204
|
+
};
|
|
205
|
+
gridStroke: {
|
|
206
|
+
weight: number;
|
|
207
|
+
fill: string;
|
|
208
|
+
};
|
|
209
|
+
spokeStroke: {
|
|
210
|
+
weight: number;
|
|
211
|
+
fill: string;
|
|
212
|
+
};
|
|
213
|
+
track: string;
|
|
214
|
+
background: never[];
|
|
215
|
+
};
|
|
216
|
+
mono: {
|
|
217
|
+
palette: string[];
|
|
218
|
+
foreground: string;
|
|
219
|
+
muted: string;
|
|
220
|
+
horizontalGrid: {
|
|
221
|
+
weight: number;
|
|
222
|
+
fill: string;
|
|
223
|
+
};
|
|
224
|
+
gridStroke: {
|
|
225
|
+
weight: number;
|
|
226
|
+
fill: string;
|
|
227
|
+
};
|
|
228
|
+
spokeStroke: {
|
|
229
|
+
weight: number;
|
|
230
|
+
fill: string;
|
|
231
|
+
};
|
|
232
|
+
track: string;
|
|
233
|
+
background: never[];
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
/** Series `index`'s colour: its own `fill`, else the palette's, cycled. */
|
|
237
|
+
export declare function paletteFill(style: Pick<ChartStyleBase, "palette">, index: number, own?: Fill): Fill;
|
|
238
|
+
/** {@link paletteFill} for a series. */
|
|
239
|
+
export declare function seriesFill(style: Pick<ChartStyleBase, "palette">, series: ChartSeries, index: number): Fill;
|
|
240
|
+
/** Axis markers, spoke labels: muted, at the base size. */
|
|
241
|
+
export declare function markerText(style: ChartTextStyle, textAlign?: TextStyle["textAlign"]): TextStyle;
|
|
242
|
+
/** Axis captions: muted, a step larger and heavier than the markers. */
|
|
243
|
+
export declare function titleText(style: ChartTextStyle): TextStyle;
|
|
244
|
+
/** Values on marks and legend captions: the foreground, at the base size. */
|
|
245
|
+
export declare function valueText(style: ChartTextStyle, textAlign?: TextStyle["textAlign"]): TextStyle;
|
|
246
|
+
/**
|
|
247
|
+
* The kit axis parts' config from a style. `x` is the axis under the plot;
|
|
248
|
+
* its grid lines are vertical (one per x marker), the `y` axis's horizontal.
|
|
249
|
+
*/
|
|
250
|
+
export declare function axisConfigOf(style: Pick<CartesianStyle, "verticalGrid" | "horizontalGrid"> & ChartTextStyle, axis: "x" | "y"): AxisConfig;
|
|
251
|
+
/** The kit legend's config: captions in the foreground, the swatch shaped by `swatch`. */
|
|
252
|
+
export declare function legendConfigOf(style: ChartTextStyle & Pick<ChartStyleBase, "swatch">): LegendConfig;
|
|
253
|
+
export {};
|
|
254
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/kit/style.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,IAAI,EACT,KAAK,cAAc,EACnB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,IA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AAED,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,GAAE,SAAS,CAAC,WAAW,CAAY,GAAG,SAAS,CAExG;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,cAAc,GAAG,gBAAgB,CAAC,GAAG,cAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,UAAU,CASzI;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,GAAG,YAAY,CAcnG"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart family's style: one `style` entry per chart, built from the groups
|
|
3
|
+
* below, so a look saved off one chart lays onto any other (a field the other
|
|
4
|
+
* chart does not draw is dropped). A chart spreads the shared groups and adds a
|
|
5
|
+
* `marks` group of its own.
|
|
6
|
+
*/
|
|
7
|
+
import { Types, } from "@motionscript/sdk";
|
|
8
|
+
/** The style family every chart shares; a host keys saved styles by it. */
|
|
9
|
+
export const CHART_STYLE_FAMILY = "chart";
|
|
10
|
+
/** The out-of-the-box series colours, cycled by series (or row) index. */
|
|
11
|
+
export const CHART_PALETTE_DEFAULT = ["#4f8cff", "#2fbf8f", "#f5a524", "#e5547a", "#9b6cf0"];
|
|
12
|
+
export const CHART_COLORS = {
|
|
13
|
+
/** A colour per series (a pie's or radial's per row), cycled. */
|
|
14
|
+
palette: Types.palette(CHART_PALETTE_DEFAULT),
|
|
15
|
+
/** Values, legend captions, centre text. */
|
|
16
|
+
foreground: Types.fill("#f4f4f5"),
|
|
17
|
+
/** Axis markers and captions, spoke labels. */
|
|
18
|
+
muted: Types.fill("#a1a1aa"),
|
|
19
|
+
/** Behind the plot; none by default, so the chart reads against the stage. */
|
|
20
|
+
background: Types.fill([]),
|
|
21
|
+
};
|
|
22
|
+
export const CHART_TEXT = {
|
|
23
|
+
/** Empty: the scene's default face. */
|
|
24
|
+
fontFamily: Types.font(""),
|
|
25
|
+
/** Marker and legend size at 1080p; titles and values scale from it. */
|
|
26
|
+
fontSize: Types.number(28, { min: 8, max: 160, step: 1, unit: "px" }),
|
|
27
|
+
fontWeight: Types.number(500, { min: 100, max: 900, step: 100 }),
|
|
28
|
+
};
|
|
29
|
+
export const CARTESIAN_GRID = {
|
|
30
|
+
/** The lines along the value ticks of a column chart (one per tick); empty draws none. */
|
|
31
|
+
horizontalGrid: Types.stroke({ weight: 2, fill: "white/15" }),
|
|
32
|
+
/** The lines under the category markers; empty draws none. */
|
|
33
|
+
verticalGrid: Types.stroke([]),
|
|
34
|
+
/** The baseline and the value-axis rule; empty draws none. */
|
|
35
|
+
axisStroke: Types.stroke([]),
|
|
36
|
+
/** Read as the chart is built: whether the category (x) axis row is drawn. */
|
|
37
|
+
showXAxis: Types.boolean(true, { animatable: false }),
|
|
38
|
+
/** Read as the chart is built: whether the value (y) axis column is drawn. */
|
|
39
|
+
showYAxis: Types.boolean(true, { animatable: false }),
|
|
40
|
+
};
|
|
41
|
+
export const CHART_LEGEND = {
|
|
42
|
+
/** Read as the chart is built: where the legend sits, or `none`. */
|
|
43
|
+
legend: Types.oneOf(["bottom", "top", "right", "none"], { animatable: false }),
|
|
44
|
+
swatch: Types.oneOf(["square", "circle", "line"]),
|
|
45
|
+
};
|
|
46
|
+
/** The rule and track fields a preset restates so its rules read on its background (a chart keeps those it draws). */
|
|
47
|
+
const _PRESET_RULES = {
|
|
48
|
+
horizontalGrid: CARTESIAN_GRID.horizontalGrid,
|
|
49
|
+
gridStroke: Types.stroke([]),
|
|
50
|
+
spokeStroke: Types.stroke([]),
|
|
51
|
+
track: Types.fill([]),
|
|
52
|
+
};
|
|
53
|
+
/** Ready-made looks, each stating every colour so applying one replaces the last. */
|
|
54
|
+
export const CHART_STYLE_PRESETS = {
|
|
55
|
+
midnight: {
|
|
56
|
+
palette: [...CHART_PALETTE_DEFAULT],
|
|
57
|
+
foreground: "#f4f4f5",
|
|
58
|
+
muted: "#a1a1aa",
|
|
59
|
+
horizontalGrid: { weight: 2, fill: "white/15" },
|
|
60
|
+
gridStroke: { weight: 2, fill: "white/15" },
|
|
61
|
+
spokeStroke: { weight: 2, fill: "white/15" },
|
|
62
|
+
track: "white/10",
|
|
63
|
+
background: [],
|
|
64
|
+
},
|
|
65
|
+
paper: {
|
|
66
|
+
palette: ["#2563eb", "#059669", "#d97706", "#db2777", "#7c3aed"],
|
|
67
|
+
foreground: "#1c1917",
|
|
68
|
+
muted: "#57534e",
|
|
69
|
+
horizontalGrid: { weight: 2, fill: "#1c1917/12" },
|
|
70
|
+
gridStroke: { weight: 2, fill: "#1c1917/12" },
|
|
71
|
+
spokeStroke: { weight: 2, fill: "#1c1917/12" },
|
|
72
|
+
track: "#1c1917/12",
|
|
73
|
+
background: "#fafaf9",
|
|
74
|
+
},
|
|
75
|
+
ember: {
|
|
76
|
+
palette: ["#d9603b", "#8194ad", "#e0a93b", "#5e9d6b", "#9ec85a"],
|
|
77
|
+
foreground: "#e9e1d4",
|
|
78
|
+
muted: "#8a7f70",
|
|
79
|
+
horizontalGrid: { weight: 2, fill: "#2c2820" },
|
|
80
|
+
gridStroke: { weight: 2, fill: "#2c2820" },
|
|
81
|
+
spokeStroke: { weight: 2, fill: "#2c2820" },
|
|
82
|
+
track: "#2c2820",
|
|
83
|
+
background: "#15130e",
|
|
84
|
+
},
|
|
85
|
+
neon: {
|
|
86
|
+
palette: ["#22d3ee", "#a3e635", "#f472b6", "#facc15", "#818cf8"],
|
|
87
|
+
foreground: "#ffffff",
|
|
88
|
+
muted: "#94a3b8",
|
|
89
|
+
horizontalGrid: { weight: 2, fill: "white/10" },
|
|
90
|
+
gridStroke: { weight: 2, fill: "white/10" },
|
|
91
|
+
spokeStroke: { weight: 2, fill: "white/10" },
|
|
92
|
+
track: "white/10",
|
|
93
|
+
background: [],
|
|
94
|
+
},
|
|
95
|
+
ocean: {
|
|
96
|
+
palette: ["#0ea5e9", "#14b8a6", "#6366f1", "#38bdf8", "#2dd4bf"],
|
|
97
|
+
foreground: "#e0f2fe",
|
|
98
|
+
muted: "#7dd3fc",
|
|
99
|
+
horizontalGrid: { weight: 2, fill: "#7dd3fc/20" },
|
|
100
|
+
gridStroke: { weight: 2, fill: "#7dd3fc/20" },
|
|
101
|
+
spokeStroke: { weight: 2, fill: "#7dd3fc/20" },
|
|
102
|
+
track: "#7dd3fc/20",
|
|
103
|
+
background: "#082f49",
|
|
104
|
+
},
|
|
105
|
+
sunset: {
|
|
106
|
+
palette: ["#f97316", "#ef4444", "#ec4899", "#f59e0b", "#a855f7"],
|
|
107
|
+
foreground: "#fff7ed",
|
|
108
|
+
muted: "#fdba74",
|
|
109
|
+
horizontalGrid: { weight: 2, fill: "#fdba74/20" },
|
|
110
|
+
gridStroke: { weight: 2, fill: "#fdba74/20" },
|
|
111
|
+
spokeStroke: { weight: 2, fill: "#fdba74/20" },
|
|
112
|
+
track: "#fdba74/20",
|
|
113
|
+
background: [],
|
|
114
|
+
},
|
|
115
|
+
pastel: {
|
|
116
|
+
palette: ["#a5b4fc", "#f9a8d4", "#86efac", "#fde68a", "#7dd3fc"],
|
|
117
|
+
foreground: "#f8fafc",
|
|
118
|
+
muted: "#cbd5e1",
|
|
119
|
+
horizontalGrid: { weight: 2, fill: "white/12" },
|
|
120
|
+
gridStroke: { weight: 2, fill: "white/12" },
|
|
121
|
+
spokeStroke: { weight: 2, fill: "white/12" },
|
|
122
|
+
track: "white/12",
|
|
123
|
+
background: [],
|
|
124
|
+
},
|
|
125
|
+
mono: {
|
|
126
|
+
palette: ["#fafafa", "#a3a3a3", "#737373", "#d4d4d4", "#525252"],
|
|
127
|
+
foreground: "#fafafa",
|
|
128
|
+
muted: "#a3a3a3",
|
|
129
|
+
horizontalGrid: { weight: 2, fill: "white/12" },
|
|
130
|
+
gridStroke: { weight: 2, fill: "white/12" },
|
|
131
|
+
spokeStroke: { weight: 2, fill: "white/12" },
|
|
132
|
+
track: "white/12",
|
|
133
|
+
background: [],
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
/** Series `index`'s colour: its own `fill`, else the palette's, cycled. */
|
|
137
|
+
export function paletteFill(style, index, own) {
|
|
138
|
+
if (own != null)
|
|
139
|
+
return own;
|
|
140
|
+
const palette = style.palette;
|
|
141
|
+
return palette.length > 0 ? palette[index % palette.length] : "white";
|
|
142
|
+
}
|
|
143
|
+
/** {@link paletteFill} for a series. */
|
|
144
|
+
export function seriesFill(style, series, index) {
|
|
145
|
+
return paletteFill(style, index, series.fill);
|
|
146
|
+
}
|
|
147
|
+
function face(style) {
|
|
148
|
+
return style.fontFamily ? { fontFamily: style.fontFamily } : {};
|
|
149
|
+
}
|
|
150
|
+
/** Axis markers, spoke labels: muted, at the base size. */
|
|
151
|
+
export function markerText(style, textAlign = "center") {
|
|
152
|
+
return { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign, fill: style.muted };
|
|
153
|
+
}
|
|
154
|
+
/** Axis captions: muted, a step larger and heavier than the markers. */
|
|
155
|
+
export function titleText(style) {
|
|
156
|
+
return {
|
|
157
|
+
...face(style),
|
|
158
|
+
fontSize: Math.round(style.fontSize * 1.1),
|
|
159
|
+
fontWeight: Math.min(900, style.fontWeight + 100),
|
|
160
|
+
textAlign: "center",
|
|
161
|
+
fill: style.muted,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/** Values on marks and legend captions: the foreground, at the base size. */
|
|
165
|
+
export function valueText(style, textAlign = "center") {
|
|
166
|
+
return { ...face(style), fontSize: style.fontSize, fontWeight: Math.min(900, style.fontWeight + 100), textAlign, fill: style.foreground };
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The kit axis parts' config from a style. `x` is the axis under the plot;
|
|
170
|
+
* its grid lines are vertical (one per x marker), the `y` axis's horizontal.
|
|
171
|
+
*/
|
|
172
|
+
export function axisConfigOf(style, axis) {
|
|
173
|
+
const gap = Math.round(style.fontSize * 0.6);
|
|
174
|
+
return {
|
|
175
|
+
labelStyle: markerText(style, axis === "x" ? "center" : "right"),
|
|
176
|
+
titleStyle: titleText(style),
|
|
177
|
+
lineStyle: axis === "x" ? style.verticalGrid : style.horizontalGrid,
|
|
178
|
+
tickPadding: axis === "x" ? { top: gap } : { right: gap },
|
|
179
|
+
titlePadding: axis === "x" ? { top: Math.round(gap / 2) } : { right: gap },
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/** The kit legend's config: captions in the foreground, the swatch shaped by `swatch`. */
|
|
183
|
+
export function legendConfigOf(style) {
|
|
184
|
+
const size = Math.max(8, Math.round(style.fontSize * 0.6));
|
|
185
|
+
const marker = style.swatch === "line"
|
|
186
|
+
? { width: Math.round(size * 2), height: Math.max(3, Math.round(size / 4)), borderRadius: size }
|
|
187
|
+
: style.swatch === "circle"
|
|
188
|
+
? { width: size, height: size, borderRadius: size / 2 }
|
|
189
|
+
: { width: size, height: size, borderRadius: Math.round(size / 4) };
|
|
190
|
+
return {
|
|
191
|
+
padding: 0,
|
|
192
|
+
textStyle: { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign: "left", fill: style.foreground },
|
|
193
|
+
itemGap: Math.round(style.fontSize * 1.4),
|
|
194
|
+
markerStyle: { ...marker, stroke: [], shadow: [] },
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/kit/style.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,GASN,MAAM,mBAAmB,CAAA;AAI1B,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAA;AAEzC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAU,C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E,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC;QACzC,WAAW,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;KACnD,CAAA;AACH,CAAC","sourcesContent":["/**\n * The chart family's style: one `style` entry per chart, built from the groups\n * below, so a look saved off one chart lays onto any other (a field the other\n * chart does not draw is dropped). A chart spreads the shared groups and adds a\n * `marks` group of its own.\n */\n\nimport {\n Types,\n type Fill,\n type StrokeResolved,\n type Stroke as _Stroke,\n type StyleInput,\n type TextStyle,\n // Named so the emitted style types reach these through the sdk, not core.\n type FillResolved as _FillResolved,\n type Type as _Type,\n} from \"@motionscript/sdk\"\n\nimport type { AxisConfig, ChartSeries, LegendConfig } from \"./shared\"\n\n/** The style family every chart shares; a host keys saved styles by it. */\nexport const CHART_STYLE_FAMILY = \"chart\"\n\n/** The out-of-the-box series colours, cycled by series (or row) index. */\nexport const CHART_PALETTE_DEFAULT = [\"#4f8cff\", \"#2fbf8f\", \"#f5a524\", \"#e5547a\", \"#9b6cf0\"] as const\n\nexport const CHART_COLORS = {\n /** A colour per series (a pie's or radial's per row), cycled. */\n palette: Types.palette(CHART_PALETTE_DEFAULT),\n /** Values, legend captions, centre text. */\n foreground: Types.fill(\"#f4f4f5\"),\n /** Axis markers and captions, spoke labels. */\n muted: Types.fill(\"#a1a1aa\"),\n /** Behind the plot; none by default, so the chart reads against the stage. */\n background: Types.fill([]),\n}\n\nexport const CHART_TEXT = {\n /** Empty: the scene's default face. */\n fontFamily: Types.font(\"\"),\n /** Marker and legend size at 1080p; titles and values scale from it. */\n fontSize: Types.number(28, { min: 8, max: 160, step: 1, unit: \"px\" }),\n fontWeight: Types.number(500, { min: 100, max: 900, step: 100 }),\n}\n\nexport const CARTESIAN_GRID = {\n /** The lines along the value ticks of a column chart (one per tick); empty draws none. */\n horizontalGrid: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** The lines under the category markers; empty draws none. */\n verticalGrid: Types.stroke([]),\n /** The baseline and the value-axis rule; empty draws none. */\n axisStroke: Types.stroke([]),\n /** Read as the chart is built: whether the category (x) axis row is drawn. */\n showXAxis: Types.boolean(true, { animatable: false }),\n /** Read as the chart is built: whether the value (y) axis column is drawn. */\n showYAxis: Types.boolean(true, { animatable: false }),\n}\n\nexport type LegendPosition = \"bottom\" | \"top\" | \"right\" | \"none\"\nexport type LegendSwatch = \"square\" | \"circle\" | \"line\"\n\nexport const CHART_LEGEND = {\n /** Read as the chart is built: where the legend sits, or `none`. */\n legend: Types.oneOf([\"bottom\", \"top\", \"right\", \"none\"] as const, { animatable: false }),\n swatch: Types.oneOf([\"square\", \"circle\", \"line\"] as const),\n}\n\n/** The type fields, and the two text colours: what every text helper reads. */\nexport interface ChartTextStyle {\n readonly foreground: Fill\n readonly muted: Fill\n readonly fontFamily: string\n readonly fontSize: number\n readonly fontWeight: number\n}\n\n/** The fields every chart's style resolves, whichever groups it spreads. */\nexport interface ChartStyleBase extends ChartTextStyle {\n readonly palette: readonly Fill[]\n readonly background: Fill\n readonly legend: LegendPosition\n readonly swatch: LegendSwatch\n}\n\n/** The cartesian grid fields, for the line and bar charts. */\nexport interface CartesianStyle extends ChartStyleBase {\n readonly horizontalGrid: StrokeResolved[]\n readonly verticalGrid: StrokeResolved[]\n readonly axisStroke: StrokeResolved[]\n readonly showXAxis: boolean\n readonly showYAxis: boolean\n}\n\n/** The rule and track fields a preset restates so its rules read on its background (a chart keeps those it draws). */\nconst _PRESET_RULES = {\n horizontalGrid: CARTESIAN_GRID.horizontalGrid,\n gridStroke: Types.stroke([]),\n spokeStroke: Types.stroke([]),\n track: Types.fill([]),\n}\n\n/** A preset's fields: any chart's, so one preset dresses every chart. */\nexport type ChartStylePreset = StyleInput<typeof CHART_COLORS & typeof CHART_TEXT & typeof _PRESET_RULES>\n\n/** Ready-made looks, each stating every colour so applying one replaces the last. */\nexport const CHART_STYLE_PRESETS = {\n midnight: {\n palette: [...CHART_PALETTE_DEFAULT],\n foreground: \"#f4f4f5\",\n muted: \"#a1a1aa\",\n horizontalGrid: { weight: 2, fill: \"white/15\" },\n gridStroke: { weight: 2, fill: \"white/15\" },\n spokeStroke: { weight: 2, fill: \"white/15\" },\n track: \"white/10\",\n background: [],\n },\n paper: {\n palette: [\"#2563eb\", \"#059669\", \"#d97706\", \"#db2777\", \"#7c3aed\"],\n foreground: \"#1c1917\",\n muted: \"#57534e\",\n horizontalGrid: { weight: 2, fill: \"#1c1917/12\" },\n gridStroke: { weight: 2, fill: \"#1c1917/12\" },\n spokeStroke: { weight: 2, fill: \"#1c1917/12\" },\n track: \"#1c1917/12\",\n background: \"#fafaf9\",\n },\n ember: {\n palette: [\"#d9603b\", \"#8194ad\", \"#e0a93b\", \"#5e9d6b\", \"#9ec85a\"],\n foreground: \"#e9e1d4\",\n muted: \"#8a7f70\",\n horizontalGrid: { weight: 2, fill: \"#2c2820\" },\n gridStroke: { weight: 2, fill: \"#2c2820\" },\n spokeStroke: { weight: 2, fill: \"#2c2820\" },\n track: \"#2c2820\",\n background: \"#15130e\",\n },\n neon: {\n palette: [\"#22d3ee\", \"#a3e635\", \"#f472b6\", \"#facc15\", \"#818cf8\"],\n foreground: \"#ffffff\",\n muted: \"#94a3b8\",\n horizontalGrid: { weight: 2, fill: \"white/10\" },\n gridStroke: { weight: 2, fill: \"white/10\" },\n spokeStroke: { weight: 2, fill: \"white/10\" },\n track: \"white/10\",\n background: [],\n },\n ocean: {\n palette: [\"#0ea5e9\", \"#14b8a6\", \"#6366f1\", \"#38bdf8\", \"#2dd4bf\"],\n foreground: \"#e0f2fe\",\n muted: \"#7dd3fc\",\n horizontalGrid: { weight: 2, fill: \"#7dd3fc/20\" },\n gridStroke: { weight: 2, fill: \"#7dd3fc/20\" },\n spokeStroke: { weight: 2, fill: \"#7dd3fc/20\" },\n track: \"#7dd3fc/20\",\n background: \"#082f49\",\n },\n sunset: {\n palette: [\"#f97316\", \"#ef4444\", \"#ec4899\", \"#f59e0b\", \"#a855f7\"],\n foreground: \"#fff7ed\",\n muted: \"#fdba74\",\n horizontalGrid: { weight: 2, fill: \"#fdba74/20\" },\n gridStroke: { weight: 2, fill: \"#fdba74/20\" },\n spokeStroke: { weight: 2, fill: \"#fdba74/20\" },\n track: \"#fdba74/20\",\n background: [],\n },\n pastel: {\n palette: [\"#a5b4fc\", \"#f9a8d4\", \"#86efac\", \"#fde68a\", \"#7dd3fc\"],\n foreground: \"#f8fafc\",\n muted: \"#cbd5e1\",\n horizontalGrid: { weight: 2, fill: \"white/12\" },\n gridStroke: { weight: 2, fill: \"white/12\" },\n spokeStroke: { weight: 2, fill: \"white/12\" },\n track: \"white/12\",\n background: [],\n },\n mono: {\n palette: [\"#fafafa\", \"#a3a3a3\", \"#737373\", \"#d4d4d4\", \"#525252\"],\n foreground: \"#fafafa\",\n muted: \"#a3a3a3\",\n horizontalGrid: { weight: 2, fill: \"white/12\" },\n gridStroke: { weight: 2, fill: \"white/12\" },\n spokeStroke: { weight: 2, fill: \"white/12\" },\n track: \"white/12\",\n background: [],\n },\n} satisfies Record<string, ChartStylePreset>\n\n/** Series `index`'s colour: its own `fill`, else the palette's, cycled. */\nexport function paletteFill(style: Pick<ChartStyleBase, \"palette\">, index: number, own?: Fill): Fill {\n if (own != null) return own\n const palette = style.palette\n return palette.length > 0 ? palette[index % palette.length] : \"white\"\n}\n\n/** {@link paletteFill} for a series. */\nexport function seriesFill(style: Pick<ChartStyleBase, \"palette\">, series: ChartSeries, index: number): Fill {\n return paletteFill(style, index, series.fill)\n}\n\nfunction face(style: Pick<ChartTextStyle, \"fontFamily\">): Pick<TextStyle, \"fontFamily\"> {\n return style.fontFamily ? { fontFamily: style.fontFamily } : {}\n}\n\n/** Axis markers, spoke labels: muted, at the base size. */\nexport function markerText(style: ChartTextStyle, textAlign: TextStyle[\"textAlign\"] = \"center\"): TextStyle {\n return { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign, fill: style.muted }\n}\n\n/** Axis captions: muted, a step larger and heavier than the markers. */\nexport function titleText(style: ChartTextStyle): TextStyle {\n return {\n ...face(style),\n fontSize: Math.round(style.fontSize * 1.1),\n fontWeight: Math.min(900, style.fontWeight + 100),\n textAlign: \"center\",\n fill: style.muted,\n }\n}\n\n/** Values on marks and legend captions: the foreground, at the base size. */\nexport function valueText(style: ChartTextStyle, textAlign: TextStyle[\"textAlign\"] = \"center\"): TextStyle {\n return { ...face(style), fontSize: style.fontSize, fontWeight: Math.min(900, style.fontWeight + 100), textAlign, fill: style.foreground }\n}\n\n/**\n * The kit axis parts' config from a style. `x` is the axis under the plot;\n * its grid lines are vertical (one per x marker), the `y` axis's horizontal.\n */\nexport function axisConfigOf(style: Pick<CartesianStyle, \"verticalGrid\" | \"horizontalGrid\"> & ChartTextStyle, axis: \"x\" | \"y\"): AxisConfig {\n const gap = Math.round(style.fontSize * 0.6)\n return {\n labelStyle: markerText(style, axis === \"x\" ? \"center\" : \"right\"),\n titleStyle: titleText(style),\n lineStyle: axis === \"x\" ? style.verticalGrid : style.horizontalGrid,\n tickPadding: axis === \"x\" ? { top: gap } : { right: gap },\n titlePadding: axis === \"x\" ? { top: Math.round(gap / 2) } : { right: gap },\n }\n}\n\n/** The kit legend's config: captions in the foreground, the swatch shaped by `swatch`. */\nexport function legendConfigOf(style: ChartTextStyle & Pick<ChartStyleBase, \"swatch\">): LegendConfig {\n const size = Math.max(8, Math.round(style.fontSize * 0.6))\n const marker =\n style.swatch === \"line\"\n ? { width: Math.round(size * 2), height: Math.max(3, Math.round(size / 4)), borderRadius: size }\n : style.swatch === \"circle\"\n ? { width: size, height: size, borderRadius: size / 2 }\n : { width: size, height: size, borderRadius: Math.round(size / 4) }\n return {\n padding: 0,\n textStyle: { ...face(style), fontSize: style.fontSize, fontWeight: style.fontWeight, textAlign: \"left\", fill: style.foreground },\n itemGap: Math.round(style.fontSize * 1.4),\n markerStyle: { ...marker, stroke: [], shadow: [] },\n }\n}\n"]}
|
|
@@ -1,60 +1,45 @@
|
|
|
1
|
-
import { type NodeOf, type Node2D, type Node2DProps } from "@motionscript/sdk";
|
|
1
|
+
import { type NodeOf, type Node2D, type Node2DProps as _Node2DProps } from "@motionscript/sdk";
|
|
2
2
|
import { type Arrival } from "./motion.js";
|
|
3
3
|
import { type AxisConfig, type Range } from "./shared.js";
|
|
4
|
-
export interface VerticalAxisProps extends Node2DProps {
|
|
5
|
-
/** `[min, max]` of the vertical scale the markers are positioned within. */
|
|
6
|
-
range: Range;
|
|
7
|
-
/**
|
|
8
|
-
* Tick values (in data units) to draw up the axis, each placed by its fraction
|
|
9
|
-
* across {@link VerticalAxisProps.range}. Need not be evenly spaced or include
|
|
10
|
-
* the ends.
|
|
11
|
-
*/
|
|
12
|
-
markers: number[];
|
|
13
|
-
/**
|
|
14
|
-
* How each marker is captioned, one per entry of `markers` and in its order.
|
|
15
|
-
* Empty (the default), or short, captions a marker with its bare numeric
|
|
16
|
-
* reading; a chart with a number format on this axis writes them through it.
|
|
17
|
-
*/
|
|
18
|
-
captions: string[];
|
|
19
|
-
/** Marker/caption text style, grid stroke, and gutters — see {@link AxisConfig}. */
|
|
20
|
-
axis: AxisConfig;
|
|
21
|
-
/**
|
|
22
|
-
* Rotated caption drawn in the gutter to the left of the marker column. Empty
|
|
23
|
-
* string (the default) hides it — no caption node is built and no label gutter
|
|
24
|
-
* is reserved.
|
|
25
|
-
*/
|
|
26
|
-
label: string;
|
|
27
|
-
}
|
|
28
|
-
/** How a tick value is captioned — see {@link VerticalAxisProps.captions}. */
|
|
29
|
-
export type MarkerLabel = (value: number) => string;
|
|
30
4
|
/** What a marker's caption reads: the one listed for its value, else its bare reading. */
|
|
31
5
|
export declare function markerCaption(s: {
|
|
32
6
|
readonly markers: readonly number[];
|
|
33
7
|
readonly captions: readonly string[];
|
|
34
8
|
}, value: number): string;
|
|
9
|
+
/** The gap between an axis's markers and the plot, and between the markers and the caption, read off its config. */
|
|
10
|
+
export declare function axisPads(axis: AxisConfig, side: "top" | "right"): {
|
|
11
|
+
tick: number;
|
|
12
|
+
title: number;
|
|
13
|
+
};
|
|
35
14
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* value
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* The
|
|
51
|
-
*
|
|
15
|
+
* A column of right-aligned captions beside the plot: `place(i)` is caption
|
|
16
|
+
* `i`'s centre height in the column (y-up), whose height it is handed. The
|
|
17
|
+
* value axis and a horizontal bar chart's category axis are both this column.
|
|
18
|
+
*/
|
|
19
|
+
export declare function captionColumn(spec: {
|
|
20
|
+
readonly count: number;
|
|
21
|
+
readonly axis: () => AxisConfig;
|
|
22
|
+
readonly text: (i: number) => string;
|
|
23
|
+
readonly place: (i: number, height: number) => number;
|
|
24
|
+
readonly arrivals: () => Readonly<Record<string, Arrival>>;
|
|
25
|
+
readonly opacity?: (i: number) => number;
|
|
26
|
+
readonly label: string;
|
|
27
|
+
}): Node2D;
|
|
28
|
+
/**
|
|
29
|
+
* The numeric vertical axis the cartesian charts share: a column of {@link Text}
|
|
30
|
+
* markers, highest at the top, each centred on its value's fraction across
|
|
31
|
+
* `range` and right-aligned against the plot. Caption and position are bound, so
|
|
32
|
+
* a rescale tweens live; only the marker count is fixed at construction. The
|
|
33
|
+
* resting state is landed.
|
|
52
34
|
*/
|
|
53
35
|
export declare const VerticalAxis: import("@motionscript/sdk").Component<"verticalAxis", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
54
36
|
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
37
|
+
/** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
|
|
55
38
|
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
39
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
56
40
|
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
57
41
|
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
42
|
+
/** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
|
|
58
43
|
readonly label: "";
|
|
59
44
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
60
45
|
}>, {
|
|
@@ -62,18 +47,24 @@ export declare const VerticalAxis: import("@motionscript/sdk").Component<"vertic
|
|
|
62
47
|
readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
63
48
|
readonly slide: import("@motionscript/sdk").Type<number, number, false>;
|
|
64
49
|
};
|
|
65
|
-
}, null, Node2D<
|
|
50
|
+
}, null, Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
66
51
|
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
52
|
+
/** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
|
|
67
53
|
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
54
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
68
55
|
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
69
56
|
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
57
|
+
/** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
|
|
70
58
|
readonly label: "";
|
|
71
59
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
72
60
|
}>, null, import("@motionscript/sdk").BuiltNode<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
73
61
|
readonly range: import("@motionscript/sdk").Type<Range, Range, false>;
|
|
62
|
+
/** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */
|
|
74
63
|
readonly markers: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
64
|
+
/** One caption per marker in its order; a missing one reads as the bare numeric value. */
|
|
75
65
|
readonly captions: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
76
66
|
readonly axis: import("@motionscript/sdk").Type<AxisConfig, AxisConfig, false>;
|
|
67
|
+
/** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */
|
|
77
68
|
readonly label: "";
|
|
78
69
|
readonly arrivals: import("@motionscript/sdk").Type<Readonly<Record<string, Arrival>>, Readonly<Record<string, Arrival>>, false>;
|
|
79
70
|
}>, {
|
|
@@ -81,6 +72,6 @@ export declare const VerticalAxis: import("@motionscript/sdk").Component<"vertic
|
|
|
81
72
|
readonly stagger: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
82
73
|
readonly slide: import("@motionscript/sdk").Type<number, number, false>;
|
|
83
74
|
};
|
|
84
|
-
}, Node2D<
|
|
75
|
+
}, Node2D<_Node2DProps>>>>;
|
|
85
76
|
export type VerticalAxis = NodeOf<typeof VerticalAxis>;
|
|
86
77
|
//# sourceMappingURL=vertical-axis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertical-axis.d.ts","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"vertical-axis.d.ts","sourceRoot":"","sources":["../../src/kit/vertical-axis.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,MAAM,EAEX,KAAK,MAAM,EACX,KAAK,WAAW,IAAI,YAAY,EACjC,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EAA8D,KAAK,OAAO,EAAE,MAAM,UAAU,CAAA;AACnG,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAIjB,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,CAAC,EAAE;IAAE,QAAQ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