@silverpoint/core 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +1018 -0
- package/dist/index.js +4770 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1018 @@
|
|
|
1
|
+
/** A row of data. Charts reach its fields through accessors. */
|
|
2
|
+
type Datum = Readonly<Record<string, unknown>>;
|
|
3
|
+
/** Access to a field: key name or pure function. */
|
|
4
|
+
type Accessor<T = number> = string | ((d: Datum, i: number) => T);
|
|
5
|
+
/** Inking mode. `precision` amounts to using NullInker (REQ-021). */
|
|
6
|
+
type InkMode = 'ink' | 'precision';
|
|
7
|
+
/** Seed. A string is converted to an integer stably (REQ-003). */
|
|
8
|
+
type Seed = number | string;
|
|
9
|
+
/** Prepared substrates of the silverpoint ground (REQ-046). */
|
|
10
|
+
type SubstrateName = 'cream' | 'green' | 'blue' | 'ochre';
|
|
11
|
+
/** Active item resolved by the interaction engine (REQ-140). */
|
|
12
|
+
interface ActiveItem {
|
|
13
|
+
readonly seriesKey: string;
|
|
14
|
+
readonly index: number;
|
|
15
|
+
readonly datum: Datum;
|
|
16
|
+
readonly value: number;
|
|
17
|
+
/** Coordinates in SVG space, not screen space. */
|
|
18
|
+
readonly point: Readonly<{
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** What a stroke is. Determines whether the Inker may touch it (REQ-022). */
|
|
25
|
+
type StrokeRole = 'encoding' | 'ornament' | 'hatch';
|
|
26
|
+
/** Semantic paint slot; maps to a CSS variable (API Spec §10). */
|
|
27
|
+
type StrokePart = 'ink' | 'ink-secondary' | 'heighten' | 'rule' | 'grid' | 'axis';
|
|
28
|
+
/**
|
|
29
|
+
* How the stylesheet paints the shape: its outline, its interior with the part colour, its
|
|
30
|
+
* interior with a hatch tile, or nothing — a toned shape whose edges other strokes draw, so the
|
|
31
|
+
* Inker hatches it and no outline covers those edges.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
type StrokePaint = 'stroke' | 'fill' | 'tile' | 'none';
|
|
35
|
+
/** Tonal level on the ground's ramp; 0 is no fill (Data Model §3.4). */
|
|
36
|
+
type ToneLevel = 0 | 1 | 2 | 3 | 4;
|
|
37
|
+
/** Stroke instruction. It carries no color: color comes from CSS (REQ-042). */
|
|
38
|
+
interface Stroke {
|
|
39
|
+
/** SVG path data, already rounded to 2 decimals (REQ-002). */
|
|
40
|
+
readonly d: string;
|
|
41
|
+
readonly role: StrokeRole;
|
|
42
|
+
readonly part: StrokePart;
|
|
43
|
+
/** Relative weight, resolved against the ground's token. */
|
|
44
|
+
readonly weight?: number;
|
|
45
|
+
/** @internal Defaults to `'stroke'`. */
|
|
46
|
+
readonly paint?: StrokePaint;
|
|
47
|
+
/** @internal Dash pattern, resolved by the stylesheet. */
|
|
48
|
+
readonly dash?: 'dotted';
|
|
49
|
+
/** @internal Tonal level a closed shape asks the Inker to hatch. */
|
|
50
|
+
readonly tone?: ToneLevel;
|
|
51
|
+
/** @internal Id of the tile in `Geometry.defs` that fills this shape. */
|
|
52
|
+
readonly tile?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Kind of text a label carries; the stylesheet sets type by it. */
|
|
55
|
+
type LabelKind = 'title' | 'badge' | 'value' | 'unit' | 'footer' | 'tick' | 'empty';
|
|
56
|
+
interface TextLabel {
|
|
57
|
+
readonly x: number;
|
|
58
|
+
readonly y: number;
|
|
59
|
+
readonly text: string;
|
|
60
|
+
readonly kind: LabelKind;
|
|
61
|
+
/** Paint slot: `text` for primary labels, `axis` for muted ones. */
|
|
62
|
+
readonly part: 'text' | 'axis';
|
|
63
|
+
readonly anchor: 'start' | 'middle' | 'end';
|
|
64
|
+
}
|
|
65
|
+
/** A datum's position, as the interaction engine sees it (REQ-140). */
|
|
66
|
+
interface HitArea {
|
|
67
|
+
readonly seriesKey: string;
|
|
68
|
+
readonly index: number;
|
|
69
|
+
readonly datum: Datum;
|
|
70
|
+
readonly value: number;
|
|
71
|
+
readonly x: number;
|
|
72
|
+
readonly y: number;
|
|
73
|
+
/** The item's area, when it has one — a bar, a cell, a tile. A pointer inside it wins. */
|
|
74
|
+
readonly box?: Rect;
|
|
75
|
+
/**
|
|
76
|
+
* The item's place in a grid, when the chart is one. When every item has one, the arrow keys
|
|
77
|
+
* move by column (left, right) and by row (up, down) across the whole grid (REQ-122).
|
|
78
|
+
*/
|
|
79
|
+
readonly cell?: Readonly<{
|
|
80
|
+
column: number;
|
|
81
|
+
row: number;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A hatch tile shared by every shape of one tonal level (REQ-029).
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
interface Tile {
|
|
89
|
+
/** Scoped to the chart instance (REQ-030). */
|
|
90
|
+
readonly id: string;
|
|
91
|
+
readonly width: number;
|
|
92
|
+
readonly height: number;
|
|
93
|
+
/** Rotation of the tile in degrees. */
|
|
94
|
+
readonly angle: number;
|
|
95
|
+
readonly strokes: readonly Stroke[];
|
|
96
|
+
}
|
|
97
|
+
interface Rect {
|
|
98
|
+
readonly x: number;
|
|
99
|
+
readonly y: number;
|
|
100
|
+
readonly width: number;
|
|
101
|
+
readonly height: number;
|
|
102
|
+
}
|
|
103
|
+
/** Everything a chart needs in order to draw itself. Serializable (REQ-011). */
|
|
104
|
+
interface Geometry {
|
|
105
|
+
readonly viewBox: Rect;
|
|
106
|
+
readonly strokes: readonly Stroke[];
|
|
107
|
+
readonly labels: readonly TextLabel[];
|
|
108
|
+
readonly hitAreas: readonly HitArea[];
|
|
109
|
+
/** @internal Hatch tiles referenced by strokes painted with `'tile'`. */
|
|
110
|
+
readonly defs: readonly Tile[];
|
|
111
|
+
/** @internal The drawing area; the interaction engine ignores anything outside it. */
|
|
112
|
+
readonly plot: Rect;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** One step of a ground's tonal ramp (Data Model §3.4). */
|
|
116
|
+
interface ToneSpec {
|
|
117
|
+
readonly style: 'hachure' | 'cross-hatch';
|
|
118
|
+
readonly gap: number;
|
|
119
|
+
/** Hatch angle in degrees; cross-hatch adds the perpendicular. */
|
|
120
|
+
readonly angle: number;
|
|
121
|
+
}
|
|
122
|
+
type TonalRamp = Readonly<Record<Exclude<ToneLevel, 0>, ToneSpec>>;
|
|
123
|
+
interface InkOptions {
|
|
124
|
+
readonly seed: number;
|
|
125
|
+
readonly roughness: number;
|
|
126
|
+
readonly bowing: number;
|
|
127
|
+
readonly hatchAngle: number;
|
|
128
|
+
readonly hatchGap: number;
|
|
129
|
+
readonly fillWeight: number;
|
|
130
|
+
/** Upper bound of nodes the Inker must not exceed. */
|
|
131
|
+
readonly nodeBudget: number;
|
|
132
|
+
/** @internal `tile` shares one hatch tile per tonal level (REQ-029). */
|
|
133
|
+
readonly hatchFill?: 'tile' | 'per-shape';
|
|
134
|
+
/** @internal The ground's tonal ramp. */
|
|
135
|
+
readonly tonalRamp?: TonalRamp;
|
|
136
|
+
/** @internal Prefix that scopes generated ids to the chart instance (REQ-030). */
|
|
137
|
+
readonly scope?: string;
|
|
138
|
+
}
|
|
139
|
+
interface Inker {
|
|
140
|
+
readonly name: string;
|
|
141
|
+
/** Receives exact geometry and returns the inked geometry. */
|
|
142
|
+
ink(geometry: Geometry, options: InkOptions): Geometry;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Name of a registered ground. */
|
|
146
|
+
type GroundName = 'silverpoint' | (string & {});
|
|
147
|
+
/** Declarative token set of a style ground (API Spec §6, Art. 7). */
|
|
148
|
+
interface Ground {
|
|
149
|
+
readonly name: string;
|
|
150
|
+
/** How it builds tonal value. `wash` is the anticipated exception to Art. 6. */
|
|
151
|
+
readonly tonalMechanism: 'hatch' | 'weight' | 'wash';
|
|
152
|
+
/** Name of the registered Inker that inks it. */
|
|
153
|
+
readonly inker: string;
|
|
154
|
+
readonly substrates: Readonly<Record<string, string>>;
|
|
155
|
+
readonly ink: Readonly<{
|
|
156
|
+
primary: string;
|
|
157
|
+
secondary: string;
|
|
158
|
+
heighten: string;
|
|
159
|
+
rule: string;
|
|
160
|
+
grid: string;
|
|
161
|
+
text: string;
|
|
162
|
+
textMuted: string;
|
|
163
|
+
}>;
|
|
164
|
+
readonly inkOptions: Omit<InkOptions, 'seed' | 'nodeBudget' | 'hatchFill' | 'tonalRamp' | 'scope'>;
|
|
165
|
+
/** Hatch density bound, to stay within the node budget. */
|
|
166
|
+
readonly maxHatchDensity: number;
|
|
167
|
+
/** Tonal levels 1-4 (Data Model §3.4). */
|
|
168
|
+
readonly tonalRamp: TonalRamp;
|
|
169
|
+
readonly typography: Readonly<{
|
|
170
|
+
display: string;
|
|
171
|
+
scale: number;
|
|
172
|
+
}>;
|
|
173
|
+
/** What to draw when there is no data (REQ-007). */
|
|
174
|
+
readonly emptyState: Readonly<{
|
|
175
|
+
text: string;
|
|
176
|
+
rule: boolean;
|
|
177
|
+
}>;
|
|
178
|
+
/** Expansion of degenerate domains (REQ-010). */
|
|
179
|
+
readonly domainPadding: number;
|
|
180
|
+
}
|
|
181
|
+
/** Name of a registered ground, or a complete ground. */
|
|
182
|
+
type GroundRef = GroundName | Ground;
|
|
183
|
+
|
|
184
|
+
/** Props present in every chart, identical in React and Angular (REQ-094). */
|
|
185
|
+
interface CommonChartProps {
|
|
186
|
+
/** Rows to draw. If omitted, the demo dataset is rendered (REQ-093). */
|
|
187
|
+
data?: readonly Datum[];
|
|
188
|
+
/** Style ground. Defaults to the app provider's, or `silverpoint`. */
|
|
189
|
+
ground?: GroundRef;
|
|
190
|
+
/** Prepared substrate within the ground (REQ-046). */
|
|
191
|
+
substrate?: SubstrateName;
|
|
192
|
+
/** `ink` by default; `precision` disables inking (REQ-021). */
|
|
193
|
+
mode?: InkMode;
|
|
194
|
+
/** Seed. If omitted, it is derived from `id` stably (REQ-003). */
|
|
195
|
+
seed?: Seed;
|
|
196
|
+
/** Stable identifier. If omitted, it is generated deterministically. */
|
|
197
|
+
id?: string;
|
|
198
|
+
/** Height of the drawing area in px. Width is the container's unless pinned. */
|
|
199
|
+
height?: number;
|
|
200
|
+
width?: number;
|
|
201
|
+
/** `card` draws the full frame; `bare` only the drawing area (REQ-095). */
|
|
202
|
+
chrome?: 'card' | 'bare';
|
|
203
|
+
/** How areas are filled (REQ-029). */
|
|
204
|
+
hatchFill?: 'tile' | 'per-shape';
|
|
205
|
+
title?: string;
|
|
206
|
+
badge?: string;
|
|
207
|
+
value?: string | number;
|
|
208
|
+
unit?: string;
|
|
209
|
+
footerLeft?: string;
|
|
210
|
+
footerRight?: string;
|
|
211
|
+
/** Accessible name. If omitted, it is derived from `title` (REQ-120). */
|
|
212
|
+
label?: string;
|
|
213
|
+
/** Long description for screen readers (REQ-120). */
|
|
214
|
+
description?: string;
|
|
215
|
+
/** Tabular alternative; `hidden` leaves it for assistive technology only (REQ-121). */
|
|
216
|
+
dataTable?: 'visible' | 'hidden' | 'none';
|
|
217
|
+
locale?: string;
|
|
218
|
+
numberFormat?: Intl.NumberFormatOptions;
|
|
219
|
+
className?: string;
|
|
220
|
+
}
|
|
221
|
+
type LineCurve = 'monotone' | 'linear' | 'natural' | 'step';
|
|
222
|
+
/** `LineChart` (REQ-060): spline with an optional dotted baseline series. */
|
|
223
|
+
interface LineChartProps extends CommonChartProps {
|
|
224
|
+
xKey?: Accessor<string | number>;
|
|
225
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
226
|
+
secondaryKey?: Accessor<number | null | undefined>;
|
|
227
|
+
curve?: LineCurve;
|
|
228
|
+
/** `all` draws the secondary series when there is one; `primary` omits it. */
|
|
229
|
+
series?: 'all' | 'primary';
|
|
230
|
+
/** Whether a gap left by a missing value is bridged (REQ-008). */
|
|
231
|
+
connectNulls?: boolean;
|
|
232
|
+
}
|
|
233
|
+
/** Configuration an application sets once for every chart (API Spec §8). */
|
|
234
|
+
interface ProviderConfig {
|
|
235
|
+
ground?: GroundRef;
|
|
236
|
+
substrate?: SubstrateName;
|
|
237
|
+
mode?: InkMode;
|
|
238
|
+
locale?: string;
|
|
239
|
+
}
|
|
240
|
+
/** `BulletChart` (REQ-069): one bar per target, with a marker at the target. Values in 0-100. */
|
|
241
|
+
interface BulletChartProps extends CommonChartProps {
|
|
242
|
+
titleKey?: Accessor<string>;
|
|
243
|
+
actualKey?: Accessor<number | null | undefined>;
|
|
244
|
+
targetKey?: Accessor<number | null | undefined>;
|
|
245
|
+
}
|
|
246
|
+
/** `PyramidChart` (REQ-070): stacked tiers whose width encodes the value (0-100). */
|
|
247
|
+
interface PyramidChartProps extends CommonChartProps {
|
|
248
|
+
labelKey?: Accessor<string>;
|
|
249
|
+
widthKey?: Accessor<number | null | undefined>;
|
|
250
|
+
toneKey?: Accessor<number | null | undefined>;
|
|
251
|
+
}
|
|
252
|
+
/** `HeatmapChart` (REQ-084): labelled rows of values, normalised against `scaleMax`. */
|
|
253
|
+
interface HeatmapChartProps extends CommonChartProps {
|
|
254
|
+
labelKey?: Accessor<string>;
|
|
255
|
+
valuesKey?: Accessor<readonly (number | null)[] | null | undefined>;
|
|
256
|
+
/** Value that maps to the darkest tone; 100 by default. */
|
|
257
|
+
scaleMax?: number;
|
|
258
|
+
/** Names of the columns, in order; missing ones fall back to `#k` (delta-006). */
|
|
259
|
+
columnLabels?: readonly string[];
|
|
260
|
+
}
|
|
261
|
+
/** `TreemapChart` (REQ-085): tiles of `cols × rows` cells placed in a `columns × rows` grid. */
|
|
262
|
+
interface TreemapChartProps extends CommonChartProps {
|
|
263
|
+
labelKey?: Accessor<string>;
|
|
264
|
+
shareKey?: Accessor<number | null | undefined>;
|
|
265
|
+
columns?: number;
|
|
266
|
+
rows?: number;
|
|
267
|
+
}
|
|
268
|
+
/** `SankeyChart` (REQ-086): flow bands between layered nodes. */
|
|
269
|
+
interface SankeyChartProps extends CommonChartProps {
|
|
270
|
+
sourceKey?: Accessor<string>;
|
|
271
|
+
targetKey?: Accessor<string>;
|
|
272
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
273
|
+
}
|
|
274
|
+
/** `ActivityGrid` (REQ-087): one cell per day, a column per week. */
|
|
275
|
+
interface ActivityGridProps extends CommonChartProps {
|
|
276
|
+
dateKey?: Accessor<string>;
|
|
277
|
+
countKey?: Accessor<number | null | undefined>;
|
|
278
|
+
levelKey?: Accessor<number | null | undefined>;
|
|
279
|
+
/** Weeks shown, the most recent last; 26 by default. */
|
|
280
|
+
weeks?: number;
|
|
281
|
+
}
|
|
282
|
+
/** `StepChart` (REQ-061): a series drawn as steps. */
|
|
283
|
+
interface StepChartProps extends CommonChartProps {
|
|
284
|
+
xKey?: Accessor<string | number>;
|
|
285
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
286
|
+
/** Where the step sits between two points; `after` by default. */
|
|
287
|
+
step?: 'after' | 'before' | 'middle';
|
|
288
|
+
}
|
|
289
|
+
/** `SparklineRows` (REQ-062): one row per series — name, sparkline, readout (delta-008). */
|
|
290
|
+
interface SparklineRowsProps extends CommonChartProps {
|
|
291
|
+
/** Rows shown, from the first; all by default. */
|
|
292
|
+
rows?: number;
|
|
293
|
+
nameKey?: Accessor<string>;
|
|
294
|
+
/** The printed readout; the last value of the series by default. */
|
|
295
|
+
readoutKey?: Accessor<string | number | null | undefined>;
|
|
296
|
+
/** The row's points: an array. */
|
|
297
|
+
seriesKey?: Accessor<readonly unknown[] | null | undefined>;
|
|
298
|
+
/** The value of one point; the point itself when it is a number, else its `value`. */
|
|
299
|
+
pointKey?: Accessor<number | null | undefined>;
|
|
300
|
+
}
|
|
301
|
+
/** `KpiCard` (REQ-063): a metric, its delta, and an area sparkline of the series. */
|
|
302
|
+
interface KpiCardProps extends CommonChartProps {
|
|
303
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
304
|
+
/** The metric's name, printed under the figure. */
|
|
305
|
+
metric?: string;
|
|
306
|
+
/** Signed change, printed with its sign and a direction mark. */
|
|
307
|
+
delta?: number;
|
|
308
|
+
/** Direction of the mark; from the sign of `delta` by default. */
|
|
309
|
+
deltaTone?: 'up' | 'down' | 'flat';
|
|
310
|
+
}
|
|
311
|
+
/** `BarChart` (REQ-064): pill bars, as columns or rows, with an optional second series. */
|
|
312
|
+
interface BarChartProps extends CommonChartProps {
|
|
313
|
+
xKey?: Accessor<string | number>;
|
|
314
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
315
|
+
secondaryKey?: Accessor<number | null | undefined>;
|
|
316
|
+
orientation?: 'columns' | 'rows';
|
|
317
|
+
}
|
|
318
|
+
/** `StackedBarChart` (REQ-065): one stacked segment per key. */
|
|
319
|
+
interface StackedBarChartProps extends CommonChartProps {
|
|
320
|
+
xKey?: Accessor<string | number>;
|
|
321
|
+
keys?: readonly string[];
|
|
322
|
+
/** Display names of the keys, in order; the keys themselves by default. */
|
|
323
|
+
names?: readonly string[];
|
|
324
|
+
}
|
|
325
|
+
/** `ComposedChart` (REQ-066): columns and a spline on one value scale. */
|
|
326
|
+
interface ComposedChartProps extends CommonChartProps {
|
|
327
|
+
xKey?: Accessor<string | number>;
|
|
328
|
+
barKey?: Accessor<number | null | undefined>;
|
|
329
|
+
lineKey?: Accessor<number | null | undefined>;
|
|
330
|
+
showLine?: boolean;
|
|
331
|
+
}
|
|
332
|
+
/** `WaterfallChart` (REQ-067): totals from zero and floating deltas from the running total. */
|
|
333
|
+
interface WaterfallChartProps extends CommonChartProps {
|
|
334
|
+
stepKey?: Accessor<string>;
|
|
335
|
+
/** An absolute total: the bar starts at zero and resets the running total. */
|
|
336
|
+
baseKey?: Accessor<number | null | undefined>;
|
|
337
|
+
/** A change from the running total. */
|
|
338
|
+
deltaKey?: Accessor<number | null | undefined>;
|
|
339
|
+
}
|
|
340
|
+
/** `FunnelChart` (REQ-068): horizontal, centred stages. */
|
|
341
|
+
interface FunnelChartProps extends CommonChartProps {
|
|
342
|
+
stageKey?: Accessor<string>;
|
|
343
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
344
|
+
}
|
|
345
|
+
/** `CandlestickChart` (REQ-071): OHLC bodies and wicks (Data Model §2.6). */
|
|
346
|
+
interface CandlestickChartProps extends CommonChartProps {
|
|
347
|
+
timeKey?: Accessor<string | number>;
|
|
348
|
+
openKey?: Accessor<number | null | undefined>;
|
|
349
|
+
highKey?: Accessor<number | null | undefined>;
|
|
350
|
+
lowKey?: Accessor<number | null | undefined>;
|
|
351
|
+
closeKey?: Accessor<number | null | undefined>;
|
|
352
|
+
/** Price bounds of the scale; derived from the data when omitted (REQ-097). */
|
|
353
|
+
bounds?: readonly [number, number];
|
|
354
|
+
}
|
|
355
|
+
/** `AreaChart` (REQ-072): a curved, toned area under its line. */
|
|
356
|
+
interface AreaChartProps extends CommonChartProps {
|
|
357
|
+
xKey?: Accessor<string | number>;
|
|
358
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
359
|
+
curve?: LineCurve;
|
|
360
|
+
}
|
|
361
|
+
/** `RangeBandChart` (REQ-073): the band between a low and a high series. */
|
|
362
|
+
interface RangeBandChartProps extends CommonChartProps {
|
|
363
|
+
xKey?: Accessor<string | number>;
|
|
364
|
+
lowKey?: Accessor<number | null | undefined>;
|
|
365
|
+
highKey?: Accessor<number | null | undefined>;
|
|
366
|
+
}
|
|
367
|
+
/** `StreamChart` (REQ-074): two waves, overlaid or stacked. */
|
|
368
|
+
interface StreamChartProps extends CommonChartProps {
|
|
369
|
+
xKey?: Accessor<string | number>;
|
|
370
|
+
keys?: readonly string[];
|
|
371
|
+
stacked?: boolean;
|
|
372
|
+
}
|
|
373
|
+
/** `ScatterChart` (REQ-082): points on two linear scales, optionally sized. */
|
|
374
|
+
interface ScatterChartProps extends CommonChartProps {
|
|
375
|
+
xKey?: Accessor<number | null | undefined>;
|
|
376
|
+
yKey?: Accessor<number | null | undefined>;
|
|
377
|
+
sizeKey?: Accessor<number | null | undefined>;
|
|
378
|
+
/** Marker area in px², smallest to largest; `[60, 240]` by default. */
|
|
379
|
+
sizeRange?: readonly [number, number];
|
|
380
|
+
}
|
|
381
|
+
/** `BubbleChart` (REQ-083): circles whose area encodes `sizeKey`. */
|
|
382
|
+
interface BubbleChartProps extends CommonChartProps {
|
|
383
|
+
xKey?: Accessor<number | null | undefined>;
|
|
384
|
+
yKey?: Accessor<number | null | undefined>;
|
|
385
|
+
sizeKey?: Accessor<number | null | undefined>;
|
|
386
|
+
/** Circle area in px², smallest to largest; `[100, 500]` by default. */
|
|
387
|
+
sizeRange?: readonly [number, number];
|
|
388
|
+
}
|
|
389
|
+
/** `DonutChart` (REQ-075): sectors ∝ value around a central readout (Data Model §2.2). */
|
|
390
|
+
interface DonutChartProps extends CommonChartProps {
|
|
391
|
+
nameKey?: Accessor<string | number>;
|
|
392
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
393
|
+
/** Printed in the centre; the total by default. */
|
|
394
|
+
centerValue?: string | number;
|
|
395
|
+
/** A line under the centre value. */
|
|
396
|
+
centerLabel?: string;
|
|
397
|
+
/** Names every sector with its share beside the ring; `true` by default. */
|
|
398
|
+
legend?: boolean;
|
|
399
|
+
}
|
|
400
|
+
/** `RadarChart` (REQ-076): one spoke per subject, a closed polygon of values (Data Model §2.2). */
|
|
401
|
+
interface RadarChartProps extends CommonChartProps {
|
|
402
|
+
subjectKey?: Accessor<string | number>;
|
|
403
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
404
|
+
/** The value range along a spoke; `[0, the largest value]`, niced, by default. */
|
|
405
|
+
domain?: readonly [number, number];
|
|
406
|
+
}
|
|
407
|
+
/** `PolarBarChart` (REQ-077): 360° bars out from a hole, length ∝ value (Data Model §2.2). */
|
|
408
|
+
interface PolarBarChartProps extends CommonChartProps {
|
|
409
|
+
nameKey?: Accessor<string | number>;
|
|
410
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
411
|
+
}
|
|
412
|
+
/** `CoxcombChart` (REQ-088): equal angles, sector **area** ∝ value (Data Model §2.2). */
|
|
413
|
+
interface CoxcombChartProps extends CommonChartProps {
|
|
414
|
+
nameKey?: Accessor<string | number>;
|
|
415
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
416
|
+
/** Where the first sector starts, in degrees clockwise from 12 o'clock; 0 by default. */
|
|
417
|
+
startAngle?: number;
|
|
418
|
+
}
|
|
419
|
+
/** `RadialArcGroup` (REQ-078): concentric 180° tracks, sweep ∝ value / the largest (Data Model §2.2). */
|
|
420
|
+
interface RadialArcGroupProps extends CommonChartProps {
|
|
421
|
+
nameKey?: Accessor<string | number>;
|
|
422
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
423
|
+
}
|
|
424
|
+
/** `RadialRings` (REQ-079): concentric progress rings, sweep ∝ value in 0-100 (Data Model §2.2). */
|
|
425
|
+
interface RadialRingsProps extends CommonChartProps {
|
|
426
|
+
nameKey?: Accessor<string | number>;
|
|
427
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
428
|
+
}
|
|
429
|
+
/** `GaugeArc` (REQ-080): a 240° arc swept to a percent (Data Model §2.3). */
|
|
430
|
+
interface GaugeArcProps extends CommonChartProps {
|
|
431
|
+
/** 0 to 100; saturated at the ends outside it. */
|
|
432
|
+
percent?: number;
|
|
433
|
+
/** Names the measure under the readout. */
|
|
434
|
+
caption?: string;
|
|
435
|
+
/** Printed in place of the percent. */
|
|
436
|
+
readout?: string;
|
|
437
|
+
}
|
|
438
|
+
/** `MeterChart` (REQ-081): a semicircular meter with a needle at a percent (Data Model §2.3). */
|
|
439
|
+
interface MeterChartProps extends CommonChartProps {
|
|
440
|
+
/** 0 to 100; saturated at the ends outside it. */
|
|
441
|
+
percent?: number;
|
|
442
|
+
/** Names the measure under the readout. */
|
|
443
|
+
caption?: string;
|
|
444
|
+
/** Printed in place of the percent. */
|
|
445
|
+
readout?: string;
|
|
446
|
+
}
|
|
447
|
+
/** `WindRose` (REQ-089): observations of (bearing, speed) binned by compass sector and speed. */
|
|
448
|
+
interface WindRoseProps extends CommonChartProps {
|
|
449
|
+
/** Where the wind blows from, in degrees clockwise from north. */
|
|
450
|
+
bearingKey?: Accessor<number | null | undefined>;
|
|
451
|
+
/** The wind speed; 0 is a calm, which has no direction. */
|
|
452
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
453
|
+
/** Compass sectors: 4, 8, 16 or 32; 16 by default. */
|
|
454
|
+
sectors?: number;
|
|
455
|
+
/** Ascending speed thresholds that split each sector; `[5, 10, 15, 20]` by default. */
|
|
456
|
+
bins?: readonly number[];
|
|
457
|
+
}
|
|
458
|
+
/** `ChordRing` (REQ-091): directed flows between categories around a circle (Data Model §2.7). */
|
|
459
|
+
interface ChordRingProps extends CommonChartProps {
|
|
460
|
+
sourceKey?: Accessor<string | number>;
|
|
461
|
+
targetKey?: Accessor<string | number>;
|
|
462
|
+
valueKey?: Accessor<number | null | undefined>;
|
|
463
|
+
/** Categories drawn; past it the smallest merge into "Other" (`SP010`). 12 by default. */
|
|
464
|
+
maxCategories?: number;
|
|
465
|
+
}
|
|
466
|
+
/** `OrbitChart` (REQ-092): nested elliptical orbits with markers along them (Data Model §2.10, delta-009). */
|
|
467
|
+
interface OrbitChartProps extends CommonChartProps {
|
|
468
|
+
/** Orbits shown, from the inside out; all by default. */
|
|
469
|
+
orbits?: number;
|
|
470
|
+
/** A row's markers; `'markers'` by default. */
|
|
471
|
+
markerKey?: Accessor<readonly unknown[] | null | undefined>;
|
|
472
|
+
/** A marker's period, 0-1 over the cycle; `'period'` by default. */
|
|
473
|
+
periodKey?: Accessor<number | null | undefined>;
|
|
474
|
+
}
|
|
475
|
+
/** `VolvelleChart` (REQ-090): concentric categorical rings read against one index (delta-010). */
|
|
476
|
+
interface VolvelleChartProps extends CommonChartProps {
|
|
477
|
+
/** Rings shown, from the inside out; all by default. */
|
|
478
|
+
rings?: number;
|
|
479
|
+
/** The ring whose segment is brought under the index, 0-based; 0 by default. */
|
|
480
|
+
indexRing?: number;
|
|
481
|
+
/** The segment of `indexRing` under the index; its first segment by default. */
|
|
482
|
+
indexValue?: string;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** Tabular alternative of a chart's data, already formatted (REQ-121). */
|
|
486
|
+
interface DataTable {
|
|
487
|
+
readonly caption: string;
|
|
488
|
+
readonly columns: readonly string[];
|
|
489
|
+
readonly rows: readonly (readonly string[])[];
|
|
490
|
+
}
|
|
491
|
+
/** What a recipe needs beyond the props: the resolved environment. */
|
|
492
|
+
interface RecipeContext {
|
|
493
|
+
/** Resolved instance id. */
|
|
494
|
+
readonly id: string;
|
|
495
|
+
/** Resolved container width in px; `undefined` while it has not been measured. */
|
|
496
|
+
readonly width: number | undefined;
|
|
497
|
+
readonly locale: string;
|
|
498
|
+
readonly emptyState: Ground['emptyState'];
|
|
499
|
+
readonly domainPadding: number;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Everything an adapter renders: the geometry plus the accessible layer. Adapters translate
|
|
503
|
+
* it into nodes and compute nothing (Art. 2).
|
|
504
|
+
*/
|
|
505
|
+
interface ChartModel {
|
|
506
|
+
readonly chart: string;
|
|
507
|
+
readonly id: string;
|
|
508
|
+
/** `deferred` while the container has no usable size (REQ-009). */
|
|
509
|
+
readonly status: 'ready' | 'deferred';
|
|
510
|
+
readonly geometry: Geometry;
|
|
511
|
+
readonly chrome: 'card' | 'bare';
|
|
512
|
+
/** Accessible name (REQ-120). */
|
|
513
|
+
readonly name: string;
|
|
514
|
+
/** Description summarising the series (REQ-120). */
|
|
515
|
+
readonly description: string;
|
|
516
|
+
readonly ids: Readonly<{
|
|
517
|
+
title: string;
|
|
518
|
+
desc: string;
|
|
519
|
+
table: string;
|
|
520
|
+
}>;
|
|
521
|
+
readonly table: DataTable;
|
|
522
|
+
readonly dataTable: 'visible' | 'hidden' | 'none';
|
|
523
|
+
}
|
|
524
|
+
/** A chart: its display name and the pure function from props to model. */
|
|
525
|
+
interface ChartRecipe<P extends CommonChartProps> {
|
|
526
|
+
readonly name: string;
|
|
527
|
+
build(props: P, context: RecipeContext): ChartModel;
|
|
528
|
+
}
|
|
529
|
+
/** Imperative handle every adapter exposes, deliberately minimal (API Spec §8.1). */
|
|
530
|
+
interface ChartHandle {
|
|
531
|
+
getGeometry(): Geometry;
|
|
532
|
+
toSVGString(): string;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/** Rounds to 2 decimals, the precision of every emitted coordinate (REQ-002). */
|
|
536
|
+
declare function round2(value: number): number;
|
|
537
|
+
/** Rounds every number inside SVG path data to 2 decimals. */
|
|
538
|
+
declare function roundPathData(d: string): string;
|
|
539
|
+
/** Rounds all coordinates of a geometry to 2 decimals, returning a new object (REQ-002). */
|
|
540
|
+
declare function roundGeometry(geometry: Geometry): Geometry;
|
|
541
|
+
|
|
542
|
+
/** Serialises a geometry to JSON. Geometry holds no functions and no DOM nodes (REQ-011). */
|
|
543
|
+
declare function serializeGeometry(geometry: Geometry): string;
|
|
544
|
+
/** Inverse of `serializeGeometry`. */
|
|
545
|
+
declare function parseGeometry(json: string): Geometry;
|
|
546
|
+
/** Bytes of path data a geometry carries, tiles included (NFR §7). */
|
|
547
|
+
declare function pathBytes(geometry: Geometry): number;
|
|
548
|
+
/** Path data budget per chart (API Spec §12). */
|
|
549
|
+
declare const PATH_BYTE_BUDGET = 40000;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* 32-bit FNV-1a over the UTF-8 bytes of the input (DD-006).
|
|
553
|
+
*
|
|
554
|
+
* Frozen by SemVer: changing it changes every derived seed, and with it every golden image.
|
|
555
|
+
*/
|
|
556
|
+
declare function fnv1a32(input: string): number;
|
|
557
|
+
/** Derives the seed of a chart from its identifier (REQ-003). */
|
|
558
|
+
declare function deriveSeed(id: string): number;
|
|
559
|
+
/** `seed ?? derive(id)`, with string seeds hashed and numbers taken as unsigned 32-bit. */
|
|
560
|
+
declare function resolveSeed(seed: Seed | undefined, id: string): number;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* A seeded 32-bit PRNG (mulberry32), for generated demo data (Data Model §4). Owned here rather
|
|
564
|
+
* than imported, so its sequence is frozen by SemVer like the seed derivation (DD-006): changing
|
|
565
|
+
* it changes demo output, which is never a patch.
|
|
566
|
+
*/
|
|
567
|
+
declare function createPrng(seed: number): () => number;
|
|
568
|
+
|
|
569
|
+
/** Days since the epoch of an ISO `YYYY-MM-DD` date; `NaN` when it is not one. */
|
|
570
|
+
declare function parseIsoDate(iso: string): number;
|
|
571
|
+
/** The ISO `YYYY-MM-DD` form of a day number. */
|
|
572
|
+
declare function isoDate(day: number): string;
|
|
573
|
+
declare function addDays(day: number, days: number): number;
|
|
574
|
+
/** Day of the week in UTC, 0 = Sunday. */
|
|
575
|
+
declare function weekday(day: number): number;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Holds the heightening rules on a geometry:
|
|
579
|
+
* - a single heightened element per chart (REQ-024); a second one throws SP005 in development
|
|
580
|
+
* and is dropped in production (REQ-025);
|
|
581
|
+
* - every heightened element carries an outline in the main ink (REQ-031), which is added
|
|
582
|
+
* when the recipe did not draw it.
|
|
583
|
+
*/
|
|
584
|
+
declare function enforceHeightening(geometry: Geometry, chart: string): Geometry;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* The SVG a chart renders, as flat element descriptors with every attribute value already a
|
|
588
|
+
* string. Each adapter's template writes these fields to the same attribute names, one to one,
|
|
589
|
+
* and computes nothing (Art. 2); `svgString` writes them too, and its output is the canonical
|
|
590
|
+
* render every adapter is compared against (Art. 3, DD-004).
|
|
591
|
+
*
|
|
592
|
+
* Colour never appears here: the stylesheet paints by `part` (REQ-042).
|
|
593
|
+
*/
|
|
594
|
+
interface SvgView {
|
|
595
|
+
readonly svg: Readonly<{
|
|
596
|
+
viewBox: string;
|
|
597
|
+
width: string;
|
|
598
|
+
height: string;
|
|
599
|
+
/** `class` attribute. */
|
|
600
|
+
class: string;
|
|
601
|
+
/** `data-substrate` attribute. */
|
|
602
|
+
substrate: string;
|
|
603
|
+
/** `data-mode` attribute. */
|
|
604
|
+
mode: InkMode;
|
|
605
|
+
role: 'img';
|
|
606
|
+
/** `aria-labelledby` attribute. */
|
|
607
|
+
labelledby: string;
|
|
608
|
+
}>;
|
|
609
|
+
readonly title: Readonly<{
|
|
610
|
+
id: string;
|
|
611
|
+
text: string;
|
|
612
|
+
}>;
|
|
613
|
+
readonly desc: Readonly<{
|
|
614
|
+
id: string;
|
|
615
|
+
text: string;
|
|
616
|
+
}>;
|
|
617
|
+
/** `<pattern>` elements inside `<defs>`; `<defs>` is omitted when there are none. */
|
|
618
|
+
readonly patterns: readonly PatternView[];
|
|
619
|
+
readonly paths: readonly PathView[];
|
|
620
|
+
readonly texts: readonly TextView[];
|
|
621
|
+
}
|
|
622
|
+
interface PatternView {
|
|
623
|
+
readonly id: string;
|
|
624
|
+
readonly width: string;
|
|
625
|
+
readonly height: string;
|
|
626
|
+
/** `patternTransform` attribute. */
|
|
627
|
+
readonly transform: string;
|
|
628
|
+
readonly paths: readonly PathView[];
|
|
629
|
+
}
|
|
630
|
+
interface PathView {
|
|
631
|
+
readonly d: string;
|
|
632
|
+
/** `part` attribute: `sp-<part>`. */
|
|
633
|
+
readonly part: string;
|
|
634
|
+
/** `data-role` attribute. */
|
|
635
|
+
readonly role: Stroke['role'];
|
|
636
|
+
/** `data-paint` attribute. */
|
|
637
|
+
readonly paint: StrokePaint;
|
|
638
|
+
/** `data-dash` attribute, omitted when `null`. */
|
|
639
|
+
readonly dash: string | null;
|
|
640
|
+
/** `fill` attribute — only ever a `url(#tile)` reference, omitted when `null`. */
|
|
641
|
+
readonly fill: string | null;
|
|
642
|
+
}
|
|
643
|
+
interface TextView {
|
|
644
|
+
readonly x: string;
|
|
645
|
+
readonly y: string;
|
|
646
|
+
/** `part` attribute: `sp-text` or `sp-axis`. */
|
|
647
|
+
readonly part: string;
|
|
648
|
+
/** `data-kind` attribute. */
|
|
649
|
+
readonly kind: TextLabel['kind'];
|
|
650
|
+
/** `text-anchor` attribute. */
|
|
651
|
+
readonly anchor: TextLabel['anchor'];
|
|
652
|
+
readonly text: string;
|
|
653
|
+
}
|
|
654
|
+
interface ViewStyle {
|
|
655
|
+
readonly ground: string;
|
|
656
|
+
readonly substrate: string;
|
|
657
|
+
readonly mode: InkMode;
|
|
658
|
+
}
|
|
659
|
+
/** Builds the element descriptors of a chart model (API Spec §10). */
|
|
660
|
+
declare function toSvgView(model: ChartModel, style: ViewStyle): SvgView;
|
|
661
|
+
/**
|
|
662
|
+
* Serialises a view to SVG markup. This is the canonical render stored with each fixture;
|
|
663
|
+
* user text is always escaped, never interpolated as markup (TD §6).
|
|
664
|
+
*/
|
|
665
|
+
declare function svgString(view: SvgView): string;
|
|
666
|
+
|
|
667
|
+
/** Stable diagnostic codes, part of the public surface (API Spec §11). */
|
|
668
|
+
type SpCode = 'SP001' | 'SP002' | 'SP003' | 'SP004' | 'SP005' | 'SP006' | 'SP007' | 'SP008' | 'SP009' | 'SP010' | 'SP011' | 'SP012' | 'SP013';
|
|
669
|
+
interface Detail {
|
|
670
|
+
/** The property involved. */
|
|
671
|
+
readonly property: string;
|
|
672
|
+
/** Specifics of this occurrence, appended to what happened. */
|
|
673
|
+
readonly message?: string;
|
|
674
|
+
}
|
|
675
|
+
/** Thrown by diagnostics of `error` severity. */
|
|
676
|
+
declare class SilverpointError extends Error {
|
|
677
|
+
readonly code: SpCode;
|
|
678
|
+
constructor(code: SpCode, message: string);
|
|
679
|
+
}
|
|
680
|
+
/** Receives every warning; replaceable so tests and tools can observe diagnostics. */
|
|
681
|
+
type DiagnosticSink = (code: SpCode, message: string) => void;
|
|
682
|
+
/**
|
|
683
|
+
* Replaces the warning sink and forgets already reported warnings. Returns a function that
|
|
684
|
+
* restores the console sink.
|
|
685
|
+
* @internal
|
|
686
|
+
*/
|
|
687
|
+
declare function __setDiagnosticSink(next: DiagnosticSink | null): () => void;
|
|
688
|
+
/**
|
|
689
|
+
* The single diagnostic channel (TD §5.4). `error` codes always throw; `warn` codes reach
|
|
690
|
+
* the sink only outside production and are stripped from production bundles.
|
|
691
|
+
*/
|
|
692
|
+
declare function diagnose(code: SpCode, chart: string, detail: Detail): void;
|
|
693
|
+
|
|
694
|
+
/** The subset of `FontFaceSet` the check needs; injected so the core stays DOM-free. */
|
|
695
|
+
interface FontFaceSetLike {
|
|
696
|
+
load(font: string): Promise<readonly unknown[]>;
|
|
697
|
+
check(font: string): boolean;
|
|
698
|
+
}
|
|
699
|
+
/** Font shorthand used to probe the display face. */
|
|
700
|
+
declare const DISPLAY_FACE_PROBE = "16px \"EB Garamond\"";
|
|
701
|
+
/**
|
|
702
|
+
* Checks that the display typeface loaded. On failure it reports SP013 and resolves `false`;
|
|
703
|
+
* it never throws and never blocks the render (REQ-032).
|
|
704
|
+
*/
|
|
705
|
+
declare function checkTypeface(fonts: FontFaceSetLike, chart: string, face?: string): Promise<boolean>;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* `extent`, `min` and `max` are owned here instead of imported from `d3-array`, which is
|
|
709
|
+
* not in the allowlist (TD §5.3).
|
|
710
|
+
*/
|
|
711
|
+
declare function min(values: readonly number[]): number | undefined;
|
|
712
|
+
declare function max(values: readonly number[]): number | undefined;
|
|
713
|
+
declare function extent(values: readonly number[]): [number, number] | undefined;
|
|
714
|
+
|
|
715
|
+
interface ScaleSite {
|
|
716
|
+
/** Chart name, for diagnostics. */
|
|
717
|
+
readonly chart: string;
|
|
718
|
+
/** Property the domain comes from, for diagnostics. */
|
|
719
|
+
readonly property: string;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Expands a zero-length domain by the ground's `domainPadding` instead of dividing by zero
|
|
723
|
+
* (REQ-010). A constant `v` becomes `[v - |v|·p, v + |v|·p]`, or `[-p, p]` around zero — `[0, 2p]`
|
|
724
|
+
* on a zero-based axis, which never shows a value below zero that no datum has.
|
|
725
|
+
*/
|
|
726
|
+
declare function expandDomain(domain: readonly [number, number], padding: number, site: ScaleSite,
|
|
727
|
+
/** A zero-based axis (bars, areas): a flat zero domain grows upward only, never below zero. */
|
|
728
|
+
fromZero?: boolean): [number, number];
|
|
729
|
+
interface LinearScale {
|
|
730
|
+
(value: number): number;
|
|
731
|
+
readonly domain: readonly [number, number];
|
|
732
|
+
ticks(count: number): number[];
|
|
733
|
+
}
|
|
734
|
+
/** Linear scale over `d3-scale`, with degenerate-domain expansion. */
|
|
735
|
+
declare function linearScale(domain: readonly [number, number], range: readonly [number, number], options: ScaleSite & {
|
|
736
|
+
readonly padding: number;
|
|
737
|
+
readonly nice?: boolean;
|
|
738
|
+
readonly fromZero?: boolean;
|
|
739
|
+
}): LinearScale;
|
|
740
|
+
interface BandScale {
|
|
741
|
+
/** Start of the band, or `undefined` for a value outside the domain. */
|
|
742
|
+
(value: string): number | undefined;
|
|
743
|
+
readonly bandwidth: number;
|
|
744
|
+
/** Centre of the band. */
|
|
745
|
+
center(value: string): number | undefined;
|
|
746
|
+
}
|
|
747
|
+
/** Band scale over `d3-scale`. */
|
|
748
|
+
declare function bandScale(domain: readonly string[], range: readonly [number, number], options?: {
|
|
749
|
+
readonly paddingInner?: number;
|
|
750
|
+
readonly paddingOuter?: number;
|
|
751
|
+
}): BandScale;
|
|
752
|
+
|
|
753
|
+
/** Returns the geometry untouched and uncopied. `precision` mode is exactly this (REQ-021). */
|
|
754
|
+
declare const NullInker: Inker;
|
|
755
|
+
|
|
756
|
+
/** Registers an inker under its `name`, replacing any previous one with that name. */
|
|
757
|
+
declare function registerInker(inker: Inker): void;
|
|
758
|
+
/**
|
|
759
|
+
* Resolves an inker by name among the registered ones and `builtins`. An unknown name falls
|
|
760
|
+
* back to `NullInker` and emits SP006; the render continues (REQ-026).
|
|
761
|
+
*/
|
|
762
|
+
declare function resolveInker(name: string, chart: string, builtins?: readonly Inker[]): Inker;
|
|
763
|
+
|
|
764
|
+
interface ResolvedConfig {
|
|
765
|
+
readonly ground: GroundRef;
|
|
766
|
+
readonly substrate: SubstrateName;
|
|
767
|
+
readonly mode: InkMode;
|
|
768
|
+
readonly chrome: 'card' | 'bare';
|
|
769
|
+
readonly hatchFill: 'tile' | 'per-shape';
|
|
770
|
+
readonly height: number;
|
|
771
|
+
readonly dataTable: 'visible' | 'hidden' | 'none';
|
|
772
|
+
readonly locale: string;
|
|
773
|
+
}
|
|
774
|
+
/** Default values, part of the contract (API Spec §5.1). */
|
|
775
|
+
declare const DEFAULTS: Readonly<{
|
|
776
|
+
readonly ground: "silverpoint";
|
|
777
|
+
readonly substrate: "cream";
|
|
778
|
+
readonly mode: "ink";
|
|
779
|
+
readonly chrome: "card";
|
|
780
|
+
readonly hatchFill: "tile";
|
|
781
|
+
readonly height: 160;
|
|
782
|
+
readonly dataTable: "hidden";
|
|
783
|
+
readonly locale: "en";
|
|
784
|
+
}>;
|
|
785
|
+
/**
|
|
786
|
+
* Resolves `ground`, `substrate` and `mode` with the precedence of API Spec §5.1: chart prop,
|
|
787
|
+
* then provider, then library default — except that a media query forcing precision wins
|
|
788
|
+
* over everything, because it is an accessibility requirement (REQ-123).
|
|
789
|
+
*/
|
|
790
|
+
declare function resolveConfig(props: CommonChartProps, provider?: ProviderConfig, environment?: {
|
|
791
|
+
readonly forcedPrecision?: boolean;
|
|
792
|
+
readonly locale?: string;
|
|
793
|
+
}): ResolvedConfig;
|
|
794
|
+
/** Media query under which the environment forces `precision` mode (REQ-123). */
|
|
795
|
+
declare const FORCED_PRECISION_QUERY = "(prefers-contrast: more), (forced-colors: active)";
|
|
796
|
+
/**
|
|
797
|
+
* Builds a deterministic instance id from the chart name and a token the adapter owns, such
|
|
798
|
+
* as React's `useId()` or Angular's creation order. The result is safe inside `id` and `url()`.
|
|
799
|
+
*/
|
|
800
|
+
declare function instanceId(chart: string, token: string | number): string;
|
|
801
|
+
|
|
802
|
+
/** `LineChart` recipe (REQ-060): props plus scales produce exact geometry. */
|
|
803
|
+
declare const lineChart: ChartRecipe<LineChartProps>;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Demo dataset of `LineChart` (REQ-093). Frozen, and part of the stable surface: changing it
|
|
807
|
+
* alters the SVG of anyone who renders without data, so it is never a patch (Data Model §4).
|
|
808
|
+
*/
|
|
809
|
+
declare const LINE_CHART_DEMO: readonly Datum[];
|
|
810
|
+
declare const LINE_CHART_DEMO_KEYS: Readonly<{
|
|
811
|
+
readonly xKey: "hour";
|
|
812
|
+
readonly valueKey: "hits";
|
|
813
|
+
readonly secondaryKey: "baseline";
|
|
814
|
+
}>;
|
|
815
|
+
|
|
816
|
+
/** SVG path of a circle, drawn as two arcs so it survives inking as a closed path. */
|
|
817
|
+
declare function circlePath(cx: number, cy: number, r: number): string;
|
|
818
|
+
|
|
819
|
+
type PointerKind = 'mouse' | 'pen' | 'touch';
|
|
820
|
+
/** Minimum touch target, in px (REQ-144). */
|
|
821
|
+
declare const MIN_TOUCH_TARGET = 24;
|
|
822
|
+
/**
|
|
823
|
+
* Resolves the active item as a pure function of a pointer position, in SVG space, and the
|
|
824
|
+
* geometry — no DOM involved (REQ-140).
|
|
825
|
+
*
|
|
826
|
+
* A pointer inside an item's box resolves to that item. Otherwise a mouse or pen resolves to the
|
|
827
|
+
* item nearest along x, then along y. Touch resolves by
|
|
828
|
+
* proximity and only within a target at least 24 px wide (REQ-144). A point outside the
|
|
829
|
+
* drawing area resolves to `null`.
|
|
830
|
+
*/
|
|
831
|
+
declare function resolveActive(geometry: Geometry, pointer: Readonly<{
|
|
832
|
+
x: number;
|
|
833
|
+
y: number;
|
|
834
|
+
}>, kind?: PointerKind): ActiveItem | null;
|
|
835
|
+
/**
|
|
836
|
+
* Converts a client-space pointer position into SVG space, given the rendered bounding box of
|
|
837
|
+
* the `<svg>` element. Adapters pass numbers; the arithmetic stays here (Art. 2).
|
|
838
|
+
*/
|
|
839
|
+
declare function toSvgPoint(client: Readonly<{
|
|
840
|
+
x: number;
|
|
841
|
+
y: number;
|
|
842
|
+
}>, box: Readonly<{
|
|
843
|
+
left: number;
|
|
844
|
+
top: number;
|
|
845
|
+
width: number;
|
|
846
|
+
height: number;
|
|
847
|
+
}>, viewBox: Rect): {
|
|
848
|
+
x: number;
|
|
849
|
+
y: number;
|
|
850
|
+
};
|
|
851
|
+
/** Keys that move the active item (REQ-122). */
|
|
852
|
+
declare const NAVIGATION_KEYS: readonly string[];
|
|
853
|
+
/**
|
|
854
|
+
* Keyboard traversal of the data points, as a pure function (REQ-122). Right and down move to
|
|
855
|
+
* the next point of the series, left and up to the previous one, Home and End to its ends,
|
|
856
|
+
* Escape clears. On a grid — every item carries a `cell` — the arrows move by column and row
|
|
857
|
+
* instead. Returns `undefined` for a key that is not a navigation key.
|
|
858
|
+
*/
|
|
859
|
+
declare function stepActive(geometry: Geometry, current: ActiveItem | null, key: string): ActiveItem | null | undefined;
|
|
860
|
+
/** Readout of an active item, positioned as percentages of the viewBox (REQ-141). */
|
|
861
|
+
interface Readout {
|
|
862
|
+
readonly heading: string;
|
|
863
|
+
readonly text: string;
|
|
864
|
+
readonly left: string;
|
|
865
|
+
readonly top: string;
|
|
866
|
+
/** Sentence announced to assistive technology (REQ-122). */
|
|
867
|
+
readonly announcement: string;
|
|
868
|
+
/** Marker drawn over the active point. */
|
|
869
|
+
readonly marker: Stroke;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Builds the readout of an active item from the chart's own tabular alternative, so the
|
|
873
|
+
* readout, the table and the announcement always say the same.
|
|
874
|
+
*/
|
|
875
|
+
declare function readout(model: {
|
|
876
|
+
readonly geometry: Geometry;
|
|
877
|
+
readonly table: {
|
|
878
|
+
readonly columns: readonly string[];
|
|
879
|
+
readonly rows: readonly (readonly string[])[];
|
|
880
|
+
};
|
|
881
|
+
}, active: ActiveItem): Readout;
|
|
882
|
+
|
|
883
|
+
type Point = Readonly<{
|
|
884
|
+
x: number;
|
|
885
|
+
y: number;
|
|
886
|
+
}>;
|
|
887
|
+
type Box = Readonly<{
|
|
888
|
+
left: number;
|
|
889
|
+
top: number;
|
|
890
|
+
width: number;
|
|
891
|
+
height: number;
|
|
892
|
+
}>;
|
|
893
|
+
/** A DOM event, reduced to the numbers the interaction engine needs. */
|
|
894
|
+
type InteractionEvent = {
|
|
895
|
+
readonly type: 'pointer' | 'click';
|
|
896
|
+
readonly client: Point;
|
|
897
|
+
readonly box: Box;
|
|
898
|
+
readonly kind: PointerKind;
|
|
899
|
+
} | {
|
|
900
|
+
readonly type: 'leave' | 'focus' | 'blur';
|
|
901
|
+
} | {
|
|
902
|
+
readonly type: 'key';
|
|
903
|
+
readonly key: string;
|
|
904
|
+
};
|
|
905
|
+
interface InteractionResult {
|
|
906
|
+
readonly active: ActiveItem | null;
|
|
907
|
+
/** The active item differs from the current one: emit `activeChange` (REQ-141, REQ-143). */
|
|
908
|
+
readonly changed: boolean;
|
|
909
|
+
/** An item was chosen: emit `select` (API Spec §9). */
|
|
910
|
+
readonly selected?: ActiveItem;
|
|
911
|
+
/** The event was consumed; a key event should not scroll the page. */
|
|
912
|
+
readonly handled: boolean;
|
|
913
|
+
}
|
|
914
|
+
/** Same item: same series and index. */
|
|
915
|
+
declare function sameActive(a: ActiveItem | null, b: ActiveItem | null): boolean;
|
|
916
|
+
/**
|
|
917
|
+
* The whole interaction of a chart as one pure function (REQ-140): current item plus event gives
|
|
918
|
+
* the next item. Adapters wire DOM events to it and keep the result; they decide nothing.
|
|
919
|
+
*/
|
|
920
|
+
declare function reduceInteraction(geometry: Geometry, current: ActiveItem | null, event: InteractionEvent): InteractionResult;
|
|
921
|
+
|
|
922
|
+
/** `BulletChart` recipe (REQ-069): a bar to the actual value and a marker at the target, on 0-100. */
|
|
923
|
+
declare const bulletChart: ChartRecipe<BulletChartProps>;
|
|
924
|
+
|
|
925
|
+
/** `PyramidChart` recipe (REQ-070): stacked, centred tiers whose width encodes the value. */
|
|
926
|
+
declare const pyramidChart: ChartRecipe<PyramidChartProps>;
|
|
927
|
+
|
|
928
|
+
/** `HeatmapChart` recipe (REQ-084): labelled rows of cells, toned by value and printed. */
|
|
929
|
+
declare const heatmapChart: ChartRecipe<HeatmapChartProps>;
|
|
930
|
+
|
|
931
|
+
/** `TreemapChart` recipe (REQ-085): tiles placed first-fit in a declared grid, each labelled with its share. */
|
|
932
|
+
declare const treemapChart: ChartRecipe<TreemapChartProps>;
|
|
933
|
+
|
|
934
|
+
/** `SankeyChart` recipe (REQ-086): flow bands between nodes layered by longest path. */
|
|
935
|
+
declare const sankeyChart: ChartRecipe<SankeyChartProps>;
|
|
936
|
+
|
|
937
|
+
/** `ActivityGrid` recipe (REQ-087): one cell per day, a column per week, sized and toned by level. */
|
|
938
|
+
declare const activityGrid: ChartRecipe<ActivityGridProps>;
|
|
939
|
+
|
|
940
|
+
/** `StepChart` recipe (REQ-061): a series drawn as exact steps. */
|
|
941
|
+
declare const stepChart: ChartRecipe<StepChartProps>;
|
|
942
|
+
|
|
943
|
+
/** `SparklineRows` recipe (REQ-062): one row per series — name, sparkline, printed readout. */
|
|
944
|
+
declare const sparklineRows: ChartRecipe<SparklineRowsProps>;
|
|
945
|
+
|
|
946
|
+
/** `KpiCard` recipe (REQ-063): the figure, its signed delta with a direction mark, and an area sparkline. */
|
|
947
|
+
declare const kpiCard: ChartRecipe<KpiCardProps>;
|
|
948
|
+
|
|
949
|
+
/** `BarChart` recipe (REQ-064): pill bars, columns or rows, with an optional second series. */
|
|
950
|
+
declare const barChart: ChartRecipe<BarChartProps>;
|
|
951
|
+
|
|
952
|
+
/** `StackedBarChart` recipe (REQ-065): one segment per key, stacked from zero, named in a legend. */
|
|
953
|
+
declare const stackedBarChart: ChartRecipe<StackedBarChartProps>;
|
|
954
|
+
|
|
955
|
+
/** `ComposedChart` recipe (REQ-066): columns and a spline on one value scale. */
|
|
956
|
+
declare const composedChart: ChartRecipe<ComposedChartProps>;
|
|
957
|
+
|
|
958
|
+
/** `WaterfallChart` recipe (REQ-067): totals from zero and signed deltas floating on the running total. */
|
|
959
|
+
declare const waterfallChart: ChartRecipe<WaterfallChartProps>;
|
|
960
|
+
|
|
961
|
+
/** `FunnelChart` recipe (REQ-068): centred stages, width ∝ value, value and share printed. */
|
|
962
|
+
declare const funnelChart: ChartRecipe<FunnelChartProps>;
|
|
963
|
+
|
|
964
|
+
/** `DonutChart` recipe (REQ-075): sectors ∝ value, a central readout, a legend with shares. */
|
|
965
|
+
declare const donutChart: ChartRecipe<DonutChartProps>;
|
|
966
|
+
|
|
967
|
+
/** `RadarChart` recipe (REQ-076): one spoke per subject, a closed polygon of values. */
|
|
968
|
+
declare const radarChart: ChartRecipe<RadarChartProps>;
|
|
969
|
+
|
|
970
|
+
/** `PolarBarChart` recipe (REQ-077): equal slots around the turn, bar length ∝ value. */
|
|
971
|
+
declare const polarBarChart: ChartRecipe<PolarBarChartProps>;
|
|
972
|
+
|
|
973
|
+
/** `CoxcombChart` recipe (REQ-088): Nightingale's polar area — equal angles, area ∝ value. */
|
|
974
|
+
declare const coxcombChart: ChartRecipe<CoxcombChartProps>;
|
|
975
|
+
|
|
976
|
+
/** `RadialArcGroup` recipe (REQ-078): concentric 180° tracks, sweep ∝ value / the largest. */
|
|
977
|
+
declare const radialArcGroup: ChartRecipe<RadialArcGroupProps>;
|
|
978
|
+
|
|
979
|
+
/** `RadialRings` recipe (REQ-079): concentric progress rings, sweep ∝ value in 0-100. */
|
|
980
|
+
declare const radialRings: ChartRecipe<RadialRingsProps>;
|
|
981
|
+
|
|
982
|
+
/** `GaugeArc` recipe (REQ-080): a 240° arc swept to a percent, the readout at its centre. */
|
|
983
|
+
declare const gaugeArc: ChartRecipe<GaugeArcProps>;
|
|
984
|
+
|
|
985
|
+
/** `MeterChart` recipe (REQ-081): a semicircular meter whose needle points at a percent. */
|
|
986
|
+
declare const meterChart: ChartRecipe<MeterChartProps>;
|
|
987
|
+
|
|
988
|
+
/** `WindRose` recipe (REQ-089): the share of observations per compass sector, stacked by speed. */
|
|
989
|
+
declare const windRose: ChartRecipe<WindRoseProps>;
|
|
990
|
+
|
|
991
|
+
/** `ChordRing` recipe (REQ-091): directed flows between categories, ribbons over `d3-chord`. */
|
|
992
|
+
declare const chordRing: ChartRecipe<ChordRingProps>;
|
|
993
|
+
|
|
994
|
+
/** `OrbitChart` recipe (REQ-092): nested tilted orbits, markers along them by period, sized by value. */
|
|
995
|
+
declare const orbitChart: ChartRecipe<OrbitChartProps>;
|
|
996
|
+
|
|
997
|
+
/** `VolvelleChart` recipe (REQ-090): concentric categorical rings read against one index. */
|
|
998
|
+
declare const volvelleChart: ChartRecipe<VolvelleChartProps>;
|
|
999
|
+
|
|
1000
|
+
/** `CandlestickChart` recipe (REQ-071): OHLC bodies and wicks, bounds derived or pinned (REQ-097). */
|
|
1001
|
+
declare const candlestickChart: ChartRecipe<CandlestickChartProps>;
|
|
1002
|
+
|
|
1003
|
+
/** `AreaChart` recipe (REQ-072): a curved area, toned, under its exact line. */
|
|
1004
|
+
declare const areaChart: ChartRecipe<AreaChartProps>;
|
|
1005
|
+
|
|
1006
|
+
/** `RangeBandChart` recipe (REQ-073): the band between a low and a high series. */
|
|
1007
|
+
declare const rangeBandChart: ChartRecipe<RangeBandChartProps>;
|
|
1008
|
+
|
|
1009
|
+
/** `StreamChart` recipe (REQ-074): two waves, overlaid or stacked, told apart by dash and name. */
|
|
1010
|
+
declare const streamChart: ChartRecipe<StreamChartProps>;
|
|
1011
|
+
|
|
1012
|
+
/** `ScatterChart` recipe (REQ-082): points on two linear scales, optionally sized by area. */
|
|
1013
|
+
declare const scatterChart: ChartRecipe<ScatterChartProps>;
|
|
1014
|
+
|
|
1015
|
+
/** `BubbleChart` recipe (REQ-083): circles whose area encodes the size. */
|
|
1016
|
+
declare const bubbleChart: ChartRecipe<BubbleChartProps>;
|
|
1017
|
+
|
|
1018
|
+
export { type Accessor, type ActiveItem, type ActivityGridProps, type AreaChartProps, type BandScale, type BarChartProps, type BubbleChartProps, type BulletChartProps, type CandlestickChartProps, type ChartHandle, type ChartModel, type ChartRecipe, type ChordRingProps, type CommonChartProps, type ComposedChartProps, type CoxcombChartProps, DEFAULTS, DISPLAY_FACE_PROBE, type DataTable, type Datum, type Detail, type DiagnosticSink, type DonutChartProps, FORCED_PRECISION_QUERY, type FontFaceSetLike, type FunnelChartProps, type GaugeArcProps, type Geometry, type Ground, type GroundName, type GroundRef, type HeatmapChartProps, type HitArea, type InkMode, type InkOptions, type Inker, type InteractionEvent, type InteractionResult, type KpiCardProps, LINE_CHART_DEMO, LINE_CHART_DEMO_KEYS, type LabelKind, type LineChartProps, type LineCurve, type LinearScale, MIN_TOUCH_TARGET, type MeterChartProps, NAVIGATION_KEYS, NullInker, type OrbitChartProps, PATH_BYTE_BUDGET, type PathView, type PatternView, type PointerKind, type PolarBarChartProps, type ProviderConfig, type PyramidChartProps, type RadarChartProps, type RadialArcGroupProps, type RadialRingsProps, type RangeBandChartProps, type Readout, type RecipeContext, type Rect, type ResolvedConfig, type SankeyChartProps, type ScaleSite, type ScatterChartProps, type Seed, SilverpointError, type SpCode, type SparklineRowsProps, type StackedBarChartProps, type StepChartProps, type StreamChartProps, type Stroke, type StrokePaint, type StrokePart, type StrokeRole, type SubstrateName, type SvgView, type TextLabel, type TextView, type Tile, type TonalRamp, type ToneLevel, type ToneSpec, type TreemapChartProps, type ViewStyle, type VolvelleChartProps, type WaterfallChartProps, type WindRoseProps, __setDiagnosticSink, activityGrid, addDays, areaChart, bandScale, barChart, bubbleChart, bulletChart, candlestickChart, checkTypeface, chordRing, circlePath, composedChart, coxcombChart, createPrng, deriveSeed, diagnose, donutChart, enforceHeightening, expandDomain, extent, fnv1a32, funnelChart, gaugeArc, heatmapChart, instanceId, isoDate, kpiCard, lineChart, linearScale, max, meterChart, min, orbitChart, parseGeometry, parseIsoDate, pathBytes, polarBarChart, pyramidChart, radarChart, radialArcGroup, radialRings, rangeBandChart, readout, reduceInteraction, registerInker, resolveActive, resolveConfig, resolveInker, resolveSeed, round2, roundGeometry, roundPathData, sameActive, sankeyChart, scatterChart, serializeGeometry, sparklineRows, stackedBarChart, stepActive, stepChart, streamChart, svgString, toSvgPoint, toSvgView, treemapChart, volvelleChart, waterfallChart, weekday, windRose };
|