@aeriz/chart 1.0.1 → 2.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/LICENSE +201 -201
- package/README.md +64 -431
- package/dist/aeriz.cjs +2781 -2338
- package/dist/aeriz.esm.js +1859 -1459
- package/dist/aeriz.esm.min.js +278 -1
- package/dist/aeriz.js +2781 -2338
- package/dist/aeriz.min.cjs +282 -1
- package/dist/aeriz.min.js +282 -1
- package/dist/esm/base.js +84 -0
- package/dist/esm/cartesian.js +13 -0
- package/dist/esm/charts/area.js +9 -0
- package/dist/esm/charts/bar.js +4 -0
- package/dist/esm/charts/boxplot.js +4 -0
- package/dist/esm/charts/bubble.js +3 -0
- package/dist/esm/charts/composite.js +11 -0
- package/dist/esm/charts/funnel.js +3 -0
- package/dist/esm/charts/gauge.js +5 -0
- package/dist/esm/charts/grouped-bar.js +5 -0
- package/dist/esm/charts/hbar.js +6 -0
- package/dist/esm/charts/heatmap.js +7 -0
- package/dist/esm/charts/line.js +9 -0
- package/dist/esm/charts/multi-line.js +8 -0
- package/dist/esm/charts/pie.js +6 -0
- package/dist/esm/charts/polar.js +3 -0
- package/dist/esm/charts/radar.js +10 -0
- package/dist/esm/charts/realtime.js +14 -0
- package/dist/esm/charts/scatter.js +6 -0
- package/dist/esm/charts/sparkline.js +5 -0
- package/dist/esm/charts/stacked-bar.js +7 -0
- package/dist/esm/charts/treemap.js +10 -0
- package/dist/esm/charts/waterfall.js +5 -0
- package/dist/esm/engine.js +33 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/jquery.js +5 -0
- package/dist/esm/math.js +32 -0
- package/dist/esm/react.js +4 -0
- package/dist/esm/shallow.js +5 -0
- package/dist/esm/svelte.js +4 -0
- package/dist/esm/vue.js +4 -0
- package/dist/index.d.ts +323 -0
- package/dist/jquery.d.ts +21 -0
- package/dist/react.d.ts +59 -0
- package/dist/svelte.d.ts +56 -0
- package/dist/types/area.d.ts +1 -0
- package/dist/types/bar.d.ts +1 -0
- package/dist/types/boxplot.d.ts +1 -0
- package/dist/types/bubble.d.ts +1 -0
- package/dist/types/composite.d.ts +1 -0
- package/dist/types/funnel.d.ts +1 -0
- package/dist/types/gauge.d.ts +1 -0
- package/dist/types/grouped-bar.d.ts +1 -0
- package/dist/types/hbar.d.ts +1 -0
- package/dist/types/heatmap.d.ts +1 -0
- package/dist/types/line.d.ts +1 -0
- package/dist/types/multi-line.d.ts +1 -0
- package/dist/types/pie.d.ts +1 -0
- package/dist/types/polar.d.ts +1 -0
- package/dist/types/radar.d.ts +1 -0
- package/dist/types/realtime.d.ts +1 -0
- package/dist/types/scatter.d.ts +1 -0
- package/dist/types/sparkline.d.ts +1 -0
- package/dist/types/stacked-bar.d.ts +1 -0
- package/dist/types/treemap.d.ts +1 -0
- package/dist/types/waterfall.d.ts +1 -0
- package/dist/vue.d.ts +63 -0
- package/package.json +60 -29
- package/src/base.js +0 -562
- package/src/charts.js +0 -1365
- package/src/composite.js +0 -187
- package/src/engine.js +0 -287
- package/src/index.d.ts +0 -517
- package/src/index.js +0 -18
- package/src/math.js +0 -178
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aeriz/chart 2.0 — visualization, light as air.
|
|
3
|
+
*
|
|
4
|
+
* 21 canvas chart types with one way to do each thing:
|
|
5
|
+
* `new XChart(target, options)` → `update(patch)` · `setState(state)` · `render()` · `destroy()`.
|
|
6
|
+
* Every chart takes its data as `data`. Framework adapters: `@aeriz/chart/react`,
|
|
7
|
+
* `/vue`, `/svelte`, `/jquery`.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ─── Shared types ────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
/** A CSS selector or a DOM element to mount the chart into. */
|
|
15
|
+
export type Target = string | HTMLElement;
|
|
16
|
+
|
|
17
|
+
/** Any CSS color. */
|
|
18
|
+
export type Color = string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Number format for tooltips and the value axis: `Intl.NumberFormat` options
|
|
22
|
+
* such as `{ style: 'currency', currency: 'KRW' }`, or a function.
|
|
23
|
+
* Without it, numbers follow the browser locale.
|
|
24
|
+
*/
|
|
25
|
+
export type NumberFormat = Intl.NumberFormatOptions | ((value: number) => string);
|
|
26
|
+
|
|
27
|
+
/** Formats category / time labels on the x axis and in tooltips. Time labels are ms timestamps. */
|
|
28
|
+
export type LabelFormat = (label: any) => string;
|
|
29
|
+
|
|
30
|
+
/** What `onClick` receives: the clicked item. */
|
|
31
|
+
export interface Hit<Row = unknown> {
|
|
32
|
+
/** Index of the row / category (heatmap: column). */
|
|
33
|
+
index: number;
|
|
34
|
+
/** Its label (category, row label, or point label). */
|
|
35
|
+
label: any;
|
|
36
|
+
/** Its value, when the item has one. */
|
|
37
|
+
value?: number;
|
|
38
|
+
/** Series index in multi-series charts (heatmap: row). */
|
|
39
|
+
series?: number;
|
|
40
|
+
/** The original data item: your row, point or series object. */
|
|
41
|
+
row?: Row;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `chart.setState()` overlays. `null` removes the overlay. */
|
|
45
|
+
export type State = 'loading' | 'empty' | 'error' | null;
|
|
46
|
+
|
|
47
|
+
/** Options every chart takes. */
|
|
48
|
+
export interface CommonOptions<D, Row = unknown> {
|
|
49
|
+
/** The data. Its shape depends on the chart — see each chart's `data`. */
|
|
50
|
+
data?: D;
|
|
51
|
+
/** Accessible name for screen readers (gauge also shows it as a caption). */
|
|
52
|
+
title?: string;
|
|
53
|
+
/** Series / item colors, in order. Defaults to `--aeriz-color-1…12`, then the built-in palette. */
|
|
54
|
+
colors?: Color[];
|
|
55
|
+
/** Number format for tooltips and the value axis. */
|
|
56
|
+
format?: NumberFormat;
|
|
57
|
+
/** Show the legend (multi-series charts and pie). Default `true`. */
|
|
58
|
+
legend?: boolean;
|
|
59
|
+
/** Animate drawing and updates. Default `true` (off with prefers-reduced-motion). */
|
|
60
|
+
animate?: boolean;
|
|
61
|
+
/** Text shown when there is no data. Default `'No data'`. */
|
|
62
|
+
emptyText?: string;
|
|
63
|
+
/** Called when an item is clicked (or Enter is pressed on it). */
|
|
64
|
+
onClick?: (hit: Hit<Row>, chart: Chart) => void;
|
|
65
|
+
/** Called when a legend item is toggled. */
|
|
66
|
+
onLegend?: (index: number, visible: boolean, chart: Chart) => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Value axis range (charts with axes). */
|
|
70
|
+
export interface AxisOptions {
|
|
71
|
+
/** Formats x-axis labels and tooltip titles. */
|
|
72
|
+
labelFormat?: LabelFormat;
|
|
73
|
+
/** Lowest value on the value axis (default: from the data, starting at 0). */
|
|
74
|
+
min?: number;
|
|
75
|
+
/** Highest value on the value axis (default: from the data). */
|
|
76
|
+
max?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ─── Data shapes ─────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
/** A `{ label, value }` row. Extra fields are allowed (use `label` / `value` accessors to read others). */
|
|
82
|
+
export interface Row {
|
|
83
|
+
label: string | number;
|
|
84
|
+
value: number;
|
|
85
|
+
/** Per-item color. */
|
|
86
|
+
color?: Color;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Single-series data, three ways that mean the same:
|
|
91
|
+
* `[64, 42, 78]` · `{ Jan: 64, Feb: 42 }` · `[{ label: 'Jan', value: 64 }]`
|
|
92
|
+
* (or your own objects with `label` / `value` accessors).
|
|
93
|
+
*/
|
|
94
|
+
export type Rows<R = Row> = number[] | Float64Array | Float32Array | Record<string, number> | R[];
|
|
95
|
+
|
|
96
|
+
/** Single-series options: read other fields with accessors. */
|
|
97
|
+
export interface RowOptions<R> {
|
|
98
|
+
/** Reads a row's label, e.g. `(row) => row.month`. */
|
|
99
|
+
label?: (row: R, index: number) => string | number;
|
|
100
|
+
/** Reads a row's value, e.g. `(row) => row.sales`. */
|
|
101
|
+
value?: (row: R, index: number) => number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface Series {
|
|
105
|
+
name: string;
|
|
106
|
+
values: ArrayLike<number | null>;
|
|
107
|
+
color?: Color;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Multi-series data. Every series has one value per category. */
|
|
111
|
+
export interface SeriesData<S extends Series = Series> {
|
|
112
|
+
categories: ArrayLike<string | number>;
|
|
113
|
+
series: S[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface Point {
|
|
117
|
+
x: number;
|
|
118
|
+
y: number;
|
|
119
|
+
/** Scatter: radius in px. Bubble: a value, drawn as the bubble's area. */
|
|
120
|
+
size?: number;
|
|
121
|
+
/** Colors points by series index. */
|
|
122
|
+
group?: number;
|
|
123
|
+
label?: string;
|
|
124
|
+
color?: Color;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ─── Base class ──────────────────────────────────────────────────
|
|
128
|
+
|
|
129
|
+
export interface ChartMeta {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
aria: string;
|
|
133
|
+
data: 'rows' | 'series' | 'stream' | 'points' | 'matrix' | 'boxes' | 'steps' | 'number';
|
|
134
|
+
options: string[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare class Chart<O = CommonOptions<unknown>> {
|
|
138
|
+
constructor(target: Target, options?: O);
|
|
139
|
+
static readonly meta: ChartMeta | null;
|
|
140
|
+
readonly container: HTMLElement;
|
|
141
|
+
readonly canvas: HTMLCanvasElement;
|
|
142
|
+
readonly options: O;
|
|
143
|
+
/** Change any options, data included. Changed values animate in. */
|
|
144
|
+
update(patch: Partial<O>): this;
|
|
145
|
+
/** Show a loading / empty / error overlay (with optional text), or remove it with `null`. */
|
|
146
|
+
setState(state: State, text?: string): this;
|
|
147
|
+
/** Re-read CSS variables and draw the final frame now — also off-screen (print, export). */
|
|
148
|
+
render(): this;
|
|
149
|
+
/** Remove the chart and undo every change to the container. */
|
|
150
|
+
destroy(): void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** The default color palette. */
|
|
154
|
+
export declare const PALETTE: readonly Color[];
|
|
155
|
+
|
|
156
|
+
// ─── Charts ──────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
type Curve = 'smooth' | 'linear' | 'step';
|
|
159
|
+
|
|
160
|
+
export interface BarOptions<R = Row> extends CommonOptions<Rows<R>, R>, AxisOptions, RowOptions<R> {
|
|
161
|
+
/** Value labels on the bars: `true`, or a function for the text. */
|
|
162
|
+
dataLabels?: boolean | ((value: number, row: R, index: number) => string);
|
|
163
|
+
}
|
|
164
|
+
export declare class BarChart<R = Row> extends Chart<BarOptions<R>> {}
|
|
165
|
+
|
|
166
|
+
export interface HBarOptions<R = Row> extends CommonOptions<Rows<R>, R>, AxisOptions, RowOptions<R> {}
|
|
167
|
+
export declare class HBarChart<R = Row> extends Chart<HBarOptions<R>> {}
|
|
168
|
+
|
|
169
|
+
export interface LineOptions<R = Row> extends CommonOptions<Rows<R>, R>, AxisOptions, RowOptions<R> {
|
|
170
|
+
/** Default `'smooth'`. */
|
|
171
|
+
curve?: Curve;
|
|
172
|
+
/** Gradient fill under the line. Default `true`. */
|
|
173
|
+
fill?: boolean;
|
|
174
|
+
/** Point markers (up to 50 points). Default `true`. */
|
|
175
|
+
points?: boolean;
|
|
176
|
+
/** `'time'`: labels are ms timestamps on a local-time axis. Default `'category'`. */
|
|
177
|
+
xScale?: 'category' | 'time';
|
|
178
|
+
/** Default `'linear'`. */
|
|
179
|
+
yScale?: 'linear' | 'log';
|
|
180
|
+
}
|
|
181
|
+
export declare class LineChart<R = Row> extends Chart<LineOptions<R>> {}
|
|
182
|
+
|
|
183
|
+
export interface AreaOptions extends CommonOptions<SeriesData, Series>, AxisOptions {
|
|
184
|
+
/** Stack the series. */
|
|
185
|
+
stacked?: boolean;
|
|
186
|
+
}
|
|
187
|
+
export declare class AreaChart extends Chart<AreaOptions> {}
|
|
188
|
+
|
|
189
|
+
export interface StackedBarOptions extends CommonOptions<SeriesData, Series>, AxisOptions {}
|
|
190
|
+
export declare class StackedBarChart extends Chart<StackedBarOptions> {}
|
|
191
|
+
|
|
192
|
+
export interface GroupedBarOptions extends CommonOptions<SeriesData, Series>, AxisOptions {}
|
|
193
|
+
export declare class GroupedBarChart extends Chart<GroupedBarOptions> {}
|
|
194
|
+
|
|
195
|
+
export interface MultiLineOptions extends CommonOptions<SeriesData, Series>, AxisOptions {
|
|
196
|
+
curve?: Curve;
|
|
197
|
+
xScale?: 'category' | 'time';
|
|
198
|
+
}
|
|
199
|
+
export declare class MultiLineChart extends Chart<MultiLineOptions> {}
|
|
200
|
+
|
|
201
|
+
export interface ScatterOptions extends CommonOptions<Point[], Point>, AxisOptions {}
|
|
202
|
+
export declare class ScatterChart extends Chart<ScatterOptions> {}
|
|
203
|
+
|
|
204
|
+
export interface BubbleOptions extends CommonOptions<Point[], Point>, AxisOptions {
|
|
205
|
+
/** Bubble radius range in px for the smallest and largest `size`. Default `[4, 32]`. */
|
|
206
|
+
radius?: [number, number];
|
|
207
|
+
}
|
|
208
|
+
export declare class BubbleChart extends Chart<BubbleOptions> {}
|
|
209
|
+
|
|
210
|
+
export interface PieOptions<R = Row> extends CommonOptions<Rows<R>, R>, RowOptions<R> {
|
|
211
|
+
/** Donut hole as a share of the radius, 0–0.9. Default `0` (pie). */
|
|
212
|
+
innerRadius?: number;
|
|
213
|
+
/** Donut center text. Default: the formatted total. `false` hides it. */
|
|
214
|
+
center?: string | false;
|
|
215
|
+
}
|
|
216
|
+
export declare class PieChart<R = Row> extends Chart<PieOptions<R>> {}
|
|
217
|
+
|
|
218
|
+
export interface RadarOptions extends CommonOptions<SeriesData, Series> {
|
|
219
|
+
labelFormat?: LabelFormat;
|
|
220
|
+
/** Value at the outer ring (default: from the data). */
|
|
221
|
+
max?: number;
|
|
222
|
+
}
|
|
223
|
+
export declare class RadarChart extends Chart<RadarOptions> {}
|
|
224
|
+
|
|
225
|
+
export interface PolarOptions<R = Row> extends CommonOptions<Rows<R>, R>, RowOptions<R> {
|
|
226
|
+
/** `'sqrt'` keeps areas true to the values. Default `'sqrt'`. */
|
|
227
|
+
scale?: 'sqrt' | 'linear';
|
|
228
|
+
}
|
|
229
|
+
export declare class PolarChart<R = Row> extends Chart<PolarOptions<R>> {}
|
|
230
|
+
|
|
231
|
+
export interface GaugeOptions extends CommonOptions<number> {
|
|
232
|
+
/** Default `0`. */
|
|
233
|
+
min?: number;
|
|
234
|
+
/** Default `100`. */
|
|
235
|
+
max?: number;
|
|
236
|
+
/** Text after the number, e.g. `'%'`. */
|
|
237
|
+
unit?: string;
|
|
238
|
+
}
|
|
239
|
+
export declare class GaugeChart extends Chart<GaugeOptions> {}
|
|
240
|
+
|
|
241
|
+
export interface HeatmapData {
|
|
242
|
+
x: ArrayLike<string | number>;
|
|
243
|
+
y: ArrayLike<string | number>;
|
|
244
|
+
/** `values[y][x]`; `null` leaves a cell empty. */
|
|
245
|
+
values: Array<ArrayLike<number | null>>;
|
|
246
|
+
}
|
|
247
|
+
export interface HeatmapOptions extends Omit<CommonOptions<HeatmapData, { x: unknown; y: unknown; value: number }>, 'colors'> {
|
|
248
|
+
labelFormat?: LabelFormat;
|
|
249
|
+
/** Colors for the lowest and highest values. */
|
|
250
|
+
colors?: { low?: Color; high?: Color };
|
|
251
|
+
}
|
|
252
|
+
export declare class HeatmapChart extends Chart<HeatmapOptions> {}
|
|
253
|
+
|
|
254
|
+
export interface Box {
|
|
255
|
+
label: string | number;
|
|
256
|
+
min: number;
|
|
257
|
+
q1: number;
|
|
258
|
+
median: number;
|
|
259
|
+
q3: number;
|
|
260
|
+
max: number;
|
|
261
|
+
outliers?: number[];
|
|
262
|
+
color?: Color;
|
|
263
|
+
}
|
|
264
|
+
export interface BoxplotOptions extends CommonOptions<Box[], Box>, AxisOptions {}
|
|
265
|
+
export declare class BoxplotChart extends Chart<BoxplotOptions> {}
|
|
266
|
+
|
|
267
|
+
export interface FunnelOptions<R = Row> extends CommonOptions<Rows<R>, R>, RowOptions<R> {
|
|
268
|
+
/** Color of labels drawn inside the segments. Default `'#fff'`. */
|
|
269
|
+
labelColor?: Color;
|
|
270
|
+
}
|
|
271
|
+
export declare class FunnelChart<R = Row> extends Chart<FunnelOptions<R>> {}
|
|
272
|
+
|
|
273
|
+
export interface TreemapOptions<R = Row> extends CommonOptions<Rows<R>, R>, RowOptions<R> {
|
|
274
|
+
/** Color of labels drawn inside the tiles. Default `'#fff'`. */
|
|
275
|
+
labelColor?: Color;
|
|
276
|
+
}
|
|
277
|
+
export declare class TreemapChart<R = Row> extends Chart<TreemapOptions<R>> {}
|
|
278
|
+
|
|
279
|
+
export interface SparklineOptions<R = Row> extends CommonOptions<Rows<R>, R>, RowOptions<R> {
|
|
280
|
+
min?: number;
|
|
281
|
+
max?: number;
|
|
282
|
+
/** Default `true`. */
|
|
283
|
+
fill?: boolean;
|
|
284
|
+
/** Dot on the last value. Default `true`. */
|
|
285
|
+
lastDot?: boolean;
|
|
286
|
+
}
|
|
287
|
+
export declare class SparklineChart<R = Row> extends Chart<SparklineOptions<R>> {}
|
|
288
|
+
|
|
289
|
+
export interface RealtimeOptions extends CommonOptions<{ series: Array<{ name: string; color?: Color }> }> {
|
|
290
|
+
min?: number;
|
|
291
|
+
max?: number;
|
|
292
|
+
/** How many samples stay visible. Default `200`. */
|
|
293
|
+
window?: number;
|
|
294
|
+
}
|
|
295
|
+
export declare class RealtimeChart extends Chart<RealtimeOptions> {
|
|
296
|
+
/** Add one sample: one value per series (a number for a single series). */
|
|
297
|
+
push(values: number | Array<number | null>): this;
|
|
298
|
+
/** Remove every sample. */
|
|
299
|
+
clear(): this;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface Step {
|
|
303
|
+
label: string | number;
|
|
304
|
+
value: number;
|
|
305
|
+
/** Draw this bar from zero to its value (a subtotal or the end result). */
|
|
306
|
+
total?: boolean;
|
|
307
|
+
}
|
|
308
|
+
export interface WaterfallOptions extends Omit<CommonOptions<Step[], Step>, 'colors'>, AxisOptions {
|
|
309
|
+
colors?: { up?: Color; down?: Color; total?: Color };
|
|
310
|
+
}
|
|
311
|
+
export declare class WaterfallChart extends Chart<WaterfallOptions> {}
|
|
312
|
+
|
|
313
|
+
export interface CompositeSeries extends Series {
|
|
314
|
+
type: 'bar' | 'line' | 'area' | 'scatter';
|
|
315
|
+
/** Put this series on the right axis. */
|
|
316
|
+
axis?: 'left' | 'right';
|
|
317
|
+
/** Number format for this series (tooltip and its axis). */
|
|
318
|
+
format?: NumberFormat;
|
|
319
|
+
}
|
|
320
|
+
export interface CompositeOptions extends CommonOptions<SeriesData<CompositeSeries>, CompositeSeries>, AxisOptions {
|
|
321
|
+
xScale?: 'category' | 'time';
|
|
322
|
+
}
|
|
323
|
+
export declare class CompositeChart extends Chart<CompositeOptions> {}
|
package/dist/jquery.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @aeriz/chart/jquery — install($, { BarChart }) then $(el).aerizChart('bar', options)
|
|
2
|
+
import type { Chart } from './index.js';
|
|
3
|
+
|
|
4
|
+
export type ChartId = 'bar' | 'hbar' | 'line' | 'area' | 'stacked-bar' | 'grouped-bar' | 'multi-line' | 'scatter' | 'bubble' | 'pie' | 'radar' | 'polar' | 'gauge' | 'heatmap' | 'boxplot' | 'funnel' | 'treemap' | 'sparkline' | 'realtime' | 'waterfall' | 'composite';
|
|
5
|
+
|
|
6
|
+
/** Adds `$.fn.aerizChart` with the given chart classes. Call again to add more. */
|
|
7
|
+
export declare function install<J extends { fn: any }>($: J, charts: Record<string, typeof Chart<any>>): J;
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
interface JQuery {
|
|
11
|
+
/** Create a chart: `.aerizChart('bar', { data })` (the chart must be installed). */
|
|
12
|
+
aerizChart(id: ChartId, options?: object): this;
|
|
13
|
+
/** Call a chart method on every matched element. */
|
|
14
|
+
aerizChart(method: 'update', patch: object): this;
|
|
15
|
+
aerizChart(method: 'setState', state: 'loading' | 'empty' | 'error' | null, text?: string): this;
|
|
16
|
+
aerizChart(method: 'render' | 'destroy' | 'clear'): this;
|
|
17
|
+
aerizChart(method: 'push', values: number | Array<number | null>): this;
|
|
18
|
+
/** The first element's chart instance, or `null`. */
|
|
19
|
+
aerizChart(method: 'instance'): Chart<any> | null;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @aeriz/chart/react — one component per chart: <BarChart data={rows} … />
|
|
2
|
+
import type { ForwardRefExoticComponent, ReactElement, Ref, CSSProperties, AriaAttributes } from 'react';
|
|
3
|
+
import type {
|
|
4
|
+
BarChart as BarC, BarOptions,
|
|
5
|
+
HBarChart as HBarC, HBarOptions,
|
|
6
|
+
LineChart as LineC, LineOptions,
|
|
7
|
+
AreaChart as AreaC, AreaOptions,
|
|
8
|
+
StackedBarChart as StackedBarC, StackedBarOptions,
|
|
9
|
+
GroupedBarChart as GroupedBarC, GroupedBarOptions,
|
|
10
|
+
MultiLineChart as MultiLineC, MultiLineOptions,
|
|
11
|
+
ScatterChart as ScatterC, ScatterOptions,
|
|
12
|
+
BubbleChart as BubbleC, BubbleOptions,
|
|
13
|
+
PieChart as PieC, PieOptions,
|
|
14
|
+
RadarChart as RadarC, RadarOptions,
|
|
15
|
+
PolarChart as PolarC, PolarOptions,
|
|
16
|
+
GaugeChart as GaugeC, GaugeOptions,
|
|
17
|
+
HeatmapChart as HeatmapC, HeatmapOptions,
|
|
18
|
+
BoxplotChart as BoxplotC, BoxplotOptions,
|
|
19
|
+
FunnelChart as FunnelC, FunnelOptions,
|
|
20
|
+
TreemapChart as TreemapC, TreemapOptions,
|
|
21
|
+
SparklineChart as SparklineC, SparklineOptions,
|
|
22
|
+
RealtimeChart as RealtimeC, RealtimeOptions,
|
|
23
|
+
WaterfallChart as WaterfallC, WaterfallOptions,
|
|
24
|
+
CompositeChart as CompositeC, CompositeOptions,
|
|
25
|
+
Row,
|
|
26
|
+
} from './index.js';
|
|
27
|
+
|
|
28
|
+
/** Chart options as props, plus wrapper-div props. `ref` gives the chart instance. */
|
|
29
|
+
export type Props<O, C> = O & AriaAttributes & {
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
id?: string;
|
|
33
|
+
role?: string;
|
|
34
|
+
tabIndex?: number;
|
|
35
|
+
ref?: Ref<C>;
|
|
36
|
+
[data: `data-${string}`]: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export declare const BarChart: <R = Row>(props: Props<BarOptions<R>, BarC<any>>) => ReactElement | null;
|
|
40
|
+
export declare const HBarChart: <R = Row>(props: Props<HBarOptions<R>, HBarC<any>>) => ReactElement | null;
|
|
41
|
+
export declare const LineChart: <R = Row>(props: Props<LineOptions<R>, LineC<any>>) => ReactElement | null;
|
|
42
|
+
export declare const AreaChart: ForwardRefExoticComponent<Props<AreaOptions, AreaC>>;
|
|
43
|
+
export declare const StackedBarChart: ForwardRefExoticComponent<Props<StackedBarOptions, StackedBarC>>;
|
|
44
|
+
export declare const GroupedBarChart: ForwardRefExoticComponent<Props<GroupedBarOptions, GroupedBarC>>;
|
|
45
|
+
export declare const MultiLineChart: ForwardRefExoticComponent<Props<MultiLineOptions, MultiLineC>>;
|
|
46
|
+
export declare const ScatterChart: ForwardRefExoticComponent<Props<ScatterOptions, ScatterC>>;
|
|
47
|
+
export declare const BubbleChart: ForwardRefExoticComponent<Props<BubbleOptions, BubbleC>>;
|
|
48
|
+
export declare const PieChart: <R = Row>(props: Props<PieOptions<R>, PieC<any>>) => ReactElement | null;
|
|
49
|
+
export declare const RadarChart: ForwardRefExoticComponent<Props<RadarOptions, RadarC>>;
|
|
50
|
+
export declare const PolarChart: <R = Row>(props: Props<PolarOptions<R>, PolarC<any>>) => ReactElement | null;
|
|
51
|
+
export declare const GaugeChart: ForwardRefExoticComponent<Props<GaugeOptions, GaugeC>>;
|
|
52
|
+
export declare const HeatmapChart: ForwardRefExoticComponent<Props<HeatmapOptions, HeatmapC>>;
|
|
53
|
+
export declare const BoxplotChart: ForwardRefExoticComponent<Props<BoxplotOptions, BoxplotC>>;
|
|
54
|
+
export declare const FunnelChart: <R = Row>(props: Props<FunnelOptions<R>, FunnelC<any>>) => ReactElement | null;
|
|
55
|
+
export declare const TreemapChart: <R = Row>(props: Props<TreemapOptions<R>, TreemapC<any>>) => ReactElement | null;
|
|
56
|
+
export declare const SparklineChart: <R = Row>(props: Props<SparklineOptions<R>, SparklineC<any>>) => ReactElement | null;
|
|
57
|
+
export declare const RealtimeChart: ForwardRefExoticComponent<Props<RealtimeOptions, RealtimeC>>;
|
|
58
|
+
export declare const WaterfallChart: ForwardRefExoticComponent<Props<WaterfallOptions, WaterfallC>>;
|
|
59
|
+
export declare const CompositeChart: ForwardRefExoticComponent<Props<CompositeOptions, CompositeC>>;
|
package/dist/svelte.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// @aeriz/chart/svelte — one action per chart: <div use:barChart={{ data }}></div>
|
|
2
|
+
import type { Chart } from './index.js';
|
|
3
|
+
import type {
|
|
4
|
+
BarChart as BarC, BarOptions,
|
|
5
|
+
HBarChart as HBarC, HBarOptions,
|
|
6
|
+
LineChart as LineC, LineOptions,
|
|
7
|
+
AreaChart as AreaC, AreaOptions,
|
|
8
|
+
StackedBarChart as StackedBarC, StackedBarOptions,
|
|
9
|
+
GroupedBarChart as GroupedBarC, GroupedBarOptions,
|
|
10
|
+
MultiLineChart as MultiLineC, MultiLineOptions,
|
|
11
|
+
ScatterChart as ScatterC, ScatterOptions,
|
|
12
|
+
BubbleChart as BubbleC, BubbleOptions,
|
|
13
|
+
PieChart as PieC, PieOptions,
|
|
14
|
+
RadarChart as RadarC, RadarOptions,
|
|
15
|
+
PolarChart as PolarC, PolarOptions,
|
|
16
|
+
GaugeChart as GaugeC, GaugeOptions,
|
|
17
|
+
HeatmapChart as HeatmapC, HeatmapOptions,
|
|
18
|
+
BoxplotChart as BoxplotC, BoxplotOptions,
|
|
19
|
+
FunnelChart as FunnelC, FunnelOptions,
|
|
20
|
+
TreemapChart as TreemapC, TreemapOptions,
|
|
21
|
+
SparklineChart as SparklineC, SparklineOptions,
|
|
22
|
+
RealtimeChart as RealtimeC, RealtimeOptions,
|
|
23
|
+
WaterfallChart as WaterfallC, WaterfallOptions,
|
|
24
|
+
CompositeChart as CompositeC, CompositeOptions,
|
|
25
|
+
} from './index.js';
|
|
26
|
+
|
|
27
|
+
/** A Svelte action whose parameter is the chart's options. */
|
|
28
|
+
export type Action<O> = (node: HTMLElement, options?: O) => {
|
|
29
|
+
update(options?: O): void;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The chart an action created on `node`, or `null`. */
|
|
34
|
+
export declare function chartOf(node: HTMLElement): Chart<any> | null;
|
|
35
|
+
|
|
36
|
+
export declare const barChart: Action<BarOptions>;
|
|
37
|
+
export declare const hbarChart: Action<HBarOptions>;
|
|
38
|
+
export declare const lineChart: Action<LineOptions>;
|
|
39
|
+
export declare const areaChart: Action<AreaOptions>;
|
|
40
|
+
export declare const stackedBarChart: Action<StackedBarOptions>;
|
|
41
|
+
export declare const groupedBarChart: Action<GroupedBarOptions>;
|
|
42
|
+
export declare const multiLineChart: Action<MultiLineOptions>;
|
|
43
|
+
export declare const scatterChart: Action<ScatterOptions>;
|
|
44
|
+
export declare const bubbleChart: Action<BubbleOptions>;
|
|
45
|
+
export declare const pieChart: Action<PieOptions>;
|
|
46
|
+
export declare const radarChart: Action<RadarOptions>;
|
|
47
|
+
export declare const polarChart: Action<PolarOptions>;
|
|
48
|
+
export declare const gaugeChart: Action<GaugeOptions>;
|
|
49
|
+
export declare const heatmapChart: Action<HeatmapOptions>;
|
|
50
|
+
export declare const boxplotChart: Action<BoxplotOptions>;
|
|
51
|
+
export declare const funnelChart: Action<FunnelOptions>;
|
|
52
|
+
export declare const treemapChart: Action<TreemapOptions>;
|
|
53
|
+
export declare const sparklineChart: Action<SparklineOptions>;
|
|
54
|
+
export declare const realtimeChart: Action<RealtimeOptions>;
|
|
55
|
+
export declare const waterfallChart: Action<WaterfallOptions>;
|
|
56
|
+
export declare const compositeChart: Action<CompositeOptions>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AreaChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BarChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BoxplotChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BubbleChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CompositeChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FunnelChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GaugeChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GroupedBarChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HBarChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HeatmapChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LineChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MultiLineChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PieChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PolarChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RadarChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RealtimeChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ScatterChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SparklineChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StackedBarChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TreemapChart } from '../index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WaterfallChart } from '../index.js';
|
package/dist/vue.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// @aeriz/chart/vue — one component per chart: <BarChart :data="rows" @click="…" />
|
|
2
|
+
import type { DefineComponent, ShallowRef } from 'vue';
|
|
3
|
+
import type { Hit, Chart } from './index.js';
|
|
4
|
+
import type {
|
|
5
|
+
BarChart as BarC, BarOptions,
|
|
6
|
+
HBarChart as HBarC, HBarOptions,
|
|
7
|
+
LineChart as LineC, LineOptions,
|
|
8
|
+
AreaChart as AreaC, AreaOptions,
|
|
9
|
+
StackedBarChart as StackedBarC, StackedBarOptions,
|
|
10
|
+
GroupedBarChart as GroupedBarC, GroupedBarOptions,
|
|
11
|
+
MultiLineChart as MultiLineC, MultiLineOptions,
|
|
12
|
+
ScatterChart as ScatterC, ScatterOptions,
|
|
13
|
+
BubbleChart as BubbleC, BubbleOptions,
|
|
14
|
+
PieChart as PieC, PieOptions,
|
|
15
|
+
RadarChart as RadarC, RadarOptions,
|
|
16
|
+
PolarChart as PolarC, PolarOptions,
|
|
17
|
+
GaugeChart as GaugeC, GaugeOptions,
|
|
18
|
+
HeatmapChart as HeatmapC, HeatmapOptions,
|
|
19
|
+
BoxplotChart as BoxplotC, BoxplotOptions,
|
|
20
|
+
FunnelChart as FunnelC, FunnelOptions,
|
|
21
|
+
TreemapChart as TreemapC, TreemapOptions,
|
|
22
|
+
SparklineChart as SparklineC, SparklineOptions,
|
|
23
|
+
RealtimeChart as RealtimeC, RealtimeOptions,
|
|
24
|
+
WaterfallChart as WaterfallC, WaterfallOptions,
|
|
25
|
+
CompositeChart as CompositeC, CompositeOptions,
|
|
26
|
+
} from './index.js';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Chart options are props; `onClick` / `onLegend` are the events `@click` / `@legend`.
|
|
30
|
+
* The template ref exposes `chart` (the chart instance).
|
|
31
|
+
*/
|
|
32
|
+
type Component<O, C> = DefineComponent<
|
|
33
|
+
Omit<O, 'onClick' | 'onLegend'>,
|
|
34
|
+
{ chart: ShallowRef<C | null> },
|
|
35
|
+
{},
|
|
36
|
+
{},
|
|
37
|
+
{},
|
|
38
|
+
{},
|
|
39
|
+
{},
|
|
40
|
+
{ click: (hit: Hit, chart: Chart) => void; legend: (index: number, visible: boolean, chart: Chart) => void }
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
export declare const BarChart: Component<BarOptions, BarC>;
|
|
44
|
+
export declare const HBarChart: Component<HBarOptions, HBarC>;
|
|
45
|
+
export declare const LineChart: Component<LineOptions, LineC>;
|
|
46
|
+
export declare const AreaChart: Component<AreaOptions, AreaC>;
|
|
47
|
+
export declare const StackedBarChart: Component<StackedBarOptions, StackedBarC>;
|
|
48
|
+
export declare const GroupedBarChart: Component<GroupedBarOptions, GroupedBarC>;
|
|
49
|
+
export declare const MultiLineChart: Component<MultiLineOptions, MultiLineC>;
|
|
50
|
+
export declare const ScatterChart: Component<ScatterOptions, ScatterC>;
|
|
51
|
+
export declare const BubbleChart: Component<BubbleOptions, BubbleC>;
|
|
52
|
+
export declare const PieChart: Component<PieOptions, PieC>;
|
|
53
|
+
export declare const RadarChart: Component<RadarOptions, RadarC>;
|
|
54
|
+
export declare const PolarChart: Component<PolarOptions, PolarC>;
|
|
55
|
+
export declare const GaugeChart: Component<GaugeOptions, GaugeC>;
|
|
56
|
+
export declare const HeatmapChart: Component<HeatmapOptions, HeatmapC>;
|
|
57
|
+
export declare const BoxplotChart: Component<BoxplotOptions, BoxplotC>;
|
|
58
|
+
export declare const FunnelChart: Component<FunnelOptions, FunnelC>;
|
|
59
|
+
export declare const TreemapChart: Component<TreemapOptions, TreemapC>;
|
|
60
|
+
export declare const SparklineChart: Component<SparklineOptions, SparklineC>;
|
|
61
|
+
export declare const RealtimeChart: Component<RealtimeOptions, RealtimeC>;
|
|
62
|
+
export declare const WaterfallChart: Component<WaterfallOptions, WaterfallC>;
|
|
63
|
+
export declare const CompositeChart: Component<CompositeOptions, CompositeC>;
|