@svgrid/grid 1.0.2 → 1.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 +1 -1
- package/README.md +137 -39
- package/dist/GridFooter.svelte +164 -0
- package/dist/GridFooter.svelte.d.ts +29 -0
- package/dist/GridMenus.svelte +570 -0
- package/dist/GridMenus.svelte.d.ts +31 -0
- package/dist/SvGrid.controller.svelte.d.ts +429 -0
- package/dist/SvGrid.controller.svelte.js +1732 -0
- package/dist/SvGrid.css +1709 -0
- package/dist/SvGrid.helpers.d.ts +35 -0
- package/dist/SvGrid.helpers.js +160 -0
- package/dist/SvGrid.svelte +344 -7043
- package/dist/SvGrid.svelte.d.ts +4 -357
- package/dist/SvGrid.types.d.ts +436 -0
- package/dist/SvGrid.types.js +1 -0
- package/dist/SvGridChart.svelte +1060 -23
- package/dist/SvGridChart.svelte.d.ts +17 -0
- package/dist/build-api.d.ts +5 -0
- package/dist/build-api.js +527 -0
- package/dist/cell-render.d.ts +15 -0
- package/dist/cell-render.js +246 -0
- package/dist/cell-values.d.ts +28 -0
- package/dist/cell-values.js +89 -0
- package/dist/chart.d.ts +370 -3
- package/dist/chart.js +1135 -42
- package/dist/clipboard.d.ts +15 -0
- package/dist/clipboard.js +356 -0
- package/dist/columns.d.ts +30 -0
- package/dist/columns.js +277 -0
- package/dist/core.d.ts +1 -1
- package/dist/css.d.ts +3 -0
- package/dist/editing.d.ts +24 -0
- package/dist/editing.js +343 -0
- package/dist/editors/cell-editors.d.ts +1 -1
- package/dist/facet-buckets.d.ts +13 -0
- package/dist/facet-buckets.js +54 -0
- package/dist/features.d.ts +5 -0
- package/dist/features.js +30 -0
- package/dist/filter-operators.d.ts +16 -0
- package/dist/filter-operators.js +69 -0
- package/dist/hyperformula-adapter.d.ts +82 -0
- package/dist/hyperformula-adapter.js +73 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/keyboard-handlers.d.ts +7 -0
- package/dist/keyboard-handlers.js +197 -0
- package/dist/menus.d.ts +40 -0
- package/dist/menus.js +389 -0
- package/dist/named-views.d.ts +27 -0
- package/dist/named-views.js +39 -0
- package/dist/row-resize.d.ts +43 -0
- package/dist/row-resize.js +158 -0
- package/dist/scroll-sync.d.ts +9 -0
- package/dist/scroll-sync.js +86 -0
- package/dist/selection.d.ts +26 -0
- package/dist/selection.js +387 -0
- package/dist/spreadsheet.d.ts +80 -0
- package/dist/spreadsheet.js +194 -0
- package/dist/summaries.d.ts +12 -0
- package/dist/summaries.js +65 -0
- package/dist/svgrid-wrapper.types.d.ts +12 -1
- package/dist/svgrid.comments-autocomplete.test.d.ts +1 -0
- package/dist/svgrid.comments-autocomplete.test.js +96 -0
- package/dist/svgrid.context-menu.test.d.ts +1 -0
- package/dist/svgrid.context-menu.test.js +102 -0
- package/dist/svgrid.new-features.wrapper.test.js +30 -4
- package/dist/svgrid.wrapper.test.js +27 -1
- package/dist/virtualization/column-virtualizer.d.ts +2 -0
- package/dist/virtualization/scroll-scaling.d.ts +28 -0
- package/dist/virtualization/scroll-scaling.js +64 -0
- package/dist/virtualization/scroll-scaling.test.d.ts +1 -0
- package/dist/virtualization/scroll-scaling.test.js +86 -0
- package/dist/virtualization/svelte-virtualizer.svelte.d.ts +2 -0
- package/dist/virtualization/svelte-virtualizer.svelte.js +2 -0
- package/dist/virtualization/virtualizer.d.ts +7 -0
- package/dist/virtualization/virtualizer.js +30 -0
- package/package.json +1 -1
- package/src/GridFooter.svelte +164 -0
- package/src/GridMenus.svelte +570 -0
- package/src/SvGrid.controller.svelte.ts +2195 -0
- package/src/SvGrid.css +1747 -0
- package/src/SvGrid.helpers.test.ts +415 -0
- package/src/SvGrid.helpers.ts +185 -0
- package/src/SvGrid.svelte +348 -7043
- package/src/SvGrid.types.ts +456 -0
- package/src/SvGridChart.svelte +1060 -23
- package/src/build-api.coverage.test.ts +532 -0
- package/src/build-api.ts +663 -0
- package/src/cell-render.test.ts +451 -0
- package/src/cell-render.ts +426 -0
- package/src/cell-values.ts +114 -0
- package/src/chart-export.test.ts +370 -0
- package/src/chart.coverage.test.ts +814 -0
- package/src/chart.ts +1352 -47
- package/src/clipboard.test.ts +731 -0
- package/src/clipboard.ts +524 -0
- package/src/collaboration.coverage.test.ts +220 -0
- package/src/columns.test.ts +702 -0
- package/src/columns.ts +419 -0
- package/src/core.ts +8 -0
- package/src/css.d.ts +3 -0
- package/src/editing.test.ts +837 -0
- package/src/editing.ts +513 -0
- package/src/editors/cell-editors.coverage.test.ts +156 -0
- package/src/editors/cell-editors.ts +1 -0
- package/src/facet-buckets.test.ts +353 -0
- package/src/facet-buckets.ts +67 -0
- package/src/features.ts +128 -0
- package/src/filter-operators.test.ts +174 -0
- package/src/filter-operators.ts +87 -0
- package/src/hyperformula-adapter.test.ts +256 -0
- package/src/hyperformula-adapter.ts +124 -0
- package/src/index.ts +37 -0
- package/src/keyboard-handlers.coverage.test.ts +560 -0
- package/src/keyboard-handlers.ts +353 -0
- package/src/keyboard.ts +97 -97
- package/src/menus.test.ts +620 -0
- package/src/menus.ts +554 -0
- package/src/named-views.coverage.test.ts +210 -0
- package/src/named-views.ts +48 -0
- package/src/row-resize.test.ts +369 -0
- package/src/row-resize.ts +171 -0
- package/src/scroll-sync.test.ts +330 -0
- package/src/scroll-sync.ts +216 -0
- package/src/selection.test.ts +722 -0
- package/src/selection.ts +545 -0
- package/src/server-data-source.coverage.test.ts +180 -0
- package/src/spreadsheet.test.ts +445 -0
- package/src/spreadsheet.ts +246 -0
- package/src/summaries.ts +204 -0
- package/src/sv-grid-scrollbar.ts +13 -1
- package/src/svgrid-wrapper.types.ts +12 -1
- package/src/svgrid.behavior.test.ts +22 -0
- package/src/svgrid.comments-autocomplete.test.ts +112 -0
- package/src/svgrid.context-menu.test.ts +126 -0
- package/src/svgrid.interaction.test.ts +30 -0
- package/src/svgrid.new-features.wrapper.test.ts +65 -4
- package/src/svgrid.wrapper.test.ts +27 -1
- package/src/test-setup.ts +9 -6
- package/src/virtualization/scroll-scaling.test.ts +148 -0
- package/src/virtualization/scroll-scaling.ts +121 -0
- package/src/virtualization/svelte-virtualizer.svelte.ts +2 -0
- package/src/virtualization/virtualizer.ts +26 -0
package/dist/chart.d.ts
CHANGED
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
* (per-series type), a secondary (right) Y axis, signed Y domains (negative
|
|
9
9
|
* values drop below a zero baseline), and nice auto-scaled ticks.
|
|
10
10
|
*/
|
|
11
|
-
export type ChartType = 'bar' | 'line' | 'area' | 'pie' | 'scatter';
|
|
12
|
-
/** A clicked bar / point / slice - the payload of `SvGridChart`'s `onSelect`.
|
|
11
|
+
export type ChartType = 'bar' | 'line' | 'area' | 'pie' | 'scatter' | 'heatmap' | 'waterfall' | 'funnel' | 'radar' | 'calendar' | 'gauge' | 'treemap' | 'sankey';
|
|
12
|
+
/** A clicked bar / point / slice - the payload of `SvGridChart`'s `onSelect`.
|
|
13
|
+
* `rowIds` is populated when the spec was built from grid rows (via
|
|
14
|
+
* `rowsToChartSpec`) and lets a drill handler filter the grid back to the
|
|
15
|
+
* source rows for the clicked category / series cell. */
|
|
13
16
|
export type ChartSelection = {
|
|
14
17
|
category: string;
|
|
15
18
|
series: string;
|
|
16
19
|
value: number;
|
|
20
|
+
rowIds?: Array<string | number>;
|
|
17
21
|
};
|
|
18
22
|
/** A single scatter / bubble point. */
|
|
19
23
|
export type ScatterPoint = {
|
|
@@ -22,6 +26,14 @@ export type ScatterPoint = {
|
|
|
22
26
|
r?: number;
|
|
23
27
|
label?: string;
|
|
24
28
|
};
|
|
29
|
+
/** A statistical / smoothing line drawn on top of a source series.
|
|
30
|
+
* - `'linear'`: ordinary least-squares regression line
|
|
31
|
+
* - `'sma:N'`: simple moving average over a window of N points
|
|
32
|
+
* - `'ema:N'`: exponential moving average with smoothing factor 2/(N+1) */
|
|
33
|
+
export type SeriesOverlay = 'linear' | `sma:${number}` | `ema:${number}`;
|
|
34
|
+
/** A texture fill applied in addition to (and on top of) the series color.
|
|
35
|
+
* Helps colorblind readers distinguish series at a glance. */
|
|
36
|
+
export type SeriesPattern = 'solid' | 'stripe' | 'crosshatch' | 'dots' | 'diagonal';
|
|
25
37
|
export type ChartSeries = {
|
|
26
38
|
label: string;
|
|
27
39
|
values: number[];
|
|
@@ -32,6 +44,44 @@ export type ChartSeries = {
|
|
|
32
44
|
axis?: 'left' | 'right';
|
|
33
45
|
/** Scatter / bubble points (used when `type === 'scatter'`). */
|
|
34
46
|
points?: ScatterPoint[];
|
|
47
|
+
/** Row IDs contributing to each data point - parallel to `values`. When
|
|
48
|
+
* present, click handlers receive these in `ChartSelection.rowIds` so
|
|
49
|
+
* callers can drill the grid back to the source rows. */
|
|
50
|
+
rowIds?: Array<Array<string | number>>;
|
|
51
|
+
/** Draw a smoothing / trend overlay on top of this series. */
|
|
52
|
+
overlay?: SeriesOverlay;
|
|
53
|
+
/** Color for the overlay line. Defaults to the series color. */
|
|
54
|
+
overlayColor?: string;
|
|
55
|
+
/** Texture fill (e.g. diagonal stripes) layered over the series color.
|
|
56
|
+
* Lets colorblind viewers tell two series apart even at the same hue. */
|
|
57
|
+
pattern?: SeriesPattern;
|
|
58
|
+
/** Interpolate the line as a curve instead of polylines. `'monotone'`
|
|
59
|
+
* cubic prevents overshoots between points (best default for data);
|
|
60
|
+
* `true` is an alias for `'monotone'`. Only meaningful for line/area. */
|
|
61
|
+
smooth?: boolean | 'monotone';
|
|
62
|
+
/** Upper envelope (e.g. forecast 95th percentile) parallel to `values`.
|
|
63
|
+
* When set alongside `lowerValues`, the chart shades the band between
|
|
64
|
+
* the two as a translucent fill in the series color. */
|
|
65
|
+
upperValues?: number[];
|
|
66
|
+
/** Lower envelope; pair with `upperValues` for a confidence band. */
|
|
67
|
+
lowerValues?: number[];
|
|
68
|
+
};
|
|
69
|
+
/** A pinned label drawn over the plot, anchored to a data point or to an
|
|
70
|
+
* arbitrary (x, y) in data space. Useful for "Release v1", "Outage", etc. */
|
|
71
|
+
export type ChartAnnotation = {
|
|
72
|
+
/** Anchor in data space. Provide either `category` + `axis` for a point on
|
|
73
|
+
* an existing series, OR raw `x` / `y` numeric coordinates in data space. */
|
|
74
|
+
at: {
|
|
75
|
+
category: string;
|
|
76
|
+
series?: string;
|
|
77
|
+
} | {
|
|
78
|
+
x: number;
|
|
79
|
+
y?: number;
|
|
80
|
+
};
|
|
81
|
+
label: string;
|
|
82
|
+
color?: string;
|
|
83
|
+
/** Where the label sits relative to the marker. Defaults to 'top'. */
|
|
84
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
35
85
|
};
|
|
36
86
|
/** A horizontal reference / target line drawn across the plot. */
|
|
37
87
|
export type ChartReferenceLine = {
|
|
@@ -71,6 +121,231 @@ export type ChartSpec = {
|
|
|
71
121
|
yAxisTitle?: string;
|
|
72
122
|
y2AxisTitle?: string;
|
|
73
123
|
xAxisTitle?: string;
|
|
124
|
+
/** Y-axis scale. `'log'` plots base-10 logarithmic - values <= 0 are
|
|
125
|
+
* treated as missing. Necessary for wide-range data (money, audience
|
|
126
|
+
* size, scientific). Default `'linear'`. */
|
|
127
|
+
yScale?: 'linear' | 'log';
|
|
128
|
+
/** Right (secondary) Y-axis scale. Default `'linear'`. */
|
|
129
|
+
y2Scale?: 'linear' | 'log';
|
|
130
|
+
/** Pinned text labels at fixed data-space positions (callouts). */
|
|
131
|
+
annotations?: ChartAnnotation[];
|
|
132
|
+
/** When true, automatically cycle through pattern fills for every series
|
|
133
|
+
* that doesn't set `pattern` explicitly. Useful as a one-flag colorblind
|
|
134
|
+
* fallback. Default false. */
|
|
135
|
+
patternFallback?: boolean;
|
|
136
|
+
/** Calendar heatmap: array of date+value samples (one per day). Date
|
|
137
|
+
* strings are 'YYYY-MM-DD'. Missing days render as blank cells. */
|
|
138
|
+
calendarValues?: Array<{
|
|
139
|
+
date: string;
|
|
140
|
+
value: number;
|
|
141
|
+
}>;
|
|
142
|
+
/** Calendar heatmap: year window. Default: span the data. */
|
|
143
|
+
calendarStart?: string;
|
|
144
|
+
calendarEnd?: string;
|
|
145
|
+
/** Gauge: the value to display. */
|
|
146
|
+
gaugeValue?: number;
|
|
147
|
+
/** Gauge: min/max of the dial scale. Defaults [0, 100]. */
|
|
148
|
+
gaugeMin?: number;
|
|
149
|
+
gaugeMax?: number;
|
|
150
|
+
/** Gauge: target marker (the line/notch on the arc). */
|
|
151
|
+
gaugeTarget?: number;
|
|
152
|
+
/** Gauge: color bands along the arc (e.g. red/amber/green). */
|
|
153
|
+
gaugeRanges?: Array<{
|
|
154
|
+
from: number;
|
|
155
|
+
to: number;
|
|
156
|
+
color: string;
|
|
157
|
+
}>;
|
|
158
|
+
/** Gauge: unit / suffix shown next to the value (e.g. '%', 'ms'). */
|
|
159
|
+
gaugeUnit?: string;
|
|
160
|
+
/** Tree-map: hierarchical root. Leaves have `value`; parents are the
|
|
161
|
+
* sum of their children's totals. */
|
|
162
|
+
treemap?: TreeNode;
|
|
163
|
+
/** Sankey: nodes + flow links between them. Link `source` / `target`
|
|
164
|
+
* reference node ids. */
|
|
165
|
+
sankeyNodes?: Array<{
|
|
166
|
+
id: string;
|
|
167
|
+
label?: string;
|
|
168
|
+
color?: string;
|
|
169
|
+
}>;
|
|
170
|
+
sankeyLinks?: Array<{
|
|
171
|
+
source: string;
|
|
172
|
+
target: string;
|
|
173
|
+
value: number;
|
|
174
|
+
color?: string;
|
|
175
|
+
}>;
|
|
176
|
+
/** Waterfall: per-category flag marking bars as totals/subtotals that
|
|
177
|
+
* reset the running sum and span from 0. Same length as `categories`. */
|
|
178
|
+
waterfallTotals?: boolean[];
|
|
179
|
+
/** Waterfall: explicit colors for positive/negative/total bars. The
|
|
180
|
+
* series color is ignored when this is set. */
|
|
181
|
+
waterfallColors?: {
|
|
182
|
+
positive?: string;
|
|
183
|
+
negative?: string;
|
|
184
|
+
total?: string;
|
|
185
|
+
};
|
|
186
|
+
/** Heatmap color scale. `'sequential'` maps min->max through one hue,
|
|
187
|
+
* `'diverging'` runs cold->neutral->warm around 0. A custom array
|
|
188
|
+
* (>=2 hex colors) defines an arbitrary gradient. Default `'sequential'`. */
|
|
189
|
+
colorScale?: 'sequential' | 'diverging' | string[];
|
|
190
|
+
};
|
|
191
|
+
/** A tree-map / sankey / treemap node spec. Used recursively as a tree. */
|
|
192
|
+
export type TreeNode = {
|
|
193
|
+
name: string;
|
|
194
|
+
value?: number;
|
|
195
|
+
color?: string;
|
|
196
|
+
children?: TreeNode[];
|
|
197
|
+
};
|
|
198
|
+
/** A laid-out tree-map rectangle. */
|
|
199
|
+
export type ChartTreemapCell = {
|
|
200
|
+
x: number;
|
|
201
|
+
y: number;
|
|
202
|
+
w: number;
|
|
203
|
+
h: number;
|
|
204
|
+
color: string;
|
|
205
|
+
textColor: string;
|
|
206
|
+
name: string;
|
|
207
|
+
value: number;
|
|
208
|
+
/** Depth from the root - useful for color cycling per level. */
|
|
209
|
+
depth: number;
|
|
210
|
+
};
|
|
211
|
+
/** A calendar-heatmap cell (one day). */
|
|
212
|
+
export type ChartCalendarCell = {
|
|
213
|
+
x: number;
|
|
214
|
+
y: number;
|
|
215
|
+
size: number;
|
|
216
|
+
date: string;
|
|
217
|
+
value: number;
|
|
218
|
+
/** Defined when a value was supplied for this day; blank otherwise. */
|
|
219
|
+
defined: boolean;
|
|
220
|
+
color: string;
|
|
221
|
+
};
|
|
222
|
+
/** A gauge dial layout. */
|
|
223
|
+
export type ChartGaugeLayout = {
|
|
224
|
+
cx: number;
|
|
225
|
+
cy: number;
|
|
226
|
+
r: number;
|
|
227
|
+
/** Track arc path (background grey). */
|
|
228
|
+
trackPath: string;
|
|
229
|
+
/** Value arc path (filled to the current value). */
|
|
230
|
+
valuePath: string;
|
|
231
|
+
/** Optional colored range arcs. */
|
|
232
|
+
rangePaths: Array<{
|
|
233
|
+
path: string;
|
|
234
|
+
color: string;
|
|
235
|
+
from: number;
|
|
236
|
+
to: number;
|
|
237
|
+
}>;
|
|
238
|
+
/** Pixel position of the target marker (when set). */
|
|
239
|
+
target: {
|
|
240
|
+
x1: number;
|
|
241
|
+
y1: number;
|
|
242
|
+
x2: number;
|
|
243
|
+
y2: number;
|
|
244
|
+
} | null;
|
|
245
|
+
/** Tick marks around the dial (major ticks are longer). */
|
|
246
|
+
ticks: Array<{
|
|
247
|
+
x1: number;
|
|
248
|
+
y1: number;
|
|
249
|
+
x2: number;
|
|
250
|
+
y2: number;
|
|
251
|
+
major: boolean;
|
|
252
|
+
}>;
|
|
253
|
+
/** Pointer needle (a kite shape) + its center hub radius. */
|
|
254
|
+
needle: {
|
|
255
|
+
path: string;
|
|
256
|
+
hubR: number;
|
|
257
|
+
};
|
|
258
|
+
/** Status color of the value arc (the band the value falls in), or null to
|
|
259
|
+
* fall back to the theme accent. */
|
|
260
|
+
valueColor: string | null;
|
|
261
|
+
/** Scale end labels positioned under the two arc ends. */
|
|
262
|
+
minLabel: {
|
|
263
|
+
x: number;
|
|
264
|
+
y: number;
|
|
265
|
+
};
|
|
266
|
+
maxLabel: {
|
|
267
|
+
x: number;
|
|
268
|
+
y: number;
|
|
269
|
+
};
|
|
270
|
+
value: number;
|
|
271
|
+
min: number;
|
|
272
|
+
max: number;
|
|
273
|
+
unit: string;
|
|
274
|
+
};
|
|
275
|
+
/** A sankey node + its laid-out rect + total flow. */
|
|
276
|
+
export type ChartSankeyNode = {
|
|
277
|
+
id: string;
|
|
278
|
+
label: string;
|
|
279
|
+
color: string;
|
|
280
|
+
x: number;
|
|
281
|
+
y: number;
|
|
282
|
+
w: number;
|
|
283
|
+
h: number;
|
|
284
|
+
/** Column (depth) the node was assigned to. */
|
|
285
|
+
column: number;
|
|
286
|
+
totalIn: number;
|
|
287
|
+
totalOut: number;
|
|
288
|
+
};
|
|
289
|
+
/** A sankey link rendered as a curved ribbon. */
|
|
290
|
+
export type ChartSankeyLink = {
|
|
291
|
+
path: string;
|
|
292
|
+
color: string;
|
|
293
|
+
/** Stroke width = link value scaled to pixels. */
|
|
294
|
+
width: number;
|
|
295
|
+
source: string;
|
|
296
|
+
target: string;
|
|
297
|
+
value: number;
|
|
298
|
+
};
|
|
299
|
+
/** A single funnel segment (trapezoid) in pixel space. */
|
|
300
|
+
export type ChartFunnelSegment = {
|
|
301
|
+
/** Pre-built SVG path for the trapezoid. */
|
|
302
|
+
path: string;
|
|
303
|
+
color: string;
|
|
304
|
+
label: string;
|
|
305
|
+
/** Original value (before any percentile normalisation). */
|
|
306
|
+
value: number;
|
|
307
|
+
/** Conversion vs. first segment, 0..1. */
|
|
308
|
+
conversion: number;
|
|
309
|
+
/** Drop-off from the previous segment, 0..1. */
|
|
310
|
+
dropoff: number;
|
|
311
|
+
/** Centre point (label anchor). */
|
|
312
|
+
cx: number;
|
|
313
|
+
cy: number;
|
|
314
|
+
/** Auto-picked black/white contrast color for in-segment labels. */
|
|
315
|
+
textColor: string;
|
|
316
|
+
};
|
|
317
|
+
/** A radar series' polygon: axis values + the closed polygon path. */
|
|
318
|
+
export type ChartRadarSeries = {
|
|
319
|
+
label: string;
|
|
320
|
+
color: string;
|
|
321
|
+
path: string;
|
|
322
|
+
/** Per-axis (x, y) endpoints so callers can draw dots / hit targets. */
|
|
323
|
+
points: Array<{
|
|
324
|
+
x: number;
|
|
325
|
+
y: number;
|
|
326
|
+
value: number;
|
|
327
|
+
axis: string;
|
|
328
|
+
}>;
|
|
329
|
+
};
|
|
330
|
+
/** Radar axis spoke + tick info. */
|
|
331
|
+
export type ChartRadarAxis = {
|
|
332
|
+
label: string;
|
|
333
|
+
/** Outermost endpoint of the spoke. */
|
|
334
|
+
x: number;
|
|
335
|
+
y: number;
|
|
336
|
+
};
|
|
337
|
+
/** A single heatmap rectangle in pixel space. */
|
|
338
|
+
export type ChartHeatmapCell = {
|
|
339
|
+
x: number;
|
|
340
|
+
y: number;
|
|
341
|
+
w: number;
|
|
342
|
+
h: number;
|
|
343
|
+
color: string;
|
|
344
|
+
/** Text color picked for contrast against `color`. */
|
|
345
|
+
textColor: string;
|
|
346
|
+
value: number;
|
|
347
|
+
rowLabel: string;
|
|
348
|
+
colLabel: string;
|
|
74
349
|
};
|
|
75
350
|
export type ChartBar = {
|
|
76
351
|
x: number;
|
|
@@ -98,6 +373,9 @@ export type ChartLine = {
|
|
|
98
373
|
color: string;
|
|
99
374
|
label: string;
|
|
100
375
|
points: ChartLinePoint[];
|
|
376
|
+
/** Confidence-band path (between upperValues + lowerValues) for this
|
|
377
|
+
* series, when both arrays are supplied. Empty otherwise. */
|
|
378
|
+
bandPath?: string;
|
|
101
379
|
};
|
|
102
380
|
export type ChartPieSlice = {
|
|
103
381
|
path: string;
|
|
@@ -185,6 +463,61 @@ export type ChartGeometry = {
|
|
|
185
463
|
catTicks: ChartAxisTick[];
|
|
186
464
|
/** Horizontal bars: vertical reference / target lines (positioned by x). */
|
|
187
465
|
referenceLinesV: ChartRefLineGeoV[];
|
|
466
|
+
/** Trend / moving-average overlay lines (parallel to `lines`). Drawn
|
|
467
|
+
* dashed on top of their source series. */
|
|
468
|
+
overlays: ChartLine[];
|
|
469
|
+
/** Pinned annotation labels with pre-resolved screen coordinates. */
|
|
470
|
+
annotations: Array<{
|
|
471
|
+
x: number;
|
|
472
|
+
y: number;
|
|
473
|
+
label: string;
|
|
474
|
+
color: string;
|
|
475
|
+
placement: 'top' | 'bottom' | 'left' | 'right';
|
|
476
|
+
}>;
|
|
477
|
+
/** Heatmap cells (type === 'heatmap'). */
|
|
478
|
+
heatmapCells: ChartHeatmapCell[];
|
|
479
|
+
/** Heatmap row labels with pre-resolved y positions (left gutter). */
|
|
480
|
+
heatmapRowTicks: ChartAxisTick[];
|
|
481
|
+
/** Heatmap column labels (bottom of plot). */
|
|
482
|
+
heatmapColTicks: ChartCategoryTick[];
|
|
483
|
+
/** Heatmap color-scale legend: ordered stops with value + color. */
|
|
484
|
+
heatmapLegend: Array<{
|
|
485
|
+
value: number;
|
|
486
|
+
color: string;
|
|
487
|
+
label: string;
|
|
488
|
+
}>;
|
|
489
|
+
/** Funnel segments (type === 'funnel'). */
|
|
490
|
+
funnelSegments: ChartFunnelSegment[];
|
|
491
|
+
/** Radar concentric grid rings (centred at `radarCenter`). */
|
|
492
|
+
radarRings: number[];
|
|
493
|
+
/** Radar axis labels + spoke endpoints. */
|
|
494
|
+
radarAxes: ChartRadarAxis[];
|
|
495
|
+
/** Radar series polygons. */
|
|
496
|
+
radarSeries: ChartRadarSeries[];
|
|
497
|
+
/** Centre of the radar / pie. Pre-computed so callers don't re-derive. */
|
|
498
|
+
radarCenter: {
|
|
499
|
+
cx: number;
|
|
500
|
+
cy: number;
|
|
501
|
+
r: number;
|
|
502
|
+
} | null;
|
|
503
|
+
/** Tree-map cells (type === 'treemap'). */
|
|
504
|
+
treemapCells: ChartTreemapCell[];
|
|
505
|
+
/** Calendar heatmap (type === 'calendar'). */
|
|
506
|
+
calendarCells: ChartCalendarCell[];
|
|
507
|
+
/** Calendar month labels along the top. */
|
|
508
|
+
calendarMonthTicks: ChartCategoryTick[];
|
|
509
|
+
/** Calendar legend stops (sequential ramp). */
|
|
510
|
+
calendarLegend: Array<{
|
|
511
|
+
value: number;
|
|
512
|
+
color: string;
|
|
513
|
+
label: string;
|
|
514
|
+
}>;
|
|
515
|
+
/** Gauge layout (type === 'gauge'). Null when not a gauge. */
|
|
516
|
+
gauge: ChartGaugeLayout | null;
|
|
517
|
+
/** Sankey nodes (type === 'sankey'). */
|
|
518
|
+
sankeyNodes: ChartSankeyNode[];
|
|
519
|
+
/** Sankey links (type === 'sankey'). */
|
|
520
|
+
sankeyLinks: ChartSankeyLink[];
|
|
188
521
|
};
|
|
189
522
|
export declare const DEFAULT_PALETTE: string[];
|
|
190
523
|
export type NiceScale = {
|
|
@@ -193,9 +526,39 @@ export type NiceScale = {
|
|
|
193
526
|
step: number;
|
|
194
527
|
ticks: number[];
|
|
195
528
|
};
|
|
529
|
+
/** Sample a hex color from an array of hex stops at fractional position t.
|
|
530
|
+
* Linearly interpolates between the two nearest stops in RGB space. */
|
|
531
|
+
export declare function sampleGradient(stops: string[], t: number): string;
|
|
532
|
+
/** Pick a black or white text color that has the better contrast against
|
|
533
|
+
* the given background. Uses the WCAG relative-luminance heuristic. */
|
|
534
|
+
export declare function pickContrastText(bgHex: string): string;
|
|
535
|
+
/** Pick the largest power of 10 that fits at the bottom of [min,max], and
|
|
536
|
+
* the smallest that covers the top, then enumerate decade boundaries. Used
|
|
537
|
+
* by log-scale axes (yScale: 'log'). */
|
|
538
|
+
export declare function niceLogScale(min: number, max: number): NiceScale;
|
|
539
|
+
/** Ordinary least-squares regression on (i, values[i]) pairs (i = x index).
|
|
540
|
+
* Returns the fitted value at each x index, or NaN where the source value
|
|
541
|
+
* was non-finite. */
|
|
542
|
+
/** Build an SVG path from a list of (x,y) pairs, optionally smoothed via
|
|
543
|
+
* monotone cubic interpolation (preserves local extrema - no overshoots).
|
|
544
|
+
* Breaks the path at `defined === false` gaps. */
|
|
545
|
+
export declare function buildLinePath(pts: Array<{
|
|
546
|
+
x: number;
|
|
547
|
+
y: number;
|
|
548
|
+
defined: boolean;
|
|
549
|
+
}>, smooth: boolean): string;
|
|
550
|
+
export declare function linearTrend(values: number[]): number[];
|
|
551
|
+
/** Simple moving average over a window of `period` values. Window centres
|
|
552
|
+
* trail to the right (typical for time-series). NaN for points before the
|
|
553
|
+
* window is full. */
|
|
554
|
+
export declare function simpleMovingAverage(values: number[], period: number): number[];
|
|
555
|
+
/** Exponential moving average. Smoothing factor alpha = 2 / (period + 1). */
|
|
556
|
+
export declare function exponentialMovingAverage(values: number[], period: number): number[];
|
|
557
|
+
/** Compute overlay values for a series spec like 'sma:7' / 'ema:14' / 'linear'. */
|
|
558
|
+
export declare function computeOverlay(values: number[], spec: SeriesOverlay): number[];
|
|
196
559
|
/** Round a [min,max] domain out to nice tick boundaries. */
|
|
197
560
|
export declare function niceScale(min: number, max: number, tickCount?: number): NiceScale;
|
|
198
|
-
export declare function buildChart(spec: ChartSpec): ChartGeometry;
|
|
561
|
+
export declare function buildChart(spec: ChartSpec, theme?: 'light' | 'dark'): ChartGeometry;
|
|
199
562
|
/**
|
|
200
563
|
* Aggregate flat rows into a chart spec. Group by a category field, reduce a
|
|
201
564
|
* value field per group. Three multi-series shapes:
|
|
@@ -223,4 +586,8 @@ export declare function rowsToChartSpec<T extends Record<string, unknown>>(rows:
|
|
|
223
586
|
topN?: number;
|
|
224
587
|
/** Label for the bucketed remainder. Default "Other". */
|
|
225
588
|
otherLabel?: string;
|
|
589
|
+
/** Field carrying each row's stable id. When set, the resulting spec's
|
|
590
|
+
* series carry `rowIds` arrays so click handlers can drill back to
|
|
591
|
+
* the source rows. */
|
|
592
|
+
idField?: keyof T & string;
|
|
226
593
|
}): ChartSpec;
|