resolvcharts 0.1.0 → 0.2.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/README.md +92 -26
- package/dist/index.cjs +216 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +111 -22
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +111 -22
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +216 -35
- package/dist/index.mjs.map +1 -1
- package/dist/resolvcharts.global.min.js +8 -8
- package/dist/resolvcharts.global.min.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
//#region src/core/types.d.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Chart type discriminator.
|
|
4
|
+
* @category Charts
|
|
5
|
+
*/
|
|
6
|
+
type ChartType = "line" | "area" | "bar" | "combo" | "sparkline" | "scatter" | "donut" | "candle" | "ohlc" | "waterfall" | "baseline";
|
|
7
|
+
/**
|
|
8
|
+
* Color/typography tokens used to render a chart.
|
|
9
|
+
* @category Theming
|
|
10
|
+
*/
|
|
5
11
|
interface ThemeTokens {
|
|
6
12
|
bg: string;
|
|
7
13
|
text: string;
|
|
@@ -22,39 +28,66 @@ interface ThemeTokens {
|
|
|
22
28
|
tooltipShadow: string;
|
|
23
29
|
fontFamily: string;
|
|
24
30
|
}
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* One series of an xy chart.
|
|
33
|
+
* @category Data
|
|
34
|
+
*/
|
|
26
35
|
interface SeriesInput {
|
|
27
36
|
label?: string;
|
|
28
37
|
color?: string;
|
|
29
38
|
y: ArrayLike<number>;
|
|
30
39
|
}
|
|
31
|
-
/** Data for xy charts (line, area, scatter, sparkline, baseline). `x` may be unsorted — it is sorted internally.
|
|
40
|
+
/** Data for xy charts (line, area, scatter, sparkline, baseline). `x` may be unsorted — it is sorted internally.
|
|
41
|
+
* @category Data
|
|
42
|
+
*/
|
|
32
43
|
interface XYData {
|
|
33
44
|
x: ArrayLike<number>;
|
|
34
45
|
series: SeriesInput[];
|
|
35
46
|
}
|
|
36
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Per-series render style inside a `combo` chart.
|
|
49
|
+
* @category Charts
|
|
50
|
+
*/
|
|
51
|
+
type CategorySeriesKind = "column" | "line" | "area";
|
|
52
|
+
/**
|
|
53
|
+
* One series of a categorical chart.
|
|
54
|
+
* @category Data
|
|
55
|
+
*/
|
|
37
56
|
interface CategorySeriesInput {
|
|
38
57
|
label?: string;
|
|
39
58
|
color?: string;
|
|
59
|
+
/** For `combo`: how this series renders (default `"column"`). */
|
|
60
|
+
kind?: CategorySeriesKind;
|
|
40
61
|
values: ArrayLike<number>;
|
|
41
62
|
}
|
|
42
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Data for `bar` and `combo` charts (one entry per `categories` element).
|
|
65
|
+
* @category Data
|
|
66
|
+
*/
|
|
43
67
|
interface CategoryData {
|
|
44
68
|
categories: string[];
|
|
45
69
|
series: CategorySeriesInput[];
|
|
46
70
|
}
|
|
47
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* One donut slice.
|
|
73
|
+
* @category Data
|
|
74
|
+
*/
|
|
48
75
|
interface DonutSlice {
|
|
49
76
|
label: string;
|
|
50
77
|
value: number;
|
|
51
78
|
color?: string;
|
|
52
79
|
}
|
|
53
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Data for `donut` charts.
|
|
82
|
+
* @category Data
|
|
83
|
+
*/
|
|
54
84
|
interface DonutData {
|
|
55
85
|
slices: DonutSlice[];
|
|
56
86
|
}
|
|
57
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* One OHLC candle. `x` is typically an epoch timestamp.
|
|
89
|
+
* @category Data
|
|
90
|
+
*/
|
|
58
91
|
interface OHLCCandle {
|
|
59
92
|
x: number;
|
|
60
93
|
open: number;
|
|
@@ -63,11 +96,17 @@ interface OHLCCandle {
|
|
|
63
96
|
close: number;
|
|
64
97
|
volume?: number;
|
|
65
98
|
}
|
|
66
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Data for `candle` and `ohlc` charts.
|
|
101
|
+
* @category Data
|
|
102
|
+
*/
|
|
67
103
|
interface OHLCData {
|
|
68
104
|
candles: OHLCCandle[];
|
|
69
105
|
}
|
|
70
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Data for `waterfall` charts.
|
|
108
|
+
* @category Data
|
|
109
|
+
*/
|
|
71
110
|
interface WaterfallData {
|
|
72
111
|
categories: string[];
|
|
73
112
|
/** Delta per category; entries listed in `totals` render as absolute columns. */
|
|
@@ -75,11 +114,19 @@ interface WaterfallData {
|
|
|
75
114
|
/** Indices into `categories` that are absolute totals (e.g. start/end/subtotal). */
|
|
76
115
|
totals?: number[];
|
|
77
116
|
}
|
|
78
|
-
/** Union of all per-type data shapes; the chart picks the matching member by `options.type`.
|
|
117
|
+
/** Union of all per-type data shapes; the chart picks the matching member by `options.type`.
|
|
118
|
+
* @category Data
|
|
119
|
+
*/
|
|
79
120
|
type ChartData = XYData | CategoryData | DonutData | OHLCData | WaterfallData;
|
|
80
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Segment interpolation: straight lines, step, or monotone cubic.
|
|
123
|
+
* @category Charts
|
|
124
|
+
*/
|
|
81
125
|
type CurveMode = "linear" | "step" | "smooth";
|
|
82
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Payload passed to `ChartOptions.onHover`.
|
|
128
|
+
* @category Charts
|
|
129
|
+
*/
|
|
83
130
|
type HoverInfo = {
|
|
84
131
|
kind: "point";
|
|
85
132
|
index: number;
|
|
@@ -91,6 +138,8 @@ type HoverInfo = {
|
|
|
91
138
|
color: string;
|
|
92
139
|
y: number;
|
|
93
140
|
}[];
|
|
141
|
+
/** Tooltip title override (e.g. category name on `combo` charts). */
|
|
142
|
+
title?: string;
|
|
94
143
|
} | {
|
|
95
144
|
kind: "bar";
|
|
96
145
|
category: string;
|
|
@@ -121,7 +170,10 @@ type HoverInfo = {
|
|
|
121
170
|
px: number;
|
|
122
171
|
py: number;
|
|
123
172
|
};
|
|
124
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Options accepted by {@link createChart}.
|
|
175
|
+
* @category Charts
|
|
176
|
+
*/
|
|
125
177
|
interface ChartOptions {
|
|
126
178
|
type: ChartType;
|
|
127
179
|
data: ChartData;
|
|
@@ -176,6 +228,14 @@ interface ChartOptions {
|
|
|
176
228
|
compat?: boolean;
|
|
177
229
|
timing?: boolean;
|
|
178
230
|
};
|
|
231
|
+
/**
|
|
232
|
+
* Canvas2D context settings passed to `getContext("2d", …)` for all layers.
|
|
233
|
+
* e.g. `{ willReadFrequently: true }` measurably cuts submit cost in Chrome
|
|
234
|
+
* (~2×) by forcing CPU rasterization — useful for small/dense charts;
|
|
235
|
+
* leave unset (default `{ alpha: true }`) to keep GPU compositing.
|
|
236
|
+
* @category Charts
|
|
237
|
+
*/
|
|
238
|
+
canvas?: CanvasRenderingContext2DSettings;
|
|
179
239
|
/** For `bar`: stack series per category instead of grouping. */
|
|
180
240
|
stacked?: boolean;
|
|
181
241
|
/** For `baseline`: reference value the line is compared against (default: first point). */
|
|
@@ -190,12 +250,18 @@ interface ChartOptions {
|
|
|
190
250
|
/** Called on pointer hover with the nearest hit, or `null` on leave. */
|
|
191
251
|
onHover?: (info: HoverInfo | null) => void;
|
|
192
252
|
}
|
|
253
|
+
/** Rectangle in pixel space.
|
|
254
|
+
* @category Types
|
|
255
|
+
*/
|
|
193
256
|
interface Rect {
|
|
194
257
|
x: number;
|
|
195
258
|
y: number;
|
|
196
259
|
w: number;
|
|
197
260
|
h: number;
|
|
198
261
|
}
|
|
262
|
+
/** Domain→range scale function returned by {@link linearScale}.
|
|
263
|
+
* @category Utilities
|
|
264
|
+
*/
|
|
199
265
|
interface Scale {
|
|
200
266
|
(v: number): number;
|
|
201
267
|
invert(px: number): number;
|
|
@@ -204,6 +270,9 @@ interface Scale {
|
|
|
204
270
|
}
|
|
205
271
|
//#endregion
|
|
206
272
|
//#region src/core/chart.d.ts
|
|
273
|
+
/** Chart instance. Create via {@link createChart}.
|
|
274
|
+
* @category Charts
|
|
275
|
+
*/
|
|
207
276
|
export declare class Chart {
|
|
208
277
|
readonly el: HTMLElement;
|
|
209
278
|
readonly options: ChartOptions;
|
|
@@ -262,6 +331,7 @@ export declare class Chart {
|
|
|
262
331
|
}
|
|
263
332
|
/**
|
|
264
333
|
* Create a chart inside `el`.
|
|
334
|
+
* @category Charts
|
|
265
335
|
*
|
|
266
336
|
* @example
|
|
267
337
|
* ```ts
|
|
@@ -287,37 +357,56 @@ export declare function createChart(el: HTMLElement, options: ChartOptions): Cha
|
|
|
287
357
|
* ys must be pixel-space y coordinates of equal length.
|
|
288
358
|
*
|
|
289
359
|
* Returns interleaved [x, y] pairs ready for path construction.
|
|
360
|
+
* @category Utilities
|
|
290
361
|
*/
|
|
291
362
|
export declare function decimateM4(xs: ArrayLike<number>, ys: ArrayLike<number>, pixelWidth: number): Float32Array;
|
|
292
363
|
//#endregion
|
|
293
364
|
//#region src/core/format.d.ts
|
|
294
|
-
/**
|
|
365
|
+
/** @category Formatting
|
|
366
|
+
* Compact number formatting: integers verbatim, else 4 significant digits. */
|
|
295
367
|
export declare function formatNumber(v: number): string;
|
|
296
|
-
/**
|
|
368
|
+
/** @category Formatting
|
|
369
|
+
* SI-suffixed formatting: `1.2k`, `3.4M`, `5B`. */
|
|
297
370
|
export declare function formatSI(v: number): string;
|
|
298
371
|
//#endregion
|
|
299
372
|
//#region src/core/hit.d.ts
|
|
300
373
|
/**
|
|
301
374
|
* Binary search for the index whose value is nearest to `target`.
|
|
302
375
|
* `xs` must be sorted ascending. Returns -1 for empty input.
|
|
376
|
+
* @category Utilities
|
|
303
377
|
*/
|
|
304
378
|
export declare function nearestIndex(xs: ArrayLike<number>, target: number): number;
|
|
305
379
|
//#endregion
|
|
306
380
|
//#region src/core/scales.d.ts
|
|
307
|
-
/**
|
|
381
|
+
/** @category Utilities
|
|
382
|
+
* Linear scale from domain `[d0, d1]` to range `[r0, r1]`, with `invert`. */
|
|
308
383
|
export declare function linearScale(d0: number, d1: number, r0: number, r1: number): Scale;
|
|
309
|
-
/**
|
|
384
|
+
/** @category Utilities
|
|
385
|
+
* `[min, max]` of `values`; degenerate inputs get a sane fallback domain. */
|
|
310
386
|
export declare function extent(values: ArrayLike<number>): [number, number];
|
|
311
|
-
/**
|
|
387
|
+
/** @category Utilities
|
|
388
|
+
* Pad a domain by 5% on each end; `includeZero` anchors the axis at 0. */
|
|
312
389
|
export declare function padDomain(min: number, max: number, includeZero?: boolean): [number, number];
|
|
313
390
|
//#endregion
|
|
314
391
|
//#region src/core/theme.d.ts
|
|
392
|
+
/** Built-in light theme.
|
|
393
|
+
* @category Theming
|
|
394
|
+
*/
|
|
315
395
|
export declare const lightTheme: ThemeTokens;
|
|
396
|
+
/** Built-in dark theme.
|
|
397
|
+
* @category Theming
|
|
398
|
+
*/
|
|
316
399
|
export declare const darkTheme: ThemeTokens;
|
|
400
|
+
/** Merge a theme option (`"light" | "dark" | partial tokens`) into full {@link ThemeTokens}.
|
|
401
|
+
* @category Theming
|
|
402
|
+
*/
|
|
317
403
|
export declare function resolveTheme(opt: ChartOptions["theme"], accent: string | undefined): ThemeTokens;
|
|
318
404
|
//#endregion
|
|
319
405
|
//#region src/core/ticks.d.ts
|
|
406
|
+
/** "Nice" round tick values covering `[min, max]`, ~`target` count.
|
|
407
|
+
* @category Utilities
|
|
408
|
+
*/
|
|
320
409
|
export declare function computeTicks(min: number, max: number, target?: number): number[];
|
|
321
410
|
//#endregion
|
|
322
|
-
export type { CategoryData, CategorySeriesInput, ChartData, ChartOptions, ChartType, CurveMode, DonutData, DonutSlice, HoverInfo, OHLCCandle, OHLCData, Rect, Scale, SeriesInput, ThemeTokens, WaterfallData, XYData };
|
|
411
|
+
export type { CategoryData, CategorySeriesInput, CategorySeriesKind, ChartData, ChartOptions, ChartType, CurveMode, DonutData, DonutSlice, HoverInfo, OHLCCandle, OHLCData, Rect, Scale, SeriesInput, ThemeTokens, WaterfallData, XYData };
|
|
323
412
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/types.ts","../src/core/chart.ts","../src/core/decimate.ts","../src/core/format.ts","../src/core/hit.ts","../src/core/scales.ts","../src/core/theme.ts","../src/core/ticks.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/types.ts","../src/core/chart.ts","../src/core/decimate.ts","../src/core/format.ts","../src/core/hit.ts","../src/core/scales.ts","../src/core/theme.ts","../src/core/ticks.ts"],"mappings":";;;;;KAIY;;;;;UAiBK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;UAOe;EACf;EACA;EACA,GAAG;;;;;UAMY;EACf,GAAG;EACH,QAAQ;;;;;;KAOE;;;;;UAMK;EACf;EACA;;EAEA,OAAO;EACP,QAAQ;;;;;;UAOO;EACf;EACA,QAAQ;;;;;;UAOO;EACf;EACA;EACA;;;;;;UAOe;EACf,QAAQ;;;;;;UAOO;EACf;EACA;EACA;EACA;EACA;EACA;;;;;;UAOe;EACf,SAAS;;;;;;UAOM;EACf;;EAEA,QAAQ;;EAER;;;;;KAMU,YACR,SACA,eACA,YACA,WACA;;;;;KAMQ;;;;;KAMA;EAEN;EACA;EACA;EACA;EACA;EACA;IAAU;IAAe;IAAe;;;EAExC;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;;EAGN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;UAOW;EACf,MAAM;EACN,MAAM;EACN,2BAA2B,QAAQ;;EAEnC;EACA,QAAQ;EACR;EACA;EACA;;EAEA;;;;;;;;EAQA;;;;;;EAMA;;;;;;;EAOA;;;;;;;;EASA;;;;;;;;;EASA;IACE;IACA;IACA;;;;;;;;;EASF,SAAS;;EAET;;EAEA;;EAEA;;EAEA;IACE,KAAK;IACL,KAAK;;;EAGP,WAAW,MAAM;;;;;UAMF;EACf;EACA;EACA;EACA;;;;;UAMe;GACd;EACD,OAAO;EACP;EACA;;;;;;;qBCnLW;WACF,IAAI;WACJ,SAAS;UACV;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UAIA;UACA;UAIA;UACA;UACA;UACA;UACA;UACA;UACA;UAGA;EAkCR,YAAY,IAAI,aAAa,SAAS;UA6C9B;UAmIA;UAUA;UASA;UAUA;UAkCA;UAoGA;UAiBA;UAmBA;UAeA;UA8EA;;UAUA;UA0CA;UA8DA;UA4DA;UAaA;;EAcR,QAAQ,MAAM;;;;;;EAYd,OAAO,WAAW;;EAoFlB;;EAoBA;;;;;;;;;;;;;;;;;;wBAmDc,YAAY,IAAI,aAAa,SAAS,eAAe;;;;;;;;;;;;;;wBC9zBrD,WACd,IAAI,mBACJ,IAAI,mBACJ,qBACC;;;;;wBCpMa,aAAa;;;wBAcb,SAAS;;;;;;;;wBCXT,aAAa,IAAI,mBAAmB;;;;;wBCDpC,YACd,YACA,YACA,YACA,aACC;;;wBAYa,OAAO,QAAQ;;;wBAkBf,UACd,aACA,aACA;;;;;;qBCnCW,YAAY;;;;qBAsBZ,WAAW;;;;wBAmCR,aACd,KAAK,uBACL,6BACC;;;;;;wBC/Ca,aAAa,aAAa,aAAa"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
//#region src/core/types.d.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Chart type discriminator.
|
|
4
|
+
* @category Charts
|
|
5
|
+
*/
|
|
6
|
+
type ChartType = "line" | "area" | "bar" | "combo" | "sparkline" | "scatter" | "donut" | "candle" | "ohlc" | "waterfall" | "baseline";
|
|
7
|
+
/**
|
|
8
|
+
* Color/typography tokens used to render a chart.
|
|
9
|
+
* @category Theming
|
|
10
|
+
*/
|
|
5
11
|
interface ThemeTokens {
|
|
6
12
|
bg: string;
|
|
7
13
|
text: string;
|
|
@@ -22,39 +28,66 @@ interface ThemeTokens {
|
|
|
22
28
|
tooltipShadow: string;
|
|
23
29
|
fontFamily: string;
|
|
24
30
|
}
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* One series of an xy chart.
|
|
33
|
+
* @category Data
|
|
34
|
+
*/
|
|
26
35
|
interface SeriesInput {
|
|
27
36
|
label?: string;
|
|
28
37
|
color?: string;
|
|
29
38
|
y: ArrayLike<number>;
|
|
30
39
|
}
|
|
31
|
-
/** Data for xy charts (line, area, scatter, sparkline, baseline). `x` may be unsorted — it is sorted internally.
|
|
40
|
+
/** Data for xy charts (line, area, scatter, sparkline, baseline). `x` may be unsorted — it is sorted internally.
|
|
41
|
+
* @category Data
|
|
42
|
+
*/
|
|
32
43
|
interface XYData {
|
|
33
44
|
x: ArrayLike<number>;
|
|
34
45
|
series: SeriesInput[];
|
|
35
46
|
}
|
|
36
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Per-series render style inside a `combo` chart.
|
|
49
|
+
* @category Charts
|
|
50
|
+
*/
|
|
51
|
+
type CategorySeriesKind = "column" | "line" | "area";
|
|
52
|
+
/**
|
|
53
|
+
* One series of a categorical chart.
|
|
54
|
+
* @category Data
|
|
55
|
+
*/
|
|
37
56
|
interface CategorySeriesInput {
|
|
38
57
|
label?: string;
|
|
39
58
|
color?: string;
|
|
59
|
+
/** For `combo`: how this series renders (default `"column"`). */
|
|
60
|
+
kind?: CategorySeriesKind;
|
|
40
61
|
values: ArrayLike<number>;
|
|
41
62
|
}
|
|
42
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Data for `bar` and `combo` charts (one entry per `categories` element).
|
|
65
|
+
* @category Data
|
|
66
|
+
*/
|
|
43
67
|
interface CategoryData {
|
|
44
68
|
categories: string[];
|
|
45
69
|
series: CategorySeriesInput[];
|
|
46
70
|
}
|
|
47
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* One donut slice.
|
|
73
|
+
* @category Data
|
|
74
|
+
*/
|
|
48
75
|
interface DonutSlice {
|
|
49
76
|
label: string;
|
|
50
77
|
value: number;
|
|
51
78
|
color?: string;
|
|
52
79
|
}
|
|
53
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Data for `donut` charts.
|
|
82
|
+
* @category Data
|
|
83
|
+
*/
|
|
54
84
|
interface DonutData {
|
|
55
85
|
slices: DonutSlice[];
|
|
56
86
|
}
|
|
57
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* One OHLC candle. `x` is typically an epoch timestamp.
|
|
89
|
+
* @category Data
|
|
90
|
+
*/
|
|
58
91
|
interface OHLCCandle {
|
|
59
92
|
x: number;
|
|
60
93
|
open: number;
|
|
@@ -63,11 +96,17 @@ interface OHLCCandle {
|
|
|
63
96
|
close: number;
|
|
64
97
|
volume?: number;
|
|
65
98
|
}
|
|
66
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Data for `candle` and `ohlc` charts.
|
|
101
|
+
* @category Data
|
|
102
|
+
*/
|
|
67
103
|
interface OHLCData {
|
|
68
104
|
candles: OHLCCandle[];
|
|
69
105
|
}
|
|
70
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* Data for `waterfall` charts.
|
|
108
|
+
* @category Data
|
|
109
|
+
*/
|
|
71
110
|
interface WaterfallData {
|
|
72
111
|
categories: string[];
|
|
73
112
|
/** Delta per category; entries listed in `totals` render as absolute columns. */
|
|
@@ -75,11 +114,19 @@ interface WaterfallData {
|
|
|
75
114
|
/** Indices into `categories` that are absolute totals (e.g. start/end/subtotal). */
|
|
76
115
|
totals?: number[];
|
|
77
116
|
}
|
|
78
|
-
/** Union of all per-type data shapes; the chart picks the matching member by `options.type`.
|
|
117
|
+
/** Union of all per-type data shapes; the chart picks the matching member by `options.type`.
|
|
118
|
+
* @category Data
|
|
119
|
+
*/
|
|
79
120
|
type ChartData = XYData | CategoryData | DonutData | OHLCData | WaterfallData;
|
|
80
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Segment interpolation: straight lines, step, or monotone cubic.
|
|
123
|
+
* @category Charts
|
|
124
|
+
*/
|
|
81
125
|
type CurveMode = "linear" | "step" | "smooth";
|
|
82
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* Payload passed to `ChartOptions.onHover`.
|
|
128
|
+
* @category Charts
|
|
129
|
+
*/
|
|
83
130
|
type HoverInfo = {
|
|
84
131
|
kind: "point";
|
|
85
132
|
index: number;
|
|
@@ -91,6 +138,8 @@ type HoverInfo = {
|
|
|
91
138
|
color: string;
|
|
92
139
|
y: number;
|
|
93
140
|
}[];
|
|
141
|
+
/** Tooltip title override (e.g. category name on `combo` charts). */
|
|
142
|
+
title?: string;
|
|
94
143
|
} | {
|
|
95
144
|
kind: "bar";
|
|
96
145
|
category: string;
|
|
@@ -121,7 +170,10 @@ type HoverInfo = {
|
|
|
121
170
|
px: number;
|
|
122
171
|
py: number;
|
|
123
172
|
};
|
|
124
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Options accepted by {@link createChart}.
|
|
175
|
+
* @category Charts
|
|
176
|
+
*/
|
|
125
177
|
interface ChartOptions {
|
|
126
178
|
type: ChartType;
|
|
127
179
|
data: ChartData;
|
|
@@ -176,6 +228,14 @@ interface ChartOptions {
|
|
|
176
228
|
compat?: boolean;
|
|
177
229
|
timing?: boolean;
|
|
178
230
|
};
|
|
231
|
+
/**
|
|
232
|
+
* Canvas2D context settings passed to `getContext("2d", …)` for all layers.
|
|
233
|
+
* e.g. `{ willReadFrequently: true }` measurably cuts submit cost in Chrome
|
|
234
|
+
* (~2×) by forcing CPU rasterization — useful for small/dense charts;
|
|
235
|
+
* leave unset (default `{ alpha: true }`) to keep GPU compositing.
|
|
236
|
+
* @category Charts
|
|
237
|
+
*/
|
|
238
|
+
canvas?: CanvasRenderingContext2DSettings;
|
|
179
239
|
/** For `bar`: stack series per category instead of grouping. */
|
|
180
240
|
stacked?: boolean;
|
|
181
241
|
/** For `baseline`: reference value the line is compared against (default: first point). */
|
|
@@ -190,12 +250,18 @@ interface ChartOptions {
|
|
|
190
250
|
/** Called on pointer hover with the nearest hit, or `null` on leave. */
|
|
191
251
|
onHover?: (info: HoverInfo | null) => void;
|
|
192
252
|
}
|
|
253
|
+
/** Rectangle in pixel space.
|
|
254
|
+
* @category Types
|
|
255
|
+
*/
|
|
193
256
|
interface Rect {
|
|
194
257
|
x: number;
|
|
195
258
|
y: number;
|
|
196
259
|
w: number;
|
|
197
260
|
h: number;
|
|
198
261
|
}
|
|
262
|
+
/** Domain→range scale function returned by {@link linearScale}.
|
|
263
|
+
* @category Utilities
|
|
264
|
+
*/
|
|
199
265
|
interface Scale {
|
|
200
266
|
(v: number): number;
|
|
201
267
|
invert(px: number): number;
|
|
@@ -204,6 +270,9 @@ interface Scale {
|
|
|
204
270
|
}
|
|
205
271
|
//#endregion
|
|
206
272
|
//#region src/core/chart.d.ts
|
|
273
|
+
/** Chart instance. Create via {@link createChart}.
|
|
274
|
+
* @category Charts
|
|
275
|
+
*/
|
|
207
276
|
export declare class Chart {
|
|
208
277
|
readonly el: HTMLElement;
|
|
209
278
|
readonly options: ChartOptions;
|
|
@@ -262,6 +331,7 @@ export declare class Chart {
|
|
|
262
331
|
}
|
|
263
332
|
/**
|
|
264
333
|
* Create a chart inside `el`.
|
|
334
|
+
* @category Charts
|
|
265
335
|
*
|
|
266
336
|
* @example
|
|
267
337
|
* ```ts
|
|
@@ -287,37 +357,56 @@ export declare function createChart(el: HTMLElement, options: ChartOptions): Cha
|
|
|
287
357
|
* ys must be pixel-space y coordinates of equal length.
|
|
288
358
|
*
|
|
289
359
|
* Returns interleaved [x, y] pairs ready for path construction.
|
|
360
|
+
* @category Utilities
|
|
290
361
|
*/
|
|
291
362
|
export declare function decimateM4(xs: ArrayLike<number>, ys: ArrayLike<number>, pixelWidth: number): Float32Array;
|
|
292
363
|
//#endregion
|
|
293
364
|
//#region src/core/format.d.ts
|
|
294
|
-
/**
|
|
365
|
+
/** @category Formatting
|
|
366
|
+
* Compact number formatting: integers verbatim, else 4 significant digits. */
|
|
295
367
|
export declare function formatNumber(v: number): string;
|
|
296
|
-
/**
|
|
368
|
+
/** @category Formatting
|
|
369
|
+
* SI-suffixed formatting: `1.2k`, `3.4M`, `5B`. */
|
|
297
370
|
export declare function formatSI(v: number): string;
|
|
298
371
|
//#endregion
|
|
299
372
|
//#region src/core/hit.d.ts
|
|
300
373
|
/**
|
|
301
374
|
* Binary search for the index whose value is nearest to `target`.
|
|
302
375
|
* `xs` must be sorted ascending. Returns -1 for empty input.
|
|
376
|
+
* @category Utilities
|
|
303
377
|
*/
|
|
304
378
|
export declare function nearestIndex(xs: ArrayLike<number>, target: number): number;
|
|
305
379
|
//#endregion
|
|
306
380
|
//#region src/core/scales.d.ts
|
|
307
|
-
/**
|
|
381
|
+
/** @category Utilities
|
|
382
|
+
* Linear scale from domain `[d0, d1]` to range `[r0, r1]`, with `invert`. */
|
|
308
383
|
export declare function linearScale(d0: number, d1: number, r0: number, r1: number): Scale;
|
|
309
|
-
/**
|
|
384
|
+
/** @category Utilities
|
|
385
|
+
* `[min, max]` of `values`; degenerate inputs get a sane fallback domain. */
|
|
310
386
|
export declare function extent(values: ArrayLike<number>): [number, number];
|
|
311
|
-
/**
|
|
387
|
+
/** @category Utilities
|
|
388
|
+
* Pad a domain by 5% on each end; `includeZero` anchors the axis at 0. */
|
|
312
389
|
export declare function padDomain(min: number, max: number, includeZero?: boolean): [number, number];
|
|
313
390
|
//#endregion
|
|
314
391
|
//#region src/core/theme.d.ts
|
|
392
|
+
/** Built-in light theme.
|
|
393
|
+
* @category Theming
|
|
394
|
+
*/
|
|
315
395
|
export declare const lightTheme: ThemeTokens;
|
|
396
|
+
/** Built-in dark theme.
|
|
397
|
+
* @category Theming
|
|
398
|
+
*/
|
|
316
399
|
export declare const darkTheme: ThemeTokens;
|
|
400
|
+
/** Merge a theme option (`"light" | "dark" | partial tokens`) into full {@link ThemeTokens}.
|
|
401
|
+
* @category Theming
|
|
402
|
+
*/
|
|
317
403
|
export declare function resolveTheme(opt: ChartOptions["theme"], accent: string | undefined): ThemeTokens;
|
|
318
404
|
//#endregion
|
|
319
405
|
//#region src/core/ticks.d.ts
|
|
406
|
+
/** "Nice" round tick values covering `[min, max]`, ~`target` count.
|
|
407
|
+
* @category Utilities
|
|
408
|
+
*/
|
|
320
409
|
export declare function computeTicks(min: number, max: number, target?: number): number[];
|
|
321
410
|
//#endregion
|
|
322
|
-
export type { CategoryData, CategorySeriesInput, ChartData, ChartOptions, ChartType, CurveMode, DonutData, DonutSlice, HoverInfo, OHLCCandle, OHLCData, Rect, Scale, SeriesInput, ThemeTokens, WaterfallData, XYData };
|
|
411
|
+
export type { CategoryData, CategorySeriesInput, CategorySeriesKind, ChartData, ChartOptions, ChartType, CurveMode, DonutData, DonutSlice, HoverInfo, OHLCCandle, OHLCData, Rect, Scale, SeriesInput, ThemeTokens, WaterfallData, XYData };
|
|
323
412
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/types.ts","../src/core/chart.ts","../src/core/decimate.ts","../src/core/format.ts","../src/core/hit.ts","../src/core/scales.ts","../src/core/theme.ts","../src/core/ticks.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/types.ts","../src/core/chart.ts","../src/core/decimate.ts","../src/core/format.ts","../src/core/hit.ts","../src/core/scales.ts","../src/core/theme.ts","../src/core/ticks.ts"],"mappings":";;;;;KAIY;;;;;UAiBK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;UAOe;EACf;EACA;EACA,GAAG;;;;;UAMY;EACf,GAAG;EACH,QAAQ;;;;;;KAOE;;;;;UAMK;EACf;EACA;;EAEA,OAAO;EACP,QAAQ;;;;;;UAOO;EACf;EACA,QAAQ;;;;;;UAOO;EACf;EACA;EACA;;;;;;UAOe;EACf,QAAQ;;;;;;UAOO;EACf;EACA;EACA;EACA;EACA;EACA;;;;;;UAOe;EACf,SAAS;;;;;;UAOM;EACf;;EAEA,QAAQ;;EAER;;;;;KAMU,YACR,SACA,eACA,YACA,WACA;;;;;KAMQ;;;;;KAMA;EAEN;EACA;EACA;EACA;EACA;EACA;IAAU;IAAe;IAAe;;;EAExC;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;;EAGN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;UAOW;EACf,MAAM;EACN,MAAM;EACN,2BAA2B,QAAQ;;EAEnC;EACA,QAAQ;EACR;EACA;EACA;;EAEA;;;;;;;;EAQA;;;;;;EAMA;;;;;;;EAOA;;;;;;;;EASA;;;;;;;;;EASA;IACE;IACA;IACA;;;;;;;;;EASF,SAAS;;EAET;;EAEA;;EAEA;;EAEA;IACE,KAAK;IACL,KAAK;;;EAGP,WAAW,MAAM;;;;;UAMF;EACf;EACA;EACA;EACA;;;;;UAMe;GACd;EACD,OAAO;EACP;EACA;;;;;;;qBCnLW;WACF,IAAI;WACJ,SAAS;UACV;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UAIA;UACA;UAIA;UACA;UACA;UACA;UACA;UACA;UACA;UAGA;EAkCR,YAAY,IAAI,aAAa,SAAS;UA6C9B;UAmIA;UAUA;UASA;UAUA;UAkCA;UAoGA;UAiBA;UAmBA;UAeA;UA8EA;;UAUA;UA0CA;UA8DA;UA4DA;UAaA;;EAcR,QAAQ,MAAM;;;;;;EAYd,OAAO,WAAW;;EAoFlB;;EAoBA;;;;;;;;;;;;;;;;;;wBAmDc,YAAY,IAAI,aAAa,SAAS,eAAe;;;;;;;;;;;;;;wBC9zBrD,WACd,IAAI,mBACJ,IAAI,mBACJ,qBACC;;;;;wBCpMa,aAAa;;;wBAcb,SAAS;;;;;;;;wBCXT,aAAa,IAAI,mBAAmB;;;;;wBCDpC,YACd,YACA,YACA,YACA,aACC;;;wBAYa,OAAO,QAAQ;;;wBAkBf,UACd,aACA,aACA;;;;;;qBCnCW,YAAY;;;;qBAsBZ,WAAW;;;;wBAmCR,aACd,KAAK,uBACL,6BACC;;;;;;wBC/Ca,aAAa,aAAa,aAAa"}
|