@doki-land/davinci 0.0.0-stage → 0.0.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/dist/chart.d.ts +583 -0
- package/dist/chart.js +6328 -0
- package/dist/diagram.d.ts +413 -0
- package/dist/diagram.js +415 -0
- package/dist/index.d.ts +1203 -0
- package/dist/index.js +7561 -0
- package/dist/motion.d.ts +214 -0
- package/dist/motion.js +72 -0
- package/dist/runtime.d.ts +129 -0
- package/dist/runtime.js +101 -0
- package/dist/scene-svg.d.ts +180 -0
- package/dist/scene-svg.js +164 -0
- package/dist/scene.d.ts +406 -0
- package/dist/scene.js +697 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.js +153 -0
- package/package.json +74 -4
- package/README.md +0 -3
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
/** Semantic kind of a data field. */
|
|
4
|
+
export type FieldSemantic = "nominal" | "ordinal" | "quantitative" | "temporal" | "unknown";
|
|
5
|
+
/** A column in the snapshot — typed array with semantic hint. */
|
|
6
|
+
export interface DataColumn {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly semantic: FieldSemantic;
|
|
9
|
+
readonly values: ReadonlyArray<number | string | boolean | null>;
|
|
10
|
+
}
|
|
11
|
+
/** Columnar snapshot. All columns share the same row count. */
|
|
12
|
+
export interface DataSnapshot {
|
|
13
|
+
readonly columns: ReadonlyArray<DataColumn>;
|
|
14
|
+
/** Row count (derived from first column). */
|
|
15
|
+
readonly rowCount: number;
|
|
16
|
+
}
|
|
17
|
+
/** Build a DataSnapshot from rows of key-value objects. */
|
|
18
|
+
export declare function fromRows(rows: ReadonlyArray<Record<string, unknown>>): DataSnapshot;
|
|
19
|
+
/** Get a column by name. */
|
|
20
|
+
export declare function column(snap: DataSnapshot, name: string): DataColumn | undefined;
|
|
21
|
+
/** Scale family. */
|
|
22
|
+
export type ScaleKind = "linear" | "band" | "point" | "log" | "quantile";
|
|
23
|
+
/** Continuous domain → continuous range. */
|
|
24
|
+
export interface LinearScale {
|
|
25
|
+
readonly kind: "linear";
|
|
26
|
+
readonly domain: [
|
|
27
|
+
number,
|
|
28
|
+
number
|
|
29
|
+
];
|
|
30
|
+
readonly range: [
|
|
31
|
+
number,
|
|
32
|
+
number
|
|
33
|
+
];
|
|
34
|
+
/** Clip to range when true (default true). */
|
|
35
|
+
readonly clamp?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Discrete domain → continuous range with padding. */
|
|
38
|
+
export interface BandScale {
|
|
39
|
+
readonly kind: "band";
|
|
40
|
+
readonly domain: ReadonlyArray<string>;
|
|
41
|
+
readonly range: [
|
|
42
|
+
number,
|
|
43
|
+
number
|
|
44
|
+
];
|
|
45
|
+
readonly padding?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Like band but points are center-aligned (no bandwidth). */
|
|
48
|
+
export interface PointScale {
|
|
49
|
+
readonly kind: "point";
|
|
50
|
+
readonly domain: ReadonlyArray<string>;
|
|
51
|
+
readonly range: [
|
|
52
|
+
number,
|
|
53
|
+
number
|
|
54
|
+
];
|
|
55
|
+
readonly padding?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Logarithmic continuous domain → continuous range. */
|
|
58
|
+
export interface LogScale {
|
|
59
|
+
readonly kind: "log";
|
|
60
|
+
readonly domain: [
|
|
61
|
+
number,
|
|
62
|
+
number
|
|
63
|
+
];
|
|
64
|
+
readonly range: [
|
|
65
|
+
number,
|
|
66
|
+
number
|
|
67
|
+
];
|
|
68
|
+
readonly base?: number;
|
|
69
|
+
}
|
|
70
|
+
/** Quantile — maps sorted quantitative domain values to discrete thresholds. */
|
|
71
|
+
export interface QuantileScale {
|
|
72
|
+
readonly kind: "quantile";
|
|
73
|
+
readonly domain: ReadonlyArray<number>;
|
|
74
|
+
readonly range: ReadonlyArray<number>;
|
|
75
|
+
}
|
|
76
|
+
export type Scale = LinearScale | BandScale | PointScale | LogScale | QuantileScale;
|
|
77
|
+
export declare function apply(s: Scale, value: number | string): number;
|
|
78
|
+
/** Bandwidth for band scales (0 for others). */
|
|
79
|
+
export declare function bandwidth(s: Scale): number;
|
|
80
|
+
/** 4–6 evenly spaced "nice" values covering the domain (single value when
|
|
81
|
+
* flat). Tick placement is derived from the domain, never from a hardcoded
|
|
82
|
+
* list, so axes stay honest when data changes. */
|
|
83
|
+
export declare function niceLinearTicks(domain: [
|
|
84
|
+
number,
|
|
85
|
+
number
|
|
86
|
+
]): {
|
|
87
|
+
values: number[];
|
|
88
|
+
decimals: number;
|
|
89
|
+
};
|
|
90
|
+
/** Minimal-decimal label for a tick value — trailing zeros dropped, never
|
|
91
|
+
* `-0`, never a floating point tail. */
|
|
92
|
+
export declare function formatTickLabel(value: number, decimals: number): string;
|
|
93
|
+
export type AggregateKind = "count" | "sum" | "mean" | "min" | "max" | "median";
|
|
94
|
+
/** Type-7 quantile (R / numpy default): h = 1 + (n-1)p, linear interpolation
|
|
95
|
+
* between the bracketing order statistics. `sorted` must be ascending. */
|
|
96
|
+
export declare function quantile(sorted: ReadonlyArray<number>, p: number): number;
|
|
97
|
+
/** Five-number summary for one boxplot group. Whiskers are the most extreme
|
|
98
|
+
* points inside the 1.5·IQR fences; anything beyond is an outlier. */
|
|
99
|
+
export interface BoxStats {
|
|
100
|
+
readonly low: number;
|
|
101
|
+
readonly q1: number;
|
|
102
|
+
readonly median: number;
|
|
103
|
+
readonly q3: number;
|
|
104
|
+
readonly high: number;
|
|
105
|
+
readonly n: number;
|
|
106
|
+
readonly outliers: ReadonlyArray<number>;
|
|
107
|
+
}
|
|
108
|
+
export declare function boxStats(values: ReadonlyArray<number | string | boolean | null>): BoxStats | null;
|
|
109
|
+
/** One histogram bin — half-open [x0, x1) except the last bin, which is
|
|
110
|
+
* closed so the maximum value lands inside a real bin. */
|
|
111
|
+
export interface HistogramBin {
|
|
112
|
+
readonly x0: number;
|
|
113
|
+
readonly x1: number;
|
|
114
|
+
readonly count: number;
|
|
115
|
+
}
|
|
116
|
+
export interface HistogramResult {
|
|
117
|
+
readonly bins: ReadonlyArray<HistogramBin>;
|
|
118
|
+
readonly binWidth: number;
|
|
119
|
+
}
|
|
120
|
+
/** Bin finite values into equal-width bins. The width targets the
|
|
121
|
+
* Freedman–Diaconis rule, falls back to sqrt(n), and is snapped to a nice
|
|
122
|
+
* 1/2/5·10^k step so axis ticks stay honest. Edges align to bin-width
|
|
123
|
+
* multiples. Flat data collapses into a single bin. */
|
|
124
|
+
export declare function binValues(values: ReadonlyArray<number | string | boolean | null>, maxBins?: number): HistogramResult;
|
|
125
|
+
/** Silverman's rule-of-thumb bandwidth for Gaussian KDE: 0.9·min(σ, IQR/1.34)·n^(−1/5).
|
|
126
|
+
* Degenerate spreads fall back to range/20 so the kernel never collapses. */
|
|
127
|
+
export declare function silvermanBandwidth(values: ReadonlyArray<number | string | boolean | null>): number;
|
|
128
|
+
/** Gaussian kernel density estimate on a shared grid. The area under the
|
|
129
|
+
* returned curve integrates to 1 (up to grid resolution). */
|
|
130
|
+
export declare function kde(values: ReadonlyArray<number | string | boolean | null>, grid: ReadonlyArray<number>, bandwidth: number): number[];
|
|
131
|
+
/** Competition ranking ("1224"): ties share the minimum rank, rank 1 is the
|
|
132
|
+
* largest value. Non-finite values get no rank. */
|
|
133
|
+
export declare function rankDescending(values: ReadonlyArray<number>): Map<number, number>;
|
|
134
|
+
/** Compute aggregate over a numeric column. Only finite numbers are usable —
|
|
135
|
+
* nulls, non-numeric cells and ±Infinity / NaN are skipped, matching how
|
|
136
|
+
* `compile` reads quantitative columns, so every result stays finite. */
|
|
137
|
+
export declare function aggregate(values: ReadonlyArray<number | string | boolean | null>, kind: AggregateKind): number;
|
|
138
|
+
/** 2D point / vector (x, y). */
|
|
139
|
+
export interface Point2D {
|
|
140
|
+
readonly x: number;
|
|
141
|
+
readonly y: number;
|
|
142
|
+
}
|
|
143
|
+
/** Affine 2D transform matrix (3x3, column-major compact form).
|
|
144
|
+
*
|
|
145
|
+
* ```text
|
|
146
|
+
* | a c tx |
|
|
147
|
+
* | b d ty |
|
|
148
|
+
* | 0 0 1 |
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* Standard affine transforms (translate, scale, rotate, skew) compose via
|
|
152
|
+
* {@link multiplyTransform}.
|
|
153
|
+
*/
|
|
154
|
+
export interface Affine2D {
|
|
155
|
+
readonly a: number;
|
|
156
|
+
readonly b: number;
|
|
157
|
+
readonly c: number;
|
|
158
|
+
readonly d: number;
|
|
159
|
+
readonly tx: number;
|
|
160
|
+
readonly ty: number;
|
|
161
|
+
}
|
|
162
|
+
/** A segment of a path — one of the SVG/Cubic-like command primitives. */
|
|
163
|
+
export type PathCommand = {
|
|
164
|
+
readonly kind: "move";
|
|
165
|
+
readonly to: Point2D;
|
|
166
|
+
} | {
|
|
167
|
+
readonly kind: "line";
|
|
168
|
+
readonly to: Point2D;
|
|
169
|
+
} | {
|
|
170
|
+
readonly kind: "cubic";
|
|
171
|
+
readonly cp1: Point2D;
|
|
172
|
+
readonly cp2: Point2D;
|
|
173
|
+
readonly to: Point2D;
|
|
174
|
+
} | {
|
|
175
|
+
readonly kind: "quadratic";
|
|
176
|
+
readonly cp: Point2D;
|
|
177
|
+
readonly to: Point2D;
|
|
178
|
+
} | {
|
|
179
|
+
readonly kind: "arc";
|
|
180
|
+
readonly rx: number;
|
|
181
|
+
readonly ry: number;
|
|
182
|
+
readonly xRot: number;
|
|
183
|
+
readonly largeArc: boolean;
|
|
184
|
+
readonly sweep: boolean;
|
|
185
|
+
readonly to: Point2D;
|
|
186
|
+
} | {
|
|
187
|
+
readonly kind: "close";
|
|
188
|
+
};
|
|
189
|
+
/** A simple path = sequence of commands, optionally closed. */
|
|
190
|
+
export interface Path {
|
|
191
|
+
readonly commands: ReadonlyArray<PathCommand>;
|
|
192
|
+
}
|
|
193
|
+
/** Canonical sRGB color with alpha (0–1 each). */
|
|
194
|
+
export interface RGBA {
|
|
195
|
+
readonly r: number;
|
|
196
|
+
readonly g: number;
|
|
197
|
+
readonly b: number;
|
|
198
|
+
readonly a: number;
|
|
199
|
+
}
|
|
200
|
+
/** A font family + size + weight/style descriptor (platform-neutral). */
|
|
201
|
+
export interface FontSpec {
|
|
202
|
+
readonly family: string;
|
|
203
|
+
readonly sizePx: number;
|
|
204
|
+
readonly weight?: number;
|
|
205
|
+
readonly italic?: boolean;
|
|
206
|
+
}
|
|
207
|
+
/** Axis-aligned rectangle (x, y is top-left, w/h non-negative). */
|
|
208
|
+
export interface Rect {
|
|
209
|
+
readonly x: number;
|
|
210
|
+
readonly y: number;
|
|
211
|
+
readonly w: number;
|
|
212
|
+
readonly h: number;
|
|
213
|
+
}
|
|
214
|
+
export type DiagnosticSeverity = "info" | "warning" | "error";
|
|
215
|
+
/** A single diagnostic item. No reliance on VMZ protocol types. */
|
|
216
|
+
export interface Diagnostic {
|
|
217
|
+
readonly severity: DiagnosticSeverity;
|
|
218
|
+
/** Stable identifier like `davinci.diagram.unsupported`. */
|
|
219
|
+
readonly code: string;
|
|
220
|
+
/** Human-readable message in English. Localization is host-scope. */
|
|
221
|
+
readonly message: string;
|
|
222
|
+
/** Optional source reference (domain, node id, field path, etc.). */
|
|
223
|
+
readonly source?: string;
|
|
224
|
+
}
|
|
225
|
+
/** Immutable diagnostic set — used as output of compile/layout. */
|
|
226
|
+
export interface DiagnosticSet {
|
|
227
|
+
readonly items: ReadonlyArray<Diagnostic>;
|
|
228
|
+
}
|
|
229
|
+
/** Mark kind (geometric primitive family). Only marks with real scene
|
|
230
|
+
* geometry are listed — an authoring surface can never name a mark the
|
|
231
|
+
* engine would silently drop. */
|
|
232
|
+
export type MarkKind = "point" | "line" | "rect" | "bar" | "circle" | "area" | "pie" | "radar" | "heatmap" | "candlestick" | "boxplot" | "histogram" | "waterfall" | "funnel" | "gauge" | "sankey" | "treemap" | "ridgeline" | "bump" | "slope" | "rose" | "radial-bar" | "bullet" | "violin" | "streamgraph" | "mosaic" | "calendar" | "sunburst" | "dumbbell" | "lollipop" | "strip" | "beeswarm" | "gantt" | "tree" | "force" | "parallel" | "hexbin" | "contour" | "chord" | "geo";
|
|
233
|
+
/** Encoding channel — how a data field maps to a visual property. */
|
|
234
|
+
export interface EncodingChannel {
|
|
235
|
+
/** Field name in DataSnapshot. */
|
|
236
|
+
readonly field: string;
|
|
237
|
+
/** Visual channel: x, y, color, size, shape, opacity, text... */
|
|
238
|
+
readonly channel: string;
|
|
239
|
+
}
|
|
240
|
+
/** Chart authoring spec (Vega-Lite-lite). */
|
|
241
|
+
export interface ChartSpec {
|
|
242
|
+
readonly mark: MarkKind;
|
|
243
|
+
readonly encoding: ReadonlyArray<EncodingChannel>;
|
|
244
|
+
/** Optional explicit scale overrides. */
|
|
245
|
+
readonly scales?: ReadonlyMap<string, Scale>;
|
|
246
|
+
/** Facet field (optional — the scene builder lays out one small-multiple
|
|
247
|
+
* panel per facet value, sharing scales across panels). */
|
|
248
|
+
readonly facetField?: string;
|
|
249
|
+
/** How grouped (series) marks share the x slot. `undefined` is the
|
|
250
|
+
* natural per-mark default: `bar`/`rect` dodge side by side, everything
|
|
251
|
+
* else overlaps. `stack` accumulates positive and negative values
|
|
252
|
+
* separately from the zero baseline (bars and areas only). `percent`
|
|
253
|
+
* normalizes each x slot's stack into a shared 0–100 percent domain
|
|
254
|
+
* (bars and areas only, negative values are dropped with a warning). */
|
|
255
|
+
readonly seriesLayout?: "overlap" | "stack" | "dodge" | "percent";
|
|
256
|
+
/** Pie only: inner radius as a fraction of the outer radius (0 = pie,
|
|
257
|
+
* 0.55–0.75 reads as a donut). */
|
|
258
|
+
readonly innerRadiusRatio?: number;
|
|
259
|
+
/** Field whose value names each row. Marks carry this key as identity, so
|
|
260
|
+
* re-sorting or filtering rows never renumbers them. Without `keyField`
|
|
261
|
+
* keys are positional (`"0"`, `"1"`, …) and only stable while the row
|
|
262
|
+
* order is. */
|
|
263
|
+
readonly keyField?: string;
|
|
264
|
+
/** Treemap only: field naming each row's parent id (`keyField` names the
|
|
265
|
+
* row's own id). Rows whose parent is absent or unknown hang at the
|
|
266
|
+
* root level with a warning. */
|
|
267
|
+
readonly parentField?: string;
|
|
268
|
+
/** Treemap only: how many levels get their own rect. The document root
|
|
269
|
+
* (or, when drilled, the drill root's direct children) is level 1.
|
|
270
|
+
* Omitted means every level is drawn. */
|
|
271
|
+
readonly treemapDepth?: number;
|
|
272
|
+
/** Treemap only: rects smaller than this many px² are omitted instead of
|
|
273
|
+
* painted as invisible slivers. Defaults to 4 px² and always keeps the
|
|
274
|
+
* largest item of a level, so a level never vanishes entirely. */
|
|
275
|
+
readonly treemapMinArea?: number;
|
|
276
|
+
/** Treemap only: id of the node rendered as the root — the drill-down
|
|
277
|
+
* surface. An unknown id raises a diagnostic and the chart stays at the
|
|
278
|
+
* document root. */
|
|
279
|
+
readonly treemapRoot?: string;
|
|
280
|
+
/** Gauge only: the [min, max] the sweep spans; defaults to [0, 100]. */
|
|
281
|
+
readonly valueDomain?: readonly [
|
|
282
|
+
number,
|
|
283
|
+
number
|
|
284
|
+
];
|
|
285
|
+
/** Sparkline mode: strip axes, grid and legend for tiny inline charts. */
|
|
286
|
+
readonly spark?: boolean;
|
|
287
|
+
/** Tree only: layout variant. `tidy` (default) packs parents over their
|
|
288
|
+
* children; `dendrogram` aligns every leaf on the deepest column;
|
|
289
|
+
* `radial` maps depth to radius and leaf order to angle. */
|
|
290
|
+
readonly treeLayout?: "tidy" | "dendrogram" | "radial";
|
|
291
|
+
/** Parallel coordinates only: ordered quantitative fields, one axis per
|
|
292
|
+
* entry. This is the multi-axis authoring surface — encodings only carry
|
|
293
|
+
* the optional `color` series. */
|
|
294
|
+
readonly dimensions?: ReadonlyArray<string>;
|
|
295
|
+
/** Geo choropleth only: basemap resource id (registered by the host) and
|
|
296
|
+
* the projection to fit it with. */
|
|
297
|
+
readonly geo?: {
|
|
298
|
+
readonly map: string;
|
|
299
|
+
readonly projection: "mercator" | "equirectangular" | "albers";
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/** Series (grouping) domain resolved once by `compile`. */
|
|
303
|
+
export interface SeriesDomain {
|
|
304
|
+
/** Encoding field that groups marks, or null when ungrouped. */
|
|
305
|
+
readonly field: string | null;
|
|
306
|
+
/** Group values in first-appearance order — legend and palette share it. */
|
|
307
|
+
readonly categories: ReadonlyArray<string>;
|
|
308
|
+
}
|
|
309
|
+
/** One resolved mark instance in the plan — will become one Scene node. */
|
|
310
|
+
export interface PlanMark {
|
|
311
|
+
/** Row index in the resolved data. */
|
|
312
|
+
readonly rowIndex: number;
|
|
313
|
+
/** Stable row identity — `keyField` value, or the row index as a string.
|
|
314
|
+
* Duplicated keys are disambiguated with a `~rowIndex` suffix and
|
|
315
|
+
* reported as `davinci.chart.duplicate-key`. */
|
|
316
|
+
readonly key: string;
|
|
317
|
+
/** Series group this row belongs to (stringified), null when ungrouped. */
|
|
318
|
+
readonly series: string | null;
|
|
319
|
+
/** Encoded channel values (scale-applied). */
|
|
320
|
+
readonly channels: ReadonlyMap<string, number | string>;
|
|
321
|
+
/** Stacked layout only: the data-unit baseline this mark starts from
|
|
322
|
+
* (cumulative sum of same-sign values below it in its x slot). */
|
|
323
|
+
readonly stackBase?: number;
|
|
324
|
+
}
|
|
325
|
+
/** Full compile plan — scene builder consumes this. */
|
|
326
|
+
export interface ChartCompilePlan {
|
|
327
|
+
readonly spec: ChartSpec;
|
|
328
|
+
readonly resolvedData: DataSnapshot;
|
|
329
|
+
readonly scales: ReadonlyMap<string, Scale>;
|
|
330
|
+
readonly marks: ReadonlyArray<PlanMark>;
|
|
331
|
+
/** Resolved grouping domain — the scene never re-reads the series column. */
|
|
332
|
+
readonly series: SeriesDomain;
|
|
333
|
+
/** Statistic snapshot produced at compile time (histogram bins, boxplot
|
|
334
|
+
* five-number summaries, ridgeline density grid). Marks of stat-driven
|
|
335
|
+
* kinds index into THIS snapshot; `null` for marks that position raw
|
|
336
|
+
* rows. The scene and hosts read it as data, never recompute it. */
|
|
337
|
+
readonly stat: DataSnapshot | null;
|
|
338
|
+
/** Data problems found while compiling — row-level, never fatal to the host. */
|
|
339
|
+
readonly diagnostics: DiagnosticSet;
|
|
340
|
+
}
|
|
341
|
+
/** Resolve the effective series layout. `undefined` is the natural per-mark
|
|
342
|
+
* default: grouped bars dodge, everything else overlaps. */
|
|
343
|
+
export declare function resolveSeriesLayout(spec: ChartSpec, hasSeries: boolean): "overlap" | "stack" | "dodge" | "percent";
|
|
344
|
+
/** Compile a ChartSpec against a DataSnapshot. */
|
|
345
|
+
export declare function compile(spec: ChartSpec, data: DataSnapshot): ChartCompilePlan;
|
|
346
|
+
declare const SCENE_VERSION = "/v0";
|
|
347
|
+
export type SceneVersion = typeof SCENE_VERSION;
|
|
348
|
+
/** A stable identifier assigned by the domain (chart, diagram, ...). */
|
|
349
|
+
export type StableId = string;
|
|
350
|
+
/** High-level semantic role — used for hit-test targets and host binding. */
|
|
351
|
+
export type SemanticRole = "chart.mark" | "chart.axis" | "chart.grid" | "chart.legend" | "diagram.node" | "diagram.edge" | "diagram.label" | "diagram.cluster" | "diagram.port" | "text" | "image" | "decorative" | "group";
|
|
352
|
+
/** Source reference — back-link to the domain object that produced this node.
|
|
353
|
+
* Opaque to Scene; used by host for provenance / edit / export links. */
|
|
354
|
+
export interface SourceRef {
|
|
355
|
+
/** Domain identifier ("chart", "diagram", ...). */
|
|
356
|
+
readonly domain: string;
|
|
357
|
+
/** Optional path within the domain (field name, row index, node id, ...). */
|
|
358
|
+
readonly path?: ReadonlyArray<string | number>;
|
|
359
|
+
}
|
|
360
|
+
/** Hit region — optional explicit target for hit-testing (overrides geometry bounds). */
|
|
361
|
+
export type HitRegion = {
|
|
362
|
+
readonly rect: Rect;
|
|
363
|
+
} | {
|
|
364
|
+
/** Annular sector for pie / donut slices: angle in radians, 0 =
|
|
365
|
+
* +x axis, positive clockwise (screen coordinates, y down). */
|
|
366
|
+
readonly sector: {
|
|
367
|
+
readonly cx: number;
|
|
368
|
+
readonly cy: number;
|
|
369
|
+
readonly rOuter: number;
|
|
370
|
+
readonly rInner: number;
|
|
371
|
+
readonly a0: number;
|
|
372
|
+
readonly a1: number;
|
|
373
|
+
};
|
|
374
|
+
} | {
|
|
375
|
+
/** Polyline vertices in scene order, each with its stable row key —
|
|
376
|
+
* lets a host snap to the nearest real data point on a line or
|
|
377
|
+
* area path instead of interpolating between pixels. */
|
|
378
|
+
readonly polyline: {
|
|
379
|
+
readonly points: ReadonlyArray<Point2D>;
|
|
380
|
+
readonly keys: ReadonlyArray<string>;
|
|
381
|
+
};
|
|
382
|
+
} | {
|
|
383
|
+
/** Closed filled polygon (funnel segments, sankey link ribbons,
|
|
384
|
+
* ridgeline ribbons): the host hit-tests with ray casting inside
|
|
385
|
+
* and falls back to edge distance outside, and anchors tooltips at
|
|
386
|
+
* the polygon centroid. */
|
|
387
|
+
readonly polygon: {
|
|
388
|
+
readonly points: ReadonlyArray<Point2D>;
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
export interface BaseSemantic {
|
|
392
|
+
/** Stable identity — MUST be unique within one Scene. */
|
|
393
|
+
readonly id: StableId;
|
|
394
|
+
/** What this node IS (semantic tag, not style). */
|
|
395
|
+
readonly role: SemanticRole;
|
|
396
|
+
/** Optional back-link to domain source. */
|
|
397
|
+
readonly source?: SourceRef;
|
|
398
|
+
/** Optional hit region override. */
|
|
399
|
+
readonly hitRegion?: HitRegion;
|
|
400
|
+
}
|
|
401
|
+
export interface SemanticTransform {
|
|
402
|
+
/** Local transform (will be composed with parent during resolve). */
|
|
403
|
+
readonly transform?: Affine2D;
|
|
404
|
+
/** Optional local clip rect (intersected with parent clip during resolve). */
|
|
405
|
+
readonly clip?: Rect;
|
|
406
|
+
}
|
|
407
|
+
export interface Stroke {
|
|
408
|
+
readonly color?: RGBA;
|
|
409
|
+
readonly width?: number;
|
|
410
|
+
readonly dash?: ReadonlyArray<number>;
|
|
411
|
+
}
|
|
412
|
+
export interface Fill {
|
|
413
|
+
readonly color?: RGBA;
|
|
414
|
+
}
|
|
415
|
+
/** A group node — container only; carries transform/clip and children. */
|
|
416
|
+
export interface SemanticGroup extends BaseSemantic, SemanticTransform {
|
|
417
|
+
readonly kind: "group";
|
|
418
|
+
readonly children: ReadonlyArray<SemanticNode>;
|
|
419
|
+
}
|
|
420
|
+
/** A path shape (SVG/Cubic-style command sequence). */
|
|
421
|
+
export interface SemanticPath extends BaseSemantic, SemanticTransform {
|
|
422
|
+
readonly kind: "path";
|
|
423
|
+
readonly path: Path;
|
|
424
|
+
readonly stroke?: Stroke;
|
|
425
|
+
readonly fill?: Fill;
|
|
426
|
+
}
|
|
427
|
+
/** An axis-aligned rectangle. */
|
|
428
|
+
export interface SemanticRect extends BaseSemantic, SemanticTransform {
|
|
429
|
+
readonly kind: "rect";
|
|
430
|
+
readonly x: number;
|
|
431
|
+
readonly y: number;
|
|
432
|
+
readonly w: number;
|
|
433
|
+
readonly h: number;
|
|
434
|
+
readonly rx?: number;
|
|
435
|
+
readonly ry?: number;
|
|
436
|
+
readonly stroke?: Stroke;
|
|
437
|
+
readonly fill?: Fill;
|
|
438
|
+
}
|
|
439
|
+
/** An ellipse defined by center + radii. */
|
|
440
|
+
export interface SemanticEllipse extends BaseSemantic, SemanticTransform {
|
|
441
|
+
readonly kind: "ellipse";
|
|
442
|
+
readonly cx: number;
|
|
443
|
+
readonly cy: number;
|
|
444
|
+
readonly rx: number;
|
|
445
|
+
readonly ry: number;
|
|
446
|
+
readonly stroke?: Stroke;
|
|
447
|
+
readonly fill?: Fill;
|
|
448
|
+
}
|
|
449
|
+
/** An image — referenced by URL / resource id; NOT raw pixels. */
|
|
450
|
+
export interface SemanticImage extends BaseSemantic, SemanticTransform {
|
|
451
|
+
readonly kind: "image";
|
|
452
|
+
readonly resourceRef: string;
|
|
453
|
+
readonly x: number;
|
|
454
|
+
readonly y: number;
|
|
455
|
+
readonly w: number;
|
|
456
|
+
readonly h: number;
|
|
457
|
+
}
|
|
458
|
+
/** A text node — string + font spec. Host provides actual metrics. */
|
|
459
|
+
export interface SemanticText extends BaseSemantic, SemanticTransform {
|
|
460
|
+
readonly kind: "text";
|
|
461
|
+
readonly text: string;
|
|
462
|
+
readonly font: FontSpec;
|
|
463
|
+
/** Anchor point (where transform-origin of the text block lives). */
|
|
464
|
+
readonly anchor?: Point2D;
|
|
465
|
+
readonly color?: RGBA;
|
|
466
|
+
}
|
|
467
|
+
/** Marker — a reusable symbol placed at points (e.g., line endpoints, scatter glyphs). */
|
|
468
|
+
export interface SemanticMarker extends BaseSemantic, SemanticTransform {
|
|
469
|
+
readonly kind: "marker";
|
|
470
|
+
readonly markerId: string;
|
|
471
|
+
/** Positions to place copies of this marker. */
|
|
472
|
+
readonly positions: ReadonlyArray<Point2D>;
|
|
473
|
+
readonly angle?: number;
|
|
474
|
+
}
|
|
475
|
+
export type SemanticShape = SemanticPath | SemanticRect | SemanticEllipse | SemanticImage | SemanticText | SemanticMarker;
|
|
476
|
+
export type SemanticNode = SemanticGroup | SemanticShape;
|
|
477
|
+
/** The root of a semantic scene. Always a group. */
|
|
478
|
+
export interface SemanticScene {
|
|
479
|
+
/** Contract namespace this scene was built under (`/v0` before 1.0.0). */
|
|
480
|
+
readonly version: SceneVersion;
|
|
481
|
+
readonly root: SemanticGroup;
|
|
482
|
+
}
|
|
483
|
+
/** Presentation tokens `buildScene` consumes. */
|
|
484
|
+
export interface ChartTheme {
|
|
485
|
+
/** Categorical palette for grouped marks. The index of a series follows
|
|
486
|
+
* its position in `ChartCompilePlan.series.categories` (first-appearance
|
|
487
|
+
* order) and wraps around, so every series is visually distinct up to
|
|
488
|
+
* the palette length. */
|
|
489
|
+
readonly seriesPalette: ReadonlyArray<RGBA>;
|
|
490
|
+
/** Fill for ungrouped marks (no series / color / group encoding). */
|
|
491
|
+
readonly markFill: RGBA;
|
|
492
|
+
/** Optional caller-supplied category → color map (treemap groups and
|
|
493
|
+
* categorical marks keyed by a `color` field). Categories missing from
|
|
494
|
+
* the map fall back to `seriesPalette`, indexed by sorted category order
|
|
495
|
+
* so reordering rows never recolors a node. */
|
|
496
|
+
readonly categoryColors?: ReadonlyMap<string, RGBA>;
|
|
497
|
+
/** Axis baseline and tick stroke. */
|
|
498
|
+
readonly axisStroke: RGBA;
|
|
499
|
+
readonly axisStrokeWidth: number;
|
|
500
|
+
/** Grid line stroke — lighter than the axis so data stays on top of the
|
|
501
|
+
* visual hierarchy. `null` disables grid emission. */
|
|
502
|
+
readonly gridStroke: RGBA | null;
|
|
503
|
+
readonly gridStrokeWidth: number;
|
|
504
|
+
/** Tick and legend label color. */
|
|
505
|
+
readonly labelColor: RGBA;
|
|
506
|
+
/** Tick label font — also drives padding and truncation widths. */
|
|
507
|
+
readonly labelFont: FontSpec;
|
|
508
|
+
/** Legend label font. */
|
|
509
|
+
readonly legendFont: FontSpec;
|
|
510
|
+
/** Stroke painted around point marks so overlapping glyphs stay
|
|
511
|
+
* separable; usually the plot background color. `null` disables it. */
|
|
512
|
+
readonly pointStroke: RGBA | null;
|
|
513
|
+
/** Opacity of the area-mark fill (the stroke keeps full strength). */
|
|
514
|
+
readonly areaFillOpacity: number;
|
|
515
|
+
/** Sequential ramp for value→color marks (heatmap): ≥2 stops, sampled at
|
|
516
|
+
* t ∈ [0, 1] from the data minimum to the maximum. */
|
|
517
|
+
readonly heatmapRamp: ReadonlyArray<RGBA>;
|
|
518
|
+
/** Rising fill for candlestick bodies and waterfall positive deltas. */
|
|
519
|
+
readonly upColor: RGBA;
|
|
520
|
+
/** Falling fill for candlestick bodies and waterfall negative deltas. */
|
|
521
|
+
readonly downColor: RGBA;
|
|
522
|
+
/** Unfilled track ring / sweep color for gauge and radial-bar marks. */
|
|
523
|
+
readonly trackColor: RGBA;
|
|
524
|
+
/** Qualitative band tints for bullet charts, poor → good. */
|
|
525
|
+
readonly rangeTints: readonly [
|
|
526
|
+
RGBA,
|
|
527
|
+
RGBA,
|
|
528
|
+
RGBA
|
|
529
|
+
];
|
|
530
|
+
/** Opacity of sankey link ribbons (nodes stay at full strength). */
|
|
531
|
+
readonly sankeyLinkOpacity: number;
|
|
532
|
+
}
|
|
533
|
+
/** The reference light theme — VMZ brand blue anchors the categorical
|
|
534
|
+
* palette, grids stay quieter than axes, and axes stay quieter than data. */
|
|
535
|
+
export declare const DEFAULT_CHART_THEME: ChartTheme;
|
|
536
|
+
/** Dark theme — same palette roles with lifted brightness and quiet chrome. */
|
|
537
|
+
export declare const DARK_CHART_THEME: ChartTheme;
|
|
538
|
+
/** Plot padding in logical pixels. */
|
|
539
|
+
export interface ScenePadding {
|
|
540
|
+
readonly top: number;
|
|
541
|
+
readonly right: number;
|
|
542
|
+
readonly bottom: number;
|
|
543
|
+
readonly left: number;
|
|
544
|
+
}
|
|
545
|
+
/** Viewport the scene is laid out into. */
|
|
546
|
+
export interface ChartViewport {
|
|
547
|
+
readonly width: number;
|
|
548
|
+
readonly height: number;
|
|
549
|
+
/** Uniform padding or per-side override. */
|
|
550
|
+
readonly padding?: number | Partial<ScenePadding>;
|
|
551
|
+
}
|
|
552
|
+
/** Options for the scene build. */
|
|
553
|
+
export interface ChartSceneOptions {
|
|
554
|
+
/** Presentation tokens; defaults to `DEFAULT_CHART_THEME`. */
|
|
555
|
+
readonly theme?: ChartTheme;
|
|
556
|
+
}
|
|
557
|
+
/** Build a SemanticScene from a ChartCompilePlan and a pixel viewport. */
|
|
558
|
+
export declare function buildScene(plan: ChartCompilePlan, viewport: ChartViewport, options?: ChartSceneOptions): SemanticScene;
|
|
559
|
+
/** GeoJSON feature shape the geo mark projects. */
|
|
560
|
+
export interface GeoFeature {
|
|
561
|
+
readonly type: "Feature";
|
|
562
|
+
readonly properties: {
|
|
563
|
+
readonly name: string;
|
|
564
|
+
readonly iso_a3: string;
|
|
565
|
+
};
|
|
566
|
+
readonly geometry: {
|
|
567
|
+
readonly type: "Polygon";
|
|
568
|
+
readonly coordinates: ReadonlyArray<ReadonlyArray<ReadonlyArray<number>>>;
|
|
569
|
+
} | {
|
|
570
|
+
readonly type: "MultiPolygon";
|
|
571
|
+
readonly coordinates: ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<number>>>>;
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
export interface GeoFeatureCollection {
|
|
575
|
+
readonly type: "FeatureCollection";
|
|
576
|
+
readonly features: ReadonlyArray<GeoFeature>;
|
|
577
|
+
}
|
|
578
|
+
/** Register a basemap under an id (host side, at startup / build time). */
|
|
579
|
+
export declare function registerGeoMap(id: string, map: GeoFeatureCollection): void;
|
|
580
|
+
/** Look a basemap up by id; undefined when the host never registered it. */
|
|
581
|
+
export declare function geoMapById(id: string): GeoFeatureCollection | undefined;
|
|
582
|
+
|
|
583
|
+
export {};
|