@clarity-js/charts 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,133 @@
1
- # Temporary Holding Version
1
+ # @clarity-js/charts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Charts for [Clarity.js](https://clarity-js.com) with Chart.js's configuration and API. Code written for
4
+ Chart.js 4 runs with the import changed; in markup, the same configuration is state.
5
+
6
+ ```js
7
+ import { Chart } from '@clarity-js/charts'
8
+
9
+ const chart = new Chart(document.getElementById('sales'), {
10
+ type: 'bar',
11
+ data: { labels: ['Mon', 'Tue', 'Wed'], datasets: [{ label: 'Visits', data: [12, 19, 3] }] },
12
+ options: { plugins: { title: { display: true, text: 'This week' } }, scales: { y: { beginAtZero: true } } },
13
+ })
14
+ chart.data.datasets[0].data.push(7)
15
+ chart.update()
16
+ ```
17
+
18
+ ```clarity
19
+ import { Chart, LineChart } from '@clarity-js/charts'
20
+
21
+ component Sales() {
22
+ state visits = [12, 19, 3]
23
+ render {
24
+ <Chart type="bar" data={ { labels: ["Mon", "Tue", "Wed"], datasets: [{ label: "Visits", data: visits }] } } />
25
+ <LineChart data={ months } x="month" y={ ["sales", "costs"] } curve="monotone" title="Sales and costs" />
26
+ }
27
+ }
28
+ ```
29
+
30
+ ## What it has
31
+
32
+ - **Types:** line, bar, radar, pie, doughnut, polarArea, bubble, scatter, and mixed charts (`type` per dataset); and thirty more (below).
33
+ - **Data:** numbers with labels, `{ x, y }`, `{ x, y, r }`, `[low, high]` floating bars, objects read through `parsing`, `null` gaps.
34
+ - **Axes:** category, linear, logarithmic, time, timeseries, radialLinear; several axes by id (`yAxisID`), `position`, `min`, `max`, `suggestedMin/Max`, `beginAtZero`, `grace`, `reverse`, `stacked` (and `'single'`), `offset`, `grid`, `border`, `ticks` (`callback`, `stepSize`, `maxTicksLimit`, `precision`, `autoSkip`, `maxRotation`), `title`, `time.unit`, `time.displayFormats`, `time.tooltipFormat`, `angleLines`, `pointLabels`, `startAngle`.
35
+ - **Lines:** `tension`, `cubicInterpolationMode: 'monotone'`, `stepped`, `spanGaps`, `showLine`, `borderDash`, `segment` styles, every `pointStyle`, `fill` to `'origin'`, `'start'`, `'end'`, `'stack'`, another dataset (`'-1'`, `2`) or `{ value }`; `above` / `below` colours for a fill to a level.
36
+ - **Bars:** grouped, stacked by `stack`, horizontal (`indexAxis: 'y'`), `barPercentage`, `categoryPercentage`, `barThickness`, `maxBarThickness`, `minBarLength`, `borderRadius`, `base`.
37
+ - **Slices:** `cutout`, `radius`, `rotation`, `circumference` (half rings), `offset`, `hoverOffset`, `spacing`, rings for several datasets with `weight`.
38
+ - **Plugins:** title, subtitle, legend (click to hide, `generateLabels`, `filter`, `sort`, `usePointStyle`), tooltip (`mode`, `intersect`, `position`, every callback, `external`), filler, decimation (`lttb`, `min-max`), colors; your own with every hook, through `Chart.register()` or `config.plugins`.
39
+ - **Interaction:** modes `point`, `nearest`, `index`, `dataset`, `x`, `y`, with `intersect` and `axis`; `onClick`, `onHover`, `events`.
40
+ - **Animation:** `duration`, `easing` (Chart.js's thirty names), `delay` (a number or a function), `loop`, `onProgress`, `onComplete`, `animateRotate`, `animateScale`; on Clarity's shared clock, so `clock.pause()` and `clock.step()` hold and step it in a test.
41
+ - **API:** `update(mode)`, `render`, `stop`, `reset`, `resize`, `clear`, `destroy`, `toBase64Image`, `getElementsAtEventForMode`, `getActiveElements`, `setActiveElements`, `getDatasetMeta` (with `meta.data`), `isDatasetVisible`, `setDatasetVisibility`, `toggleDataVisibility`, `getDataVisibility`, `hide`, `show`, `isPointInArea`, `chart.tooltip.setActiveElements`; `Chart.defaults`, `Chart.register`, `Chart.getChart`, `Chart.instances`.
42
+ - **Options:** scriptable (a function of the context) and indexable (an array per point), as in Chart.js; dataset options at the root of `options`, in `options.datasets[type]`, or in `options.elements`.
43
+
44
+ ## Beyond Chart.js: what Highcharts and ApexCharts have (1.1)
45
+
46
+ Each type is a dataset `type`, under the names those libraries give it, and mixes with the others.
47
+
48
+ ```js
49
+ new Chart(el, { type: 'candlestick', data: { datasets: [
50
+ { label: 'Price', data: days }, // { x, o, h, l, c }, { x, open, … }, [x, o, h, l, c] or { x, y: [o, h, l, c] }
51
+ { type: 'sma', linkedTo: 0, period: 20 }, // indicators read the dataset they are linked to
52
+ { type: 'bar', label: 'Volume', data: volume, yAxisID: 'volume' },
53
+ ] }, options: {
54
+ scales: { y: { stack: 'panes', stackWeight: 3 }, volume: { stack: 'panes', stackWeight: 1 } }, // prices above volume
55
+ plugins: { navigator: { enabled: true }, rangeSelector: { enabled: true }, toolbar: { display: true },
56
+ zoom: { zoom: { drag: { enabled: true }, mode: 'x' }, pan: { enabled: true, modifierKey: 'shift' } }, crosshair: { enabled: true } },
57
+ } })
58
+ ```
59
+
60
+ - **Finance:** `candlestick`, `hollowcandlestick`, `heikinashi`, `ohlc`, `hlc` (colours by `upColor`, `downColor`), on a
61
+ `timeseries` axis that leaves out the days with no trading; indicators `sma`, `ema`, `wma`, `bollinger`, `macd`, `rsi`,
62
+ `momentum` (`linkedTo`, `period` or Highcharts's `params`).
63
+ - **Statistics and ranges:** `boxplot` (numbers, or `{ min, q1, median, q3, max }`, or five with `summary: true`), `violin`,
64
+ `areaRange`, `errorBar` (`linkedTo` a bar dataset), `dumbbell`, `lollipop`, `bullet` (`target`, `ranges`).
65
+ - **Trees, flows and grids:** `treemap` and `sunburst` (rows `{ id, parent, name, value }`), `sankey` (`{ from, to, flow }`),
66
+ `funnel`, `pyramid`, `waterfall` (`{ isSum: true }`, `{ isIntermediateSum: true }`), `heatmap` (`{ x, y, v }`, `[x, y, v]`
67
+ or a dataset per row) on `options.colorAxis`, `timeline` (`xrange` `{ x, x2, y }`, `rangeBar` `{ x, y: [start, end] }`).
68
+ - **Dials and the rest:** `gauge` (`min`, `max`, `startAngle`, `endAngle`, `bands`), `solidgauge` (`stops`), `radialBar`,
69
+ `wordcloud`, `item` (a parliament, or `layout: 'grid'`), `streamgraph`.
70
+ - **Maps:** `map` (`choropleth`) of `@clarity-js/charts/maps/world` (countries by ISO code, ISO-3 code or name),
71
+ `@clarity-js/charts/maps/turkey` (81 provinces by code, plate or name) or GeoJSON of your own (`joinBy` one of its
72
+ properties); on `options.colorAxis`, with `nullColor` and `labels`; projections `equalEarth`, `naturalEarth`, `mercator`,
73
+ `equirectangular` and `orthographic` (a globe: `rotate`, and a drag turns it); `mapbubble` and `mappoint` by country or
74
+ `{ lon, lat }`; zoom and pan as on any chart. The maps are made from [Natural Earth](https://www.naturalearthdata.com)
75
+ (public domain) by `scripts/build-chart-maps.mjs`.
76
+ - **3D:** `column3d` and `bar3d` (`options.chart3d: { alpha, beta, depth }`; `grouped: false` puts datasets in rows, one
77
+ behind another), `pie3d` and `doughnut3d` (a slice pulled out by `offset` or `sliced`), `scatter3d` (`{ x, y, z }`,
78
+ `chart3d.axes` with `min`, `max`, `title`) and `surface` (a grid of values, coloured on the colour axis; `wireframe: false` leaves out its lines);
79
+ dragging turns them (`plugins.rotate3d`).
80
+ - **Networks, trees and sets:** `network` (`networkgraph`: `[from, to]` links and `nodes`, laid out by forces the same way
81
+ each time; a node can be dragged), `organization` (rows `{ id, parent, name, title }`, or `[from, to]` with `nodes`;
82
+ `inverted: true` goes across), `treegraph`, `venn` (`{ sets: ['A', 'B'], value }`; a region is found under the pointer),
83
+ `parallel` (`parallelCoordinates`: the labels are the dimensions, a row is an array or an object, words make an axis of
84
+ their own; `options.parallelAxes` for `min`, `max`, `reversed`).
85
+ - **Gantt:** `gantt` (a timeline) with `id`, `dependency` (one task or several) drawn as arrows, `milestone: true` as a
86
+ diamond, and `completed` (or `{ amount }`).
87
+ - **Stacking:** `stacked: 'percent'` (`'100%'`), `'expand'` and `'stream'`; axes in a stack with `stack` and `stackWeight`.
88
+ - **Around a chart (plugins):** `annotation` (line, box, ellipse, point, label, polygon) and an axis's `plotBands` and
89
+ `plotLines`; `datalabels` (anchor, align, offset, formatter, contrast colour, `display: 'auto'` leaves out overlaps);
90
+ `zoom` (drag, wheel, pinch; pan with a modifier; limits) with `chart.zoom()`, `chart.pan()`, `chart.resetZoom()`;
91
+ `measure` (a ruler); `crosshair`; `options.group` (charts that hover and zoom together); `navigator`; `rangeSelector`;
92
+ `brush` (a small chart that sets another's range, by `options.id`); `toolbar` (zoom, pan, reset, PNG, SVG, CSV);
93
+ `options.drilldown` (Highcharts's series by id; `chart.drillUp()`); `dataGrouping`; the colour axis's legend.
94
+ - **Looks:** `theme: 'light' | 'dark' | 'auto'` or one of your own with `Chart.registerTheme()`; palettes; gradients and
95
+ patterns wherever a colour goes (`{ type: 'linear', angle, stops }`, Highcharts's `{ linearGradient, stops }`,
96
+ `{ pattern: 'diagonal' }`); `responsive` rules in Highcharts's (`{ rules }`) or ApexCharts's (`[{ breakpoint }]`) form;
97
+ `sparkline: true`.
98
+ - **API:** `addPoint(dataset, point, { shift, maxPoints })` and `appendData()` (the marks slide along); `saveView()` and
99
+ `restoreView(token)`; `toCSV()`, `toSVG()`, `download('png' | 'svg' | 'csv')`; `sonify()` (the data as notes, each point
100
+ shown as it sounds); `setView()`, `getView()`, `getZoomLevel()`.
101
+ - **Lighter:** `import { Chart } from '@clarity-js/charts/lite'` is Chart.js's eight types and plugins alone, about
102
+ 40 kB gzipped against 102 kB for the whole. The maps are imported on their own: the world is 31 kB, Turkey 19 kB.
103
+ - **Their configuration, as they write it:** `Highcharts.chart(el, options)`, `Highcharts.stockChart()`,
104
+ `Highcharts.mapChart()`, `Highcharts.ganttChart()` and `new ApexCharts(el, options).render()` translate the common
105
+ options (types, axes, series, stacking, tooltips, legends, plot bands, drilldown, colour axes, exporting, zooming,
106
+ themes, annotations, responsive rules, `options3d`, `parallelCoordinates`, a map's `joinBy`) and return handles with
107
+ their usual methods; `fromHighcharts()` and `fromApex()` give the configuration itself.
108
+
109
+ ## What Clarity adds
110
+
111
+ - **SVG by default.** Every mark is an element: the chart is a picture a screen reader can name (a
112
+ sentence on what it shows: where each series starts, ends, peaks and dips), with a table of its numbers
113
+ and legend buttons for the keyboard. The arrows, Home, End and Enter move along the points.
114
+ `renderer: 'canvas'` (or a `<canvas>` given to `new Chart`) draws on a canvas, with `chart.ctx` for
115
+ plugins that draw.
116
+ - **A strict Content-Security-Policy.** No inline styles in markup, no HTML strings: styles are set through
117
+ the CSSOM.
118
+ - **Drawn on a server.** `renderToSVG(config, { width, height })` returns the chart as an SVG string, for
119
+ server rendering, e-mail and files.
120
+ - **Less motion.** When the reader asks for less motion, charts appear without animating.
121
+
122
+ ## What is different
123
+
124
+ - Dates are formatted by a small built-in formatter, in UTC (`time.displayFormats` take patterns such as
125
+ `'MMM d, yyyy'`); Chart.js's date adapters (date-fns, Luxon, Moment) are not used.
126
+ - `toBase64Image()` on an SVG chart returns an SVG data URL; `await chart.toImage()` returns a PNG.
127
+ - Not yet: per-property `animations` and `transitions`, custom interaction modes and tooltip positioners,
128
+ right-to-left legends and tooltips, images as point styles, and `borderRadius` on slices.
129
+ - Not here from Highcharts: 3D areas, funnels and cylinders; its map collections in TopoJSON (GeoJSON is read) and map
130
+ navigation buttons; the Gantt chart's grid of columns and rows that fold; vector and wind barbs, dependency wheels and
131
+ arc diagrams, packed bubbles, bell curves, Pareto, pictorial and variwide series, the event timeline; its format
132
+ strings beyond `{point.y}`, `{point.name}`, `{series.name}`. The Boost module's WebGL is `renderer: 'canvas'` here.
133
+ - A category axis that stands up lists its labels from the top down, as Chart.js does (1.1; 1.0 went from the bottom up).
package/index.d.ts ADDED
@@ -0,0 +1,407 @@
1
+ // @clarity-js/charts — types. The configuration follows Chart.js 4: the same names, the same shapes;
2
+ // the types and options Highcharts and ApexCharts add are written the same way.
3
+
4
+ export type ChartJsType = 'line' | 'bar' | 'radar' | 'pie' | 'doughnut' | 'polarArea' | 'bubble' | 'scatter';
5
+ /** The types beyond Chart.js's eight, under the names Highcharts and ApexCharts give them. */
6
+ export type MoreType =
7
+ | 'areaRange' | 'arearange' | 'rangeArea' | 'areasplinerange' | 'boxplot' | 'boxPlot' | 'violin'
8
+ | 'candlestick' | 'hollowcandlestick' | 'hollowCandlestick' | 'heikinashi' | 'ohlc' | 'hlc'
9
+ | 'heatmap' | 'matrix' | 'treemap' | 'sunburst' | 'funnel' | 'pyramid' | 'waterfall' | 'timeline' | 'xrange' | 'rangeBar'
10
+ | 'errorBar' | 'errorbar' | 'dumbbell' | 'lollipop' | 'bullet' | 'gauge' | 'solidgauge' | 'radialBar' | 'sankey' | 'wordcloud' | 'item' | 'parliament' | 'streamgraph'
11
+ | 'sma' | 'ema' | 'wma' | 'momentum' | 'rsi' | 'bollinger' | 'bb' | 'macd'
12
+ | 'map' | 'choropleth' | 'mapbubble' | 'mappoint'
13
+ | 'column3d' | 'bar3d' | 'pie3d' | 'doughnut3d' | 'scatter3d' | 'surface'
14
+ | 'network' | 'networkgraph' | 'organization' | 'treegraph' | 'venn' | 'parallel' | 'parallelCoordinates' | 'gantt';
15
+ export type ChartType = ChartJsType | MoreType;
16
+ export type Scriptable<T, C = ScriptableContext> = T | ((ctx: C) => T);
17
+ export type Indexable<T> = T | T[];
18
+ /** A gradient or a pattern, wherever a colour goes: the native form, Highcharts's, or a pattern's name. */
19
+ export type Paint =
20
+ | { type?: 'linear'; angle?: number; from?: 'left' | 'right' | 'top' | 'bottom'; stops?: [number, string][]; colors?: string[] }
21
+ | { type: 'radial'; cx?: number; cy?: number; r?: number; stops: [number, string][] }
22
+ | { linearGradient: { x1: number; y1: number; x2: number; y2: number } | [number, number, number, number]; stops: [number, string][] }
23
+ | { radialGradient: { cx: number; cy: number; r: number }; stops: [number, string][] }
24
+ | { pattern: 'diagonal' | 'diagonalBack' | 'dots' | 'cross' | 'horizontal' | 'vertical' | 'grid' | 'zigzag' | { path: string; color?: string; width?: number; height?: number; backgroundColor?: string }; color?: string; background?: string; size?: number };
25
+ export type Color = string | Paint;
26
+
27
+ export interface ScriptableContext {
28
+ chart: ChartInstance; type: 'data' | 'dataset'; dataset: ChartDataset; datasetIndex: number; dataIndex: number; index: number;
29
+ raw: unknown; parsed?: { x: number; y: number; r?: number }; active: boolean; mode?: string;
30
+ }
31
+ export interface Point { x: number | string | Date; y: number | null; r?: number }
32
+ export type PointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle' | false;
33
+ export type FillTarget = boolean | number | string | { value: number } | 'origin' | 'start' | 'end' | 'stack';
34
+
35
+ export interface ChartDataset {
36
+ type?: ChartType; label?: string;
37
+ data: Array<number | null | [number, number] | Point | Record<string, unknown> | Array<string | number | null>>;
38
+ hidden?: boolean; order?: number; stack?: string; xAxisID?: string; yAxisID?: string; indexAxis?: 'x' | 'y';
39
+ parsing?: false | { xAxisKey?: string; yAxisKey?: string; key?: string };
40
+ backgroundColor?: Scriptable<Indexable<Color>>; borderColor?: Scriptable<Indexable<Color>>; borderWidth?: Scriptable<Indexable<number>>;
41
+ hoverBackgroundColor?: Scriptable<Indexable<Color>>; hoverBorderColor?: Scriptable<Indexable<Color>>; hoverBorderWidth?: Scriptable<Indexable<number>>;
42
+ // line, radar
43
+ fill?: FillTarget | { target: FillTarget; above?: Color; below?: Color }; tension?: number; stepped?: boolean | 'before' | 'after' | 'middle';
44
+ cubicInterpolationMode?: 'default' | 'monotone'; spanGaps?: boolean | number; showLine?: boolean; borderDash?: number[]; borderDashOffset?: number;
45
+ borderCapStyle?: 'butt' | 'round' | 'square'; borderJoinStyle?: 'bevel' | 'round' | 'miter';
46
+ segment?: { borderColor?: (ctx: SegmentContext) => Color | undefined; borderDash?: (ctx: SegmentContext) => number[] | undefined; borderWidth?: (ctx: SegmentContext) => number | undefined };
47
+ pointRadius?: Scriptable<Indexable<number>>; pointHoverRadius?: Scriptable<Indexable<number>>; pointHitRadius?: Scriptable<Indexable<number>>; pointStyle?: Scriptable<Indexable<PointStyle>>;
48
+ pointBackgroundColor?: Scriptable<Indexable<Color>>; pointBorderColor?: Scriptable<Indexable<Color>>; pointBorderWidth?: Scriptable<Indexable<number>>; pointRotation?: Scriptable<Indexable<number>>;
49
+ pointHoverBackgroundColor?: Scriptable<Indexable<Color>>; pointHoverBorderColor?: Scriptable<Indexable<Color>>; pointHoverBorderWidth?: Scriptable<Indexable<number>>;
50
+ // bar
51
+ barPercentage?: number; categoryPercentage?: number; barThickness?: number | 'flex'; maxBarThickness?: number; minBarLength?: number; base?: number; grouped?: boolean;
52
+ borderRadius?: Scriptable<Indexable<number | { topLeft?: number; topRight?: number; bottomLeft?: number; bottomRight?: number }>>; borderSkipped?: 'start' | 'end' | 'left' | 'right' | 'top' | 'bottom' | 'middle' | boolean;
53
+ // pie, doughnut, polarArea
54
+ cutout?: number | string; radius?: number | string; rotation?: number; circumference?: number; offset?: Scriptable<Indexable<number>>; hoverOffset?: number; spacing?: number; weight?: number;
55
+ // bubble
56
+ radiusScale?: never;
57
+ // the types beyond Chart.js (each reads the options it knows; see the README)
58
+ /** Indicators: the dataset (index, id or label) they read; and their periods. */
59
+ linkedTo?: number | string; period?: number; params?: { period?: number; standardDeviation?: number; shortPeriod?: number; longPeriod?: number; signalPeriod?: number };
60
+ /** Candles: colours up, down and unchanged; hollow candles; Heikin-Ashi. */
61
+ upColor?: Color; downColor?: Color; unchangedColor?: Color; hollow?: boolean; heikinAshi?: boolean;
62
+ /** Box plots: an array of five is a summary; whiskers at coef × IQR; the mean and outliers. */
63
+ summary?: boolean; coef?: number; meanRadius?: number; outlierRadius?: number;
64
+ /** Waterfall: colours for a rise, a fall and a sum; the dashed lines between. */
65
+ sumColor?: Color; showConnector?: boolean; connector?: { color?: Color; width?: number; dash?: number[] };
66
+ /** Bullet: a target for each value, and the ranges behind. */
67
+ targets?: number[]; ranges?: Array<number | { from?: number; to: number; color?: Color }>;
68
+ /** Gauges and radial bars. */
69
+ min?: number; max?: number; startAngle?: number; endAngle?: number; bands?: { from?: number; to?: number; color?: Color; thickness?: string | number }[]; stops?: [number, string][]; unit?: string;
70
+ /** Treemap and sunburst rows: { id, parent, name, value, color }; labels inside. */
71
+ labels?: { display?: boolean; color?: Color | 'auto'; font?: FontSpec; formatter?: (value: number, ctx: object) => string | string[]; value?: boolean } | Record<string, string>;
72
+ /** Maps: the map (`@clarity-js/charts/maps/world`, `/maps/turkey`, or GeoJSON); the feature property values join by; regions with no value; the sea of a globe; a projection; where a globe faces; bubble sizes. */
73
+ map?: import('./maps/index.js').MapData | { type: 'FeatureCollection'; features: unknown[] }; joinBy?: string; nullColor?: Color; oceanColor?: Color;
74
+ projection?: 'equalEarth' | 'naturalEarth' | 'mercator' | 'equirectangular' | 'orthographic'; rotate?: [number, number]; minSize?: number; maxSize?: number;
75
+ /** 3D: a surface's lines. */
76
+ wireframe?: boolean;
77
+ /** Networks and trees: nodes { id, name, title, color, radius, group }; how long the layout runs; node size; a tree across. */
78
+ nodes?: { id: string; name?: string; title?: string; color?: Color; radius?: number; group?: string | number }[]; iterations?: number; nodeRadius?: number; nodeWidth?: number; nodeHeight?: number; inverted?: boolean;
79
+ /** Gantt: the arrows' colour, or false for none. */
80
+ dependencies?: boolean; dependencyColor?: Color;
81
+ /** Drilldown: the id of each point's series in options.drilldown.series. */
82
+ drilldown?: Array<string | null>;
83
+ /** Data labels for this dataset only. */
84
+ datalabels?: DataLabelsOptions;
85
+ /** Data grouping for this dataset only. */
86
+ dataGrouping?: { enabled?: boolean; groupPixelWidth?: number; approximation?: 'average' | 'sum' | 'open' | 'high' | 'low' | 'close' | 'ohlc'; forced?: boolean };
87
+ /** Keep no more than this many points when addPoint() adds one. */
88
+ maxPoints?: number;
89
+ [option: string]: unknown;
90
+ }
91
+ export interface SegmentContext { type: 'segment'; p0: ChartElement; p1: ChartElement; p0DataIndex: number; p1DataIndex: number; datasetIndex: number; chart: ChartInstance }
92
+ export interface ChartData { labels?: Array<string | number | Date | string[]>; datasets: ChartDataset[] }
93
+
94
+ export interface FontSpec { family?: string; size?: number; style?: 'normal' | 'italic'; weight?: string | number; lineHeight?: number }
95
+ export interface TickOptions { display?: boolean; color?: Scriptable<Color>; font?: FontSpec; padding?: number; stepSize?: number; count?: number; maxTicksLimit?: number; precision?: number; autoSkip?: boolean; maxRotation?: number; format?: Intl.NumberFormatOptions; callback?: (this: Axis, value: number, index: number, ticks: { value: number }[]) => string | string[] | number | null | undefined; showLabelBackdrop?: boolean; backdropColor?: Color }
96
+ export interface ScaleOptions {
97
+ type?: 'category' | 'linear' | 'logarithmic' | 'time' | 'timeseries' | 'radialLinear'; axis?: 'x' | 'y' | 'r'; position?: 'left' | 'right' | 'top' | 'bottom';
98
+ display?: boolean | 'auto'; min?: number | string; max?: number | string; suggestedMin?: number; suggestedMax?: number; beginAtZero?: boolean; grace?: number | string; reverse?: boolean;
99
+ stacked?: boolean | 'single' | 'percent' | '100%' | 'expand' | 'stream'; offset?: boolean; labels?: string[];
100
+ /** Axes with the same stack share their side, each stackWeight of its height (prices above volume). */
101
+ stack?: string; stackWeight?: number; stackGap?: number;
102
+ /** Highcharts's plot bands and lines, on this axis. */
103
+ plotBands?: { from: number | string; to: number | string; color?: Color; label?: { text: string; align?: 'left' | 'center' | 'right' } }[];
104
+ plotLines?: { value: number | string; color?: Color; width?: number; dashStyle?: string; dash?: number[]; label?: { text: string; align?: 'left' | 'center' | 'right' } }[];
105
+ grid?: { display?: boolean; color?: Scriptable<Color>; lineWidth?: Scriptable<number>; drawOnChartArea?: boolean; drawTicks?: boolean; tickLength?: number; offset?: boolean; circular?: boolean };
106
+ border?: { display?: boolean; color?: Color; width?: number; dash?: number[] };
107
+ ticks?: TickOptions; title?: { display?: boolean; text?: string; color?: Color; font?: FontSpec };
108
+ time?: { unit?: 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; stepSize?: number; displayFormats?: Record<string, string>; tooltipFormat?: string };
109
+ angleLines?: { display?: boolean; color?: Color; lineWidth?: number }; pointLabels?: { display?: boolean; color?: Color; font?: FontSpec }; startAngle?: number;
110
+ }
111
+ export interface TooltipItem { chart: ChartInstance; dataset: ChartDataset; datasetIndex: number; dataIndex: number; element: ChartElement; raw: unknown; parsed: { x: number; y: number; r?: number }; label: string; formattedValue: string }
112
+ export interface TooltipModel { opacity: number; x: number; y: number; title: string[]; body: { before: string[]; lines: string[]; after: string[] }[]; footer: string[]; labelColors: { backgroundColor: Color; borderColor: Color }[]; dataPoints: TooltipItem[] }
113
+ export interface LegendItem { text: string; fillStyle: Color; strokeStyle: Color; lineWidth: number; lineDash?: number[]; hidden: boolean; datasetIndex?: number; index?: number; pointStyle?: PointStyle }
114
+ export interface ChartEvent { type: 'mousemove' | 'mouseout' | 'click' | 'touchstart' | 'touchmove' | 'keyboard'; x: number; y: number; native: Event | null; chart: ChartInstance }
115
+ export interface ActiveElement { datasetIndex: number; index: number; element: ChartElement }
116
+ export type InteractionMode = 'point' | 'nearest' | 'index' | 'dataset' | 'x' | 'y';
117
+
118
+ export interface Axis3D { min?: number; max?: number; title?: string }
119
+ export interface ChartOptions {
120
+ renderer?: 'svg' | 'canvas'; maintainAspectRatio?: boolean; aspectRatio?: number; resizeDelay?: number; devicePixelRatio?: number; locale?: string;
121
+ indexAxis?: 'x' | 'y'; color?: Color; font?: FontSpec; layout?: { padding?: number | { left?: number; right?: number; top?: number; bottom?: number }; autoPadding?: boolean };
122
+ animation?: false | { duration?: number; easing?: keyof typeof easing | ((t: number) => number); delay?: number | ((ctx: ScriptableContext) => number); loop?: boolean; animateRotate?: boolean; animateScale?: boolean; onProgress?: (e: { chart: ChartInstance; currentStep: number; numSteps: number; initial: boolean }) => void; onComplete?: (e: { chart: ChartInstance; initial: boolean }) => void };
123
+ interaction?: { mode?: InteractionMode; intersect?: boolean; axis?: 'x' | 'y' | 'xy' | 'r'; includeInvisible?: boolean }; hover?: { mode?: InteractionMode; intersect?: boolean; axis?: 'x' | 'y' | 'xy' };
124
+ events?: Array<'mousemove' | 'mouseout' | 'click' | 'touchstart' | 'touchmove'>;
125
+ onClick?: (event: ChartEvent, elements: ActiveElement[], chart: ChartInstance) => void; onHover?: (event: ChartEvent, elements: ActiveElement[], chart: ChartInstance) => void; onResize?: (chart: ChartInstance, size: { width: number; height: number }) => void;
126
+ scales?: Record<string, ScaleOptions>;
127
+ /** 'light' (the default), 'dark', 'auto', a theme registered with Chart.registerTheme, or the colours themselves. */
128
+ theme?: string | ThemeSpec;
129
+ /** The chart's background (a theme may set one). */
130
+ background?: Color;
131
+ chartArea?: { backgroundColor?: Color };
132
+ /** The line alone: no axes, legend or title (ApexCharts's sparkline). */
133
+ sparkline?: boolean | { enabled: boolean };
134
+ /** 3D: the angles a chart is seen from, its depth and how far the eye is (a drag changes alpha and beta); a cube's axes. */
135
+ chart3d?: { alpha?: number; beta?: number; depth?: number; viewDistance?: number; axes?: { x?: Axis3D; y?: Axis3D; z?: Axis3D } };
136
+ /** Parallel coordinates: an axis's range or direction, by index or by label. */
137
+ parallelAxes?: Array<{ min?: number; max?: number; reversed?: boolean }> | Record<string, { min?: number; max?: number; reversed?: boolean }>;
138
+ /** Charts in the same group hover and zoom together. */
139
+ group?: string;
140
+ /** A name another chart's brush can target. */
141
+ id?: string;
142
+ /** Rules for other sizes: Highcharts's { rules } or ApexCharts's [{ breakpoint, options }]. */
143
+ responsive?: boolean | { rules: { condition: { maxWidth?: number; minWidth?: number; maxHeight?: number; minHeight?: number; callback?: (size: { width: number; height: number }) => boolean }; chartOptions: ChartOptions }[] } | { breakpoint: number; options: ChartOptions }[];
144
+ /** The series a point with a drilldown opens. */
145
+ drilldown?: { series: { id: string; name?: string; type?: ChartType; data: Array<number | [string, number] | { name: string; y: number; drilldown?: string }>; labels?: string[]; datasets?: ChartDataset[] }[] };
146
+ /** The colours of a heatmap (and a treemap coloured by value): stops, min and max colours, or classes. */
147
+ colorAxis?: { min?: number; max?: number; stops?: [number, string][]; minColor?: string; maxColor?: string; dataClasses?: { from?: number; to?: number; color?: string; name?: string }[]; type?: 'linear' | 'logarithmic'; reversed?: boolean; nullColor?: string; legend?: { display?: boolean; position?: 'top' | 'bottom' | 'left' | 'right'; thickness?: number } };
148
+ elements?: { point?: Record<string, unknown>; line?: Record<string, unknown>; bar?: Record<string, unknown>; arc?: Record<string, unknown> };
149
+ datasets?: Partial<Record<ChartType, Partial<ChartDataset>>>;
150
+ parsing?: ChartDataset['parsing']; spanGaps?: boolean | number; clip?: false;
151
+ plugins?: {
152
+ title?: TitleOptions;
153
+ subtitle?: TitleOptions;
154
+ legend?: { display?: boolean; position?: 'top' | 'bottom' | 'left' | 'right'; align?: 'start' | 'center' | 'end'; reverse?: boolean; onClick?: (e: ChartEvent, item: LegendItem, legend: unknown) => void; onHover?: (e: ChartEvent, item: LegendItem, legend: unknown) => void; onLeave?: (e: ChartEvent, item: LegendItem, legend: unknown) => void; labels?: { boxWidth?: number; boxHeight?: number; padding?: number; usePointStyle?: boolean; pointStyle?: PointStyle; color?: Color; font?: FontSpec; filter?: (item: LegendItem, data: ChartData) => boolean; sort?: (a: LegendItem, b: LegendItem, data: ChartData) => number; generateLabels?: (chart: ChartInstance) => LegendItem[] }; title?: { display?: boolean; text?: string; color?: Color; font?: FontSpec; padding?: number } } | false;
155
+ tooltip?: { enabled?: boolean; mode?: InteractionMode; intersect?: boolean; position?: 'average' | 'nearest'; external?: (ctx: { chart: ChartInstance; tooltip: TooltipModel }) => void; backgroundColor?: Color; titleColor?: Color; bodyColor?: Color; footerColor?: Color; displayColors?: boolean; padding?: number; cornerRadius?: number; boxWidth?: number; boxHeight?: number; usePointStyle?: boolean; filter?: (item: TooltipItem) => boolean; itemSort?: (a: TooltipItem, b: TooltipItem) => number; callbacks?: Partial<Record<'beforeTitle' | 'title' | 'afterTitle' | 'beforeBody' | 'afterBody' | 'beforeFooter' | 'footer' | 'afterFooter', (items: TooltipItem[]) => string | string[] | void> & Record<'beforeLabel' | 'label' | 'afterLabel', (item: TooltipItem) => string | string[] | void> & { labelColor: (item: TooltipItem) => { backgroundColor: Color; borderColor: Color } }> } | false;
156
+ decimation?: { enabled?: boolean; algorithm?: 'lttb' | 'min-max'; samples?: number; threshold?: number };
157
+ filler?: { propagate?: boolean };
158
+ colors?: { enabled?: boolean; forceOverride?: boolean; palette?: Color[] };
159
+ annotation?: { annotations: Record<string, Annotation> | Annotation[]; drawTime?: DrawTime };
160
+ datalabels?: DataLabelsOptions;
161
+ zoom?: { zoom?: { wheel?: { enabled?: boolean; speed?: number; modifierKey?: ModifierKey }; drag?: { enabled?: boolean; backgroundColor?: Color; borderColor?: Color; borderWidth?: number; threshold?: number; modifierKey?: ModifierKey }; pinch?: { enabled?: boolean }; mode?: 'x' | 'y' | 'xy'; onZoom?: (ctx: { chart: ChartInstance }) => void; onZoomComplete?: (ctx: { chart: ChartInstance }) => void }; pan?: { enabled?: boolean; mode?: 'x' | 'y' | 'xy'; modifierKey?: ModifierKey; threshold?: number; onPan?: (ctx: { chart: ChartInstance }) => void; onPanComplete?: (ctx: { chart: ChartInstance }) => void }; limits?: Record<string, { min?: number | 'original'; max?: number | 'original'; minRange?: number }>; sync?: boolean };
162
+ measure?: { enabled?: boolean; modifierKey?: ModifierKey; color?: Color };
163
+ crosshair?: { enabled?: boolean; mode?: 'x' | 'y' | 'xy'; snap?: boolean; color?: Color; width?: number; dash?: number[]; labels?: boolean; group?: string };
164
+ navigator?: { enabled?: boolean; height?: number; margin?: number; datasetIndex?: number };
165
+ rangeSelector?: { enabled?: boolean; buttons?: { type: 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'ytd' | 'year' | 'all'; count?: number; text: string }[]; selected?: number; position?: 'top' | 'bottom'; align?: 'left' | 'right' };
166
+ brush?: { enabled?: boolean; target: string | ChartInstance; selection?: { min: number | string; max: number | string } };
167
+ toolbar?: { display?: boolean; buttons?: Array<'zoomIn' | 'zoomOut' | 'pan' | 'reset' | 'download'>; download?: Array<'png' | 'jpeg' | 'svg' | 'csv'>; filename?: string };
168
+ dataGrouping?: { enabled?: boolean; groupPixelWidth?: number; approximation?: 'average' | 'sum' | 'open' | 'high' | 'low' | 'close' | 'ohlc'; forced?: boolean };
169
+ [plugin: string]: unknown;
170
+ };
171
+ [option: string]: unknown;
172
+ }
173
+ export type ModifierKey = 'shift' | 'alt' | 'ctrl' | 'meta' | null;
174
+ export type DrawTime = 'beforeDraw' | 'beforeDatasetsDraw' | 'afterDatasetsDraw' | 'afterDraw';
175
+ export interface AnnotationLabel { display?: boolean; content?: string | string[]; position?: 'start' | 'center' | 'end'; color?: Color; backgroundColor?: Color | null; font?: FontSpec; padding?: number; borderRadius?: number; xAdjust?: number; yAdjust?: number }
176
+ export interface Annotation {
177
+ type: 'line' | 'box' | 'ellipse' | 'point' | 'label' | 'polygon'; drawTime?: DrawTime; display?: boolean | ((ctx: { chart: ChartInstance }) => boolean);
178
+ scaleID?: string; value?: number | string; endValue?: number | string; xScaleID?: string; yScaleID?: string;
179
+ xMin?: number | string; xMax?: number | string; yMin?: number | string; yMax?: number | string; xValue?: number | string; yValue?: number | string;
180
+ borderColor?: Color; borderWidth?: number; borderDash?: number[]; backgroundColor?: Color; borderRadius?: number; radius?: number; sides?: number; rotation?: number;
181
+ content?: string | string[]; color?: Color; font?: FontSpec; label?: AnnotationLabel; click?: (ctx: { chart: ChartInstance; element: Annotation }, event: ChartEvent) => void;
182
+ }
183
+ export interface DataLabelsContext { chart: ChartInstance; dataset: ChartDataset; datasetIndex: number; dataIndex: number; active: boolean; percent?: number; raw: unknown; parsed: unknown }
184
+ export interface DataLabelsOptions {
185
+ display?: boolean | 'auto' | ((ctx: DataLabelsContext) => boolean | 'auto'); formatter?: (value: number, ctx: DataLabelsContext) => string | string[] | null;
186
+ anchor?: 'start' | 'center' | 'end'; align?: 'start' | 'center' | 'end' | 'top' | 'bottom' | 'left' | 'right' | number; offset?: number; clamp?: boolean;
187
+ color?: Color | 'auto'; backgroundColor?: Color | null; font?: FontSpec; padding?: number; borderRadius?: number; opacity?: number; percent?: boolean;
188
+ }
189
+ export interface ThemeSpec { mode?: 'light' | 'dark' | 'auto'; extends?: string; palette?: string | string[]; monochrome?: { enabled: boolean; color?: string }; text?: string; ink?: string; grid?: string; axis?: string; bg?: string; background?: string | null; tooltip?: { backgroundColor?: string; color?: string }; font?: FontSpec }
190
+ export interface TitleOptions { display?: boolean; text?: string | string[]; position?: 'top' | 'bottom' | 'left' | 'right'; align?: 'start' | 'center' | 'end'; color?: Color; font?: FontSpec; padding?: number | { top?: number; bottom?: number } }
191
+ export interface ChartConfiguration { type: ChartType; data: ChartData; options?: ChartOptions; plugins?: Plugin[] }
192
+
193
+ export interface ChartElement { kind: 'point' | 'bar' | 'arc' | 'box' | 'candle' | 'cell' | 'rect' | 'poly' | 'whisker' | 'flow' | 'node' | 'word' | 'item'; bounds?: { l: number; r: number; t: number; b: number }; center?: { x: number; y: number }; tip?: { x: number; y: number }; datasetIndex: number; index: number; x: number; y: number; base?: number; width?: number; horizontal?: boolean; radius?: number; startAngle?: number; endAngle?: number; innerRadius?: number; outerRadius?: number; cx?: number; cy?: number; skip: boolean; raw: unknown; parsed: { index: number; value: number; low?: number; r?: number }; options: Record<string, unknown> }
194
+ export interface DatasetMeta { index: number; type: ChartType; dataset: ChartDataset; label: string; order: number; data: ChartElement[]; elements: ChartElement[]; hidden: boolean | null; iAxisID: string | null; vAxisID: string | null; indexAxis: 'x' | 'y' }
195
+ export interface ChartArea { left: number; top: number; right: number; bottom: number; width: number; height: number }
196
+
197
+ export interface Plugin {
198
+ id: string; defaults?: Record<string, unknown>;
199
+ install?(chart: ChartInstance, args: object, options: any): void; beforeInit?(chart: ChartInstance, args: object, options: any): void; afterInit?(chart: ChartInstance, args: object, options: any): void;
200
+ beforeUpdate?(chart: ChartInstance, args: { mode?: string; cancelable: true }, options: any): boolean | void; afterUpdate?(chart: ChartInstance, args: { mode?: string }, options: any): void;
201
+ beforeLayout?(chart: ChartInstance, args: object, options: any): void; afterLayout?(chart: ChartInstance, args: object, options: any): void;
202
+ beforeDatasetsUpdate?(chart: ChartInstance, args: { mode?: string }, options: any): void; afterDatasetsUpdate?(chart: ChartInstance, args: { mode?: string }, options: any): void;
203
+ beforeDatasetUpdate?(chart: ChartInstance, args: { meta: DatasetMeta; index: number; mode?: string }, options: any): void; afterDatasetUpdate?(chart: ChartInstance, args: { meta: DatasetMeta; index: number; mode?: string }, options: any): void;
204
+ beforeDraw?(chart: ChartInstance, args: { cancelable: true }, options: any): boolean | void; afterDraw?(chart: ChartInstance, args: object, options: any): void;
205
+ beforeDatasetsDraw?(chart: ChartInstance, args: { cancelable: true }, options: any): boolean | void; afterDatasetsDraw?(chart: ChartInstance, args: object, options: any): void;
206
+ beforeDatasetDraw?(chart: ChartInstance, args: { meta: DatasetMeta; index: number; cancelable: true }, options: any): boolean | void; afterDatasetDraw?(chart: ChartInstance, args: { meta: DatasetMeta; index: number }, options: any): void;
207
+ beforeEvent?(chart: ChartInstance, args: { event: ChartEvent; inChartArea: boolean; cancelable: true }, options: any): boolean | void; afterEvent?(chart: ChartInstance, args: { event: ChartEvent; changed?: boolean }, options: any): void;
208
+ resize?(chart: ChartInstance, args: { size: { width: number; height: number } }, options: any): void;
209
+ beforeDestroy?(chart: ChartInstance, args: object, options: any): void; afterDestroy?(chart: ChartInstance, args: object, options: any): void; uninstall?(chart: ChartInstance, args: object, options: any): void;
210
+ [hook: string]: unknown;
211
+ }
212
+
213
+ /** What a drawing surface offers a plugin: the same calls on SVG, canvas and a string. */
214
+ export interface Painter {
215
+ kind: 'svg' | 'canvas' | 'string'; ctx?: CanvasRenderingContext2D;
216
+ layer(name: string): unknown; path(d: string, style?: PaintStyle): unknown; rect(x: number, y: number, w: number, h: number, style?: PaintStyle): unknown; circle(cx: number, cy: number, r: number, style?: PaintStyle): unknown;
217
+ line(x1: number, y1: number, x2: number, y2: number, style?: PaintStyle): unknown; text(text: string, x: number, y: number, style?: PaintStyle & { font?: FontSpec; align?: 'left' | 'center' | 'right'; baseline?: 'top' | 'middle' | 'bottom' | 'alphabetic'; rotate?: number }): unknown;
218
+ clipRect(x: number, y: number, w: number, h: number): string; clipPath(d: string): string; measure(text: string, font?: FontSpec): number;
219
+ }
220
+ export interface PaintStyle { fill?: Color | null; stroke?: Color | null; width?: number; dash?: number[]; opacity?: number; cap?: string; join?: string; radius?: number; clip?: string | null }
221
+
222
+ export declare class Axis {
223
+ id: string; type: string; axis: 'x' | 'y' | 'r'; position: string; min: number; max: number; ticks: { value: number; label: string }[]; options: ScaleOptions;
224
+ left: number; top: number; right: number; bottom: number; width: number; height: number; labels: unknown[];
225
+ isHorizontal(): boolean; getPixelForValue(value: unknown, index?: number): number; getValueForPixel(pixel: number): number; getBasePixel(): number; getBaseValue(): number;
226
+ }
227
+ export declare class RadialAxis extends Axis { cx: number; cy: number; radius: number; getDistanceFromCenterForValue(v: number): number; getPointPosition(index: number, distance: number): { x: number; y: number; angle: number }; getPointPositionForValue(index: number, value: number): { x: number; y: number; angle: number } }
228
+
229
+ export interface ChartInstance {
230
+ id: string; config: ChartConfiguration; data: ChartData; options: ChartOptions; resolved: ChartOptions; type: ChartType;
231
+ canvas?: HTMLCanvasElement; svg?: SVGSVGElement; ctx: CanvasRenderingContext2D | null; container: HTMLElement; painter: Painter;
232
+ width: number; height: number; chartArea: ChartArea; scales: Record<string, Axis>;
233
+ tooltip?: { model?: TooltipModel; getActiveElements(): ActiveElement[]; setActiveElements(list: { datasetIndex: number; index: number }[], at?: { x: number; y: number }): void };
234
+ legend?: { items: LegendItem[]; legendItems: LegendItem[] };
235
+ update(mode?: 'none' | 'active' | 'resize' | 'reset' | 'show' | 'hide'): void; render(): void; draw(): void; stop(): this; reset(): void; resize(width?: number, height?: number): void; clear(): this; destroy(): void;
236
+ toBase64Image(type?: string, quality?: number): string; toImage(type?: string, quality?: number, scale?: number): Promise<string>;
237
+ getElementsAtEventForMode(e: Event | { x: number; y: number }, mode: InteractionMode, options?: { intersect?: boolean; axis?: 'x' | 'y' | 'xy'; includeInvisible?: boolean }, useFinal?: boolean): ActiveElement[];
238
+ getActiveElements(): ActiveElement[]; setActiveElements(list: { datasetIndex: number; index: number }[]): void; isPointInArea(p: { x: number; y: number }): boolean;
239
+ getDatasetMeta(index: number): DatasetMeta; getSortedVisibleDatasetMetas(): DatasetMeta[]; getVisibleDatasetCount(): number; isDatasetVisible(index: number): boolean; setDatasetVisibility(index: number, visible: boolean): void;
240
+ toggleDataVisibility(index: number): void; getDataVisibility(index: number): boolean; hide(datasetIndex: number, dataIndex?: number): void; show(datasetIndex: number, dataIndex?: number): void;
241
+ notify(hook: string, args?: object): boolean;
242
+ // views: zoom, pan, navigator, range selector and brush
243
+ setView(axisId: string, min: number | string | null, max: number | string | null, options?: { mode?: string; silent?: boolean }): this;
244
+ getView(axisId: string): { min: number; max: number; dataMin: number; dataMax: number } | null;
245
+ resetView(mode?: string): this; isZoomedOrPanned(): boolean;
246
+ zoom(amount: number | Record<string, number | [unknown, unknown]>, mode?: 'x' | 'y' | 'xy'): this; pan(delta: number | { x?: number; y?: number }, mode?: 'x' | 'y' | 'xy'): this;
247
+ resetZoom(mode?: string): this; zoomScale(axisId: string, range: { min?: unknown; max?: unknown }, mode?: string): this; getZoomLevel(): number;
248
+ selectRange?(button: number | string): void;
249
+ // data that keeps coming
250
+ addPoint(datasetIndex: number, point: unknown, options?: { label?: unknown; shift?: boolean; maxPoints?: number; mode?: string }): this;
251
+ appendData(list: Array<{ data: unknown[] } | unknown[]>, options?: { labels?: unknown[]; maxPoints?: number; mode?: string }): this;
252
+ // views as tokens, the data as files and as sound
253
+ saveView(): string; restoreView(token: string, mode?: string): this;
254
+ toCSV(options?: { delimiter?: string; lineEnd?: string }): string; toSVG(): string; download(format?: 'png' | 'jpeg' | 'svg' | 'csv', filename?: string): Promise<string>;
255
+ sonify(options?: { duration?: number; low?: number; high?: number; datasetIndex?: number; type?: OscillatorType; volume?: number; gap?: number; highlight?: boolean }): { notes: { time: number; duration: number; frequency: number; pan: number; value: number; datasetIndex: number; index: number }[]; stop(): void; done: Promise<unknown[]>; readonly playing: boolean };
256
+ drillDown(datasetIndex: number, index: number): boolean; drillUp(): boolean;
257
+ fillOf(meta: DatasetMeta, index: number): Color; strokeOf(meta: DatasetMeta, index: number): Color;
258
+ }
259
+
260
+ export interface ChartStatic {
261
+ /** new Chart(el | canvas | id, config): a chart, as in Chart.js. */
262
+ new (item: HTMLElement | HTMLCanvasElement | CanvasRenderingContext2D | string, config: ChartConfiguration): ChartInstance;
263
+ /** <Chart type data options /> in markup. */
264
+ (props: ChartProps): HTMLElement;
265
+ defaults: ChartOptions & Record<string, any>; overrides: Record<string, ChartOptions>; instances: Record<string, ChartInstance>; version: string;
266
+ themes: Record<string, ThemeSpec>; palettes: Record<string, string[]>; registerTheme(name: string, theme: ThemeSpec): ThemeSpec;
267
+ register(...items: Array<Plugin | { id: string; controller: unknown } | { id: string; axis: typeof Axis }>): void; unregister(...items: unknown[]): void; getChart(key: HTMLElement | HTMLCanvasElement | string): ChartInstance | null;
268
+ }
269
+ type State<T> = T | (() => T);
270
+ export interface ChartProps { type?: State<ChartType>; data: State<ChartData>; options?: State<ChartOptions>; plugins?: State<Plugin[]>; height?: State<number | string>; width?: State<number | string>; renderer?: State<'svg' | 'canvas'>; updateMode?: State<'none' | 'active'>; onCreated?: (chart: ChartInstance) => void; ref?: unknown; class?: State<string> }
271
+ export declare const Chart: ChartStatic;
272
+ export declare function ChartView(props: ChartProps): HTMLElement;
273
+
274
+ interface ShortProps<Row = Record<string, unknown>> { data: State<Row[]>; title?: State<string>; height?: State<number | string>; colors?: State<Color[]>; labels?: State<Record<string, string>>; yFormat?: (v: number) => string; xFormat?: (v: unknown, i: number) => string; onSelect?: (row: Row, index: number) => void; options?: State<ChartOptions>; renderer?: State<'svg' | 'canvas'> }
275
+ export declare function LineChart<Row>(props: ShortProps<Row> & { x: string | ((row: Row) => unknown); y: State<string | string[]>; curve?: State<'linear' | 'smooth' | 'monotone' | 'step'>; area?: State<boolean>; stacked?: State<boolean>; dots?: State<boolean>; zero?: State<boolean> }): HTMLElement;
276
+ export declare function AreaChart<Row>(props: Parameters<typeof LineChart<Row>>[0]): HTMLElement;
277
+ export declare function BarChart<Row>(props: ShortProps<Row> & { x: string | ((row: Row) => unknown); y: State<string | string[]>; stacked?: State<boolean>; horizontal?: State<boolean> }): HTMLElement;
278
+ export declare function ScatterChart<Row>(props: ShortProps<Row> & { x: string; y: State<string | string[]>; size?: State<string> }): HTMLElement;
279
+ export declare function PieChart<Row>(props: ShortProps<Row> & { label: string; value: string; donut?: State<number>; half?: State<boolean> }): HTMLElement;
280
+ export declare function Histogram(props: { values: State<number[]>; bins?: State<number>; label?: State<string>; title?: State<string>; height?: State<number | string>; options?: State<ChartOptions> }): HTMLElement;
281
+ export declare function Sparkline(props: { values: State<number[]>; width?: State<number>; height?: State<number>; color?: State<Color>; options?: State<ChartOptions> }): HTMLElement;
282
+
283
+ export declare const defaults: ChartOptions & Record<string, any>;
284
+ export declare const easing: Record<'linear' | 'easeInQuad' | 'easeOutQuad' | 'easeInOutQuad' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic' | 'easeInQuart' | 'easeOutQuart' | 'easeInOutQuart' | 'easeInQuint' | 'easeOutQuint' | 'easeInOutQuint' | 'easeInSine' | 'easeOutSine' | 'easeInOutSine' | 'easeInExpo' | 'easeOutExpo' | 'easeInOutExpo' | 'easeInCirc' | 'easeOutCirc' | 'easeInOutCirc' | 'easeInBack' | 'easeOutBack' | 'easeInOutBack' | 'easeInElastic' | 'easeOutElastic' | 'easeInOutElastic' | 'easeInBounce' | 'easeOutBounce' | 'easeInOutBounce', (t: number) => number>;
285
+ export declare const VERSION: string;
286
+ export declare const registerables: never[];
287
+ export declare function merge<T extends object>(...objects: Partial<T>[]): T;
288
+ /** A chart drawn as an SVG string with no page (a server, an e-mail, a file). */
289
+ export declare function renderToSVG(config: ChartConfiguration, size?: { width?: number; height?: number }): string;
290
+ /** The sentence a screen reader is given for a chart. */
291
+ export declare function describe(chart: ChartInstance, title?: string): string;
292
+ export declare const BUILT_IN_PLUGINS: Plugin[];
293
+ export declare const Title: Plugin, SubTitle: Plugin, Legend: Plugin, Tooltip: Plugin, Filler: Plugin, Decimation: Plugin, Colors: Plugin;
294
+ export declare const PALETTE: Color[];
295
+ export declare function generateLabels(chart: ChartInstance): LegendItem[];
296
+ export declare function lttb<P extends { index: number; value: number }>(points: P[], samples: number): P[];
297
+ export declare function minMax<P extends { index: number; value: number }>(points: P[], width: number, x0: number, x1: number): P[];
298
+ export declare function svgPainter(svg: SVGSVGElement): Painter;
299
+ export declare function canvasPainter(canvas: HTMLCanvasElement, options?: { pixelRatio?: number }): Painter;
300
+ export declare function stringPainter(): Painter & { toString(label?: string): string };
301
+ export declare function measureText(text: string, font?: FontSpec): number;
302
+ export declare function formatTime(ms: number, pattern?: string): string;
303
+ export declare function formatNumber(v: number, options?: { compact?: boolean; decimals?: number; step?: number; locale?: string; prefix?: string; suffix?: string }): string;
304
+ export declare function formatDate(ms: number, unit?: string): string;
305
+ export declare function formatFull(ms: number): string;
306
+ export declare const CONTROLLERS: Record<string, unknown>;
307
+ export declare function pathThrough(points: { x: number; y: number }[], options?: { tension?: number; stepped?: boolean | string; cubicInterpolationMode?: string; closed?: boolean }): string;
308
+ export declare function pointShape(style: PointStyle | string, x: number, y: number, r: number, rotation?: number): string;
309
+ export declare function barPath(x: number, y: number, w: number, h: number, radius?: number | Record<string, number>): string;
310
+ export declare function linear(domain?: [number, number], range?: [number, number]): ((v: number) => number) & { ticks(count?: number): number[]; nice(count?: number): any; invert(p: number): number };
311
+ export declare function log(domain?: [number, number], range?: [number, number]): ((v: number) => number) & { ticks(): number[]; invert(p: number): number };
312
+ export declare function band(domain?: unknown[], range?: [number, number], options?: { padding?: number; outer?: number }): ((v: unknown) => number) & { bandwidth: number; step: number; center(v: unknown): number };
313
+ export declare function time(domain?: [unknown, unknown], range?: [number, number]): ((v: unknown) => number) & { ticks(count?: number): number[]; unit?: string };
314
+ export declare function niceStep(span: number, count?: number): number;
315
+ export declare function linePath(points: [number, number][], curve?: 'linear' | 'monotone' | 'step'): string;
316
+ export declare function areaPath(points: [number, number][], base: number | number[], curve?: 'linear' | 'monotone' | 'step'): string;
317
+ export declare function arcPath(cx: number, cy: number, r0: number, r1: number, a0: number, a1: number): string;
318
+ export declare function stack(rows: Record<string, unknown>[], keys: string[], value?: (row: any, key: string) => number): [number, number][][];
319
+ export declare function extent(values: number[]): [number, number];
320
+ export declare function bins(values: number[], count?: number): { x0: number; x1: number; count: number }[];
321
+ export declare function decimate(points: [number, number][], width: number, x0?: number, x1?: number): [number, number][];
322
+
323
+ // ── beyond Chart.js ───────────────────────────────────────────────────────────────────────
324
+ export declare const MORE_TYPES: Record<MoreType, unknown>;
325
+ export declare const MORE_PLUGINS: Plugin[];
326
+ export declare const MAP_TYPES: Record<'map' | 'choropleth' | 'mapbubble' | 'mappoint', unknown>;
327
+ export declare const DEPTH_TYPES: Record<'column3d' | 'bar3d' | 'pie3d' | 'doughnut3d' | 'scatter3d' | 'surface', unknown>;
328
+ export declare const GRAPH_TYPES: Record<'network' | 'networkgraph' | 'organization' | 'treegraph' | 'venn' | 'parallel' | 'parallelCoordinates', unknown>;
329
+ /** Projections: [longitude, latitude] in degrees → [x, y], y up. */
330
+ export declare const PROJECTIONS: Record<'equalEarth' | 'naturalEarth' | 'mercator' | 'equirectangular', (lon: number, lat: number) => [number, number]>;
331
+ /** A globe facing [longitude, latitude]: [x, y, onTheFarSide]. */
332
+ export declare function orthographic(rotate?: [number, number]): (lon: number, lat: number) => [number, number, boolean];
333
+ /** A map's features with their rings as [lon, lat] points (these modules' maps, or GeoJSON). */
334
+ export declare function featuresOf(map: unknown): { id: string; name: string; rings: [number, number][][]; label: [number, number]; [key: string]: unknown }[];
335
+ /** Places for a network's nodes, laid out by forces: the same each time for the same graph. */
336
+ export declare function forceLayout(count: number, links: { s: number; t: number; weight?: number }[], options?: { w?: number; h?: number; iterations?: number; fixed?: Map<number, { x: number; y: number }> }): { x: number; y: number }[];
337
+ /** Places a tree's leaves one after another (each node gets u), a parent over the middle of its children. */
338
+ export declare function treeLayout(roots: object[]): { span: number };
339
+ /** Circles for sets ([{ sets: ['A'], value }, { sets: ['A', 'B'], value }…]): exact for two, close for more. */
340
+ export declare function vennLayout(rows: { sets: string[]; value: number }[]): Record<string, { x: number; y: number; r: number }>;
341
+ /** The area two circles share at a distance. */
342
+ export declare function circleOverlap(r1: number, r2: number, distance: number): number;
343
+ export declare const Annotation: Plugin, DataLabels: Plugin, Zoom: Plugin, Measure: Plugin, Crosshair: Plugin, Navigator: Plugin, RangeSelector: Plugin, Brush: Plugin, Toolbar: Plugin, Drilldown: Plugin, DataGrouping: Plugin, ColorAxisLegend: Plugin;
344
+ export declare function colorScaleOf(chart: ChartInstance, meta?: DatasetMeta): { min: number; max: number; colorOf(value: number): string; stops?: [number, string][]; classes?: { from?: number; to?: number; color: string; name?: string }[] };
345
+ export declare function measureBetween(chart: ChartInstance, x0: number, y0: number, x1: number, y1: number): { dx: number; dy: number; percent: number; text: string[] };
346
+ export declare function rangeOf(chart: ChartInstance, button: { type: string; count?: number }): [number, number] | null;
347
+ export declare const THEMES: Record<string, ThemeSpec>;
348
+ export declare const PALETTES: Record<'default' | 'vivid' | 'pastel' | 'colorblind' | 'mono' | 'warm' | 'cool' | 'night' | string, string[]>;
349
+ export declare function registerTheme(name: string, theme: ThemeSpec): ThemeSpec;
350
+ export declare function resolveTheme(spec?: string | ThemeSpec): ThemeSpec;
351
+ export declare function monochrome(color: string): string[];
352
+ export declare function isPaint(v: unknown): v is Paint;
353
+ export declare function normalizePaint(v: Paint): object;
354
+ export declare function cssPaint(v: Color): string;
355
+ export declare function mix(a: string, b: string, t: number): string;
356
+ export declare function shade(color: string, k: number): string;
357
+ export declare function withAlpha(color: string, alpha: number): string;
358
+ export declare function luminance(color: Color): number;
359
+ export declare function contrastOn(fill: Color): string;
360
+ export declare function parseColor(color: string): [number, number, number, number] | null;
361
+ // the arithmetic behind the types
362
+ export declare function quantile(sorted: number[], p: number): number;
363
+ export declare function boxStats(values: number[], options?: { coef?: number }): { min: number; q1: number; median: number; q3: number; max: number; mean: number; outliers: number[]; n: number; sorted: number[] } | null;
364
+ export declare function density(values: number[], options?: { points?: number; bandwidth?: number }): { coords: { v: number; d: number }[]; max: number; min: number; maxV: number };
365
+ export declare function heikinAshi<C extends { open: number; high: number; low: number; close: number }>(candles: C[]): C[];
366
+ export declare function sma(values: number[], period?: number): number[];
367
+ export declare function ema(values: number[], period?: number): number[];
368
+ export declare function wma(values: number[], period?: number): number[];
369
+ export declare function bollinger(values: number[], period?: number, k?: number): { mid: number; low: number; high: number }[];
370
+ export declare function macd(values: number[], short?: number, long?: number, signal?: number): { macd: number; signal: number; histogram: number }[];
371
+ export declare function rsi(values: number[], period?: number): number[];
372
+ export declare function momentum(values: number[], period?: number): number[];
373
+ export declare function squarify(values: number[], box?: { x?: number; y?: number; w?: number; h?: number }): { x: number; y: number; w: number; h: number; i: number }[];
374
+ export declare function treeOf(rows: object[], keys?: { id?: string; parent?: string; value?: string; name?: string }): { roots: any[]; nodes: any[] };
375
+ export declare function sankeyLayout(flows: { from: string; to: string; flow?: number; weight?: number }[], box?: { x?: number; y?: number; w?: number; h?: number; nodeWidth?: number; nodePadding?: number; order?: string[] }): { nodes: any[]; links: any[]; ky: number };
376
+ export declare function cloudLayout(words: { w: number; h: number }[], options?: { w?: number; h?: number; padding?: number; spiral?: 'archimedean' | 'rectangular' }): { x: number; y: number; w: number; h: number; placed: boolean }[];
377
+ export declare function parliamentSeats(n: number, options?: { rows?: number; startAngle?: number; endAngle?: number; inner?: number }): { seats: { x: number; y: number }[]; r: number };
378
+ export declare function groupPoints<P extends { index: number; value: number }>(points: P[], size: number, approximation?: 'average' | 'sum' | 'open' | 'high' | 'low' | 'close' | 'ohlc'): P[];
379
+ // their configuration, as they write it
380
+ /** Highcharts options → this package's configuration. */
381
+ export declare function fromHighcharts(options: Record<string, any>): ChartConfiguration;
382
+ /** ApexCharts options → this package's configuration. */
383
+ export declare function fromApex(options: Record<string, any>): ChartConfiguration;
384
+ export interface HighchartsSeriesHandle { name: string; index: number; readonly visible: boolean; readonly data: unknown[]; setData(data: unknown[], redraw?: boolean): void; addPoint(point: unknown, redraw?: boolean, shift?: boolean): void; setVisible(visible?: boolean): void; hide(): void; show(): void; update(options: object): void; remove(): void }
385
+ export interface HighchartsAxisHandle { setExtremes(min?: number | null, max?: number | null): void; getExtremes(): { min: number; max: number; dataMin: number; dataMax: number } | null }
386
+ export interface HighchartsChart {
387
+ chart: ChartInstance; container: HTMLElement; options: Record<string, any>; readonly series: HighchartsSeriesHandle[]; readonly xAxis: HighchartsAxisHandle[]; readonly yAxis: HighchartsAxisHandle[];
388
+ addSeries(series: object, redraw?: boolean): void; update(options: object, redraw?: boolean): void; setTitle(title?: object, subtitle?: object): void; redraw(): void; reflow(): void; setSize(width?: number, height?: number): void;
389
+ getCSV(): string; getSVG(): string; exportChart(options?: { type?: string; filename?: string }): Promise<string>; sonify(options?: object): unknown; destroy(): void;
390
+ }
391
+ export declare const Highcharts: {
392
+ chart(el: string | HTMLElement, options: Record<string, any>, callback?: (chart: HighchartsChart) => void): HighchartsChart;
393
+ stockChart(el: string | HTMLElement, options: Record<string, any>, callback?: (chart: HighchartsChart) => void): HighchartsChart;
394
+ mapChart(el: string | HTMLElement, options: Record<string, any>, callback?: (chart: HighchartsChart) => void): HighchartsChart;
395
+ ganttChart(el: string | HTMLElement, options: Record<string, any>, callback?: (chart: HighchartsChart) => void): HighchartsChart;
396
+ setOptions(options: Record<string, any>): Record<string, any>; getOptions(): Record<string, any>;
397
+ };
398
+ export declare class ApexCharts {
399
+ static getChartByID(id: string): ApexCharts | null;
400
+ static exec(id: string, method: string, ...args: unknown[]): unknown;
401
+ constructor(el: string | HTMLElement, options: Record<string, any>);
402
+ chart: ChartInstance | null;
403
+ render(): Promise<this>; updateOptions(options: object, redraw?: boolean): Promise<this>; updateSeries(series: unknown[]): Promise<this>; appendSeries(series: object): Promise<this>; appendData(data: { data: unknown[] }[]): Promise<this>;
404
+ toggleSeries(name: string): boolean | undefined; showSeries(name: string): void; hideSeries(name: string): void; resetSeries(): void; zoomX(min: number, max: number): void;
405
+ addXaxisAnnotation(a: object): void; addYaxisAnnotation(a: object): void; addPointAnnotation(a: object): void; clearAnnotations(): void;
406
+ dataURI(options?: { scale?: number }): Promise<{ imgURI: string }>; exportToCSV(options?: { filename?: string }): Promise<string>; destroy(): void;
407
+ }
@@ -0,0 +1,5 @@
1
+ // A map of @clarity-js/charts: Natural Earth (public domain), simplified.
2
+ export interface MapFeature { id: string; name: string; nameTr?: string; nameEn?: string; iso3?: string; plate?: number; continent?: string; region?: string; label: [number, number]; rings: number[][] }
3
+ export interface MapData { name: string; source: string; scale: number; projection: 'equalEarth' | 'naturalEarth' | 'mercator' | 'equirectangular' | 'orthographic'; features: MapFeature[] }
4
+ declare const map: MapData;
5
+ export default map;