expressive-charts 0.3.0 → 0.4.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 +40 -1
- package/README.md +6 -6
- package/dist/define-DeZLs1h7.js +95 -0
- package/dist/define-DeZLs1h7.js.map +1 -0
- package/dist/drawing-Dz_IvJPB.d.cts +208 -0
- package/dist/drawing-Dz_IvJPB.d.ts +208 -0
- package/dist/effect-CdH5449m.d.ts +232 -0
- package/dist/effect-uYC8Vs6_.d.cts +232 -0
- package/dist/expressive-charts.css +2 -0
- package/dist/expressive-charts.css.d.cts +1 -2
- package/dist/expressive-charts.css.d.ts +1 -2
- package/dist/expressive-charts.global.js +45 -47
- package/dist/expressive-charts.global.js.map +1 -1
- package/dist/icons/sport.cjs +211 -156
- package/dist/icons/sport.cjs.map +1 -1
- package/dist/icons/sport.d.cts +5 -7
- package/dist/icons/sport.d.ts +5 -7
- package/dist/icons/sport.js +122 -71
- package/dist/icons/sport.js.map +1 -1
- package/dist/index.cjs +12632 -9979
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +913 -871
- package/dist/index.d.ts +913 -871
- package/dist/index.js +10444 -8232
- package/dist/index.js.map +1 -1
- package/dist/path-data-DnEckjY8.js +123 -0
- package/dist/path-data-DnEckjY8.js.map +1 -0
- package/dist/testing.cjs +2030 -1252
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +135 -139
- package/dist/testing.d.ts +135 -139
- package/dist/testing.js +696 -499
- package/dist/testing.js.map +1 -1
- package/dist/transition-DSRt2DH3.js +2053 -0
- package/dist/transition-DSRt2DH3.js.map +1 -0
- package/package.json +6 -6
- package/dist/chunk-7A7LXXT4.js +0 -70
- package/dist/chunk-7A7LXXT4.js.map +0 -1
- package/dist/chunk-CJUQHEX6.js +0 -618
- package/dist/chunk-CJUQHEX6.js.map +0 -1
- package/dist/chunk-N2BLUETM.js +0 -1194
- package/dist/chunk-N2BLUETM.js.map +0 -1
- package/dist/drawing-CdTgixMY.d.cts +0 -206
- package/dist/drawing-CdTgixMY.d.ts +0 -206
- package/dist/effect-Bu3MHHeg.d.ts +0 -247
- package/dist/effect-D4vmdYP4.d.cts +0 -247
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
interface Point {
|
|
2
|
-
readonly x: number;
|
|
3
|
-
readonly y: number;
|
|
4
|
-
}
|
|
5
|
-
interface Rect {
|
|
6
|
-
readonly x: number;
|
|
7
|
-
readonly y: number;
|
|
8
|
-
readonly width: number;
|
|
9
|
-
readonly height: number;
|
|
10
|
-
}
|
|
11
|
-
interface Outline {
|
|
12
|
-
/** SVG path data in the mark's coordinate space. */
|
|
13
|
-
readonly d: string;
|
|
14
|
-
/** True for areas (bars, slices, markers), false for strokes (lines). */
|
|
15
|
-
readonly closed: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Closed outlines: n points (n a multiple of 4), walking clockwise on screen from the start-left
|
|
18
|
-
* corner, n/4 per side in the order left, end, right, start, evenly spaced along each side. The
|
|
19
|
-
* corners are at indices 0, n/4, n/2 and 3n/4. Open outlines: n points along the stroke, from
|
|
20
|
-
* start to end inclusive. Morph depends on this.
|
|
21
|
-
*/
|
|
22
|
-
sample(n: number): readonly Point[];
|
|
23
|
-
}
|
|
24
|
-
interface MarkGeometry {
|
|
25
|
-
/** Stable identity across updates. Segments are keyed "<mark key>/<series>". */
|
|
26
|
-
readonly key: string;
|
|
27
|
-
/** The series this mark or segment belongs to, if any ("goals", "xg"). */
|
|
28
|
-
readonly series?: string;
|
|
29
|
-
/** Equals path(0). */
|
|
30
|
-
readonly start: Point;
|
|
31
|
-
/** Equals path(1). */
|
|
32
|
-
readonly end: Point;
|
|
33
|
-
/** Length of the walk in px; 0 for marks with no direction (a scatter dot). */
|
|
34
|
-
readonly length: number;
|
|
35
|
-
/** t in [0, 1], proportional to distance along the walk. Values outside are clamped. */
|
|
36
|
-
path(t: number): Point;
|
|
37
|
-
/** Direction of travel in radians, in (-PI, PI]; the mark's "up" side is angle - PI/2. */
|
|
38
|
-
angle(t: number): number;
|
|
39
|
-
/** SVG path data for the part of the walk between t0 and t1, in either order. It leaves out the gaps. */
|
|
40
|
-
slice(t0: number, t1: number): string;
|
|
41
|
-
/**
|
|
42
|
-
* The stretches of the walk with no data, as [from, to] values of t, in order and apart: each with
|
|
43
|
-
* 0 ≤ from < to ≤ 1, ending at or before the next starts. A line that skips a value has one, from
|
|
44
|
-
* the value before to the value after. The walk runs straight across a gap, so `path` and `angle`
|
|
45
|
-
* work as on any walk, and `outline.sample(n)` runs along it all; `slice()` and an open outline's
|
|
46
|
-
* `d` leave the gaps out, with a moveto across each. Unset means none.
|
|
47
|
-
*/
|
|
48
|
-
readonly gaps?: readonly (readonly [from: number, to: number])[];
|
|
49
|
-
/** Px across the walk: bar height, ring width, stroke width, marker diameter. */
|
|
50
|
-
readonly thickness: number;
|
|
51
|
-
readonly outline: Outline;
|
|
52
|
-
readonly bounds: Rect;
|
|
53
|
-
/** Visual centre: tooltips, focus rings, labels. */
|
|
54
|
-
readonly center: Point;
|
|
55
|
-
/** Where the mark is attached to the chart: a bar's baseline, a donut's centre. */
|
|
56
|
-
readonly pivot: Point;
|
|
57
|
-
/**
|
|
58
|
-
* The boxes of the text the chart draws for this mark, so an effect's text can keep clear of
|
|
59
|
-
* them: a bar's category and value labels, a slice's label outside the ring, a line's end label.
|
|
60
|
-
* Unset when nothing says where they are (segments, points, and marks the library didn't draw).
|
|
61
|
-
*/
|
|
62
|
-
readonly labelBounds?: readonly Rect[];
|
|
63
|
-
/** Ordered parts, from the baseline (goals, then assists). Every bar has at least one. */
|
|
64
|
-
readonly segments?: readonly MarkGeometry[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** One path of an icon, drawn in order (the first is at the bottom). */
|
|
68
|
-
interface IconShape {
|
|
69
|
-
/** Path data in icon units. */
|
|
70
|
-
readonly d: string;
|
|
71
|
-
/** Unset draws no fill (unlike SVG, where it's black). */
|
|
72
|
-
readonly fill?: Color;
|
|
73
|
-
/** Unset draws no stroke. */
|
|
74
|
-
readonly stroke?: Color;
|
|
75
|
-
/** Stroke width in icon units, so it scales with the icon. Default 1. */
|
|
76
|
-
readonly width?: number;
|
|
77
|
-
/** Default "butt". */
|
|
78
|
-
readonly linecap?: "butt" | "round";
|
|
79
|
-
/** Default "miter". */
|
|
80
|
-
readonly linejoin?: "miter" | "round";
|
|
81
|
-
/** Path data, in icon units, that clips this shape (the ball's panel pattern). */
|
|
82
|
-
readonly clip?: string;
|
|
83
|
-
/** Default "nonzero". "evenodd" leaves a hole where the path's parts overlap, as solid icon sets draw them. */
|
|
84
|
-
readonly fillRule?: "nonzero" | "evenodd";
|
|
85
|
-
/** From 0 to 1, for the whole shape, fill and stroke together (a duotone set's lighter part). Default 1. */
|
|
86
|
-
readonly opacity?: number;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Build one with defineIcon() or iconFromSvg(), which fill the defaults and check it. Icon units
|
|
90
|
-
* are px at the icon's natural size: `layer.icon(icon, { size })` scales it by size / icon.size
|
|
91
|
-
* about its anchor before `place()`.
|
|
92
|
-
*/
|
|
93
|
-
interface Icon {
|
|
94
|
-
readonly name: string;
|
|
95
|
-
/** Drawn facing +x, with its up side towards −y, in icon units. */
|
|
96
|
-
readonly shapes: readonly IconShape[];
|
|
97
|
-
/** Icon-space bounds. */
|
|
98
|
-
readonly box: Rect;
|
|
99
|
-
/** The natural length along the walk, in px (and icon units). */
|
|
100
|
-
readonly size: number;
|
|
101
|
-
/** The icon-space point that sits on the walk. */
|
|
102
|
-
readonly anchor: Point;
|
|
103
|
-
/** What it spins or tilts around. */
|
|
104
|
-
readonly pivot: Point;
|
|
105
|
-
/** Extent along +x from the anchor, which travel keeps inside the mark. */
|
|
106
|
-
readonly footprint: readonly [behind: number, ahead: number];
|
|
107
|
-
/** The gait travel uses unless it's given one. */
|
|
108
|
-
readonly gait?: "roll" | "step" | "slide";
|
|
109
|
-
/** Rolling radius; default box height / 2. */
|
|
110
|
-
readonly radius?: number;
|
|
111
|
-
/** Mirror instead of turning upside down (a boot keeps its sole down). */
|
|
112
|
-
readonly upright?: boolean;
|
|
113
|
-
}
|
|
114
|
-
/** Resolves icon names; the composition root fills it from the icon registry. */
|
|
115
|
-
interface IconSource {
|
|
116
|
-
get(name: string): Icon | undefined;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* A theme token or any CSS colour. Tokens: "text", "text-muted", "surface", "grid", "axis", "focus",
|
|
121
|
-
* "negative", "series-N" and "series-N-strong" (palette slots 1–8), and "mark" / "mark-strong", the
|
|
122
|
-
* colours of the mark a run belongs to (its first segment's, for a stack).
|
|
123
|
-
*/
|
|
124
|
-
type Color = string;
|
|
125
|
-
/**
|
|
126
|
-
* A 2D affine transform in SVG order: x' = a·x + c·y + e, y' = b·x + d·y + f.
|
|
127
|
-
* Build one with the `matrix` helpers.
|
|
128
|
-
*/
|
|
129
|
-
type Matrix = readonly [a: number, b: number, c: number, d: number, e: number, f: number];
|
|
130
|
-
interface Paint {
|
|
131
|
-
readonly fill?: Color;
|
|
132
|
-
readonly stroke?: Color;
|
|
133
|
-
readonly width?: number;
|
|
134
|
-
readonly opacity?: number;
|
|
135
|
-
readonly linecap?: "butt" | "round";
|
|
136
|
-
}
|
|
137
|
-
interface MarkStyle {
|
|
138
|
-
/** In chart space. Moves the mark's body; its labels and pointer target stay put. */
|
|
139
|
-
readonly transform?: Matrix;
|
|
140
|
-
readonly opacity?: number;
|
|
141
|
-
/** 0–1 toward the series' strong colour. */
|
|
142
|
-
readonly emphasis?: number;
|
|
143
|
-
/**
|
|
144
|
-
* A stroke along the outline, behind the mark. `width` is the stroke width, so half of it shows
|
|
145
|
-
* outside the mark (the prototype's flash peaks at 8). Default colour: the mark's own.
|
|
146
|
-
*/
|
|
147
|
-
readonly halo?: {
|
|
148
|
-
readonly width: number;
|
|
149
|
-
readonly opacity: number;
|
|
150
|
-
readonly color?: Color;
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
/** Restyles the mark itself. The runner resets it when the run is cleared. */
|
|
154
|
-
interface MarkHandle {
|
|
155
|
-
/** Changes only the fields given, so parallel effects don't undo each other. A field given as undefined goes back to its default. */
|
|
156
|
-
set(style: MarkStyle): void;
|
|
157
|
-
/** Back to the mark's own style. */
|
|
158
|
-
reset(): void;
|
|
159
|
-
}
|
|
160
|
-
interface IconHandle {
|
|
161
|
-
/** Moves the icon: a transform from icon space into chart space. The icon is hidden until first placed. */
|
|
162
|
-
place(transform: Matrix): void;
|
|
163
|
-
remove(): void;
|
|
164
|
-
}
|
|
165
|
-
interface PathHandle {
|
|
166
|
-
/** Replaces the path data; paint fields given are merged into the current paint. */
|
|
167
|
-
update(d: string, paint?: Partial<Paint>): void;
|
|
168
|
-
remove(): void;
|
|
169
|
-
}
|
|
170
|
-
/** Effects that label a change ("+2") need text, drawn in theme text colours by default. */
|
|
171
|
-
interface TextStyle {
|
|
172
|
-
/** The anchor point, on the text's baseline. */
|
|
173
|
-
readonly at: Point;
|
|
174
|
-
readonly anchor?: "start" | "middle" | "end";
|
|
175
|
-
/** Default "text". Series colours are allowed only for swatches, never for words. */
|
|
176
|
-
readonly color?: Color;
|
|
177
|
-
readonly opacity?: number;
|
|
178
|
-
}
|
|
179
|
-
interface TextHandle {
|
|
180
|
-
/** Style fields given are merged into the current style; content is replaced if given. */
|
|
181
|
-
update(style: Partial<TextStyle>, content?: string): void;
|
|
182
|
-
remove(): void;
|
|
183
|
-
}
|
|
184
|
-
/** One run's own overlay group, above the marks, in chart coordinates. The runner empties it when the run is cleared. */
|
|
185
|
-
interface Layer {
|
|
186
|
-
/**
|
|
187
|
-
* Draws an icon, hidden until its first `place()`.
|
|
188
|
-
*
|
|
189
|
-
* Size rule: with `size`, the icon is scaled by `size / icon.size` about its anchor, in icon space,
|
|
190
|
-
* before the `place()` transform. So effects build the transform as if the icon were its natural
|
|
191
|
-
* size, and the anchor still lands where the transform puts it. Icon-space lengths (footprint,
|
|
192
|
-
* radius, the pivot's offset from the anchor) scale by the same factor. A negative size throws.
|
|
193
|
-
*
|
|
194
|
-
* Each shape is one path, in order (the first at the bottom). An unset `fill` or `stroke` draws
|
|
195
|
-
* none; `width` is in icon units (default 1), so it scales with the icon. `clip` is path data in
|
|
196
|
-
* icon space.
|
|
197
|
-
*/
|
|
198
|
-
icon(icon: Icon, options?: {
|
|
199
|
-
readonly size?: number;
|
|
200
|
-
}): IconHandle;
|
|
201
|
-
/** Draws an overlay path, unfilled unless `paint.fill` is given. */
|
|
202
|
-
path(d: string, paint: Paint): PathHandle;
|
|
203
|
-
text(content: string, style: TextStyle): TextHandle;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export type { Color as C, Icon as I, Layer as L, MarkGeometry as M, Outline as O, Paint as P, Rect as R, TextStyle as T, Matrix as a, MarkStyle as b, MarkHandle as c, IconSource as d, Point as e, IconHandle as f, IconShape as g, PathHandle as h, TextHandle as i };
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { M as MarkGeometry, c as MarkHandle, L as Layer, d as IconSource } from './drawing-CdTgixMY.js';
|
|
2
|
-
|
|
3
|
-
/** Where frames come from. The default uses requestAnimationFrame, or a 16 ms timer outside the browser. */
|
|
4
|
-
interface FrameSource {
|
|
5
|
-
now(): number;
|
|
6
|
-
/** Ask for one callback on the next frame. Returns a function that cancels it. */
|
|
7
|
-
request(callback: (now: number) => void): () => void;
|
|
8
|
-
}
|
|
9
|
-
interface Clock {
|
|
10
|
-
now(): number;
|
|
11
|
-
/** Call `callback` on every frame until the returned function is called. */
|
|
12
|
-
onFrame(callback: (now: number) => void): () => void;
|
|
13
|
-
}
|
|
14
|
-
/** A clock that only moves when told to. For tests. */
|
|
15
|
-
interface ManualClock extends Clock {
|
|
16
|
-
/** Move time forward by `ms` and run one frame at the new time. */
|
|
17
|
-
advance(ms: number): void;
|
|
18
|
-
/** True when nothing is waiting for a frame. */
|
|
19
|
-
readonly idle: boolean;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* One shared frame loop. It requests a frame only while something is
|
|
23
|
-
* subscribed, so an idle page costs nothing.
|
|
24
|
-
*/
|
|
25
|
-
declare function createClock(source?: FrameSource): Clock;
|
|
26
|
-
declare function manualClock(start?: number): ManualClock;
|
|
27
|
-
/** The page-wide clock every tween uses unless given another. */
|
|
28
|
-
declare const defaultClock: Clock;
|
|
29
|
-
|
|
30
|
-
/** Maps linear progress (0–1) to eased progress. Any function of this shape works. */
|
|
31
|
-
type Easing = (t: number) => number;
|
|
32
|
-
/** For playback, where speed should stay constant. */
|
|
33
|
-
declare const linear: Easing;
|
|
34
|
-
/** For data transitions: starts and ends gently. */
|
|
35
|
-
declare const easeInOutCubic: Easing;
|
|
36
|
-
/** For travel, and for animations retargeted mid-flight: starts at speed, settles gently. */
|
|
37
|
-
declare const easeOutCubic: Easing;
|
|
38
|
-
|
|
39
|
-
type MotionMode = "presentation" | "analysis" | "off";
|
|
40
|
-
/** What a duration is for. Each kind scales differently by mode. */
|
|
41
|
-
type Timing = "feedback" | "transition" | "effect" | "playback" | "stagger";
|
|
42
|
-
/** Base ms × factor, clamped to [min(base, min), max]. A floor never makes an animation longer than its base. */
|
|
43
|
-
interface ScalingRule {
|
|
44
|
-
readonly factor: number;
|
|
45
|
-
readonly min?: number;
|
|
46
|
-
readonly max?: number;
|
|
47
|
-
}
|
|
48
|
-
type ScaledMode = Exclude<MotionMode, "off">;
|
|
49
|
-
type ScalingTable = {
|
|
50
|
-
readonly [M in ScaledMode]: {
|
|
51
|
-
readonly [T in Timing]: ScalingRule;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
type ScalingOverrides = {
|
|
55
|
-
readonly [M in ScaledMode]?: {
|
|
56
|
-
readonly [T in Timing]?: ScalingRule;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/** Starting values from the prototype; tuned in the demos. Off is always 0. */
|
|
60
|
-
declare const defaultScaling: ScalingTable;
|
|
61
|
-
/** What charts and effects need from the motion system. */
|
|
62
|
-
interface MotionView {
|
|
63
|
-
/** The effective mode, after the reduced-motion rule. */
|
|
64
|
-
readonly mode: MotionMode;
|
|
65
|
-
/** True only in presentation: split data changes into stages. */
|
|
66
|
-
readonly staged: boolean;
|
|
67
|
-
/** Scale a base duration (ms) for the current mode. 0 means "jump to the end". */
|
|
68
|
-
duration(base: number, timing?: Timing): number;
|
|
69
|
-
}
|
|
70
|
-
interface Motion extends MotionView {
|
|
71
|
-
/** The mode the page author asked for. */
|
|
72
|
-
readonly requested: MotionMode;
|
|
73
|
-
/** The mode the viewer picked in an on-page control, if any. */
|
|
74
|
-
readonly viewerChoice: MotionMode | undefined;
|
|
75
|
-
/** Live value of `prefers-reduced-motion: reduce`. */
|
|
76
|
-
readonly prefersReduced: boolean;
|
|
77
|
-
/** The author's default. Never overrides reduced motion. */
|
|
78
|
-
setMode(mode: MotionMode): void;
|
|
79
|
-
/** The viewer's explicit choice from an on-page control. Overrides reduced motion. */
|
|
80
|
-
chooseMode(mode: MotionMode): void;
|
|
81
|
-
/** Forget the viewer's choice and follow the author's mode and the device setting again. */
|
|
82
|
-
clearChoice(): void;
|
|
83
|
-
/** Called whenever the mode, the viewer's choice or the device setting changes. */
|
|
84
|
-
subscribe(listener: () => void): () => void;
|
|
85
|
-
}
|
|
86
|
-
/** A live reduced-motion preference. */
|
|
87
|
-
interface ReducedMotionSource {
|
|
88
|
-
readonly matches: boolean;
|
|
89
|
-
subscribe(listener: () => void): () => void;
|
|
90
|
-
}
|
|
91
|
-
interface MotionOptions {
|
|
92
|
-
/** The author's mode. Default "presentation". */
|
|
93
|
-
readonly mode?: MotionMode;
|
|
94
|
-
readonly scaling?: ScalingOverrides;
|
|
95
|
-
/** Default: the `prefers-reduced-motion` media query. */
|
|
96
|
-
readonly reducedMotion?: ReducedMotionSource;
|
|
97
|
-
}
|
|
98
|
-
declare function createMotion(options?: MotionOptions): Motion;
|
|
99
|
-
declare function scaleDuration(base: number, rule: ScalingRule): number;
|
|
100
|
-
/** Reads `prefers-reduced-motion` lazily: nothing touches the DOM until `matches` is read or someone subscribes. */
|
|
101
|
-
declare function mediaReducedMotion(query?: string): ReducedMotionSource;
|
|
102
|
-
/** The page-wide motion every chart follows unless given its own. */
|
|
103
|
-
declare const motion: Motion;
|
|
104
|
-
|
|
105
|
-
/** The clock and motion settings an animation runs against. */
|
|
106
|
-
interface MotionEnv {
|
|
107
|
-
readonly clock: Clock;
|
|
108
|
-
readonly motion: MotionView;
|
|
109
|
-
}
|
|
110
|
-
interface TweenOptions {
|
|
111
|
-
/** Base duration in ms, scaled by the motion mode. */
|
|
112
|
-
readonly duration: number;
|
|
113
|
-
/** Default "transition". */
|
|
114
|
-
readonly timing?: Timing;
|
|
115
|
-
/** Default easeInOutCubic. */
|
|
116
|
-
readonly ease?: Easing;
|
|
117
|
-
/** Base delay in ms before progress starts, scaled like the duration. */
|
|
118
|
-
readonly delay?: number;
|
|
119
|
-
/** Called with eased progress: once with ease(0) at the start, then every frame, then with ease(1) at the end. */
|
|
120
|
-
readonly update: (progress: number) => void;
|
|
121
|
-
readonly signal?: AbortSignal;
|
|
122
|
-
}
|
|
123
|
-
type TweenResult = "done" | "cancelled";
|
|
124
|
-
interface Tween {
|
|
125
|
-
/** Resolves when the tween ends. Never rejects. */
|
|
126
|
-
readonly finished: Promise<TweenResult>;
|
|
127
|
-
readonly state: "running" | TweenResult;
|
|
128
|
-
/** Stop where it is. */
|
|
129
|
-
cancel(): void;
|
|
130
|
-
/** Jump to the end now. */
|
|
131
|
-
finish(): void;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Animate progress from 0 to 1. If the motion mode scales the duration to 0,
|
|
135
|
-
* `update(ease(1))` runs synchronously, before `tween` returns. If the mode
|
|
136
|
-
* turns off while the tween runs, it jumps to the end on the next frame.
|
|
137
|
-
*/
|
|
138
|
-
declare function tween(options: TweenOptions, env?: Partial<MotionEnv>): Tween;
|
|
139
|
-
|
|
140
|
-
interface Sample {
|
|
141
|
-
/** Where along the walk, in [0, 1]. */
|
|
142
|
-
readonly t: number;
|
|
143
|
-
readonly value: number;
|
|
144
|
-
/** The x value or label behind the sample (a week, a date). */
|
|
145
|
-
readonly at?: string | number | Date;
|
|
146
|
-
/** True on the first sample after a gap in the data, so a data effect doesn't join it to the one before. */
|
|
147
|
-
readonly gapBefore?: boolean;
|
|
148
|
-
}
|
|
149
|
-
interface MarkData<D = unknown> {
|
|
150
|
-
/**
|
|
151
|
-
* The row behind the mark: a bar's or a slice's row, a line point's row. A line's is the row at its
|
|
152
|
-
* revealed end; its other rows' values are in `samples`.
|
|
153
|
-
*/
|
|
154
|
-
readonly datum: D;
|
|
155
|
-
/** Data values along the walk, t ascending. */
|
|
156
|
-
readonly samples: readonly Sample[];
|
|
157
|
-
/** Another series in the same chart, if it exists. */
|
|
158
|
-
related(series: string): MarkData<D> | undefined;
|
|
159
|
-
/** The values before this update, for update effects that show change. */
|
|
160
|
-
readonly previous?: MarkData<D>;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
interface EffectContext {
|
|
164
|
-
/** Aborted on leave, re-trigger, data update or destroy. */
|
|
165
|
-
readonly signal: AbortSignal;
|
|
166
|
-
readonly motion: MotionView;
|
|
167
|
-
/** A tween with the clock, motion and signal already bound. */
|
|
168
|
-
tween(options: TweenOptions): Tween;
|
|
169
|
-
/** Restyles the mark itself; reset by the runner on clear. */
|
|
170
|
-
readonly mark: MarkHandle;
|
|
171
|
-
/** This run's own overlay group, above the marks; emptied on clear. */
|
|
172
|
-
readonly layer: Layer;
|
|
173
|
-
readonly icons: IconSource;
|
|
174
|
-
/** Position in a multi-mark event, for stagger. */
|
|
175
|
-
readonly batch: {
|
|
176
|
-
readonly index: number;
|
|
177
|
-
readonly count: number;
|
|
178
|
-
};
|
|
179
|
-
/** Called when the geometry moves (transitions, resizes, line reveals); unsubscribed on clear. */
|
|
180
|
-
onChange(listener: (mark: MarkGeometry, data?: MarkData) => void): void;
|
|
181
|
-
/** The mark's geometry before this update, on update events. */
|
|
182
|
-
readonly previous?: MarkGeometry;
|
|
183
|
-
}
|
|
184
|
-
interface GeometryEffect {
|
|
185
|
-
readonly kind: "geometry";
|
|
186
|
-
/** Resolves when done or cancelled. */
|
|
187
|
-
run(mark: MarkGeometry, ctx: EffectContext): Promise<void>;
|
|
188
|
-
/** Draws the final state immediately, on a fresh context. Used when the effective mode is off. */
|
|
189
|
-
end(mark: MarkGeometry, ctx: EffectContext): void;
|
|
190
|
-
/** Extra cleanup beyond what the runner does. */
|
|
191
|
-
clear(ctx: EffectContext): void;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* `run` and `end` are function-typed properties, not methods, on purpose: TypeScript checks method
|
|
195
|
-
* parameters loosely in both directions, which would let an effect that needs more fields than a
|
|
196
|
-
* chart's rows have (DataEffect<Row & { target: number }> on a chart of Row) slip through.
|
|
197
|
-
*/
|
|
198
|
-
interface DataEffect<D = unknown> {
|
|
199
|
-
readonly kind: "data";
|
|
200
|
-
/** Checked when the chart is created, so a missing series throws instead of drawing nothing. */
|
|
201
|
-
readonly needs?: {
|
|
202
|
-
readonly related?: readonly string[];
|
|
203
|
-
};
|
|
204
|
-
readonly run: (mark: MarkGeometry, data: MarkData<D>, ctx: EffectContext) => Promise<void>;
|
|
205
|
-
readonly end: (mark: MarkGeometry, data: MarkData<D>, ctx: EffectContext) => void;
|
|
206
|
-
readonly clear: (ctx: EffectContext) => void;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* A transition run's context. While a transition plays, both views' marks are hidden, so `mark` does
|
|
210
|
-
* nothing and `onChange` never fires: a resize lands the transition instead.
|
|
211
|
-
*/
|
|
212
|
-
interface TransitionContext extends EffectContext {
|
|
213
|
-
/**
|
|
214
|
-
* Where the run begins, from 0 to 1, in the effect's own progress (morph's is the shapes' eased
|
|
215
|
-
* progress). 0 plays it all. A switch back mid-way plays the reverse pair from 1 minus the progress
|
|
216
|
-
* the first had reached, so an effect that honours it retraces; one that ignores it replays from its
|
|
217
|
-
* beginning.
|
|
218
|
-
*/
|
|
219
|
-
readonly start: number;
|
|
220
|
-
}
|
|
221
|
-
/** Morph and future chart-to-chart transitions: from one geometry to another. */
|
|
222
|
-
interface TransitionEffect {
|
|
223
|
-
readonly kind: "transition";
|
|
224
|
-
/** Resolves when done or cancelled, leaving `to`'s end state drawn until cleared. */
|
|
225
|
-
run(from: MarkGeometry, to: MarkGeometry, ctx: TransitionContext): Promise<void>;
|
|
226
|
-
/** Draws the final state immediately, on a fresh context. Used when the effective mode is off. */
|
|
227
|
-
end(from: MarkGeometry, to: MarkGeometry, ctx: TransitionContext): void;
|
|
228
|
-
/** Extra cleanup beyond what the player does. */
|
|
229
|
-
clear(ctx: TransitionContext): void;
|
|
230
|
-
}
|
|
231
|
-
/** What combinators accept: any mark effect, whatever rows it reads. */
|
|
232
|
-
type AnyMarkEffect = GeometryEffect | DataEffect<any>;
|
|
233
|
-
type MarkEffect<D = unknown> = GeometryEffect | DataEffect<D>;
|
|
234
|
-
/** The row type a single effect needs; geometry effects need nothing (unknown). */
|
|
235
|
-
type RowNeeds<E> = E extends DataEffect<infer D> ? D : unknown;
|
|
236
|
-
/**
|
|
237
|
-
* The rows a combination needs: every part's needs at once (an intersection, not a union, so a
|
|
238
|
-
* generic part such as threshold() can't widen a typed part's needs back to unknown).
|
|
239
|
-
*/
|
|
240
|
-
type AllRowNeeds<E extends readonly unknown[]> = E extends readonly [] ? unknown : E extends readonly [infer First, ...infer Rest] ? RowNeeds<First> & AllRowNeeds<Rest> : E extends readonly (infer Item)[] ? RowNeeds<Item> : unknown;
|
|
241
|
-
/** What `sequence` and `parallel` return: a data effect if any part is one. */
|
|
242
|
-
type Combined<E extends readonly AnyMarkEffect[]> = [Extract<E[number], {
|
|
243
|
-
kind: "data";
|
|
244
|
-
}>] extends [never] ? GeometryEffect : DataEffect<AllRowNeeds<E>>;
|
|
245
|
-
|
|
246
|
-
export { motion as B, scaleDuration as H, tween as I, createClock as r, createMotion as s, defaultClock as t, defaultScaling as u, easeInOutCubic as v, easeOutCubic as w, linear as x, manualClock as y, mediaReducedMotion as z };
|
|
247
|
-
export type { AnyMarkEffect as A, Combined as C, DataEffect as D, EffectContext as E, FrameSource as F, GeometryEffect as G, MarkData as M, ReducedMotionSource as R, ScalingOverrides as S, TransitionEffect as T, Motion as a, ManualClock as b, MotionMode as c, Timing as d, Easing as e, TweenResult as f, MotionEnv as g, MarkEffect as h, Sample as i, Clock as j, MotionOptions as k, MotionView as l, ScalingRule as m, ScalingTable as n, TransitionContext as o, Tween as p, TweenOptions as q };
|