@motionscript/charts 0.1.0 → 0.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/bar-chart/bar-chart.d.ts +22 -93
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +48 -121
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +11 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +15 -38
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +43 -74
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +31 -59
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -10
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +0 -7
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +27 -90
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +15 -54
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-4SMRCU24.js +2 -0
- package/dist/browser/chunks/chunk-4SMRCU24.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +4 -16
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +4 -16
- package/dist/engine.js.map +1 -1
- package/dist/kit/cartesian.d.ts +8 -28
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +7 -19
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-border.d.ts +9 -18
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +4 -9
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +25 -36
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +13 -13
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +14 -61
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +17 -65
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +2 -0
- package/dist/kit/entries.d.ts.map +1 -1
- package/dist/kit/entries.js +2 -0
- package/dist/kit/entries.js.map +1 -1
- package/dist/kit/motion.d.ts +11 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +7 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/kit/shared.d.ts +60 -175
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +40 -157
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +16 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +17 -42
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +16 -41
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +14 -43
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -27
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +8 -22
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +16 -43
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +13 -42
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +1 -13
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +0 -12
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +23 -109
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +45 -141
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +33 -107
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +28 -81
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +14 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +29 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +0 -12
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -12
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +1 -12
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +0 -9
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +37 -71
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +31 -65
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +11 -26
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +14 -39
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +50 -192
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +75 -247
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +45 -131
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +29 -72
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +51 -165
- package/src/bar-chart/category-axis.ts +16 -57
- package/src/bar-chart/chart-bars.ts +43 -120
- package/src/bar-chart/index.ts +2 -10
- package/src/bar-chart/shared.ts +29 -97
- package/src/engine.ts +4 -16
- package/src/kit/cartesian.ts +11 -26
- package/src/kit/chart-border.ts +6 -20
- package/src/kit/chart-canvas.ts +15 -40
- package/src/kit/chart-legend.ts +17 -86
- package/src/kit/entries.ts +4 -1
- package/src/kit/motion.ts +11 -2
- package/src/kit/shared.ts +58 -219
- package/src/kit/vertical-axis.ts +18 -71
- package/src/line-chart/chart-line.ts +16 -44
- package/src/line-chart/chart-region.ts +10 -23
- package/src/line-chart/horizontal-axis.ts +13 -42
- package/src/line-chart/index.ts +1 -13
- package/src/line-chart/line-chart.ts +50 -184
- package/src/line-chart/shared.ts +51 -145
- package/src/line-chart/x-scale.ts +31 -121
- package/src/nodes.ts +0 -12
- package/src/pie-chart/index.ts +1 -12
- package/src/pie-chart/pie-chart.ts +34 -102
- package/src/pie-chart/pie-legend.ts +14 -55
- package/src/pie-chart/pie-ring.ts +80 -307
- package/src/pie-chart/shared.ts +50 -139
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
package/dist/kit/shared.d.ts
CHANGED
|
@@ -1,111 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* What every chart shares: series, axis scaling and formatting, and the theme
|
|
3
|
+
* leaves each chart's theme is assembled from. No `Node` imports, so a host's
|
|
4
|
+
* inspector mappings can build a partial theme without the components.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* label, and a theme is a tree of paints with one mapper and one tween. Writing
|
|
12
|
-
* that three times would mean three answers to "how does a chart round its axis"
|
|
13
|
-
* within one app.
|
|
14
|
-
*
|
|
15
|
-
* Kept renderer-agnostic (no `Node` imports) so a host's own inspector
|
|
16
|
-
* mappings can build a partial theme without pulling the components in.
|
|
17
|
-
*
|
|
18
|
-
* **Two conventions run through every resolver and lerp below**, inherited from
|
|
19
|
-
* the shape system's `resolveStroke`/`resolveShadow`:
|
|
20
|
-
*
|
|
21
|
-
* - A **mapper** merges the author's loose, partial input onto a `previous`
|
|
22
|
-
* resolved value and resolves every leaf, so the tween always has resolved
|
|
23
|
-
* data to interpolate. It is idempotent.
|
|
24
|
-
* - A **tween** interpolates two resolved values leaf by leaf. Categorical
|
|
25
|
-
* fields (`fontFamily`, `textAlign`) and fields that are `undefined` on either
|
|
26
|
-
* side **step at the midpoint**, because there is no meaningful in-between and
|
|
27
|
-
* defaulting the missing side to 0 would animate a font weight down to nothing
|
|
28
|
-
* on the way to "unset".
|
|
6
|
+
* A mapper merges partial input onto a `previous` resolved value (idempotent). A
|
|
7
|
+
* tween interpolates two resolved values leaf by leaf, but categorical fields
|
|
8
|
+
* (`fontFamily`, `textAlign`) and any field `undefined` on either side step at
|
|
9
|
+
* the midpoint: defaulting the missing side to 0 would animate a font weight
|
|
10
|
+
* down to nothing on the way to "unset".
|
|
29
11
|
*/
|
|
30
12
|
import { type DataRecord, type Fill, type Insets, type Shadow, type Stroke, type TextStyle } from "@motionscript/sdk";
|
|
31
|
-
/**
|
|
32
|
-
* One series of a chart: a column of the table, captioned and painted.
|
|
33
|
-
*
|
|
34
|
-
* `field` names the column carrying this series' values. What that becomes is
|
|
35
|
-
* the chart's business — a traced polyline, a column of bars, a wedge — but the
|
|
36
|
-
* three questions asked of it are the same everywhere: which column, what to
|
|
37
|
-
* call it, what to paint it, and whether it is currently drawn.
|
|
38
|
-
*
|
|
39
|
-
* `fill` is an **override**: omit it and the series takes the theme palette's
|
|
40
|
-
* entry for its own index, which is what makes a chart nobody has themed come
|
|
41
|
-
* out in five distinct colours rather than five identical ones.
|
|
42
|
-
*/
|
|
13
|
+
/** One series of a chart: a column of the table, captioned and painted. */
|
|
43
14
|
export interface ChartSeries {
|
|
44
15
|
/** Key into each data row for this series' value. */
|
|
45
16
|
field: string;
|
|
46
|
-
/** Legend caption for this series. */
|
|
47
17
|
label: string;
|
|
48
|
-
/**
|
|
49
|
-
* Paint override for this series' mark and its legend swatch. Omit to take
|
|
50
|
-
* the theme palette's entry for this series' index.
|
|
51
|
-
*/
|
|
18
|
+
/** Overrides the theme palette's entry for this series' index, for its mark and legend swatch. */
|
|
52
19
|
fill?: Fill;
|
|
53
|
-
/**
|
|
20
|
+
/** Defaults to `true`. */
|
|
54
21
|
enabled?: boolean;
|
|
55
22
|
}
|
|
56
23
|
/** A `[min, max]` numeric range in data units. */
|
|
57
24
|
export type Range = [min: number, max: number];
|
|
58
|
-
/**
|
|
59
|
-
* One axis's *data* domain — what it shows — as opposed to {@link AxisConfig},
|
|
60
|
-
* which is how it's *styled*. Every field is optional: `range`/`ticks` derive
|
|
61
|
-
* from the plotted data when omitted, and `label` defaults to `""`.
|
|
62
|
-
*/
|
|
25
|
+
/** One axis's *data* domain, as opposed to {@link AxisConfig}, which is how it is styled. */
|
|
63
26
|
export interface AxisDomainConfig {
|
|
64
|
-
/** Caption drawn alongside the axis
|
|
27
|
+
/** Caption drawn alongside the axis; `""` hides it. */
|
|
65
28
|
label?: string;
|
|
66
|
-
/**
|
|
29
|
+
/** Derived from the data bounds when omitted. */
|
|
67
30
|
range?: Range;
|
|
68
|
-
/**
|
|
31
|
+
/** Derived (five evenly spaced) when omitted. */
|
|
69
32
|
ticks?: number[];
|
|
70
33
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* Here rather than in {@link AxisConfig} because it is a statement about the
|
|
75
|
-
* *numbers*, not about the ink they are set in: `$` on a revenue axis says
|
|
76
|
-
* what the column holds, and it has to survive a re-theme. It sits beside
|
|
77
|
-
* `range` and `ticks` for the same reason those do.
|
|
34
|
+
* A `number-format` pattern such as `#,##0.00` or `$#,##0`. It lives here, not
|
|
35
|
+
* in {@link AxisConfig}, because it says what the column holds and has to
|
|
36
|
+
* survive a re-theme.
|
|
78
37
|
*/
|
|
79
38
|
format?: string;
|
|
80
39
|
}
|
|
40
|
+
/** An {@link AxisDomainConfig} with `range` and `ticks` worked out. */
|
|
41
|
+
export type ResolvedAxisDomain = AxisDomainConfig & {
|
|
42
|
+
readonly range: Range;
|
|
43
|
+
readonly ticks: number[];
|
|
44
|
+
};
|
|
81
45
|
/**
|
|
82
|
-
*
|
|
83
|
-
* `
|
|
84
|
-
*
|
|
85
|
-
* after the merge is the auto-derive signal the scale getters read.
|
|
46
|
+
* Merges partial input onto `previous`, so a later `.set({ yAxis: {...} })`
|
|
47
|
+
* patches `label`/`range`/`ticks` independently. An unset `range`/`ticks` is the
|
|
48
|
+
* auto-derive signal.
|
|
86
49
|
*/
|
|
87
50
|
export declare function resolveAxisDomain(domain: AxisDomainConfig | undefined, previous?: AxisDomainConfig): AxisDomainConfig;
|
|
88
51
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* auto-derive mode, step at the midpoint.
|
|
52
|
+
* Interpolates `range` and `ticks` numerically (ticks pairwise by index).
|
|
53
|
+
* `label`, `format`, and either field when one side is auto, step at the
|
|
54
|
+
* midpoint: there is no halfway between `$#,##0` and `0.0%`.
|
|
93
55
|
*/
|
|
94
56
|
export declare function lerpAxisDomain(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig;
|
|
95
|
-
/**
|
|
96
|
-
* Where a generic `to()` of an axis domain should land, given the domain as it
|
|
97
|
-
* is *drawn* (`drawn`, with `range` and `ticks` resolved off the data), or
|
|
98
|
-
* `undefined` when the request states neither a `range` nor `ticks` and the
|
|
99
|
-
* plain property tween will do.
|
|
100
|
-
*
|
|
101
|
-
* The stored domain of an auto axis has no `range` and no `ticks`, and
|
|
102
|
-
* {@link lerpAxisDomain} steps an unset side at the midpoint, so tweening the
|
|
103
|
-
* stored value from an auto axis is a cut. The charts therefore tween between
|
|
104
|
-
* resolved domains, as their zoom does; this builds the destination. A `range`
|
|
105
|
-
* given without `ticks` keeps the tick *count* the axis already draws, so each
|
|
106
|
-
* marker slides from its old value to its new one instead of the row popping.
|
|
107
|
-
*/
|
|
108
|
-
export declare function axisTweenTarget(drawn: AxisDomainConfig, requested: AxisDomainConfig | undefined): AxisDomainConfig | undefined;
|
|
109
57
|
/**
|
|
110
58
|
* An axis domain part-way through a tween that leaves or reaches a `range` or
|
|
111
59
|
* `ticks` left to the data: both ends as stored, and how far along. Only the
|
|
@@ -121,90 +69,55 @@ export interface AxisDomainBlend extends AxisDomainConfig {
|
|
|
121
69
|
};
|
|
122
70
|
}
|
|
123
71
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* draws: a rescale from an auto axis is continuous, not a cut at the midpoint.
|
|
72
|
+
* The axis entry tween behind `to({ yAxis: { range } })`. Between explicit
|
|
73
|
+
* domains it is {@link lerpAxisDomain}, and a restated `range` without `ticks`
|
|
74
|
+
* spreads ticks across it, keeping their count. When either end leaves `range`
|
|
75
|
+
* or `ticks` to the data, the value between is an {@link AxisDomainBlend}, so a
|
|
76
|
+
* rescale from an auto axis is continuous rather than a cut at the midpoint.
|
|
130
77
|
*/
|
|
131
78
|
export declare function lerpAxisEntry(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig;
|
|
132
|
-
/**
|
|
133
|
-
* `domain` as the chart draws it: `drawn` resolves a plain domain's auto `range`
|
|
134
|
-
* and `ticks` off the data, and a blend is the lerp of what its two ends draw.
|
|
135
|
-
*/
|
|
79
|
+
/** `domain` as drawn: `drawn` resolves a plain domain's auto `range` and `ticks`; a blend is the lerp of what its ends draw. */
|
|
136
80
|
export declare function settleAxisDomain(domain: AxisDomainConfig, drawn: (domain: AxisDomainConfig) => AxisDomainConfig): AxisDomainConfig;
|
|
137
|
-
/**
|
|
138
|
-
* The low-level colour tokens the default themes are built from — a dark plot
|
|
139
|
-
* panel with warm-grey axis furniture.
|
|
140
|
-
*/
|
|
81
|
+
/** The colour tokens the default themes are built from: a dark plot panel with warm-grey axis furniture. */
|
|
141
82
|
export declare const CHART_PALETTE: {
|
|
142
|
-
/** Fill of the plot panel behind the marks. */
|
|
143
83
|
readonly plotFill: "#15130e";
|
|
144
|
-
/** Colour of the plot's thick border. */
|
|
145
84
|
readonly borderColor: "#4a4036";
|
|
146
|
-
/** Colour of the faint grid lines spanning the plot. */
|
|
147
85
|
readonly gridColor: "#2c2820";
|
|
148
|
-
/**
|
|
86
|
+
/** Axis markers, axis captions and legend labels. */
|
|
149
87
|
readonly markerColor: "#8a7f70";
|
|
150
|
-
/**
|
|
88
|
+
/** A spotlit region's dashed rules and wash. */
|
|
151
89
|
readonly regionColor: "#d99a3a";
|
|
152
90
|
};
|
|
153
91
|
/** The out-of-the-box series palette, cycled by series index. */
|
|
154
92
|
export declare const DEFAULT_SERIES_COLORS: readonly ["#d9603b", "#8194ad", "#e0a93b", "#5e9d6b", "#9ec85a"];
|
|
155
|
-
/**
|
|
156
|
-
* Opacity an *un*-spotlighted series fades to — its mark and its legend entry
|
|
157
|
-
* alike, so the two dim together.
|
|
158
|
-
*/
|
|
93
|
+
/** Opacity an un-spotlighted series fades to, mark and legend entry alike. */
|
|
159
94
|
export declare const SPOTLIGHT_DIM = 0.2;
|
|
160
|
-
/** Clamp a number into `[0, 1]` — the range every reveal signal here runs in. */
|
|
161
|
-
export declare function clampUnit(value: number): number;
|
|
162
95
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* A column left as strings silently plots as 0, which is why the CSV parser's
|
|
167
|
-
* numeric auto-coercion matters — a quoted or unit-suffixed column won't plot
|
|
168
|
-
* until it's coerced.
|
|
96
|
+
* Reads a numeric field off a row. A string column plots as 0, so a quoted or
|
|
97
|
+
* unit-suffixed column needs the CSV parser's numeric coercion first.
|
|
169
98
|
*/
|
|
170
99
|
export declare function num(row: DataRecord, field: string | undefined): number;
|
|
171
|
-
/**
|
|
172
|
-
* Read a field off a row as its caption — the counterpart to {@link num} for
|
|
173
|
-
* the columns a chart *names* things by rather than measures them by (a bar's
|
|
174
|
-
* category, a wedge's slice). A missing cell reads as empty rather than as the
|
|
175
|
-
* string `"undefined"`.
|
|
176
|
-
*/
|
|
100
|
+
/** The counterpart to {@link num} for the columns a chart names things by; a missing cell reads as empty, not `"undefined"`. */
|
|
177
101
|
export declare function text(row: DataRecord, field: string | undefined): string;
|
|
178
102
|
/**
|
|
179
|
-
* Every column
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* A column counts as numeric only if every non-empty cell in it is a number, so
|
|
183
|
-
* a stray text cell leaves the column out rather than plotting zeros. This is
|
|
184
|
-
* what lets a chart plot "every other column" without the author naming twenty
|
|
185
|
-
* fields.
|
|
103
|
+
* Every numeric column of `data` in header order, skipping `exclude`. A column
|
|
104
|
+
* is numeric only if every non-empty cell is a number, so a stray text cell
|
|
105
|
+
* drops the column rather than plotting zeros.
|
|
186
106
|
*/
|
|
187
107
|
export declare function numericFields(data: DataRecord[], exclude?: string[]): string[];
|
|
188
108
|
/** One axis's (x or y) style vocabulary. */
|
|
189
109
|
export interface AxisConfig {
|
|
190
110
|
/** Style of each marker along the axis. */
|
|
191
111
|
labelStyle: TextStyle;
|
|
192
|
-
/** Style of the axis caption. */
|
|
193
112
|
titleStyle: TextStyle;
|
|
194
|
-
/**
|
|
195
|
-
* This axis's direction of the plot's internal grid — weight+fill honoured,
|
|
196
|
-
* dash/cap/join ignored (grid lines are drawn as filled rects).
|
|
197
|
-
*/
|
|
113
|
+
/** This axis's grid lines: weight and fill honoured, dash/cap/join ignored (they are filled rects). */
|
|
198
114
|
lineStyle: Stroke;
|
|
199
|
-
/**
|
|
200
|
-
* Gap between the plot and the marker row. Only the side facing the plot is
|
|
201
|
-
* read — `.top` for a horizontal axis, `.right` for a vertical one.
|
|
202
|
-
*/
|
|
115
|
+
/** Gap between the plot and the marker row; only the side facing the plot is read (`.top` horizontal, `.right` vertical). */
|
|
203
116
|
tickPadding: Insets;
|
|
204
117
|
/** Gap between the marker row and the caption, read the same side. */
|
|
205
118
|
titlePadding: Insets;
|
|
206
119
|
}
|
|
207
|
-
/** A legend's per-series colour swatch
|
|
120
|
+
/** A legend's per-series colour swatch. */
|
|
208
121
|
export interface LegendMarkerConfig {
|
|
209
122
|
width: number;
|
|
210
123
|
height: number;
|
|
@@ -212,12 +125,10 @@ export interface LegendMarkerConfig {
|
|
|
212
125
|
stroke: Stroke;
|
|
213
126
|
shadow: Shadow;
|
|
214
127
|
}
|
|
215
|
-
/** A legend's visual theme. */
|
|
216
128
|
export interface LegendConfig {
|
|
217
129
|
padding: Insets;
|
|
218
|
-
/**
|
|
130
|
+
/** Only the swatch carries the series colour. */
|
|
219
131
|
textStyle: TextStyle;
|
|
220
|
-
/** Gap between legend entries. */
|
|
221
132
|
itemGap: number;
|
|
222
133
|
markerStyle: LegendMarkerConfig;
|
|
223
134
|
}
|
|
@@ -227,33 +138,26 @@ export interface PlotAreaConfig {
|
|
|
227
138
|
fill: Fill;
|
|
228
139
|
shadow: Shadow;
|
|
229
140
|
}
|
|
230
|
-
/** The default styling of a horizontal (marker row beneath the plot) axis. */
|
|
231
141
|
export declare const DEFAULT_X_AXIS: AxisConfig;
|
|
232
|
-
/** The default styling of a vertical (marker column beside the plot) axis. */
|
|
233
142
|
export declare const DEFAULT_Y_AXIS: AxisConfig;
|
|
234
|
-
/**
|
|
235
|
-
* The default plot panel: **unpainted**, framed. A chart reads against the
|
|
236
|
-
* stage rather than punching a panel into it, which is the look the family was
|
|
237
|
-
* designed at.
|
|
238
|
-
*/
|
|
143
|
+
/** Unpainted but framed: a chart reads against the stage rather than punching a panel into it. */
|
|
239
144
|
export declare const DEFAULT_PLOT_AREA: PlotAreaConfig;
|
|
240
|
-
/** The default legend styling, shared by every chart that draws one. */
|
|
241
145
|
export declare const DEFAULT_LEGEND: LegendConfig;
|
|
242
|
-
/**
|
|
146
|
+
/** {@link DEFAULT_SERIES_COLORS} as 4px strokes. */
|
|
243
147
|
export declare const DEFAULT_SERIES_STROKES: Stroke[];
|
|
244
|
-
/**
|
|
148
|
+
/** {@link DEFAULT_SERIES_COLORS} as solid fills. */
|
|
245
149
|
export declare const DEFAULT_SERIES_FILLS: Fill[];
|
|
246
150
|
export declare function resolveAxisConfig(axis: Partial<AxisConfig> | undefined, previous: AxisConfig): AxisConfig;
|
|
247
151
|
export declare function lerpAxisConfig(from: AxisConfig, to: AxisConfig, t: number): AxisConfig;
|
|
248
152
|
export declare function resolvePlotArea(plotArea: Partial<PlotAreaConfig> | undefined, previous: PlotAreaConfig): PlotAreaConfig;
|
|
249
153
|
export declare function lerpPlotArea(from: PlotAreaConfig, to: PlotAreaConfig, t: number): PlotAreaConfig;
|
|
250
|
-
/** A legend theme as the author may state it
|
|
154
|
+
/** A legend theme as the author may state it: every branch optional. */
|
|
251
155
|
export type LegendTheme = Partial<Omit<LegendConfig, "markerStyle">> & {
|
|
252
156
|
markerStyle?: Partial<LegendMarkerConfig>;
|
|
253
157
|
};
|
|
254
158
|
export declare function resolveLegendConfig(legend: LegendTheme | undefined, previous: LegendConfig): LegendConfig;
|
|
255
159
|
export declare function lerpLegendConfig(from: LegendConfig, to: LegendConfig, t: number): LegendConfig;
|
|
256
|
-
/** A
|
|
160
|
+
/** A palette override replaces the previous palette outright. */
|
|
257
161
|
export declare function resolveSeriesStrokes(styles: Stroke[] | undefined, previous: Stroke[]): Stroke[];
|
|
258
162
|
/** Pairwise by index; a palette that grows/shrinks holds the longer side's tail. */
|
|
259
163
|
export declare function lerpSeriesStrokes(from: Stroke[], to: Stroke[], t: number): Stroke[];
|
|
@@ -262,34 +166,16 @@ export declare function resolveSeriesFills(fills: Fill[] | undefined, previous:
|
|
|
262
166
|
/** The fill-palette twin of {@link lerpSeriesStrokes}. */
|
|
263
167
|
export declare function lerpSeriesFills(from: Fill[], to: Fill[], t: number): Fill[];
|
|
264
168
|
/**
|
|
265
|
-
* The
|
|
266
|
-
*
|
|
267
|
-
* the last (topmost) layer's colour.
|
|
169
|
+
* The stroke for series `index`: the palette's entry at `index % palette.length`,
|
|
170
|
+
* with the series' own `fill`, if set, replacing just the topmost layer's colour.
|
|
268
171
|
*/
|
|
269
172
|
export declare function resolveSeriesStroke(palette: Stroke[], series: ChartSeries, index: number): Stroke;
|
|
270
|
-
/**
|
|
271
|
-
* The effective *colour* for series `index` — the same colour
|
|
272
|
-
* {@link resolveSeriesStroke} draws its line in — for contexts (a legend
|
|
273
|
-
* swatch) that only need the fill.
|
|
274
|
-
*/
|
|
173
|
+
/** The colour {@link resolveSeriesStroke} draws series `index` in, for a legend swatch. */
|
|
275
174
|
export declare function resolveSeriesFill(palette: Stroke[], series: ChartSeries, index: number): Fill;
|
|
276
175
|
/**
|
|
277
|
-
*
|
|
278
|
-
* the
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
* The stroke twin above has to reach inside a stroke to swap one layer's colour;
|
|
282
|
-
* a filled mark has no such geometry wrapped around its paint, so an override is
|
|
283
|
-
* simply the whole answer.
|
|
284
|
-
*/
|
|
285
|
-
export declare function resolvePalettePaint(palette: Fill[], override: Fill | undefined, index: number): Fill;
|
|
286
|
-
/**
|
|
287
|
-
* Format a marker value: integers plain, otherwise trimmed to one decimal, or to
|
|
288
|
-
* as many as the axis's tick `step` needs to tell neighbouring ticks apart.
|
|
289
|
-
*
|
|
290
|
-
* One decimal is the floor, so a step of 0.1 or more reads exactly as it always
|
|
291
|
-
* has; a finer step (a unit axis ticked every 0.05) gets two, instead of five
|
|
292
|
-
* ticks captioned `0.1 0.1 0.2 0.2 0.3`. Trailing zeros are dropped either way.
|
|
176
|
+
* Format a marker value: integers plain, otherwise one decimal, or as many as
|
|
177
|
+
* the tick `step` needs to tell neighbours apart (a unit axis ticked every 0.05
|
|
178
|
+
* gets two, not `0.1 0.1 0.2 0.2 0.3`). Trailing zeros are dropped.
|
|
293
179
|
*/
|
|
294
180
|
export declare function formatMarker(value: number, step?: number): string;
|
|
295
181
|
/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */
|
|
@@ -298,5 +184,4 @@ export declare function markerStep(markers: readonly number[]): number | undefin
|
|
|
298
184
|
export declare function formatPercent(fraction: number): string;
|
|
299
185
|
/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */
|
|
300
186
|
export declare function markerValues([min, max]: Range, markerCount: number): number[];
|
|
301
|
-
export { niceStep, enterBudget } from "@motionscript/sdk/component";
|
|
302
187
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/kit/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAOL,KAAK,UAAU,EACf,KAAK,IAAI,EAET,KAAK,MAAM,EAEX,KAAK,MAAM,EAEX,KAAK,MAAM,EAEX,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAA;AAE1B,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,kGAAkG;IAClG,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,0BAA0B;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAE9C,6FAA6F;AAC7F,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAAE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