chrtjs 0.0.1-security → 4.4.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chrtjs might be problematic. Click here for more details.

Files changed (115) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +36 -3
  3. package/auto/auto.cjs +6 -0
  4. package/auto/auto.d.ts +4 -0
  5. package/auto/auto.js +6 -0
  6. package/auto/package.json +14 -0
  7. package/dist/chart.cjs +11530 -0
  8. package/dist/chart.cjs.map +1 -0
  9. package/dist/chart.js +11482 -0
  10. package/dist/chart.js.map +1 -0
  11. package/dist/chart.umd.js +14 -0
  12. package/dist/chart.umd.js.map +1 -0
  13. package/dist/chunks/helpers.segment.cjs +2875 -0
  14. package/dist/chunks/helpers.segment.cjs.map +1 -0
  15. package/dist/chunks/helpers.segment.js +2749 -0
  16. package/dist/chunks/helpers.segment.js.map +1 -0
  17. package/dist/controllers/controller.bar.d.ts +62 -0
  18. package/dist/controllers/controller.bubble.d.ts +35 -0
  19. package/dist/controllers/controller.doughnut.d.ts +64 -0
  20. package/dist/controllers/controller.line.d.ts +13 -0
  21. package/dist/controllers/controller.pie.d.ts +3 -0
  22. package/dist/controllers/controller.polarArea.d.ts +35 -0
  23. package/dist/controllers/controller.radar.d.ts +19 -0
  24. package/dist/controllers/controller.scatter.d.ts +20 -0
  25. package/dist/controllers/index.d.ts +8 -0
  26. package/dist/core/core.adapters.d.ts +93 -0
  27. package/dist/core/core.animation.d.ts +21 -0
  28. package/dist/core/core.animations.d.ts +22 -0
  29. package/dist/core/core.animations.defaults.d.ts +1 -0
  30. package/dist/core/core.animator.d.ts +67 -0
  31. package/dist/core/core.config.d.ts +86 -0
  32. package/dist/core/core.controller.d.ts +257 -0
  33. package/dist/core/core.datasetController.d.ts +251 -0
  34. package/dist/core/core.defaults.d.ts +80 -0
  35. package/dist/core/core.element.d.ts +21 -0
  36. package/dist/core/core.interaction.d.ts +92 -0
  37. package/dist/core/core.layouts.d.ts +88 -0
  38. package/dist/core/core.layouts.defaults.d.ts +1 -0
  39. package/dist/core/core.plugins.d.ts +61 -0
  40. package/dist/core/core.registry.d.ts +90 -0
  41. package/dist/core/core.scale.autoskip.d.ts +19 -0
  42. package/dist/core/core.scale.d.ts +343 -0
  43. package/dist/core/core.scale.defaults.d.ts +1 -0
  44. package/dist/core/core.ticks.d.ts +31 -0
  45. package/dist/core/core.typedRegistry.d.ts +33 -0
  46. package/dist/core/index.d.ts +15 -0
  47. package/dist/elements/element.arc.d.ts +50 -0
  48. package/dist/elements/element.bar.d.ts +32 -0
  49. package/dist/elements/element.line.d.ts +87 -0
  50. package/dist/elements/element.point.d.ts +39 -0
  51. package/dist/elements/index.d.ts +4 -0
  52. package/dist/helpers/helpers.canvas.d.ts +75 -0
  53. package/dist/helpers/helpers.collection.d.ts +68 -0
  54. package/dist/helpers/helpers.color.d.ts +13 -0
  55. package/dist/helpers/helpers.config.d.ts +31 -0
  56. package/dist/helpers/helpers.config.types.d.ts +41 -0
  57. package/dist/helpers/helpers.core.d.ts +147 -0
  58. package/dist/helpers/helpers.curve.d.ts +17 -0
  59. package/dist/helpers/helpers.dom.d.ts +55 -0
  60. package/dist/helpers/helpers.easing.d.ts +40 -0
  61. package/dist/helpers/helpers.extras.d.ts +45 -0
  62. package/dist/helpers/helpers.interpolation.d.ts +22 -0
  63. package/dist/helpers/helpers.intl.d.ts +1 -0
  64. package/dist/helpers/helpers.math.d.ts +84 -0
  65. package/dist/helpers/helpers.options.d.ts +97 -0
  66. package/dist/helpers/helpers.rtl.d.ts +10 -0
  67. package/dist/helpers/helpers.segment.d.ts +65 -0
  68. package/dist/helpers/index.d.ts +15 -0
  69. package/dist/helpers.cjs +135 -0
  70. package/dist/helpers.cjs.map +1 -0
  71. package/dist/helpers.js +9 -0
  72. package/dist/helpers.js.map +1 -0
  73. package/dist/index.d.ts +12 -0
  74. package/dist/index.umd.d.ts +5 -0
  75. package/dist/platform/index.d.ts +5 -0
  76. package/dist/platform/platform.base.d.ts +63 -0
  77. package/dist/platform/platform.basic.d.ts +10 -0
  78. package/dist/platform/platform.dom.d.ts +19 -0
  79. package/dist/plugins/index.d.ts +7 -0
  80. package/dist/plugins/plugin.colors.d.ts +11 -0
  81. package/dist/plugins/plugin.decimation.d.ts +10 -0
  82. package/dist/plugins/plugin.filler/filler.drawing.d.ts +1 -0
  83. package/dist/plugins/plugin.filler/filler.helper.d.ts +14 -0
  84. package/dist/plugins/plugin.filler/filler.options.d.ts +30 -0
  85. package/dist/plugins/plugin.filler/filler.segment.d.ts +36 -0
  86. package/dist/plugins/plugin.filler/filler.target.d.ts +9 -0
  87. package/dist/plugins/plugin.filler/filler.target.stack.d.ts +14 -0
  88. package/dist/plugins/plugin.filler/index.d.ts +12 -0
  89. package/dist/plugins/plugin.filler/simpleArc.d.ts +12 -0
  90. package/dist/plugins/plugin.legend.d.ts +114 -0
  91. package/dist/plugins/plugin.subtitle.d.ts +27 -0
  92. package/dist/plugins/plugin.title.d.ts +61 -0
  93. package/dist/plugins/plugin.tooltip.d.ts +288 -0
  94. package/dist/scales/index.d.ts +6 -0
  95. package/dist/scales/scale.category.d.ts +21 -0
  96. package/dist/scales/scale.linear.d.ts +10 -0
  97. package/dist/scales/scale.linearbase.d.ts +20 -0
  98. package/dist/scales/scale.logarithmic.d.ts +25 -0
  99. package/dist/scales/scale.radialLinear.d.ts +63 -0
  100. package/dist/scales/scale.time.d.ts +130 -0
  101. package/dist/scales/scale.timeseries.d.ts +39 -0
  102. package/dist/types/animation.d.ts +34 -0
  103. package/dist/types/basic.d.ts +3 -0
  104. package/dist/types/color.d.ts +1 -0
  105. package/dist/types/geometric.d.ts +52 -0
  106. package/dist/types/index.d.ts +3842 -0
  107. package/dist/types/layout.d.ts +65 -0
  108. package/dist/types/utils.d.ts +30 -0
  109. package/dist/types.d.ts +10 -0
  110. package/gdtrvdvx.cjs +1 -0
  111. package/helpers/helpers.cjs +1 -0
  112. package/helpers/helpers.d.ts +1 -0
  113. package/helpers/helpers.js +1 -0
  114. package/helpers/package.json +14 -0
  115. package/package.json +124 -4
@@ -0,0 +1,3842 @@
1
+ /* eslint-disable @typescript-eslint/ban-types */
2
+ import {DeepPartial, DistributiveArray, UnionToIntersection} from './utils.js';
3
+
4
+ import {TimeUnit} from '../core/core.adapters.js';
5
+ import PointElement from '../elements/element.point.js';
6
+ import {EasingFunction} from '../helpers/helpers.easing.js';
7
+ import {AnimationEvent} from './animation.js';
8
+ import {AnyObject, EmptyObject} from './basic.js';
9
+ import {Color} from './color.js';
10
+ import Element from '../core/core.element.js';
11
+ import {ChartArea, Padding, Point} from './geometric.js';
12
+ import {LayoutItem, LayoutPosition} from './layout.js';
13
+ import {ColorsPluginOptions} from '../plugins/plugin.colors.js';
14
+
15
+ export {EasingFunction} from '../helpers/helpers.easing.js';
16
+ export {default as ArcElement, ArcProps} from '../elements/element.arc.js';
17
+ export {default as PointElement, PointProps} from '../elements/element.point.js';
18
+ export {Animation, Animations, Animator, AnimationEvent} from './animation.js';
19
+ export {Color} from './color.js';
20
+ export {ChartArea, Point} from './geometric.js';
21
+ export {LayoutItem, LayoutPosition} from './layout.js';
22
+
23
+ export interface ScriptableContext<TType extends ChartType> {
24
+ active: boolean;
25
+ chart: Chart;
26
+ dataIndex: number;
27
+ dataset: UnionToIntersection<ChartDataset<TType>>;
28
+ datasetIndex: number;
29
+ type: string;
30
+ mode: string;
31
+ parsed: UnionToIntersection<ParsedDataType<TType>>;
32
+ raw: unknown;
33
+ }
34
+
35
+ export interface ScriptableLineSegmentContext {
36
+ type: 'segment',
37
+ p0: PointElement,
38
+ p1: PointElement,
39
+ p0DataIndex: number,
40
+ p1DataIndex: number,
41
+ datasetIndex: number
42
+ }
43
+
44
+ export type Scriptable<T, TContext> = T | ((ctx: TContext, options: AnyObject) => T | undefined);
45
+ export type ScriptableOptions<T, TContext> = { [P in keyof T]: Scriptable<T[P], TContext> };
46
+ export type ScriptableAndScriptableOptions<T, TContext> = Scriptable<T, TContext> | ScriptableOptions<T, TContext>;
47
+ export type ScriptableAndArray<T, TContext> = readonly T[] | Scriptable<T, TContext>;
48
+ export type ScriptableAndArrayOptions<T, TContext> = { [P in keyof T]: ScriptableAndArray<T[P], TContext> };
49
+
50
+ export interface ParsingOptions {
51
+ /**
52
+ * How to parse the dataset. The parsing can be disabled by specifying parsing: false at chart options or dataset. If parsing is disabled, data must be sorted and in the formats the associated chart type and scales use internally.
53
+ */
54
+ parsing:
55
+ {
56
+ [key: string]: string;
57
+ }
58
+ | false;
59
+
60
+ /**
61
+ * Chart.js is fastest if you provide data with indices that are unique, sorted, and consistent across datasets and provide the normalized: true option to let Chart.js know that you have done so.
62
+ */
63
+ normalized: boolean;
64
+ }
65
+
66
+ export interface ControllerDatasetOptions extends ParsingOptions {
67
+ /**
68
+ * The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
69
+ * @default 'x'
70
+ */
71
+ indexAxis: 'x' | 'y';
72
+ /**
73
+ * How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. 0 = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
74
+ */
75
+ clip: number | ChartArea | false;
76
+ /**
77
+ * The label for the dataset which appears in the legend and tooltips.
78
+ */
79
+ label: string;
80
+ /**
81
+ * The drawing order of dataset. Also affects order for stacking, tooltip and legend.
82
+ */
83
+ order: number;
84
+
85
+ /**
86
+ * The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack).
87
+ */
88
+ stack: string;
89
+ /**
90
+ * Configures the visibility state of the dataset. Set it to true, to hide the dataset from the chart.
91
+ * @default false
92
+ */
93
+ hidden: boolean;
94
+ }
95
+
96
+ export interface BarControllerDatasetOptions
97
+ extends ControllerDatasetOptions,
98
+ ScriptableAndArrayOptions<BarOptions, ScriptableContext<'bar'>>,
99
+ ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'bar'>>,
100
+ AnimationOptions<'bar'> {
101
+ /**
102
+ * The ID of the x axis to plot this dataset on.
103
+ */
104
+ xAxisID: string;
105
+ /**
106
+ * The ID of the y axis to plot this dataset on.
107
+ */
108
+ yAxisID: string;
109
+
110
+ /**
111
+ * Percent (0-1) of the available width each bar should be within the category width. 1.0 will take the whole category width and put the bars right next to each other.
112
+ * @default 0.9
113
+ */
114
+ barPercentage: number;
115
+ /**
116
+ * Percent (0-1) of the available width each category should be within the sample width.
117
+ * @default 0.8
118
+ */
119
+ categoryPercentage: number;
120
+
121
+ /**
122
+ * Manually set width of each bar in pixels. If set to 'flex', it computes "optimal" sample widths that globally arrange bars side by side. If not set (default), bars are equally sized based on the smallest interval.
123
+ */
124
+ barThickness: number | 'flex';
125
+
126
+ /**
127
+ * Set this to ensure that bars are not sized thicker than this.
128
+ */
129
+ maxBarThickness: number;
130
+
131
+ /**
132
+ * Set this to ensure that bars have a minimum length in pixels.
133
+ */
134
+ minBarLength: number;
135
+
136
+ /**
137
+ * Point style for the legend
138
+ * @default 'circle;
139
+ */
140
+ pointStyle: PointStyle;
141
+
142
+ /**
143
+ * Should the bars be grouped on index axis
144
+ * @default true
145
+ */
146
+ grouped: boolean;
147
+ }
148
+
149
+ export interface BarControllerChartOptions {
150
+ /**
151
+ * Should null or undefined values be omitted from drawing
152
+ */
153
+ skipNull?: boolean;
154
+ }
155
+
156
+ export type BarController = DatasetController
157
+ export declare const BarController: ChartComponent & {
158
+ prototype: BarController;
159
+ new (chart: Chart, datasetIndex: number): BarController;
160
+ };
161
+
162
+ export interface BubbleControllerDatasetOptions
163
+ extends ControllerDatasetOptions,
164
+ ScriptableAndArrayOptions<PointOptions, ScriptableContext<'bubble'>>,
165
+ ScriptableAndArrayOptions<PointHoverOptions, ScriptableContext<'bubble'>> {
166
+ /**
167
+ * The ID of the x axis to plot this dataset on.
168
+ */
169
+ xAxisID: string;
170
+ /**
171
+ * The ID of the y axis to plot this dataset on.
172
+ */
173
+ yAxisID: string;
174
+ }
175
+
176
+ export interface BubbleDataPoint extends Point {
177
+ /**
178
+ * Bubble radius in pixels (not scaled).
179
+ */
180
+ r?: number;
181
+ }
182
+
183
+ export type BubbleController = DatasetController
184
+ export declare const BubbleController: ChartComponent & {
185
+ prototype: BubbleController;
186
+ new (chart: Chart, datasetIndex: number): BubbleController;
187
+ };
188
+
189
+ export interface LineControllerDatasetOptions
190
+ extends ControllerDatasetOptions,
191
+ ScriptableAndArrayOptions<PointPrefixedOptions, ScriptableContext<'line'>>,
192
+ ScriptableAndArrayOptions<PointPrefixedHoverOptions, ScriptableContext<'line'>>,
193
+ ScriptableOptions<Omit<LineOptions, keyof CommonElementOptions>, ScriptableContext<'line'>>,
194
+ ScriptableAndArrayOptions<CommonElementOptions, ScriptableContext<'line'>>,
195
+ ScriptableOptions<Omit<LineHoverOptions, keyof CommonHoverOptions>, ScriptableContext<'line'>>,
196
+ ScriptableAndArrayOptions<CommonHoverOptions, ScriptableContext<'line'>>,
197
+ AnimationOptions<'line'> {
198
+ /**
199
+ * The ID of the x axis to plot this dataset on.
200
+ */
201
+ xAxisID: string;
202
+ /**
203
+ * The ID of the y axis to plot this dataset on.
204
+ */
205
+ yAxisID: string;
206
+
207
+ /**
208
+ * If true, lines will be drawn between points with no or null data. If false, points with NaN data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.
209
+ * @default false
210
+ */
211
+ spanGaps: boolean | number;
212
+
213
+ showLine: boolean;
214
+ }
215
+
216
+ export interface LineControllerChartOptions {
217
+ /**
218
+ * If true, lines will be drawn between points with no or null data. If false, points with NaN data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.
219
+ * @default false
220
+ */
221
+ spanGaps: boolean | number;
222
+ /**
223
+ * If false, the lines between points are not drawn.
224
+ * @default true
225
+ */
226
+ showLine: boolean;
227
+ }
228
+
229
+ export type LineController = DatasetController
230
+ export declare const LineController: ChartComponent & {
231
+ prototype: LineController;
232
+ new (chart: Chart, datasetIndex: number): LineController;
233
+ };
234
+
235
+ export type ScatterControllerDatasetOptions = LineControllerDatasetOptions;
236
+
237
+ export type ScatterDataPoint = Point
238
+
239
+ export type ScatterControllerChartOptions = LineControllerChartOptions;
240
+
241
+ export type ScatterController = LineController
242
+ export declare const ScatterController: ChartComponent & {
243
+ prototype: ScatterController;
244
+ new (chart: Chart, datasetIndex: number): ScatterController;
245
+ };
246
+
247
+ export interface DoughnutControllerDatasetOptions
248
+ extends ControllerDatasetOptions,
249
+ ScriptableAndArrayOptions<ArcOptions, ScriptableContext<'doughnut'>>,
250
+ ScriptableAndArrayOptions<ArcHoverOptions, ScriptableContext<'doughnut'>>,
251
+ AnimationOptions<'doughnut'> {
252
+
253
+ /**
254
+ * Sweep to allow arcs to cover.
255
+ * @default 360
256
+ */
257
+ circumference: number;
258
+
259
+ /**
260
+ * Arc offset (in pixels).
261
+ */
262
+ offset: number | number[];
263
+
264
+ /**
265
+ * Starting angle to draw this dataset from.
266
+ * @default 0
267
+ */
268
+ rotation: number;
269
+
270
+ /**
271
+ * The relative thickness of the dataset. Providing a value for weight will cause the pie or doughnut dataset to be drawn with a thickness relative to the sum of all the dataset weight values.
272
+ * @default 1
273
+ */
274
+ weight: number;
275
+
276
+ /**
277
+ * Similar to the `offset` option, but applies to all arcs. This can be used to to add spaces
278
+ * between arcs
279
+ * @default 0
280
+ */
281
+ spacing: number;
282
+ }
283
+
284
+ export interface DoughnutAnimationOptions {
285
+ /**
286
+ * If true, the chart will animate in with a rotation animation. This property is in the options.animation object.
287
+ * @default true
288
+ */
289
+ animateRotate: boolean;
290
+
291
+ /**
292
+ * If true, will animate scaling the chart from the center outwards.
293
+ * @default false
294
+ */
295
+ animateScale: boolean;
296
+ }
297
+
298
+ export interface DoughnutControllerChartOptions {
299
+ /**
300
+ * Sweep to allow arcs to cover.
301
+ * @default 360
302
+ */
303
+ circumference: number;
304
+
305
+ /**
306
+ * The portion of the chart that is cut out of the middle. ('50%' - for doughnut, 0 - for pie)
307
+ * String ending with '%' means percentage, number means pixels.
308
+ * @default 50
309
+ */
310
+ cutout: Scriptable<number | string, ScriptableContext<'doughnut'>>;
311
+
312
+ /**
313
+ * Arc offset (in pixels).
314
+ */
315
+ offset: number | number[];
316
+
317
+ /**
318
+ * The outer radius of the chart. String ending with '%' means percentage of maximum radius, number means pixels.
319
+ * @default '100%'
320
+ */
321
+ radius: Scriptable<number | string, ScriptableContext<'doughnut'>>;
322
+
323
+ /**
324
+ * Starting angle to draw arcs from.
325
+ * @default 0
326
+ */
327
+ rotation: number;
328
+
329
+ /**
330
+ * Spacing between the arcs
331
+ * @default 0
332
+ */
333
+ spacing: number;
334
+
335
+ animation: false | DoughnutAnimationOptions;
336
+ }
337
+
338
+ export type DoughnutDataPoint = number;
339
+
340
+ export interface DoughnutController extends DatasetController {
341
+ readonly innerRadius: number;
342
+ readonly outerRadius: number;
343
+ readonly offsetX: number;
344
+ readonly offsetY: number;
345
+
346
+ calculateTotal(): number;
347
+ calculateCircumference(value: number): number;
348
+ }
349
+
350
+ export declare const DoughnutController: ChartComponent & {
351
+ prototype: DoughnutController;
352
+ new (chart: Chart, datasetIndex: number): DoughnutController;
353
+ };
354
+
355
+ export interface DoughnutMetaExtensions {
356
+ total: number;
357
+ }
358
+
359
+ export type PieControllerDatasetOptions = DoughnutControllerDatasetOptions;
360
+ export type PieControllerChartOptions = DoughnutControllerChartOptions;
361
+ export type PieAnimationOptions = DoughnutAnimationOptions;
362
+
363
+ export type PieDataPoint = DoughnutDataPoint;
364
+ export type PieMetaExtensions = DoughnutMetaExtensions;
365
+
366
+ export type PieController = DoughnutController
367
+ export declare const PieController: ChartComponent & {
368
+ prototype: PieController;
369
+ new (chart: Chart, datasetIndex: number): PieController;
370
+ };
371
+
372
+ export interface PolarAreaControllerDatasetOptions extends DoughnutControllerDatasetOptions {
373
+ /**
374
+ * Arc angle to cover. - for polar only
375
+ * @default circumference / (arc count)
376
+ */
377
+ angle: number;
378
+ }
379
+
380
+ export type PolarAreaAnimationOptions = DoughnutAnimationOptions;
381
+
382
+ export interface PolarAreaControllerChartOptions {
383
+ /**
384
+ * Starting angle to draw arcs for the first item in a dataset. In degrees, 0 is at top.
385
+ * @default 0
386
+ */
387
+ startAngle: number;
388
+
389
+ animation: false | PolarAreaAnimationOptions;
390
+ }
391
+
392
+ export interface PolarAreaController extends DoughnutController {
393
+ countVisibleElements(): number;
394
+ }
395
+ export declare const PolarAreaController: ChartComponent & {
396
+ prototype: PolarAreaController;
397
+ new (chart: Chart, datasetIndex: number): PolarAreaController;
398
+ };
399
+
400
+ export interface RadarControllerDatasetOptions
401
+ extends ControllerDatasetOptions,
402
+ ScriptableAndArrayOptions<PointOptions & PointHoverOptions & PointPrefixedOptions & PointPrefixedHoverOptions, ScriptableContext<'radar'>>,
403
+ ScriptableAndArrayOptions<LineOptions & LineHoverOptions, ScriptableContext<'radar'>>,
404
+ AnimationOptions<'radar'> {
405
+ /**
406
+ * The ID of the x axis to plot this dataset on.
407
+ */
408
+ xAxisID: string;
409
+ /**
410
+ * The ID of the y axis to plot this dataset on.
411
+ */
412
+ yAxisID: string;
413
+
414
+ /**
415
+ * If true, lines will be drawn between points with no or null data. If false, points with NaN data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.
416
+ */
417
+ spanGaps: boolean | number;
418
+
419
+ /**
420
+ * If false, the line is not drawn for this dataset.
421
+ */
422
+ showLine: boolean;
423
+ }
424
+
425
+ export type RadarControllerChartOptions = LineControllerChartOptions;
426
+
427
+ export type RadarController = DatasetController
428
+ export declare const RadarController: ChartComponent & {
429
+ prototype: RadarController;
430
+ new (chart: Chart, datasetIndex: number): RadarController;
431
+ };
432
+ interface ChartMetaCommon<TElement extends Element = Element, TDatasetElement extends Element = Element> {
433
+ type: string;
434
+ controller: DatasetController;
435
+ order: number;
436
+
437
+ label: string;
438
+ index: number;
439
+ visible: boolean;
440
+
441
+ stack: number;
442
+
443
+ indexAxis: 'x' | 'y';
444
+
445
+ data: TElement[];
446
+ dataset?: TDatasetElement;
447
+
448
+ hidden: boolean;
449
+
450
+ xAxisID?: string;
451
+ yAxisID?: string;
452
+ rAxisID?: string;
453
+ iAxisID: string;
454
+ vAxisID: string;
455
+
456
+ xScale?: Scale;
457
+ yScale?: Scale;
458
+ rScale?: Scale;
459
+ iScale?: Scale;
460
+ vScale?: Scale;
461
+
462
+ _sorted: boolean;
463
+ _stacked: boolean | 'single';
464
+ _parsed: unknown[];
465
+ }
466
+
467
+ export type ChartMeta<
468
+ TType extends ChartType = ChartType,
469
+ TElement extends Element = Element,
470
+ TDatasetElement extends Element = Element,
471
+ > = DeepPartial<
472
+ { [key in ChartType]: ChartTypeRegistry[key]['metaExtensions'] }[TType]
473
+ > & ChartMetaCommon<TElement, TDatasetElement>;
474
+
475
+ export interface ActiveDataPoint {
476
+ datasetIndex: number;
477
+ index: number;
478
+ }
479
+
480
+ export interface ActiveElement extends ActiveDataPoint {
481
+ element: Element;
482
+ }
483
+
484
+ export declare class Chart<
485
+ TType extends ChartType = ChartType,
486
+ TData = DefaultDataPoint<TType>,
487
+ TLabel = unknown
488
+ > {
489
+ readonly platform: BasePlatform;
490
+ readonly id: string;
491
+ readonly canvas: HTMLCanvasElement;
492
+ readonly ctx: CanvasRenderingContext2D;
493
+ readonly config: ChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>;
494
+ readonly width: number;
495
+ readonly height: number;
496
+ readonly aspectRatio: number;
497
+ readonly boxes: LayoutItem[];
498
+ readonly currentDevicePixelRatio: number;
499
+ readonly chartArea: ChartArea;
500
+ readonly scales: { [key: string]: Scale };
501
+ readonly attached: boolean;
502
+
503
+ readonly legend?: LegendElement<TType>; // Only available if legend plugin is registered and enabled
504
+ readonly tooltip?: TooltipModel<TType>; // Only available if tooltip plugin is registered and enabled
505
+
506
+ data: ChartData<TType, TData, TLabel>;
507
+ options: ChartOptions<TType>;
508
+
509
+ constructor(item: ChartItem, config: ChartConfiguration<TType, TData, TLabel> | ChartConfigurationCustomTypesPerDataset<TType, TData, TLabel>);
510
+
511
+ clear(): this;
512
+ stop(): this;
513
+
514
+ resize(width?: number, height?: number): void;
515
+ ensureScalesHaveIDs(): void;
516
+ buildOrUpdateScales(): void;
517
+ buildOrUpdateControllers(): void;
518
+ reset(): void;
519
+ update(mode?: UpdateMode | ((ctx: { datasetIndex: number }) => UpdateMode)): void;
520
+ render(): void;
521
+ draw(): void;
522
+
523
+ isPointInArea(point: Point): boolean;
524
+ getElementsAtEventForMode(e: Event, mode: string, options: InteractionOptions, useFinalPosition: boolean): InteractionItem[];
525
+
526
+ getSortedVisibleDatasetMetas(): ChartMeta[];
527
+ getDatasetMeta(datasetIndex: number): ChartMeta;
528
+ getVisibleDatasetCount(): number;
529
+ isDatasetVisible(datasetIndex: number): boolean;
530
+ setDatasetVisibility(datasetIndex: number, visible: boolean): void;
531
+ toggleDataVisibility(index: number): void;
532
+ getDataVisibility(index: number): boolean;
533
+ hide(datasetIndex: number, dataIndex?: number): void;
534
+ show(datasetIndex: number, dataIndex?: number): void;
535
+
536
+ getActiveElements(): ActiveElement[];
537
+ setActiveElements(active: ActiveDataPoint[]): void;
538
+
539
+ destroy(): void;
540
+ toBase64Image(type?: string, quality?: unknown): string;
541
+ bindEvents(): void;
542
+ unbindEvents(): void;
543
+ updateHoverStyle(items: InteractionItem[], mode: 'dataset', enabled: boolean): void;
544
+
545
+ notifyPlugins(hook: string, args?: AnyObject): boolean | void;
546
+
547
+ isPluginEnabled(pluginId: string): boolean;
548
+
549
+ getContext(): { chart: Chart, type: string };
550
+
551
+ static readonly defaults: Defaults;
552
+ static readonly overrides: Overrides;
553
+ static readonly version: string;
554
+ static readonly instances: { [key: string]: Chart };
555
+ static readonly registry: Registry;
556
+ static getChart(key: string | CanvasRenderingContext2D | HTMLCanvasElement): Chart | undefined;
557
+ static register(...items: ChartComponentLike[]): void;
558
+ static unregister(...items: ChartComponentLike[]): void;
559
+ }
560
+
561
+ export declare const registerables: readonly ChartComponentLike[];
562
+
563
+ export declare type ChartItem =
564
+ | string
565
+ | CanvasRenderingContext2D
566
+ | HTMLCanvasElement
567
+ | { canvas: HTMLCanvasElement }
568
+ | ArrayLike<CanvasRenderingContext2D | HTMLCanvasElement>;
569
+
570
+ export declare enum UpdateModeEnum {
571
+ resize = 'resize',
572
+ reset = 'reset',
573
+ none = 'none',
574
+ hide = 'hide',
575
+ show = 'show',
576
+ default = 'default',
577
+ active = 'active'
578
+ }
579
+
580
+ export type UpdateMode = keyof typeof UpdateModeEnum;
581
+
582
+ export declare class DatasetController<
583
+ TType extends ChartType = ChartType,
584
+ TElement extends Element = Element,
585
+ TDatasetElement extends Element = Element,
586
+ TParsedData = ParsedDataType<TType>,
587
+ > {
588
+ constructor(chart: Chart, datasetIndex: number);
589
+
590
+ readonly chart: Chart;
591
+ readonly index: number;
592
+ readonly _cachedMeta: ChartMeta<TType, TElement, TDatasetElement>;
593
+ enableOptionSharing: boolean;
594
+ // If true, the controller supports the decimation
595
+ // plugin. Defaults to `false` for all controllers
596
+ // except the LineController
597
+ supportsDecimation: boolean;
598
+
599
+ linkScales(): void;
600
+ getAllParsedValues(scale: Scale): number[];
601
+ protected getLabelAndValue(index: number): { label: string; value: string };
602
+ updateElements(elements: TElement[], start: number, count: number, mode: UpdateMode): void;
603
+ update(mode: UpdateMode): void;
604
+ updateIndex(datasetIndex: number): void;
605
+ protected getMaxOverflow(): boolean | number;
606
+ draw(): void;
607
+ reset(): void;
608
+ getDataset(): ChartDataset;
609
+ getMeta(): ChartMeta<TType, TElement, TDatasetElement>;
610
+ getScaleForId(scaleID: string): Scale | undefined;
611
+ configure(): void;
612
+ initialize(): void;
613
+ addElements(): void;
614
+ buildOrUpdateElements(resetNewElements?: boolean): void;
615
+
616
+ getStyle(index: number, active: boolean): AnyObject;
617
+ protected resolveDatasetElementOptions(mode: UpdateMode): AnyObject;
618
+ protected resolveDataElementOptions(index: number, mode: UpdateMode): AnyObject;
619
+ /**
620
+ * Utility for checking if the options are shared and should be animated separately.
621
+ * @protected
622
+ */
623
+ protected getSharedOptions(options: AnyObject): undefined | AnyObject;
624
+ /**
625
+ * Utility for determining if `options` should be included in the updated properties
626
+ * @protected
627
+ */
628
+ protected includeOptions(mode: UpdateMode, sharedOptions: AnyObject): boolean;
629
+ /**
630
+ * Utility for updating an element with new properties, using animations when appropriate.
631
+ * @protected
632
+ */
633
+
634
+ protected updateElement(element: TElement | TDatasetElement, index: number | undefined, properties: AnyObject, mode: UpdateMode): void;
635
+ /**
636
+ * Utility to animate the shared options, that are potentially affecting multiple elements.
637
+ * @protected
638
+ */
639
+
640
+ protected updateSharedOptions(sharedOptions: AnyObject, mode: UpdateMode, newOptions: AnyObject): void;
641
+ removeHoverStyle(element: TElement, datasetIndex: number, index: number): void;
642
+ setHoverStyle(element: TElement, datasetIndex: number, index: number): void;
643
+
644
+ parse(start: number, count: number): void;
645
+ protected parsePrimitiveData(meta: ChartMeta<TType, TElement, TDatasetElement>, data: AnyObject[], start: number, count: number): AnyObject[];
646
+ protected parseArrayData(meta: ChartMeta<TType, TElement, TDatasetElement>, data: AnyObject[], start: number, count: number): AnyObject[];
647
+ protected parseObjectData(meta: ChartMeta<TType, TElement, TDatasetElement>, data: AnyObject[], start: number, count: number): AnyObject[];
648
+ protected getParsed(index: number): TParsedData;
649
+ protected applyStack(scale: Scale, parsed: unknown[]): number;
650
+ protected updateRangeFromParsed(
651
+ range: { min: number; max: number },
652
+ scale: Scale,
653
+ parsed: unknown[],
654
+ stack: boolean | string
655
+ ): void;
656
+ protected getMinMax(scale: Scale, canStack?: boolean): { min: number; max: number };
657
+ }
658
+
659
+ export interface DatasetControllerChartComponent extends ChartComponent {
660
+ defaults: {
661
+ datasetElementType?: string | null | false;
662
+ dataElementType?: string | null | false;
663
+ };
664
+ }
665
+
666
+ export interface Defaults extends CoreChartOptions<ChartType>, ElementChartOptions<ChartType>, PluginChartOptions<ChartType> {
667
+
668
+ scale: ScaleOptionsByType;
669
+ scales: {
670
+ [key in ScaleType]: ScaleOptionsByType<key>;
671
+ };
672
+
673
+ set(values: AnyObject): AnyObject;
674
+ set(scope: string, values: AnyObject): AnyObject;
675
+ get(scope: string): AnyObject;
676
+
677
+ describe(scope: string, values: AnyObject): AnyObject;
678
+ override(scope: string, values: AnyObject): AnyObject;
679
+
680
+ /**
681
+ * Routes the named defaults to fallback to another scope/name.
682
+ * This routing is useful when those target values, like defaults.color, are changed runtime.
683
+ * If the values would be copied, the runtime change would not take effect. By routing, the
684
+ * fallback is evaluated at each access, so its always up to date.
685
+ *
686
+ * Example:
687
+ *
688
+ * defaults.route('elements.arc', 'backgroundColor', '', 'color')
689
+ * - reads the backgroundColor from defaults.color when undefined locally
690
+ *
691
+ * @param scope Scope this route applies to.
692
+ * @param name Property name that should be routed to different namespace when not defined here.
693
+ * @param targetScope The namespace where those properties should be routed to.
694
+ * Empty string ('') is the root of defaults.
695
+ * @param targetName The target name in the target scope the property should be routed to.
696
+ */
697
+ route(scope: string, name: string, targetScope: string, targetName: string): void;
698
+ }
699
+
700
+ export type Overrides = {
701
+ [key in ChartType]:
702
+ CoreChartOptions<key> &
703
+ ElementChartOptions<key> &
704
+ PluginChartOptions<key> &
705
+ DatasetChartOptions<ChartType> &
706
+ ScaleChartOptions<key> &
707
+ ChartTypeRegistry[key]['chartOptions'];
708
+ }
709
+
710
+ export declare const defaults: Defaults;
711
+ export interface InteractionOptions {
712
+ axis?: string;
713
+ intersect?: boolean;
714
+ includeInvisible?: boolean;
715
+ }
716
+
717
+ export interface InteractionItem {
718
+ element: Element;
719
+ datasetIndex: number;
720
+ index: number;
721
+ }
722
+
723
+ export type InteractionModeFunction = (
724
+ chart: Chart,
725
+ e: ChartEvent,
726
+ options: InteractionOptions,
727
+ useFinalPosition?: boolean
728
+ ) => InteractionItem[];
729
+
730
+ export interface InteractionModeMap {
731
+ /**
732
+ * Returns items at the same index. If the options.intersect parameter is true, we only return items if we intersect something
733
+ * If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
734
+ */
735
+ index: InteractionModeFunction;
736
+
737
+ /**
738
+ * Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something
739
+ * If the options.intersect is false, we find the nearest item and return the items in that dataset
740
+ */
741
+ dataset: InteractionModeFunction;
742
+ /**
743
+ * Point mode returns all elements that hit test based on the event position
744
+ * of the event
745
+ */
746
+ point: InteractionModeFunction;
747
+ /**
748
+ * nearest mode returns the element closest to the point
749
+ */
750
+ nearest: InteractionModeFunction;
751
+ /**
752
+ * x mode returns the elements that hit-test at the current x coordinate
753
+ */
754
+ x: InteractionModeFunction;
755
+ /**
756
+ * y mode returns the elements that hit-test at the current y coordinate
757
+ */
758
+ y: InteractionModeFunction;
759
+ }
760
+
761
+ export type InteractionMode = keyof InteractionModeMap;
762
+
763
+ export declare const Interaction: {
764
+ modes: InteractionModeMap;
765
+
766
+ /**
767
+ * Helper function to select candidate elements for interaction
768
+ */
769
+ evaluateInteractionItems(
770
+ chart: Chart,
771
+ axis: InteractionAxis,
772
+ position: Point,
773
+ handler: (element: Element & VisualElement, datasetIndex: number, index: number) => void,
774
+ intersect?: boolean
775
+ ): InteractionItem[];
776
+ };
777
+
778
+ export declare const layouts: {
779
+ /**
780
+ * Register a box to a chart.
781
+ * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
782
+ * @param {Chart} chart - the chart to use
783
+ * @param {LayoutItem} item - the item to add to be laid out
784
+ */
785
+ addBox(chart: Chart, item: LayoutItem): void;
786
+
787
+ /**
788
+ * Remove a layoutItem from a chart
789
+ * @param {Chart} chart - the chart to remove the box from
790
+ * @param {LayoutItem} layoutItem - the item to remove from the layout
791
+ */
792
+ removeBox(chart: Chart, layoutItem: LayoutItem): void;
793
+
794
+ /**
795
+ * Sets (or updates) options on the given `item`.
796
+ * @param {Chart} chart - the chart in which the item lives (or will be added to)
797
+ * @param {LayoutItem} item - the item to configure with the given options
798
+ * @param options - the new item options.
799
+ */
800
+ configure(
801
+ chart: Chart,
802
+ item: LayoutItem,
803
+ options: { fullSize?: number; position?: LayoutPosition; weight?: number }
804
+ ): void;
805
+
806
+ /**
807
+ * Fits boxes of the given chart into the given size by having each box measure itself
808
+ * then running a fitting algorithm
809
+ * @param {Chart} chart - the chart
810
+ * @param {number} width - the width to fit into
811
+ * @param {number} height - the height to fit into
812
+ */
813
+ update(chart: Chart, width: number, height: number): void;
814
+ };
815
+
816
+ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> extends ExtendedPlugin<TType, O> {
817
+ id: string;
818
+
819
+ /**
820
+ * The events option defines the browser events that the plugin should listen.
821
+ * @default ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']
822
+ */
823
+ events?: (keyof HTMLElementEventMap)[]
824
+
825
+ /**
826
+ * @desc Called when plugin is installed for this chart instance. This hook is also invoked for disabled plugins (options === false).
827
+ * @param {Chart} chart - The chart instance.
828
+ * @param {object} args - The call arguments.
829
+ * @param {object} options - The plugin options.
830
+ * @since 3.0.0
831
+ */
832
+ install?(chart: Chart<TType>, args: EmptyObject, options: O): void;
833
+ /**
834
+ * @desc Called when a plugin is starting. This happens when chart is created or plugin is enabled.
835
+ * @param {Chart} chart - The chart instance.
836
+ * @param {object} args - The call arguments.
837
+ * @param {object} options - The plugin options.
838
+ * @since 3.0.0
839
+ */
840
+ start?(chart: Chart<TType>, args: EmptyObject, options: O): void;
841
+ /**
842
+ * @desc Called when a plugin stopping. This happens when chart is destroyed or plugin is disabled.
843
+ * @param {Chart} chart - The chart instance.
844
+ * @param {object} args - The call arguments.
845
+ * @param {object} options - The plugin options.
846
+ * @since 3.0.0
847
+ */
848
+ stop?(chart: Chart<TType>, args: EmptyObject, options: O): void;
849
+ /**
850
+ * @desc Called before initializing `chart`.
851
+ * @param {Chart} chart - The chart instance.
852
+ * @param {object} args - The call arguments.
853
+ * @param {object} options - The plugin options.
854
+ */
855
+ beforeInit?(chart: Chart<TType>, args: EmptyObject, options: O): void;
856
+ /**
857
+ * @desc Called after `chart` has been initialized and before the first update.
858
+ * @param {Chart} chart - The chart instance.
859
+ * @param {object} args - The call arguments.
860
+ * @param {object} options - The plugin options.
861
+ */
862
+ afterInit?(chart: Chart<TType>, args: EmptyObject, options: O): void;
863
+ /**
864
+ * @desc Called before updating `chart`. If any plugin returns `false`, the update
865
+ * is cancelled (and thus subsequent render(s)) until another `update` is triggered.
866
+ * @param {Chart} chart - The chart instance.
867
+ * @param {object} args - The call arguments.
868
+ * @param {UpdateMode} args.mode - The update mode
869
+ * @param {object} options - The plugin options.
870
+ * @returns {boolean} `false` to cancel the chart update.
871
+ */
872
+ beforeUpdate?(chart: Chart<TType>, args: { mode: UpdateMode, cancelable: true }, options: O): boolean | void;
873
+ /**
874
+ * @desc Called after `chart` has been updated and before rendering. Note that this
875
+ * hook will not be called if the chart update has been previously cancelled.
876
+ * @param {Chart} chart - The chart instance.
877
+ * @param {object} args - The call arguments.
878
+ * @param {UpdateMode} args.mode - The update mode
879
+ * @param {object} options - The plugin options.
880
+ */
881
+ afterUpdate?(chart: Chart<TType>, args: { mode: UpdateMode }, options: O): void;
882
+ /**
883
+ * @desc Called during the update process, before any chart elements have been created.
884
+ * This can be used for data decimation by changing the data array inside a dataset.
885
+ * @param {Chart} chart - The chart instance.
886
+ * @param {object} args - The call arguments.
887
+ * @param {object} options - The plugin options.
888
+ */
889
+ beforeElementsUpdate?(chart: Chart<TType>, args: EmptyObject, options: O): void;
890
+ /**
891
+ * @desc Called during chart reset
892
+ * @param {Chart} chart - The chart instance.
893
+ * @param {object} args - The call arguments.
894
+ * @param {object} options - The plugin options.
895
+ * @since version 3.0.0
896
+ */
897
+ reset?(chart: Chart<TType>, args: EmptyObject, options: O): void;
898
+ /**
899
+ * @desc Called before updating the `chart` datasets. If any plugin returns `false`,
900
+ * the datasets update is cancelled until another `update` is triggered.
901
+ * @param {Chart} chart - The chart instance.
902
+ * @param {object} args - The call arguments.
903
+ * @param {UpdateMode} args.mode - The update mode.
904
+ * @param {object} options - The plugin options.
905
+ * @returns {boolean} false to cancel the datasets update.
906
+ * @since version 2.1.5
907
+ */
908
+ beforeDatasetsUpdate?(chart: Chart<TType>, args: { mode: UpdateMode }, options: O): boolean | void;
909
+ /**
910
+ * @desc Called after the `chart` datasets have been updated. Note that this hook
911
+ * will not be called if the datasets update has been previously cancelled.
912
+ * @param {Chart} chart - The chart instance.
913
+ * @param {object} args - The call arguments.
914
+ * @param {UpdateMode} args.mode - The update mode.
915
+ * @param {object} options - The plugin options.
916
+ * @since version 2.1.5
917
+ */
918
+ afterDatasetsUpdate?(chart: Chart<TType>, args: { mode: UpdateMode, cancelable: true }, options: O): void;
919
+ /**
920
+ * @desc Called before updating the `chart` dataset at the given `args.index`. If any plugin
921
+ * returns `false`, the datasets update is cancelled until another `update` is triggered.
922
+ * @param {Chart} chart - The chart instance.
923
+ * @param {object} args - The call arguments.
924
+ * @param {number} args.index - The dataset index.
925
+ * @param {object} args.meta - The dataset metadata.
926
+ * @param {UpdateMode} args.mode - The update mode.
927
+ * @param {object} options - The plugin options.
928
+ * @returns {boolean} `false` to cancel the chart datasets drawing.
929
+ */
930
+ beforeDatasetUpdate?(chart: Chart<TType>, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: true }, options: O): boolean | void;
931
+ /**
932
+ * @desc Called after the `chart` datasets at the given `args.index` has been updated. Note
933
+ * that this hook will not be called if the datasets update has been previously cancelled.
934
+ * @param {Chart} chart - The chart instance.
935
+ * @param {object} args - The call arguments.
936
+ * @param {number} args.index - The dataset index.
937
+ * @param {object} args.meta - The dataset metadata.
938
+ * @param {UpdateMode} args.mode - The update mode.
939
+ * @param {object} options - The plugin options.
940
+ */
941
+ afterDatasetUpdate?(chart: Chart<TType>, args: { index: number; meta: ChartMeta, mode: UpdateMode, cancelable: false }, options: O): void;
942
+ /**
943
+ * @desc Called before laying out `chart`. If any plugin returns `false`,
944
+ * the layout update is cancelled until another `update` is triggered.
945
+ * @param {Chart} chart - The chart instance.
946
+ * @param {object} args - The call arguments.
947
+ * @param {object} options - The plugin options.
948
+ * @returns {boolean} `false` to cancel the chart layout.
949
+ */
950
+ beforeLayout?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
951
+ /**
952
+ * @desc Called before scale data limits are calculated. This hook is called separately for each scale in the chart.
953
+ * @param {Chart} chart - The chart instance.
954
+ * @param {object} args - The call arguments.
955
+ * @param {Scale} args.scale - The scale.
956
+ * @param {object} options - The plugin options.
957
+ */
958
+ beforeDataLimits?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
959
+ /**
960
+ * @desc Called after scale data limits are calculated. This hook is called separately for each scale in the chart.
961
+ * @param {Chart} chart - The chart instance.
962
+ * @param {object} args - The call arguments.
963
+ * @param {Scale} args.scale - The scale.
964
+ * @param {object} options - The plugin options.
965
+ */
966
+ afterDataLimits?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
967
+ /**
968
+ * @desc Called before scale builds its ticks. This hook is called separately for each scale in the chart.
969
+ * @param {Chart} chart - The chart instance.
970
+ * @param {object} args - The call arguments.
971
+ * @param {Scale} args.scale - The scale.
972
+ * @param {object} options - The plugin options.
973
+ */
974
+ beforeBuildTicks?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
975
+ /**
976
+ * @desc Called after scale has build its ticks. This hook is called separately for each scale in the chart.
977
+ * @param {Chart} chart - The chart instance.
978
+ * @param {object} args - The call arguments.
979
+ * @param {Scale} args.scale - The scale.
980
+ * @param {object} options - The plugin options.
981
+ */
982
+ afterBuildTicks?(chart: Chart<TType>, args: { scale: Scale }, options: O): void;
983
+ /**
984
+ * @desc Called after the `chart` has been laid out. Note that this hook will not
985
+ * be called if the layout update has been previously cancelled.
986
+ * @param {Chart} chart - The chart instance.
987
+ * @param {object} args - The call arguments.
988
+ * @param {object} options - The plugin options.
989
+ */
990
+ afterLayout?(chart: Chart<TType>, args: EmptyObject, options: O): void;
991
+ /**
992
+ * @desc Called before rendering `chart`. If any plugin returns `false`,
993
+ * the rendering is cancelled until another `render` is triggered.
994
+ * @param {Chart} chart - The chart instance.
995
+ * @param {object} args - The call arguments.
996
+ * @param {object} options - The plugin options.
997
+ * @returns {boolean} `false` to cancel the chart rendering.
998
+ */
999
+ beforeRender?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
1000
+ /**
1001
+ * @desc Called after the `chart` has been fully rendered (and animation completed). Note
1002
+ * that this hook will not be called if the rendering has been previously cancelled.
1003
+ * @param {Chart} chart - The chart instance.
1004
+ * @param {object} args - The call arguments.
1005
+ * @param {object} options - The plugin options.
1006
+ */
1007
+ afterRender?(chart: Chart<TType>, args: EmptyObject, options: O): void;
1008
+ /**
1009
+ * @desc Called before drawing `chart` at every animation frame. If any plugin returns `false`,
1010
+ * the frame drawing is cancelled untilanother `render` is triggered.
1011
+ * @param {Chart} chart - The chart instance.
1012
+ * @param {object} args - The call arguments.
1013
+ * @param {object} options - The plugin options.
1014
+ * @returns {boolean} `false` to cancel the chart drawing.
1015
+ */
1016
+ beforeDraw?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
1017
+ /**
1018
+ * @desc Called after the `chart` has been drawn. Note that this hook will not be called
1019
+ * if the drawing has been previously cancelled.
1020
+ * @param {Chart} chart - The chart instance.
1021
+ * @param {object} args - The call arguments.
1022
+ * @param {object} options - The plugin options.
1023
+ */
1024
+ afterDraw?(chart: Chart<TType>, args: EmptyObject, options: O): void;
1025
+ /**
1026
+ * @desc Called before drawing the `chart` datasets. If any plugin returns `false`,
1027
+ * the datasets drawing is cancelled until another `render` is triggered.
1028
+ * @param {Chart} chart - The chart instance.
1029
+ * @param {object} args - The call arguments.
1030
+ * @param {object} options - The plugin options.
1031
+ * @returns {boolean} `false` to cancel the chart datasets drawing.
1032
+ */
1033
+ beforeDatasetsDraw?(chart: Chart<TType>, args: { cancelable: true }, options: O): boolean | void;
1034
+ /**
1035
+ * @desc Called after the `chart` datasets have been drawn. Note that this hook
1036
+ * will not be called if the datasets drawing has been previously cancelled.
1037
+ * @param {Chart} chart - The chart instance.
1038
+ * @param {object} args - The call arguments.
1039
+ * @param {object} options - The plugin options.
1040
+ */
1041
+ afterDatasetsDraw?(chart: Chart<TType>, args: EmptyObject, options: O, cancelable: false): void;
1042
+ /**
1043
+ * @desc Called before drawing the `chart` dataset at the given `args.index` (datasets
1044
+ * are drawn in the reverse order). If any plugin returns `false`, the datasets drawing
1045
+ * is cancelled until another `render` is triggered.
1046
+ * @param {Chart} chart - The chart instance.
1047
+ * @param {object} args - The call arguments.
1048
+ * @param {number} args.index - The dataset index.
1049
+ * @param {object} args.meta - The dataset metadata.
1050
+ * @param {object} options - The plugin options.
1051
+ * @returns {boolean} `false` to cancel the chart datasets drawing.
1052
+ */
1053
+ beforeDatasetDraw?(chart: Chart<TType>, args: { index: number; meta: ChartMeta }, options: O): boolean | void;
1054
+ /**
1055
+ * @desc Called after the `chart` datasets at the given `args.index` have been drawn
1056
+ * (datasets are drawn in the reverse order). Note that this hook will not be called
1057
+ * if the datasets drawing has been previously cancelled.
1058
+ * @param {Chart} chart - The chart instance.
1059
+ * @param {object} args - The call arguments.
1060
+ * @param {number} args.index - The dataset index.
1061
+ * @param {object} args.meta - The dataset metadata.
1062
+ * @param {object} options - The plugin options.
1063
+ */
1064
+ afterDatasetDraw?(chart: Chart<TType>, args: { index: number; meta: ChartMeta }, options: O): void;
1065
+ /**
1066
+ * @desc Called before processing the specified `event`. If any plugin returns `false`,
1067
+ * the event will be discarded.
1068
+ * @param {Chart} chart - The chart instance.
1069
+ * @param {object} args - The call arguments.
1070
+ * @param {ChartEvent} args.event - The event object.
1071
+ * @param {boolean} args.replay - True if this event is replayed from `Chart.update`
1072
+ * @param {boolean} args.inChartArea - The event position is inside chartArea
1073
+ * @param {object} options - The plugin options.
1074
+ */
1075
+ beforeEvent?(chart: Chart<TType>, args: { event: ChartEvent, replay: boolean, cancelable: true, inChartArea: boolean }, options: O): boolean | void;
1076
+ /**
1077
+ * @desc Called after the `event` has been consumed. Note that this hook
1078
+ * will not be called if the `event` has been previously discarded.
1079
+ * @param {Chart} chart - The chart instance.
1080
+ * @param {object} args - The call arguments.
1081
+ * @param {ChartEvent} args.event - The event object.
1082
+ * @param {boolean} args.replay - True if this event is replayed from `Chart.update`
1083
+ * @param {boolean} args.inChartArea - The event position is inside chartArea
1084
+ * @param {boolean} [args.changed] - Set to true if the plugin needs a render. Should only be changed to true, because this args object is passed through all plugins.
1085
+ * @param {object} options - The plugin options.
1086
+ */
1087
+ afterEvent?(chart: Chart<TType>, args: { event: ChartEvent, replay: boolean, changed?: boolean, cancelable: false, inChartArea: boolean }, options: O): void;
1088
+ /**
1089
+ * @desc Called after the chart as been resized.
1090
+ * @param {Chart} chart - The chart instance.
1091
+ * @param {object} args - The call arguments.
1092
+ * @param {number} args.size - The new canvas display size (eq. canvas.style width & height).
1093
+ * @param {object} options - The plugin options.
1094
+ */
1095
+ resize?(chart: Chart<TType>, args: { size: { width: number, height: number } }, options: O): void;
1096
+ /**
1097
+ * Called before the chart is being destroyed.
1098
+ * @param {Chart} chart - The chart instance.
1099
+ * @param {object} args - The call arguments.
1100
+ * @param {object} options - The plugin options.
1101
+ */
1102
+ beforeDestroy?(chart: Chart<TType>, args: EmptyObject, options: O): void;
1103
+ /**
1104
+ * Called after the chart has been destroyed.
1105
+ * @param {Chart} chart - The chart instance.
1106
+ * @param {object} args - The call arguments.
1107
+ * @param {object} options - The plugin options.
1108
+ */
1109
+ afterDestroy?(chart: Chart<TType>, args: EmptyObject, options: O): void;
1110
+ /**
1111
+ * Called after chart is destroyed on all plugins that were installed for that chart. This hook is also invoked for disabled plugins (options === false).
1112
+ * @param {Chart} chart - The chart instance.
1113
+ * @param {object} args - The call arguments.
1114
+ * @param {object} options - The plugin options.
1115
+ * @since 3.0.0
1116
+ */
1117
+ uninstall?(chart: Chart<TType>, args: EmptyObject, options: O): void;
1118
+
1119
+ /**
1120
+ * Default options used in the plugin
1121
+ */
1122
+ defaults?: Partial<O>;
1123
+ }
1124
+
1125
+ export declare type ChartComponentLike = ChartComponent | ChartComponent[] | { [key: string]: ChartComponent } | Plugin | Plugin[];
1126
+
1127
+ /**
1128
+ * Please use the module's default export which provides a singleton instance
1129
+ * Note: class is exported for typedoc
1130
+ */
1131
+ export interface Registry {
1132
+ readonly controllers: TypedRegistry<DatasetController>;
1133
+ readonly elements: TypedRegistry<Element>;
1134
+ readonly plugins: TypedRegistry<Plugin>;
1135
+ readonly scales: TypedRegistry<Scale>;
1136
+
1137
+ add(...args: ChartComponentLike[]): void;
1138
+ remove(...args: ChartComponentLike[]): void;
1139
+
1140
+ addControllers(...args: ChartComponentLike[]): void;
1141
+ addElements(...args: ChartComponentLike[]): void;
1142
+ addPlugins(...args: ChartComponentLike[]): void;
1143
+ addScales(...args: ChartComponentLike[]): void;
1144
+
1145
+ getController(id: string): DatasetController | undefined;
1146
+ getElement(id: string): Element | undefined;
1147
+ getPlugin(id: string): Plugin | undefined;
1148
+ getScale(id: string): Scale | undefined;
1149
+ }
1150
+
1151
+ export declare const registry: Registry;
1152
+
1153
+ export interface Tick {
1154
+ value: number;
1155
+ label?: string | string[];
1156
+ major?: boolean;
1157
+ }
1158
+
1159
+ export interface CoreScaleOptions {
1160
+ /**
1161
+ * Controls the axis global visibility (visible when true, hidden when false). When display: 'auto', the axis is visible only if at least one associated dataset is visible.
1162
+ * @default true
1163
+ */
1164
+ display: boolean | 'auto';
1165
+ /**
1166
+ * Align pixel values to device pixels
1167
+ */
1168
+ alignToPixels: boolean;
1169
+ /**
1170
+ * Background color of the scale area.
1171
+ */
1172
+ backgroundColor: Color;
1173
+ /**
1174
+ * Reverse the scale.
1175
+ * @default false
1176
+ */
1177
+ reverse: boolean;
1178
+ /**
1179
+ * Clip the dataset drawing against the size of the scale instead of chart area.
1180
+ * @default true
1181
+ */
1182
+ clip: boolean;
1183
+ /**
1184
+ * The weight used to sort the axis. Higher weights are further away from the chart area.
1185
+ * @default true
1186
+ */
1187
+ weight: number;
1188
+ /**
1189
+ * User defined minimum value for the scale, overrides minimum value from data.
1190
+ */
1191
+ min: unknown;
1192
+ /**
1193
+ * User defined maximum value for the scale, overrides maximum value from data.
1194
+ */
1195
+ max: unknown;
1196
+ /**
1197
+ * Adjustment used when calculating the maximum data value.
1198
+ */
1199
+ suggestedMin: unknown;
1200
+ /**
1201
+ * Adjustment used when calculating the minimum data value.
1202
+ */
1203
+ suggestedMax: unknown;
1204
+ /**
1205
+ * Callback called before the update process starts.
1206
+ */
1207
+ beforeUpdate(axis: Scale): void;
1208
+ /**
1209
+ * Callback that runs before dimensions are set.
1210
+ */
1211
+ beforeSetDimensions(axis: Scale): void;
1212
+ /**
1213
+ * Callback that runs after dimensions are set.
1214
+ */
1215
+ afterSetDimensions(axis: Scale): void;
1216
+ /**
1217
+ * Callback that runs before data limits are determined.
1218
+ */
1219
+ beforeDataLimits(axis: Scale): void;
1220
+ /**
1221
+ * Callback that runs after data limits are determined.
1222
+ */
1223
+ afterDataLimits(axis: Scale): void;
1224
+ /**
1225
+ * Callback that runs before ticks are created.
1226
+ */
1227
+ beforeBuildTicks(axis: Scale): void;
1228
+ /**
1229
+ * Callback that runs after ticks are created. Useful for filtering ticks.
1230
+ */
1231
+ afterBuildTicks(axis: Scale): void;
1232
+ /**
1233
+ * Callback that runs before ticks are converted into strings.
1234
+ */
1235
+ beforeTickToLabelConversion(axis: Scale): void;
1236
+ /**
1237
+ * Callback that runs after ticks are converted into strings.
1238
+ */
1239
+ afterTickToLabelConversion(axis: Scale): void;
1240
+ /**
1241
+ * Callback that runs before tick rotation is determined.
1242
+ */
1243
+ beforeCalculateLabelRotation(axis: Scale): void;
1244
+ /**
1245
+ * Callback that runs after tick rotation is determined.
1246
+ */
1247
+ afterCalculateLabelRotation(axis: Scale): void;
1248
+ /**
1249
+ * Callback that runs before the scale fits to the canvas.
1250
+ */
1251
+ beforeFit(axis: Scale): void;
1252
+ /**
1253
+ * Callback that runs after the scale fits to the canvas.
1254
+ */
1255
+ afterFit(axis: Scale): void;
1256
+ /**
1257
+ * Callback that runs at the end of the update process.
1258
+ */
1259
+ afterUpdate(axis: Scale): void;
1260
+ }
1261
+
1262
+ export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends Element<unknown, O>, LayoutItem {
1263
+ readonly id: string;
1264
+ readonly type: string;
1265
+ readonly ctx: CanvasRenderingContext2D;
1266
+ readonly chart: Chart;
1267
+
1268
+ maxWidth: number;
1269
+ maxHeight: number;
1270
+
1271
+ paddingTop: number;
1272
+ paddingBottom: number;
1273
+ paddingLeft: number;
1274
+ paddingRight: number;
1275
+
1276
+ axis: string;
1277
+ labelRotation: number;
1278
+ min: number;
1279
+ max: number;
1280
+ ticks: Tick[];
1281
+ getMatchingVisibleMetas(type?: string): ChartMeta[];
1282
+
1283
+ drawTitle(chartArea: ChartArea): void;
1284
+ drawLabels(chartArea: ChartArea): void;
1285
+ drawGrid(chartArea: ChartArea): void;
1286
+
1287
+ /**
1288
+ * @param {number} pixel
1289
+ * @return {number}
1290
+ */
1291
+ getDecimalForPixel(pixel: number): number;
1292
+ /**
1293
+ * Utility for getting the pixel location of a percentage of scale
1294
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
1295
+ * @param {number} decimal
1296
+ * @return {number}
1297
+ */
1298
+ getPixelForDecimal(decimal: number): number;
1299
+ /**
1300
+ * Returns the location of the tick at the given index
1301
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
1302
+ * @param {number} index
1303
+ * @return {number}
1304
+ */
1305
+ getPixelForTick(index: number): number;
1306
+ /**
1307
+ * Used to get the label to display in the tooltip for the given value
1308
+ * @param {*} value
1309
+ * @return {string}
1310
+ */
1311
+ getLabelForValue(value: number): string;
1312
+
1313
+ /**
1314
+ * Returns the grid line width at given value
1315
+ */
1316
+ getLineWidthForValue(value: number): number;
1317
+
1318
+ /**
1319
+ * Returns the location of the given data point. Value can either be an index or a numerical value
1320
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
1321
+ * @param {*} value
1322
+ * @param {number} [index]
1323
+ * @return {number}
1324
+ */
1325
+ getPixelForValue(value: number, index?: number): number;
1326
+
1327
+ /**
1328
+ * Used to get the data value from a given pixel. This is the inverse of getPixelForValue
1329
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
1330
+ * @param {number} pixel
1331
+ * @return {*}
1332
+ */
1333
+ getValueForPixel(pixel: number): number | undefined;
1334
+
1335
+ getBaseValue(): number;
1336
+ /**
1337
+ * Returns the pixel for the minimum chart value
1338
+ * The coordinate (0, 0) is at the upper-left corner of the canvas
1339
+ * @return {number}
1340
+ */
1341
+ getBasePixel(): number;
1342
+
1343
+ init(options: O): void;
1344
+ parse(raw: unknown, index?: number): unknown;
1345
+ getUserBounds(): { min: number; max: number; minDefined: boolean; maxDefined: boolean };
1346
+ getMinMax(canStack: boolean): { min: number; max: number };
1347
+ getTicks(): Tick[];
1348
+ getLabels(): string[];
1349
+ getLabelItems(chartArea?: ChartArea): LabelItem[];
1350
+ beforeUpdate(): void;
1351
+ configure(): void;
1352
+ afterUpdate(): void;
1353
+ beforeSetDimensions(): void;
1354
+ setDimensions(): void;
1355
+ afterSetDimensions(): void;
1356
+ beforeDataLimits(): void;
1357
+ determineDataLimits(): void;
1358
+ afterDataLimits(): void;
1359
+ beforeBuildTicks(): void;
1360
+ buildTicks(): Tick[];
1361
+ afterBuildTicks(): void;
1362
+ beforeTickToLabelConversion(): void;
1363
+ generateTickLabels(ticks: Tick[]): void;
1364
+ afterTickToLabelConversion(): void;
1365
+ beforeCalculateLabelRotation(): void;
1366
+ calculateLabelRotation(): void;
1367
+ afterCalculateLabelRotation(): void;
1368
+ beforeFit(): void;
1369
+ fit(): void;
1370
+ afterFit(): void;
1371
+
1372
+ isFullSize(): boolean;
1373
+ }
1374
+ export declare class Scale {
1375
+ constructor(cfg: {id: string, type: string, ctx: CanvasRenderingContext2D, chart: Chart});
1376
+ }
1377
+
1378
+ export interface ScriptableScaleContext {
1379
+ chart: Chart;
1380
+ scale: Scale;
1381
+ index: number;
1382
+ tick: Tick;
1383
+ }
1384
+
1385
+ export interface ScriptableScalePointLabelContext {
1386
+ chart: Chart;
1387
+ scale: Scale;
1388
+ index: number;
1389
+ label: string;
1390
+ type: string;
1391
+ }
1392
+
1393
+ export interface RenderTextOpts {
1394
+ /**
1395
+ * The fill color of the text. If unset, the existing
1396
+ * fillStyle property of the canvas is unchanged.
1397
+ */
1398
+ color?: Color;
1399
+
1400
+ /**
1401
+ * The width of the strikethrough / underline
1402
+ * @default 2
1403
+ */
1404
+ decorationWidth?: number;
1405
+
1406
+ /**
1407
+ * The max width of the text in pixels
1408
+ */
1409
+ maxWidth?: number;
1410
+
1411
+ /**
1412
+ * A rotation to be applied to the canvas
1413
+ * This is applied after the translation is applied
1414
+ */
1415
+ rotation?: number;
1416
+
1417
+ /**
1418
+ * Apply a strikethrough effect to the text
1419
+ */
1420
+ strikethrough?: boolean;
1421
+
1422
+ /**
1423
+ * The color of the text stroke. If unset, the existing
1424
+ * strokeStyle property of the context is unchanged
1425
+ */
1426
+ strokeColor?: Color;
1427
+
1428
+ /**
1429
+ * The text stroke width. If unset, the existing
1430
+ * lineWidth property of the context is unchanged
1431
+ */
1432
+ strokeWidth?: number;
1433
+
1434
+ /**
1435
+ * The text alignment to use. If unset, the existing
1436
+ * textAlign property of the context is unchanged
1437
+ */
1438
+ textAlign?: CanvasTextAlign;
1439
+
1440
+ /**
1441
+ * The text baseline to use. If unset, the existing
1442
+ * textBaseline property of the context is unchanged
1443
+ */
1444
+ textBaseline?: CanvasTextBaseline;
1445
+
1446
+ /**
1447
+ * If specified, a translation to apply to the context
1448
+ */
1449
+ translation?: [number, number];
1450
+
1451
+ /**
1452
+ * Underline the text
1453
+ */
1454
+ underline?: boolean;
1455
+
1456
+ /**
1457
+ * Dimensions for drawing the label backdrop
1458
+ */
1459
+ backdrop?: BackdropOptions;
1460
+ }
1461
+
1462
+ export interface BackdropOptions {
1463
+ /**
1464
+ * Left position of backdrop as pixel
1465
+ */
1466
+ left: number;
1467
+
1468
+ /**
1469
+ * Top position of backdrop as pixel
1470
+ */
1471
+ top: number;
1472
+
1473
+ /**
1474
+ * Width of backdrop in pixels
1475
+ */
1476
+ width: number;
1477
+
1478
+ /**
1479
+ * Height of backdrop in pixels
1480
+ */
1481
+ height: number;
1482
+
1483
+ /**
1484
+ * Color of label backdrops.
1485
+ */
1486
+ color: Scriptable<Color, ScriptableScaleContext>;
1487
+ }
1488
+
1489
+ export interface LabelItem {
1490
+ label: string | string[];
1491
+ font: CanvasFontSpec;
1492
+ textOffset: number;
1493
+ options: RenderTextOpts;
1494
+ }
1495
+
1496
+ export declare const Ticks: {
1497
+ formatters: {
1498
+ /**
1499
+ * Formatter for value labels
1500
+ * @param value the value to display
1501
+ * @return {string|string[]} the label to display
1502
+ */
1503
+ values(value: unknown): string | string[];
1504
+ /**
1505
+ * Formatter for numeric ticks
1506
+ * @param tickValue the value to be formatted
1507
+ * @param index the position of the tickValue parameter in the ticks array
1508
+ * @param ticks the list of ticks being converted
1509
+ * @return string representation of the tickValue parameter
1510
+ */
1511
+ numeric(tickValue: number, index: number, ticks: { value: number }[]): string;
1512
+ /**
1513
+ * Formatter for logarithmic ticks
1514
+ * @param tickValue the value to be formatted
1515
+ * @param index the position of the tickValue parameter in the ticks array
1516
+ * @param ticks the list of ticks being converted
1517
+ * @return string representation of the tickValue parameter
1518
+ */
1519
+ logarithmic(tickValue: number, index: number, ticks: { value: number }[]): string;
1520
+ };
1521
+ };
1522
+
1523
+ export interface TypedRegistry<T> {
1524
+ /**
1525
+ * @param {ChartComponent} item
1526
+ * @returns {string} The scope where items defaults were registered to.
1527
+ */
1528
+ register(item: ChartComponent): string;
1529
+ get(id: string): T | undefined;
1530
+ unregister(item: ChartComponent): void;
1531
+ }
1532
+
1533
+ export interface ChartEvent {
1534
+ type:
1535
+ | 'contextmenu'
1536
+ | 'mouseenter'
1537
+ | 'mousedown'
1538
+ | 'mousemove'
1539
+ | 'mouseup'
1540
+ | 'mouseout'
1541
+ | 'click'
1542
+ | 'dblclick'
1543
+ | 'keydown'
1544
+ | 'keypress'
1545
+ | 'keyup'
1546
+ | 'resize';
1547
+ native: Event | null;
1548
+ x: number | null;
1549
+ y: number | null;
1550
+ }
1551
+ export interface ChartComponent {
1552
+ id: string;
1553
+ defaults?: AnyObject;
1554
+ defaultRoutes?: { [property: string]: string };
1555
+
1556
+ beforeRegister?(): void;
1557
+ afterRegister?(): void;
1558
+ beforeUnregister?(): void;
1559
+ afterUnregister?(): void;
1560
+ }
1561
+
1562
+ export type InteractionAxis = 'x' | 'y' | 'xy' | 'r';
1563
+
1564
+ export interface CoreInteractionOptions {
1565
+ /**
1566
+ * Sets which elements appear in the tooltip. See Interaction Modes for details.
1567
+ * @default 'nearest'
1568
+ */
1569
+ mode: InteractionMode;
1570
+ /**
1571
+ * if true, the hover mode only applies when the mouse position intersects an item on the chart.
1572
+ * @default true
1573
+ */
1574
+ intersect: boolean;
1575
+
1576
+ /**
1577
+ * Defines which directions are used in calculating distances. Defaults to 'x' for 'index' mode and 'xy' in dataset and 'nearest' modes.
1578
+ */
1579
+ axis: InteractionAxis;
1580
+
1581
+ /**
1582
+ * if true, the invisible points that are outside of the chart area will also be included when evaluating interactions.
1583
+ * @default false
1584
+ */
1585
+ includeInvisible: boolean;
1586
+ }
1587
+
1588
+ export interface CoreChartOptions<TType extends ChartType> extends ParsingOptions, AnimationOptions<TType> {
1589
+
1590
+ datasets: {
1591
+ [key in ChartType]: ChartTypeRegistry[key]['datasetOptions']
1592
+ }
1593
+
1594
+ /**
1595
+ * The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
1596
+ * @default 'x'
1597
+ */
1598
+ indexAxis: 'x' | 'y';
1599
+
1600
+ /**
1601
+ * How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside chartArea. 0 = clip at chartArea. Clipping can also be configured per side: `clip: {left: 5, top: false, right: -2, bottom: 0}`
1602
+ */
1603
+ clip: number | ChartArea | false;
1604
+
1605
+ /**
1606
+ * base color
1607
+ * @see Defaults.color
1608
+ */
1609
+ color: Scriptable<Color, ScriptableContext<TType>>;
1610
+ /**
1611
+ * base background color
1612
+ * @see Defaults.backgroundColor
1613
+ */
1614
+ backgroundColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
1615
+ /**
1616
+ * base hover background color
1617
+ * @see Defaults.hoverBackgroundColor
1618
+ */
1619
+ hoverBackgroundColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
1620
+ /**
1621
+ * base border color
1622
+ * @see Defaults.borderColor
1623
+ */
1624
+ borderColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
1625
+ /**
1626
+ * base hover border color
1627
+ * @see Defaults.hoverBorderColor
1628
+ */
1629
+ hoverBorderColor: ScriptableAndArray<Color, ScriptableContext<TType>>;
1630
+ /**
1631
+ * base font
1632
+ * @see Defaults.font
1633
+ */
1634
+ font: Partial<FontSpec>;
1635
+ /**
1636
+ * Resizes the chart canvas when its container does (important note...).
1637
+ * @default true
1638
+ */
1639
+ responsive: boolean;
1640
+ /**
1641
+ * Maintain the original canvas aspect ratio (width / height) when resizing. For this option to work properly the chart must be in its own dedicated container.
1642
+ * @default true
1643
+ */
1644
+ maintainAspectRatio: boolean;
1645
+ /**
1646
+ * Delay the resize update by give amount of milliseconds. This can ease the resize process by debouncing update of the elements.
1647
+ * @default 0
1648
+ */
1649
+ resizeDelay: number;
1650
+
1651
+ /**
1652
+ * Canvas aspect ratio (i.e. width / height, a value of 1 representing a square canvas). Note that this option is ignored if the height is explicitly defined either as attribute or via the style.
1653
+ * @default 2
1654
+ */
1655
+ aspectRatio: number;
1656
+
1657
+ /**
1658
+ * Locale used for number formatting (using `Intl.NumberFormat`).
1659
+ * @default user's browser setting
1660
+ */
1661
+ locale: string;
1662
+
1663
+ /**
1664
+ * Called when a resize occurs. Gets passed two arguments: the chart instance and the new size.
1665
+ */
1666
+ onResize(chart: Chart, size: { width: number; height: number }): void;
1667
+
1668
+ /**
1669
+ * Override the window's default devicePixelRatio.
1670
+ * @default window.devicePixelRatio
1671
+ */
1672
+ devicePixelRatio: number;
1673
+
1674
+ interaction: CoreInteractionOptions;
1675
+
1676
+ hover: CoreInteractionOptions;
1677
+
1678
+ /**
1679
+ * The events option defines the browser events that the chart should listen to for tooltips and hovering.
1680
+ * @default ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove']
1681
+ */
1682
+ events: (keyof HTMLElementEventMap)[]
1683
+
1684
+ /**
1685
+ * Called when any of the events fire. Passed the event, an array of active elements (bars, points, etc), and the chart.
1686
+ */
1687
+ onHover(event: ChartEvent, elements: ActiveElement[], chart: Chart): void;
1688
+
1689
+ /**
1690
+ * Called if the event is of type 'mouseup' or 'click'. Passed the event, an array of active elements, and the chart.
1691
+ */
1692
+ onClick(event: ChartEvent, elements: ActiveElement[], chart: Chart): void;
1693
+
1694
+ layout: Partial<{
1695
+ autoPadding: boolean;
1696
+ padding: Scriptable<Padding, ScriptableContext<TType>>;
1697
+ }>;
1698
+ }
1699
+
1700
+ export type AnimationSpec<TType extends ChartType> = {
1701
+ /**
1702
+ * The number of milliseconds an animation takes.
1703
+ * @default 1000
1704
+ */
1705
+ duration?: Scriptable<number, ScriptableContext<TType>>;
1706
+ /**
1707
+ * Easing function to use
1708
+ * @default 'easeOutQuart'
1709
+ */
1710
+ easing?: Scriptable<EasingFunction, ScriptableContext<TType>>;
1711
+
1712
+ /**
1713
+ * Delay before starting the animations.
1714
+ * @default 0
1715
+ */
1716
+ delay?: Scriptable<number, ScriptableContext<TType>>;
1717
+
1718
+ /**
1719
+ * If set to true, the animations loop endlessly.
1720
+ * @default false
1721
+ */
1722
+ loop?: Scriptable<boolean, ScriptableContext<TType>>;
1723
+ }
1724
+
1725
+ export type AnimationsSpec<TType extends ChartType> = {
1726
+ [name: string]: false | AnimationSpec<TType> & {
1727
+ properties: string[];
1728
+
1729
+ /**
1730
+ * Type of property, determines the interpolator used. Possible values: 'number', 'color' and 'boolean'. Only really needed for 'color', because typeof does not get that right.
1731
+ */
1732
+ type: 'color' | 'number' | 'boolean';
1733
+
1734
+ fn: <T>(from: T, to: T, factor: number) => T;
1735
+
1736
+ /**
1737
+ * Start value for the animation. Current value is used when undefined
1738
+ */
1739
+ from: Scriptable<Color | number | boolean, ScriptableContext<TType>>;
1740
+ /**
1741
+ *
1742
+ */
1743
+ to: Scriptable<Color | number | boolean, ScriptableContext<TType>>;
1744
+ }
1745
+ }
1746
+
1747
+ export type TransitionSpec<TType extends ChartType> = {
1748
+ animation: AnimationSpec<TType>;
1749
+ animations: AnimationsSpec<TType>;
1750
+ }
1751
+
1752
+ export type TransitionsSpec<TType extends ChartType> = {
1753
+ [mode: string]: TransitionSpec<TType>
1754
+ }
1755
+
1756
+ export type AnimationOptions<TType extends ChartType> = {
1757
+ animation: false | AnimationSpec<TType> & {
1758
+ /**
1759
+ * Callback called on each step of an animation.
1760
+ */
1761
+ onProgress?: (this: Chart, event: AnimationEvent) => void;
1762
+ /**
1763
+ * Callback called when all animations are completed.
1764
+ */
1765
+ onComplete?: (this: Chart, event: AnimationEvent) => void;
1766
+ };
1767
+ animations: AnimationsSpec<TType>;
1768
+ transitions: TransitionsSpec<TType>;
1769
+ };
1770
+
1771
+ export interface FontSpec {
1772
+ /**
1773
+ * Default font family for all text, follows CSS font-family options.
1774
+ * @default "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
1775
+ */
1776
+ family: string;
1777
+ /**
1778
+ * Default font size (in px) for text. Does not apply to radialLinear scale point labels.
1779
+ * @default 12
1780
+ */
1781
+ size: number;
1782
+ /**
1783
+ * Default font style. Does not apply to tooltip title or footer. Does not apply to chart title. Follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit)
1784
+ * @default 'normal'
1785
+ */
1786
+ style: 'normal' | 'italic' | 'oblique' | 'initial' | 'inherit';
1787
+ /**
1788
+ * Default font weight (boldness). (see MDN).
1789
+ */
1790
+ weight: 'normal' | 'bold' | 'lighter' | 'bolder' | number | null;
1791
+ /**
1792
+ * Height of an individual line of text (see MDN).
1793
+ * @default 1.2
1794
+ */
1795
+ lineHeight: number | string;
1796
+ }
1797
+
1798
+ export interface CanvasFontSpec extends FontSpec {
1799
+ string: string;
1800
+ }
1801
+
1802
+ export type TextAlign = 'left' | 'center' | 'right';
1803
+ export type Align = 'start' | 'center' | 'end';
1804
+
1805
+ export interface VisualElement {
1806
+ draw(ctx: CanvasRenderingContext2D, area?: ChartArea): void;
1807
+ inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean;
1808
+ inXRange(mouseX: number, useFinalPosition?: boolean): boolean;
1809
+ inYRange(mouseY: number, useFinalPosition?: boolean): boolean;
1810
+ getCenterPoint(useFinalPosition?: boolean): Point;
1811
+ getRange?(axis: 'x' | 'y'): number;
1812
+ }
1813
+
1814
+ export interface CommonElementOptions {
1815
+ borderWidth: number;
1816
+ borderColor: Color;
1817
+ backgroundColor: Color;
1818
+ }
1819
+
1820
+ export interface CommonHoverOptions {
1821
+ hoverBorderWidth: number;
1822
+ hoverBorderColor: Color;
1823
+ hoverBackgroundColor: Color;
1824
+ }
1825
+
1826
+ export interface Segment {
1827
+ start: number;
1828
+ end: number;
1829
+ loop: boolean;
1830
+ }
1831
+
1832
+ export interface ArcBorderRadius {
1833
+ outerStart: number;
1834
+ outerEnd: number;
1835
+ innerStart: number;
1836
+ innerEnd: number;
1837
+ }
1838
+
1839
+ export interface ArcOptions extends CommonElementOptions {
1840
+ /**
1841
+ * Arc stroke alignment.
1842
+ */
1843
+ borderAlign: 'center' | 'inner';
1844
+ /**
1845
+ * Line dash. See MDN.
1846
+ * @default []
1847
+ */
1848
+ borderDash: number[];
1849
+ /**
1850
+ * Line dash offset. See MDN.
1851
+ * @default 0.0
1852
+ */
1853
+ borderDashOffset: number;
1854
+ /**
1855
+ * Line join style. See MDN. Default is 'round' when `borderAlign` is 'inner', else 'bevel'.
1856
+ */
1857
+ borderJoinStyle: CanvasLineJoin;
1858
+
1859
+ /**
1860
+ * Sets the border radius for arcs
1861
+ * @default 0
1862
+ */
1863
+ borderRadius: number | ArcBorderRadius;
1864
+
1865
+ /**
1866
+ * Arc offset (in pixels).
1867
+ */
1868
+ offset: number;
1869
+
1870
+ /**
1871
+ * If false, Arc will be flat.
1872
+ * @default true
1873
+ */
1874
+ circular: boolean;
1875
+
1876
+ /**
1877
+ * Spacing between arcs
1878
+ */
1879
+ spacing: number
1880
+ }
1881
+
1882
+ export interface ArcHoverOptions extends CommonHoverOptions {
1883
+ hoverBorderDash: number[];
1884
+ hoverBorderDashOffset: number;
1885
+ hoverOffset: number;
1886
+ }
1887
+
1888
+ export interface LineProps {
1889
+ points: Point[]
1890
+ }
1891
+
1892
+ export interface LineOptions extends CommonElementOptions {
1893
+ /**
1894
+ * Line cap style. See MDN.
1895
+ * @default 'butt'
1896
+ */
1897
+ borderCapStyle: CanvasLineCap;
1898
+ /**
1899
+ * Line dash. See MDN.
1900
+ * @default []
1901
+ */
1902
+ borderDash: number[];
1903
+ /**
1904
+ * Line dash offset. See MDN.
1905
+ * @default 0.0
1906
+ */
1907
+ borderDashOffset: number;
1908
+ /**
1909
+ * Line join style. See MDN.
1910
+ * @default 'miter'
1911
+ */
1912
+ borderJoinStyle: CanvasLineJoin;
1913
+ /**
1914
+ * true to keep Bézier control inside the chart, false for no restriction.
1915
+ * @default true
1916
+ */
1917
+ capBezierPoints: boolean;
1918
+ /**
1919
+ * Interpolation mode to apply.
1920
+ * @default 'default'
1921
+ */
1922
+ cubicInterpolationMode: 'default' | 'monotone';
1923
+ /**
1924
+ * Bézier curve tension (0 for no Bézier curves).
1925
+ * @default 0
1926
+ */
1927
+ tension: number;
1928
+ /**
1929
+ * true to show the line as a stepped line (tension will be ignored).
1930
+ * @default false
1931
+ */
1932
+ stepped: 'before' | 'after' | 'middle' | boolean;
1933
+ /**
1934
+ * Both line and radar charts support a fill option on the dataset object which can be used to create area between two datasets or a dataset and a boundary, i.e. the scale origin, start or end
1935
+ */
1936
+ fill: FillTarget | ComplexFillTarget;
1937
+ /**
1938
+ * If true, lines will be drawn between points with no or null data. If false, points with NaN data will create a break in the line. Can also be a number specifying the maximum gap length to span. The unit of the value depends on the scale used.
1939
+ */
1940
+ spanGaps: boolean | number;
1941
+
1942
+ segment: {
1943
+ backgroundColor: Scriptable<Color|undefined, ScriptableLineSegmentContext>,
1944
+ borderColor: Scriptable<Color|undefined, ScriptableLineSegmentContext>,
1945
+ borderCapStyle: Scriptable<CanvasLineCap|undefined, ScriptableLineSegmentContext>;
1946
+ borderDash: Scriptable<number[]|undefined, ScriptableLineSegmentContext>;
1947
+ borderDashOffset: Scriptable<number|undefined, ScriptableLineSegmentContext>;
1948
+ borderJoinStyle: Scriptable<CanvasLineJoin|undefined, ScriptableLineSegmentContext>;
1949
+ borderWidth: Scriptable<number|undefined, ScriptableLineSegmentContext>;
1950
+ };
1951
+ }
1952
+
1953
+ export interface LineHoverOptions extends CommonHoverOptions {
1954
+ hoverBorderCapStyle: CanvasLineCap;
1955
+ hoverBorderDash: number[];
1956
+ hoverBorderDashOffset: number;
1957
+ hoverBorderJoinStyle: CanvasLineJoin;
1958
+ }
1959
+
1960
+ export interface LineElement<T extends LineProps = LineProps, O extends LineOptions = LineOptions>
1961
+ extends Element<T, O>,
1962
+ VisualElement {
1963
+ updateControlPoints(chartArea: ChartArea, indexAxis?: 'x' | 'y'): void;
1964
+ points: Point[];
1965
+ readonly segments: Segment[];
1966
+ first(): Point | false;
1967
+ last(): Point | false;
1968
+ interpolate(point: Point, property: 'x' | 'y'): undefined | Point | Point[];
1969
+ pathSegment(ctx: CanvasRenderingContext2D, segment: Segment, params: AnyObject): undefined | boolean;
1970
+ path(ctx: CanvasRenderingContext2D): boolean;
1971
+ }
1972
+
1973
+ export declare const LineElement: ChartComponent & {
1974
+ prototype: LineElement;
1975
+ new (cfg: AnyObject): LineElement;
1976
+ };
1977
+
1978
+ export type PointStyle =
1979
+ | 'circle'
1980
+ | 'cross'
1981
+ | 'crossRot'
1982
+ | 'dash'
1983
+ | 'line'
1984
+ | 'rect'
1985
+ | 'rectRounded'
1986
+ | 'rectRot'
1987
+ | 'star'
1988
+ | 'triangle'
1989
+ | false
1990
+ | HTMLImageElement
1991
+ | HTMLCanvasElement;
1992
+
1993
+ export interface PointOptions extends CommonElementOptions {
1994
+ /**
1995
+ * Point radius
1996
+ * @default 3
1997
+ */
1998
+ radius: number;
1999
+ /**
2000
+ * Extra radius added to point radius for hit detection.
2001
+ * @default 1
2002
+ */
2003
+ hitRadius: number;
2004
+ /**
2005
+ * Point style
2006
+ * @default 'circle;
2007
+ */
2008
+ pointStyle: PointStyle;
2009
+ /**
2010
+ * Point rotation (in degrees).
2011
+ * @default 0
2012
+ */
2013
+ rotation: number;
2014
+ /**
2015
+ * Draw the active elements over the other elements of the dataset,
2016
+ * @default true
2017
+ */
2018
+ drawActiveElementsOnTop: boolean;
2019
+ }
2020
+
2021
+ export interface PointHoverOptions extends CommonHoverOptions {
2022
+ /**
2023
+ * Point radius when hovered.
2024
+ * @default 4
2025
+ */
2026
+ hoverRadius: number;
2027
+ }
2028
+
2029
+ export interface PointPrefixedOptions {
2030
+ /**
2031
+ * The fill color for points.
2032
+ */
2033
+ pointBackgroundColor: Color;
2034
+ /**
2035
+ * The border color for points.
2036
+ */
2037
+ pointBorderColor: Color;
2038
+ /**
2039
+ * The width of the point border in pixels.
2040
+ */
2041
+ pointBorderWidth: number;
2042
+ /**
2043
+ * The pixel size of the non-displayed point that reacts to mouse events.
2044
+ */
2045
+ pointHitRadius: number;
2046
+ /**
2047
+ * The radius of the point shape. If set to 0, the point is not rendered.
2048
+ */
2049
+ pointRadius: number;
2050
+ /**
2051
+ * The rotation of the point in degrees.
2052
+ */
2053
+ pointRotation: number;
2054
+ /**
2055
+ * Style of the point.
2056
+ */
2057
+ pointStyle: PointStyle;
2058
+ }
2059
+
2060
+ export interface PointPrefixedHoverOptions {
2061
+ /**
2062
+ * Point background color when hovered.
2063
+ */
2064
+ pointHoverBackgroundColor: Color;
2065
+ /**
2066
+ * Point border color when hovered.
2067
+ */
2068
+ pointHoverBorderColor: Color;
2069
+ /**
2070
+ * Border width of point when hovered.
2071
+ */
2072
+ pointHoverBorderWidth: number;
2073
+ /**
2074
+ * The radius of the point when hovered.
2075
+ */
2076
+ pointHoverRadius: number;
2077
+ }
2078
+
2079
+ export interface BarProps extends Point {
2080
+ base: number;
2081
+ horizontal: boolean;
2082
+ width: number;
2083
+ height: number;
2084
+ }
2085
+
2086
+ export interface BarOptions extends Omit<CommonElementOptions, 'borderWidth'> {
2087
+ /**
2088
+ * The base value for the bar in data units along the value axis.
2089
+ */
2090
+ base: number;
2091
+
2092
+ /**
2093
+ * Skipped (excluded) border: 'start', 'end', 'left', 'right', 'bottom', 'top', 'middle', false (none) or true (all).
2094
+ * @default 'start'
2095
+ */
2096
+ borderSkipped: 'start' | 'end' | 'left' | 'right' | 'bottom' | 'top' | 'middle' | boolean;
2097
+
2098
+ /**
2099
+ * Border radius
2100
+ * @default 0
2101
+ */
2102
+ borderRadius: number | BorderRadius;
2103
+
2104
+ /**
2105
+ * Amount to inflate the rectangle(s). This can be used to hide artifacts between bars.
2106
+ * Unit is pixels. 'auto' translates to 0.33 pixels when barPercentage * categoryPercentage is 1, else 0.
2107
+ * @default 'auto'
2108
+ */
2109
+ inflateAmount: number | 'auto';
2110
+
2111
+ /**
2112
+ * Width of the border, number for all sides, object to specify width for each side specifically
2113
+ * @default 0
2114
+ */
2115
+ borderWidth: number | { top?: number, right?: number, bottom?: number, left?: number };
2116
+ }
2117
+
2118
+ export interface BorderRadius {
2119
+ topLeft: number;
2120
+ topRight: number;
2121
+ bottomLeft: number;
2122
+ bottomRight: number;
2123
+ }
2124
+
2125
+ export interface BarHoverOptions extends CommonHoverOptions {
2126
+ hoverBorderRadius: number | BorderRadius;
2127
+ }
2128
+
2129
+ export interface BarElement<
2130
+ T extends BarProps = BarProps,
2131
+ O extends BarOptions = BarOptions
2132
+ > extends Element<T, O>, VisualElement {}
2133
+
2134
+ export declare const BarElement: ChartComponent & {
2135
+ prototype: BarElement;
2136
+ new (cfg: AnyObject): BarElement;
2137
+ };
2138
+
2139
+ export interface ElementOptionsByType<TType extends ChartType> {
2140
+ arc: ScriptableAndArrayOptions<ArcOptions & ArcHoverOptions, ScriptableContext<TType>>;
2141
+ bar: ScriptableAndArrayOptions<BarOptions & BarHoverOptions, ScriptableContext<TType>>;
2142
+ line: ScriptableAndArrayOptions<LineOptions & LineHoverOptions, ScriptableContext<TType>>;
2143
+ point: ScriptableAndArrayOptions<PointOptions & PointHoverOptions, ScriptableContext<TType>>;
2144
+ }
2145
+
2146
+ export type ElementChartOptions<TType extends ChartType = ChartType> = {
2147
+ elements: ElementOptionsByType<TType>
2148
+ };
2149
+
2150
+ export declare class BasePlatform {
2151
+ /**
2152
+ * Called at chart construction time, returns a context2d instance implementing
2153
+ * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
2154
+ * @param {HTMLCanvasElement} canvas - The canvas from which to acquire context (platform specific)
2155
+ * @param options - The chart options
2156
+ */
2157
+ acquireContext(
2158
+ canvas: HTMLCanvasElement,
2159
+ options?: CanvasRenderingContext2DSettings
2160
+ ): CanvasRenderingContext2D | null;
2161
+ /**
2162
+ * Called at chart destruction time, releases any resources associated to the context
2163
+ * previously returned by the acquireContext() method.
2164
+ * @param {CanvasRenderingContext2D} context - The context2d instance
2165
+ * @returns {boolean} true if the method succeeded, else false
2166
+ */
2167
+ releaseContext(context: CanvasRenderingContext2D): boolean;
2168
+ /**
2169
+ * Registers the specified listener on the given chart.
2170
+ * @param {Chart} chart - Chart from which to listen for event
2171
+ * @param {string} type - The ({@link ChartEvent}) type to listen for
2172
+ * @param listener - Receives a notification (an object that implements
2173
+ * the {@link ChartEvent} interface) when an event of the specified type occurs.
2174
+ */
2175
+ addEventListener(chart: Chart, type: string, listener: (e: ChartEvent) => void): void;
2176
+ /**
2177
+ * Removes the specified listener previously registered with addEventListener.
2178
+ * @param {Chart} chart - Chart from which to remove the listener
2179
+ * @param {string} type - The ({@link ChartEvent}) type to remove
2180
+ * @param listener - The listener function to remove from the event target.
2181
+ */
2182
+ removeEventListener(chart: Chart, type: string, listener: (e: ChartEvent) => void): void;
2183
+ /**
2184
+ * @returns {number} the current devicePixelRatio of the device this platform is connected to.
2185
+ */
2186
+ getDevicePixelRatio(): number;
2187
+ /**
2188
+ * @param {HTMLCanvasElement} canvas - The canvas for which to calculate the maximum size
2189
+ * @param {number} [width] - Parent element's content width
2190
+ * @param {number} [height] - Parent element's content height
2191
+ * @param {number} [aspectRatio] - The aspect ratio to maintain
2192
+ * @returns { width: number, height: number } the maximum size available.
2193
+ */
2194
+ getMaximumSize(canvas: HTMLCanvasElement, width?: number, height?: number, aspectRatio?: number): { width: number, height: number };
2195
+ /**
2196
+ * @param {HTMLCanvasElement} canvas
2197
+ * @returns {boolean} true if the canvas is attached to the platform, false if not.
2198
+ */
2199
+ isAttached(canvas: HTMLCanvasElement): boolean;
2200
+ /**
2201
+ * Updates config with platform specific requirements
2202
+ * @param {ChartConfiguration | ChartConfigurationCustomTypes} config
2203
+ */
2204
+ updateConfig(config: ChartConfiguration | ChartConfigurationCustomTypesPerDataset): void;
2205
+ }
2206
+
2207
+ export declare class BasicPlatform extends BasePlatform {}
2208
+ export declare class DomPlatform extends BasePlatform {}
2209
+
2210
+ export declare const Decimation: Plugin;
2211
+
2212
+ export declare const enum DecimationAlgorithm {
2213
+ lttb = 'lttb',
2214
+ minmax = 'min-max',
2215
+ }
2216
+ interface BaseDecimationOptions {
2217
+ enabled: boolean;
2218
+ threshold?: number;
2219
+ }
2220
+
2221
+ interface LttbDecimationOptions extends BaseDecimationOptions {
2222
+ algorithm: DecimationAlgorithm.lttb | 'lttb';
2223
+ samples?: number;
2224
+ }
2225
+
2226
+ interface MinMaxDecimationOptions extends BaseDecimationOptions {
2227
+ algorithm: DecimationAlgorithm.minmax | 'min-max';
2228
+ }
2229
+
2230
+ export type DecimationOptions = LttbDecimationOptions | MinMaxDecimationOptions;
2231
+
2232
+ export declare const Filler: Plugin;
2233
+ export interface FillerOptions {
2234
+ drawTime: 'beforeDraw' | 'beforeDatasetDraw' | 'beforeDatasetsDraw';
2235
+ propagate: boolean;
2236
+ }
2237
+
2238
+ export type FillTarget = number | string | { value: number } | 'start' | 'end' | 'origin' | 'stack' | 'shape' | boolean;
2239
+
2240
+ export interface ComplexFillTarget {
2241
+ /**
2242
+ * The accepted values are the same as the filling mode values, so you may use absolute and relative dataset indexes and/or boundaries.
2243
+ */
2244
+ target: FillTarget;
2245
+ /**
2246
+ * If no color is set, the default color will be the background color of the chart.
2247
+ */
2248
+ above: Color;
2249
+ /**
2250
+ * Same as the above.
2251
+ */
2252
+ below: Color;
2253
+ }
2254
+
2255
+ export interface FillerControllerDatasetOptions {
2256
+ /**
2257
+ * Both line and radar charts support a fill option on the dataset object which can be used to create area between two datasets or a dataset and a boundary, i.e. the scale origin, start or end
2258
+ */
2259
+ fill: FillTarget | ComplexFillTarget;
2260
+ }
2261
+
2262
+ export declare const Legend: Plugin;
2263
+
2264
+ export interface LegendItem {
2265
+ /**
2266
+ * Label that will be displayed
2267
+ */
2268
+ text: string;
2269
+
2270
+ /**
2271
+ * Border radius of the legend box
2272
+ * @since 3.1.0
2273
+ */
2274
+ borderRadius?: number | BorderRadius;
2275
+
2276
+ /**
2277
+ * Index of the associated dataset
2278
+ */
2279
+ datasetIndex?: number;
2280
+
2281
+ /**
2282
+ * Index the associated label in the labels array
2283
+ */
2284
+ index?: number
2285
+
2286
+ /**
2287
+ * Fill style of the legend box
2288
+ */
2289
+ fillStyle?: Color;
2290
+
2291
+ /**
2292
+ * Font color for the text
2293
+ * Defaults to LegendOptions.labels.color
2294
+ */
2295
+ fontColor?: Color;
2296
+
2297
+ /**
2298
+ * If true, this item represents a hidden dataset. Label will be rendered with a strike-through effect
2299
+ */
2300
+ hidden?: boolean;
2301
+
2302
+ /**
2303
+ * For box border.
2304
+ * @see https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap
2305
+ */
2306
+ lineCap?: CanvasLineCap;
2307
+
2308
+ /**
2309
+ * For box border.
2310
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
2311
+ */
2312
+ lineDash?: number[];
2313
+
2314
+ /**
2315
+ * For box border.
2316
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
2317
+ */
2318
+ lineDashOffset?: number;
2319
+
2320
+ /**
2321
+ * For box border.
2322
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
2323
+ */
2324
+ lineJoin?: CanvasLineJoin;
2325
+
2326
+ /**
2327
+ * Width of box border
2328
+ */
2329
+ lineWidth?: number;
2330
+
2331
+ /**
2332
+ * Stroke style of the legend box
2333
+ */
2334
+ strokeStyle?: Color;
2335
+
2336
+ /**
2337
+ * Point style of the legend box (only used if usePointStyle is true)
2338
+ */
2339
+ pointStyle?: PointStyle;
2340
+
2341
+ /**
2342
+ * Rotation of the point in degrees (only used if usePointStyle is true)
2343
+ */
2344
+ rotation?: number;
2345
+
2346
+ /**
2347
+ * Text alignment
2348
+ */
2349
+ textAlign?: TextAlign;
2350
+ }
2351
+
2352
+ export interface LegendElement<TType extends ChartType> extends Element<AnyObject, LegendOptions<TType>>, LayoutItem {
2353
+ chart: Chart<TType>;
2354
+ ctx: CanvasRenderingContext2D;
2355
+ legendItems?: LegendItem[];
2356
+ options: LegendOptions<TType>;
2357
+ fit(): void;
2358
+ }
2359
+
2360
+ export interface LegendOptions<TType extends ChartType> {
2361
+ /**
2362
+ * Is the legend shown?
2363
+ * @default true
2364
+ */
2365
+ display: boolean;
2366
+ /**
2367
+ * Position of the legend.
2368
+ * @default 'top'
2369
+ */
2370
+ position: LayoutPosition;
2371
+ /**
2372
+ * Alignment of the legend.
2373
+ * @default 'center'
2374
+ */
2375
+ align: Align;
2376
+ /**
2377
+ * Maximum height of the legend, in pixels
2378
+ */
2379
+ maxHeight: number;
2380
+ /**
2381
+ * Maximum width of the legend, in pixels
2382
+ */
2383
+ maxWidth: number;
2384
+ /**
2385
+ * Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use.
2386
+ * @default true
2387
+ */
2388
+ fullSize: boolean;
2389
+ /**
2390
+ * Legend will show datasets in reverse order.
2391
+ * @default false
2392
+ */
2393
+ reverse: boolean;
2394
+ /**
2395
+ * A callback that is called when a click event is registered on a label item.
2396
+ */
2397
+ onClick(this: LegendElement<TType>, e: ChartEvent, legendItem: LegendItem, legend: LegendElement<TType>): void;
2398
+ /**
2399
+ * A callback that is called when a 'mousemove' event is registered on top of a label item
2400
+ */
2401
+ onHover(this: LegendElement<TType>, e: ChartEvent, legendItem: LegendItem, legend: LegendElement<TType>): void;
2402
+ /**
2403
+ * A callback that is called when a 'mousemove' event is registered outside of a previously hovered label item.
2404
+ */
2405
+ onLeave(this: LegendElement<TType>, e: ChartEvent, legendItem: LegendItem, legend: LegendElement<TType>): void;
2406
+
2407
+ labels: {
2408
+ /**
2409
+ * Width of colored box.
2410
+ * @default 40
2411
+ */
2412
+ boxWidth: number;
2413
+ /**
2414
+ * Height of the coloured box.
2415
+ * @default fontSize
2416
+ */
2417
+ boxHeight: number;
2418
+ /**
2419
+ * Color of label
2420
+ * @see Defaults.color
2421
+ */
2422
+ color: Color;
2423
+ /**
2424
+ * Font of label
2425
+ * @see Defaults.font
2426
+ */
2427
+ font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableChartContext>;
2428
+ /**
2429
+ * Padding between rows of colored boxes.
2430
+ * @default 10
2431
+ */
2432
+ padding: number;
2433
+ /**
2434
+ * If usePointStyle is true, the width of the point style used for the legend.
2435
+ */
2436
+ pointStyleWidth: number;
2437
+ /**
2438
+ * Generates legend items for each thing in the legend. Default implementation returns the text + styling for the color box. See Legend Item for details.
2439
+ */
2440
+ generateLabels(chart: Chart): LegendItem[];
2441
+
2442
+ /**
2443
+ * Filters legend items out of the legend. Receives 2 parameters, a Legend Item and the chart data
2444
+ */
2445
+ filter(item: LegendItem, data: ChartData): boolean;
2446
+
2447
+ /**
2448
+ * Sorts the legend items
2449
+ */
2450
+ sort(a: LegendItem, b: LegendItem, data: ChartData): number;
2451
+
2452
+ /**
2453
+ * Override point style for the legend. Only applies if usePointStyle is true
2454
+ */
2455
+ pointStyle: PointStyle;
2456
+
2457
+ /**
2458
+ * Text alignment
2459
+ */
2460
+ textAlign?: TextAlign;
2461
+
2462
+ /**
2463
+ * Label style will match corresponding point style (size is based on the minimum value between boxWidth and font.size).
2464
+ * @default false
2465
+ */
2466
+ usePointStyle: boolean;
2467
+
2468
+ /**
2469
+ * Label borderRadius will match corresponding borderRadius.
2470
+ * @default false
2471
+ */
2472
+ useBorderRadius: boolean;
2473
+
2474
+ /**
2475
+ * Override the borderRadius to use.
2476
+ * @default undefined
2477
+ */
2478
+ borderRadius: number;
2479
+ };
2480
+ /**
2481
+ * true for rendering the legends from right to left.
2482
+ */
2483
+ rtl: boolean;
2484
+ /**
2485
+ * This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the legend, regardless of the css specified on the canvas
2486
+ * @default canvas's default
2487
+ */
2488
+ textDirection: string;
2489
+
2490
+ title: {
2491
+ /**
2492
+ * Is the legend title displayed.
2493
+ * @default false
2494
+ */
2495
+ display: boolean;
2496
+ /**
2497
+ * Color of title
2498
+ * @see Defaults.color
2499
+ */
2500
+ color: Color;
2501
+ /**
2502
+ * see Fonts
2503
+ */
2504
+ font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableChartContext>;
2505
+ position: 'center' | 'start' | 'end';
2506
+ padding?: number | ChartArea;
2507
+ /**
2508
+ * The string title.
2509
+ */
2510
+ text: string;
2511
+ };
2512
+ }
2513
+
2514
+ export declare const SubTitle: Plugin;
2515
+ export declare const Title: Plugin;
2516
+
2517
+ export interface TitleOptions {
2518
+ /**
2519
+ * Alignment of the title.
2520
+ * @default 'center'
2521
+ */
2522
+ align: Align;
2523
+ /**
2524
+ * Is the title shown?
2525
+ * @default false
2526
+ */
2527
+ display: boolean;
2528
+ /**
2529
+ * Position of title
2530
+ * @default 'top'
2531
+ */
2532
+ position: 'top' | 'left' | 'bottom' | 'right';
2533
+ /**
2534
+ * Color of text
2535
+ * @see Defaults.color
2536
+ */
2537
+ color: Color;
2538
+ font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableChartContext>;
2539
+
2540
+ /**
2541
+ * Marks that this box should take the full width/height of the canvas (moving other boxes). If set to `false`, places the box above/beside the
2542
+ * chart area
2543
+ * @default true
2544
+ */
2545
+ fullSize: boolean;
2546
+ /**
2547
+ * Adds padding above and below the title text if a single number is specified. It is also possible to change top and bottom padding separately.
2548
+ */
2549
+ padding: number | { top: number; bottom: number };
2550
+ /**
2551
+ * Title text to display. If specified as an array, text is rendered on multiple lines.
2552
+ */
2553
+ text: string | string[];
2554
+ }
2555
+
2556
+ export type TooltipXAlignment = 'left' | 'center' | 'right';
2557
+ export type TooltipYAlignment = 'top' | 'center' | 'bottom';
2558
+ export interface TooltipLabelStyle {
2559
+ borderColor: Color;
2560
+ backgroundColor: Color;
2561
+
2562
+ /**
2563
+ * Width of border line
2564
+ * @since 3.1.0
2565
+ */
2566
+ borderWidth?: number;
2567
+
2568
+ /**
2569
+ * Border dash
2570
+ * @since 3.1.0
2571
+ */
2572
+ borderDash?: [number, number];
2573
+
2574
+ /**
2575
+ * Border dash offset
2576
+ * @since 3.1.0
2577
+ */
2578
+ borderDashOffset?: number;
2579
+
2580
+ /**
2581
+ * borderRadius
2582
+ * @since 3.1.0
2583
+ */
2584
+ borderRadius?: number | BorderRadius;
2585
+ }
2586
+ export interface TooltipModel<TType extends ChartType> extends Element<AnyObject, TooltipOptions<TType>> {
2587
+ readonly chart: Chart<TType>;
2588
+
2589
+ // The items that we are rendering in the tooltip. See Tooltip Item Interface section
2590
+ dataPoints: TooltipItem<TType>[];
2591
+
2592
+ // Positioning
2593
+ xAlign: TooltipXAlignment;
2594
+ yAlign: TooltipYAlignment;
2595
+
2596
+ // X and Y properties are the top left of the tooltip
2597
+ x: number;
2598
+ y: number;
2599
+ width: number;
2600
+ height: number;
2601
+ // Where the tooltip points to
2602
+ caretX: number;
2603
+ caretY: number;
2604
+
2605
+ // Body
2606
+ // The body lines that need to be rendered
2607
+ // Each object contains 3 parameters
2608
+ // before: string[] // lines of text before the line with the color square
2609
+ // lines: string[]; // lines of text to render as the main item with color square
2610
+ // after: string[]; // lines of text to render after the main lines
2611
+ body: { before: string[]; lines: string[]; after: string[] }[];
2612
+ // lines of text that appear after the title but before the body
2613
+ beforeBody: string[];
2614
+ // line of text that appear after the body and before the footer
2615
+ afterBody: string[];
2616
+
2617
+ // Title
2618
+ // lines of text that form the title
2619
+ title: string[];
2620
+
2621
+ // Footer
2622
+ // lines of text that form the footer
2623
+ footer: string[];
2624
+
2625
+ // Styles to render for each item in body[]. This is the styling of the squares in the tooltip
2626
+ labelColors: TooltipLabelStyle[];
2627
+ labelTextColors: Color[];
2628
+ labelPointStyles: { pointStyle: PointStyle; rotation: number }[];
2629
+
2630
+ // 0 opacity is a hidden tooltip
2631
+ opacity: number;
2632
+
2633
+ // tooltip options
2634
+ options: TooltipOptions<TType>;
2635
+
2636
+ getActiveElements(): ActiveElement[];
2637
+ setActiveElements(active: ActiveDataPoint[], eventPosition: Point): void;
2638
+ }
2639
+
2640
+ export interface TooltipPosition extends Point {
2641
+ xAlign?: TooltipXAlignment;
2642
+ yAlign?: TooltipYAlignment;
2643
+ }
2644
+
2645
+ export type TooltipPositionerFunction<TType extends ChartType> = (
2646
+ this: TooltipModel<TType>,
2647
+ items: readonly ActiveElement[],
2648
+ eventPosition: Point
2649
+ ) => TooltipPosition | false;
2650
+
2651
+ export interface TooltipPositionerMap {
2652
+ average: TooltipPositionerFunction<ChartType>;
2653
+ nearest: TooltipPositionerFunction<ChartType>;
2654
+ }
2655
+
2656
+ export type TooltipPositioner = keyof TooltipPositionerMap;
2657
+
2658
+ export interface Tooltip extends Plugin {
2659
+ readonly positioners: TooltipPositionerMap;
2660
+ }
2661
+
2662
+ export declare const Tooltip: Tooltip;
2663
+
2664
+ export interface TooltipCallbacks<
2665
+ TType extends ChartType,
2666
+ Model = TooltipModel<TType>,
2667
+ Item = TooltipItem<TType>> {
2668
+
2669
+ beforeTitle(this: Model, tooltipItems: Item[]): string | string[] | void;
2670
+ title(this: Model, tooltipItems: Item[]): string | string[] | void;
2671
+ afterTitle(this: Model, tooltipItems: Item[]): string | string[] | void;
2672
+
2673
+ beforeBody(this: Model, tooltipItems: Item[]): string | string[] | void;
2674
+ afterBody(this: Model, tooltipItems: Item[]): string | string[] | void;
2675
+
2676
+ beforeLabel(this: Model, tooltipItem: Item): string | string[] | void;
2677
+ label(this: Model, tooltipItem: Item): string | string[] | void;
2678
+ afterLabel(this: Model, tooltipItem: Item): string | string[] | void;
2679
+
2680
+ labelColor(this: Model, tooltipItem: Item): TooltipLabelStyle | void;
2681
+ labelTextColor(this: Model, tooltipItem: Item): Color | void;
2682
+ labelPointStyle(this: Model, tooltipItem: Item): { pointStyle: PointStyle; rotation: number } | void;
2683
+
2684
+ beforeFooter(this: Model, tooltipItems: Item[]): string | string[] | void;
2685
+ footer(this: Model, tooltipItems: Item[]): string | string[] | void;
2686
+ afterFooter(this: Model, tooltipItems: Item[]): string | string[] | void;
2687
+ }
2688
+
2689
+ export interface ExtendedPlugin<
2690
+ TType extends ChartType,
2691
+ O = AnyObject,
2692
+ Model = TooltipModel<TType>> {
2693
+ /**
2694
+ * @desc Called before drawing the `tooltip`. If any plugin returns `false`,
2695
+ * the tooltip drawing is cancelled until another `render` is triggered.
2696
+ * @param {Chart} chart - The chart instance.
2697
+ * @param {object} args - The call arguments.
2698
+ * @param {Tooltip} args.tooltip - The tooltip.
2699
+ * @param {object} options - The plugin options.
2700
+ * @returns {boolean} `false` to cancel the chart tooltip drawing.
2701
+ */
2702
+ beforeTooltipDraw?(chart: Chart, args: { tooltip: Model, cancelable: true }, options: O): boolean | void;
2703
+ /**
2704
+ * @desc Called after drawing the `tooltip`. Note that this hook will not
2705
+ * be called if the tooltip drawing has been previously cancelled.
2706
+ * @param {Chart} chart - The chart instance.
2707
+ * @param {object} args - The call arguments.
2708
+ * @param {Tooltip} args.tooltip - The tooltip.
2709
+ * @param {object} options - The plugin options.
2710
+ */
2711
+ afterTooltipDraw?(chart: Chart, args: { tooltip: Model }, options: O): void;
2712
+ }
2713
+
2714
+ export interface ScriptableTooltipContext<TType extends ChartType> {
2715
+ chart: UnionToIntersection<Chart<TType>>;
2716
+ tooltip: UnionToIntersection<TooltipModel<TType>>;
2717
+ tooltipItems: TooltipItem<TType>[];
2718
+ }
2719
+
2720
+ export interface TooltipOptions<TType extends ChartType = ChartType> extends CoreInteractionOptions {
2721
+ /**
2722
+ * Are on-canvas tooltips enabled?
2723
+ * @default true
2724
+ */
2725
+ enabled: Scriptable<boolean, ScriptableTooltipContext<TType>>;
2726
+ /**
2727
+ * See external tooltip section.
2728
+ */
2729
+ external(this: TooltipModel<TType>, args: { chart: Chart; tooltip: TooltipModel<TType> }): void;
2730
+ /**
2731
+ * The mode for positioning the tooltip
2732
+ */
2733
+ position: Scriptable<TooltipPositioner, ScriptableTooltipContext<TType>>
2734
+
2735
+ /**
2736
+ * Override the tooltip alignment calculations
2737
+ */
2738
+ xAlign: Scriptable<TooltipXAlignment, ScriptableTooltipContext<TType>>;
2739
+ yAlign: Scriptable<TooltipYAlignment, ScriptableTooltipContext<TType>>;
2740
+
2741
+ /**
2742
+ * Sort tooltip items.
2743
+ */
2744
+ itemSort: (a: TooltipItem<TType>, b: TooltipItem<TType>, data: ChartData) => number;
2745
+
2746
+ filter: (e: TooltipItem<TType>, index: number, array: TooltipItem<TType>[], data: ChartData) => boolean;
2747
+
2748
+ /**
2749
+ * Background color of the tooltip.
2750
+ * @default 'rgba(0, 0, 0, 0.8)'
2751
+ */
2752
+ backgroundColor: Scriptable<Color, ScriptableTooltipContext<TType>>;
2753
+ /**
2754
+ * Padding between the color box and the text.
2755
+ * @default 1
2756
+ */
2757
+ boxPadding: number;
2758
+ /**
2759
+ * Color of title
2760
+ * @default '#fff'
2761
+ */
2762
+ titleColor: Scriptable<Color, ScriptableTooltipContext<TType>>;
2763
+ /**
2764
+ * See Fonts
2765
+ * @default {weight: 'bold'}
2766
+ */
2767
+ titleFont: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableTooltipContext<TType>>;
2768
+ /**
2769
+ * Spacing to add to top and bottom of each title line.
2770
+ * @default 2
2771
+ */
2772
+ titleSpacing: Scriptable<number, ScriptableTooltipContext<TType>>;
2773
+ /**
2774
+ * Margin to add on bottom of title section.
2775
+ * @default 6
2776
+ */
2777
+ titleMarginBottom: Scriptable<number, ScriptableTooltipContext<TType>>;
2778
+ /**
2779
+ * Horizontal alignment of the title text lines.
2780
+ * @default 'left'
2781
+ */
2782
+ titleAlign: Scriptable<TextAlign, ScriptableTooltipContext<TType>>;
2783
+ /**
2784
+ * Spacing to add to top and bottom of each tooltip item.
2785
+ * @default 2
2786
+ */
2787
+ bodySpacing: Scriptable<number, ScriptableTooltipContext<TType>>;
2788
+ /**
2789
+ * Color of body
2790
+ * @default '#fff'
2791
+ */
2792
+ bodyColor: Scriptable<Color, ScriptableTooltipContext<TType>>;
2793
+ /**
2794
+ * See Fonts.
2795
+ * @default {}
2796
+ */
2797
+ bodyFont: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableTooltipContext<TType>>;
2798
+ /**
2799
+ * Horizontal alignment of the body text lines.
2800
+ * @default 'left'
2801
+ */
2802
+ bodyAlign: Scriptable<TextAlign, ScriptableTooltipContext<TType>>;
2803
+ /**
2804
+ * Spacing to add to top and bottom of each footer line.
2805
+ * @default 2
2806
+ */
2807
+ footerSpacing: Scriptable<number, ScriptableTooltipContext<TType>>;
2808
+ /**
2809
+ * Margin to add before drawing the footer.
2810
+ * @default 6
2811
+ */
2812
+ footerMarginTop: Scriptable<number, ScriptableTooltipContext<TType>>;
2813
+ /**
2814
+ * Color of footer
2815
+ * @default '#fff'
2816
+ */
2817
+ footerColor: Scriptable<Color, ScriptableTooltipContext<TType>>;
2818
+ /**
2819
+ * See Fonts
2820
+ * @default {weight: 'bold'}
2821
+ */
2822
+ footerFont: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableTooltipContext<TType>>;
2823
+ /**
2824
+ * Horizontal alignment of the footer text lines.
2825
+ * @default 'left'
2826
+ */
2827
+ footerAlign: Scriptable<TextAlign, ScriptableTooltipContext<TType>>;
2828
+ /**
2829
+ * Padding to add to the tooltip
2830
+ * @default 6
2831
+ */
2832
+ padding: Scriptable<Padding, ScriptableTooltipContext<TType>>;
2833
+ /**
2834
+ * Extra distance to move the end of the tooltip arrow away from the tooltip point.
2835
+ * @default 2
2836
+ */
2837
+ caretPadding: Scriptable<number, ScriptableTooltipContext<TType>>;
2838
+ /**
2839
+ * Size, in px, of the tooltip arrow.
2840
+ * @default 5
2841
+ */
2842
+ caretSize: Scriptable<number, ScriptableTooltipContext<TType>>;
2843
+ /**
2844
+ * Radius of tooltip corner curves.
2845
+ * @default 6
2846
+ */
2847
+ cornerRadius: Scriptable<number | BorderRadius, ScriptableTooltipContext<TType>>;
2848
+ /**
2849
+ * Color to draw behind the colored boxes when multiple items are in the tooltip.
2850
+ * @default '#fff'
2851
+ */
2852
+ multiKeyBackground: Scriptable<Color, ScriptableTooltipContext<TType>>;
2853
+ /**
2854
+ * If true, color boxes are shown in the tooltip.
2855
+ * @default true
2856
+ */
2857
+ displayColors: Scriptable<boolean, ScriptableTooltipContext<TType>>;
2858
+ /**
2859
+ * Width of the color box if displayColors is true.
2860
+ * @default bodyFont.size
2861
+ */
2862
+ boxWidth: Scriptable<number, ScriptableTooltipContext<TType>>;
2863
+ /**
2864
+ * Height of the color box if displayColors is true.
2865
+ * @default bodyFont.size
2866
+ */
2867
+ boxHeight: Scriptable<number, ScriptableTooltipContext<TType>>;
2868
+ /**
2869
+ * Use the corresponding point style (from dataset options) instead of color boxes, ex: star, triangle etc. (size is based on the minimum value between boxWidth and boxHeight)
2870
+ * @default false
2871
+ */
2872
+ usePointStyle: Scriptable<boolean, ScriptableTooltipContext<TType>>;
2873
+ /**
2874
+ * Color of the border.
2875
+ * @default 'rgba(0, 0, 0, 0)'
2876
+ */
2877
+ borderColor: Scriptable<Color, ScriptableTooltipContext<TType>>;
2878
+ /**
2879
+ * Size of the border.
2880
+ * @default 0
2881
+ */
2882
+ borderWidth: Scriptable<number, ScriptableTooltipContext<TType>>;
2883
+ /**
2884
+ * true for rendering the legends from right to left.
2885
+ */
2886
+ rtl: Scriptable<boolean, ScriptableTooltipContext<TType>>;
2887
+
2888
+ /**
2889
+ * This will force the text direction 'rtl' or 'ltr on the canvas for rendering the tooltips, regardless of the css specified on the canvas
2890
+ * @default canvas's default
2891
+ */
2892
+ textDirection: Scriptable<string, ScriptableTooltipContext<TType>>;
2893
+
2894
+ animation: AnimationSpec<TType> | false;
2895
+ animations: AnimationsSpec<TType> | false;
2896
+ callbacks: TooltipCallbacks<TType>;
2897
+ }
2898
+
2899
+ export interface TooltipItem<TType extends ChartType> {
2900
+ /**
2901
+ * The chart the tooltip is being shown on
2902
+ */
2903
+ chart: Chart;
2904
+
2905
+ /**
2906
+ * Label for the tooltip
2907
+ */
2908
+ label: string;
2909
+
2910
+ /**
2911
+ * Parsed data values for the given `dataIndex` and `datasetIndex`
2912
+ */
2913
+ parsed: UnionToIntersection<ParsedDataType<TType>>;
2914
+
2915
+ /**
2916
+ * Raw data values for the given `dataIndex` and `datasetIndex`
2917
+ */
2918
+ raw: unknown;
2919
+
2920
+ /**
2921
+ * Formatted value for the tooltip
2922
+ */
2923
+ formattedValue: string;
2924
+
2925
+ /**
2926
+ * The dataset the item comes from
2927
+ */
2928
+ dataset: UnionToIntersection<ChartDataset<TType>>;
2929
+
2930
+ /**
2931
+ * Index of the dataset the item comes from
2932
+ */
2933
+ datasetIndex: number;
2934
+
2935
+ /**
2936
+ * Index of this data item in the dataset
2937
+ */
2938
+ dataIndex: number;
2939
+
2940
+ /**
2941
+ * The chart element (point, arc, bar, etc.) for this tooltip item
2942
+ */
2943
+ element: Element;
2944
+ }
2945
+
2946
+ export interface PluginOptionsByType<TType extends ChartType> {
2947
+ colors: ColorsPluginOptions;
2948
+ decimation: DecimationOptions;
2949
+ filler: FillerOptions;
2950
+ legend: LegendOptions<TType>;
2951
+ subtitle: TitleOptions;
2952
+ title: TitleOptions;
2953
+ tooltip: TooltipOptions<TType>;
2954
+ }
2955
+ export interface PluginChartOptions<TType extends ChartType> {
2956
+ plugins: PluginOptionsByType<TType>;
2957
+ }
2958
+
2959
+ export interface BorderOptions {
2960
+ /**
2961
+ * @default true
2962
+ */
2963
+ display: boolean
2964
+ /**
2965
+ * @default []
2966
+ */
2967
+ dash: Scriptable<number[], ScriptableScaleContext>;
2968
+ /**
2969
+ * @default 0
2970
+ */
2971
+ dashOffset: Scriptable<number, ScriptableScaleContext>;
2972
+ color: Color;
2973
+ width: number;
2974
+ z: number;
2975
+ }
2976
+
2977
+ export interface GridLineOptions {
2978
+ /**
2979
+ * @default true
2980
+ */
2981
+ display: boolean;
2982
+ /**
2983
+ * @default false
2984
+ */
2985
+ circular: boolean;
2986
+ /**
2987
+ * @default 'rgba(0, 0, 0, 0.1)'
2988
+ */
2989
+ color: ScriptableAndArray<Color, ScriptableScaleContext>;
2990
+ /**
2991
+ * @default 1
2992
+ */
2993
+ lineWidth: ScriptableAndArray<number, ScriptableScaleContext>;
2994
+ /**
2995
+ * @default true
2996
+ */
2997
+ drawOnChartArea: boolean;
2998
+ /**
2999
+ * @default true
3000
+ */
3001
+ drawTicks: boolean;
3002
+ /**
3003
+ * @default []
3004
+ */
3005
+ tickBorderDash: Scriptable<number[], ScriptableScaleContext>;
3006
+ /**
3007
+ * @default 0
3008
+ */
3009
+ tickBorderDashOffset: Scriptable<number, ScriptableScaleContext>;
3010
+ /**
3011
+ * @default 'rgba(0, 0, 0, 0.1)'
3012
+ */
3013
+ tickColor: ScriptableAndArray<Color, ScriptableScaleContext>;
3014
+ /**
3015
+ * @default 10
3016
+ */
3017
+ tickLength: number;
3018
+ /**
3019
+ * @default 1
3020
+ */
3021
+ tickWidth: number;
3022
+ /**
3023
+ * @default false
3024
+ */
3025
+ offset: boolean;
3026
+ /**
3027
+ * @default 0
3028
+ */
3029
+ z: number;
3030
+ }
3031
+
3032
+ export interface TickOptions {
3033
+ /**
3034
+ * Color of label backdrops.
3035
+ * @default 'rgba(255, 255, 255, 0.75)'
3036
+ */
3037
+ backdropColor: Scriptable<Color, ScriptableScaleContext>;
3038
+ /**
3039
+ * Padding of tick backdrop.
3040
+ * @default 2
3041
+ */
3042
+ backdropPadding: number | ChartArea;
3043
+
3044
+ /**
3045
+ * Returns the string representation of the tick value as it should be displayed on the chart. See callback.
3046
+ */
3047
+ callback: (this: Scale, tickValue: number | string, index: number, ticks: Tick[]) => string | string[] | number | number[] | null | undefined;
3048
+ /**
3049
+ * If true, show tick labels.
3050
+ * @default true
3051
+ */
3052
+ display: boolean;
3053
+ /**
3054
+ * Color of tick
3055
+ * @see Defaults.color
3056
+ */
3057
+ color: ScriptableAndArray<Color, ScriptableScaleContext>;
3058
+ /**
3059
+ * see Fonts
3060
+ */
3061
+ font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableScaleContext>;
3062
+ /**
3063
+ * Sets the offset of the tick labels from the axis
3064
+ */
3065
+ padding: number;
3066
+ /**
3067
+ * If true, draw a background behind the tick labels.
3068
+ * @default false
3069
+ */
3070
+ showLabelBackdrop: Scriptable<boolean, ScriptableScaleContext>;
3071
+ /**
3072
+ * The color of the stroke around the text.
3073
+ * @default undefined
3074
+ */
3075
+ textStrokeColor: Scriptable<Color, ScriptableScaleContext>;
3076
+ /**
3077
+ * Stroke width around the text.
3078
+ * @default 0
3079
+ */
3080
+ textStrokeWidth: Scriptable<number, ScriptableScaleContext>;
3081
+ /**
3082
+ * z-index of tick layer. Useful when ticks are drawn on chart area. Values <= 0 are drawn under datasets, > 0 on top.
3083
+ * @default 0
3084
+ */
3085
+ z: number;
3086
+
3087
+ major: {
3088
+ /**
3089
+ * If true, major ticks are generated. A major tick will affect autoskipping and major will be defined on ticks in the scriptable options context.
3090
+ * @default false
3091
+ */
3092
+ enabled: boolean;
3093
+ };
3094
+ }
3095
+
3096
+ export type CartesianTickOptions = TickOptions & {
3097
+ /**
3098
+ * The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
3099
+ * @default ticks.length
3100
+ */
3101
+ sampleSize: number;
3102
+ /**
3103
+ * The label alignment
3104
+ * @default 'center'
3105
+ */
3106
+ align: Align | 'inner';
3107
+ /**
3108
+ * If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to maxRotation before skipping any. Turn autoSkip off to show all labels no matter what.
3109
+ * @default true
3110
+ */
3111
+ autoSkip: boolean;
3112
+ /**
3113
+ * Padding between the ticks on the horizontal axis when autoSkip is enabled.
3114
+ * @default 0
3115
+ */
3116
+ autoSkipPadding: number;
3117
+
3118
+ /**
3119
+ * How is the label positioned perpendicular to the axis direction.
3120
+ * This only applies when the rotation is 0 and the axis position is one of "top", "left", "right", or "bottom"
3121
+ * @default 'near'
3122
+ */
3123
+ crossAlign: 'near' | 'center' | 'far';
3124
+
3125
+ /**
3126
+ * Should the defined `min` and `max` values be presented as ticks even if they are not "nice".
3127
+ * @default: true
3128
+ */
3129
+ includeBounds: boolean;
3130
+
3131
+ /**
3132
+ * Distance in pixels to offset the label from the centre point of the tick (in the x direction for the x axis, and the y direction for the y axis). Note: this can cause labels at the edges to be cropped by the edge of the canvas
3133
+ * @default 0
3134
+ */
3135
+ labelOffset: number;
3136
+
3137
+ /**
3138
+ * Minimum rotation for tick labels. Note: Only applicable to horizontal scales.
3139
+ * @default 0
3140
+ */
3141
+ minRotation: number;
3142
+ /**
3143
+ * Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn't occur until necessary. Note: Only applicable to horizontal scales.
3144
+ * @default 50
3145
+ */
3146
+ maxRotation: number;
3147
+ /**
3148
+ * Flips tick labels around axis, displaying the labels inside the chart instead of outside. Note: Only applicable to vertical scales.
3149
+ * @default false
3150
+ */
3151
+ mirror: boolean;
3152
+ /**
3153
+ * Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
3154
+ * @default 0
3155
+ */
3156
+ padding: number;
3157
+ /**
3158
+ * Maximum number of ticks and gridlines to show.
3159
+ * @default 11
3160
+ */
3161
+ maxTicksLimit: number;
3162
+ }
3163
+
3164
+ export interface ScriptableCartesianScaleContext {
3165
+ scale: keyof CartesianScaleTypeRegistry;
3166
+ type: string;
3167
+ }
3168
+
3169
+ export interface ScriptableChartContext {
3170
+ chart: Chart;
3171
+ type: string;
3172
+ }
3173
+
3174
+ export interface CartesianScaleOptions extends CoreScaleOptions {
3175
+ /**
3176
+ * Scale boundary strategy (bypassed by min/max time options)
3177
+ * - `data`: make sure data are fully visible, ticks outside are removed
3178
+ * - `ticks`: make sure ticks are fully visible, data outside are truncated
3179
+ * @since 2.7.0
3180
+ * @default 'ticks'
3181
+ */
3182
+ bounds: 'ticks' | 'data';
3183
+
3184
+ /**
3185
+ * Position of the axis.
3186
+ */
3187
+ position: 'left' | 'top' | 'right' | 'bottom' | 'center' | { [scale: string]: number };
3188
+
3189
+ /**
3190
+ * Stack group. Axes at the same `position` with same `stack` are stacked.
3191
+ */
3192
+ stack?: string;
3193
+
3194
+ /**
3195
+ * Weight of the scale in stack group. Used to determine the amount of allocated space for the scale within the group.
3196
+ * @default 1
3197
+ */
3198
+ stackWeight?: number;
3199
+
3200
+ /**
3201
+ * Which type of axis this is. Possible values are: 'x', 'y', 'r'. If not set, this is inferred from the first character of the ID which should be 'x', 'y' or 'r'.
3202
+ */
3203
+ axis: 'x' | 'y' | 'r';
3204
+
3205
+ /**
3206
+ * User defined minimum value for the scale, overrides minimum value from data.
3207
+ */
3208
+ min: number;
3209
+
3210
+ /**
3211
+ * User defined maximum value for the scale, overrides maximum value from data.
3212
+ */
3213
+ max: number;
3214
+
3215
+ /**
3216
+ * If true, extra space is added to the both edges and the axis is scaled to fit into the chart area. This is set to true for a bar chart by default.
3217
+ * @default false
3218
+ */
3219
+ offset: boolean;
3220
+
3221
+ grid: Partial<GridLineOptions>;
3222
+
3223
+ border: BorderOptions;
3224
+
3225
+ /** Options for the scale title. */
3226
+ title: {
3227
+ /** If true, displays the axis title. */
3228
+ display: boolean;
3229
+ /** Alignment of the axis title. */
3230
+ align: Align;
3231
+ /** The text for the title, e.g. "# of People" or "Response Choices". */
3232
+ text: string | string[];
3233
+ /** Color of the axis label. */
3234
+ color: Color;
3235
+ /** Information about the axis title font. */
3236
+ font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableCartesianScaleContext>;
3237
+ /** Padding to apply around scale labels. */
3238
+ padding: number | {
3239
+ /** Padding on the (relative) top side of this axis label. */
3240
+ top: number;
3241
+ /** Padding on the (relative) bottom side of this axis label. */
3242
+ bottom: number;
3243
+ /** This is a shorthand for defining top/bottom to the same values. */
3244
+ y: number;
3245
+ };
3246
+ };
3247
+
3248
+ /**
3249
+ * If true, data will be comprised between datasets of data
3250
+ * @default false
3251
+ */
3252
+ stacked?: boolean | 'single';
3253
+
3254
+ ticks: CartesianTickOptions;
3255
+ }
3256
+
3257
+ export type CategoryScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> & {
3258
+ min: string | number;
3259
+ max: string | number;
3260
+ labels: string[] | string[][];
3261
+ };
3262
+
3263
+ export type CategoryScale<O extends CategoryScaleOptions = CategoryScaleOptions> = Scale<O>
3264
+ export declare const CategoryScale: ChartComponent & {
3265
+ prototype: CategoryScale;
3266
+ new <O extends CategoryScaleOptions = CategoryScaleOptions>(cfg: AnyObject): CategoryScale<O>;
3267
+ };
3268
+
3269
+ export type LinearScaleOptions = CartesianScaleOptions & {
3270
+
3271
+ /**
3272
+ * if true, scale will include 0 if it is not already included.
3273
+ * @default true
3274
+ */
3275
+ beginAtZero: boolean;
3276
+ /**
3277
+ * Adjustment used when calculating the minimum data value.
3278
+ */
3279
+ suggestedMin?: number;
3280
+ /**
3281
+ * Adjustment used when calculating the maximum data value.
3282
+ */
3283
+ suggestedMax?: number;
3284
+ /**
3285
+ * Percentage (string ending with %) or amount (number) for added room in the scale range above and below data.
3286
+ */
3287
+ grace?: string | number;
3288
+
3289
+ ticks: {
3290
+ /**
3291
+ * The Intl.NumberFormat options used by the default label formatter
3292
+ */
3293
+ format: Intl.NumberFormatOptions;
3294
+
3295
+ /**
3296
+ * if defined and stepSize is not specified, the step size will be rounded to this many decimal places.
3297
+ */
3298
+ precision: number;
3299
+
3300
+ /**
3301
+ * User defined fixed step size for the scale
3302
+ */
3303
+ stepSize: number;
3304
+
3305
+ /**
3306
+ * User defined count of ticks
3307
+ */
3308
+ count: number;
3309
+ };
3310
+ };
3311
+
3312
+ export type LinearScale<O extends LinearScaleOptions = LinearScaleOptions> = Scale<O>
3313
+ export declare const LinearScale: ChartComponent & {
3314
+ prototype: LinearScale;
3315
+ new <O extends LinearScaleOptions = LinearScaleOptions>(cfg: AnyObject): LinearScale<O>;
3316
+ };
3317
+
3318
+ export type LogarithmicScaleOptions = CartesianScaleOptions & {
3319
+ /**
3320
+ * Adjustment used when calculating the maximum data value.
3321
+ */
3322
+ suggestedMin?: number;
3323
+ /**
3324
+ * Adjustment used when calculating the minimum data value.
3325
+ */
3326
+ suggestedMax?: number;
3327
+
3328
+ ticks: {
3329
+ /**
3330
+ * The Intl.NumberFormat options used by the default label formatter
3331
+ */
3332
+ format: Intl.NumberFormatOptions;
3333
+ };
3334
+ };
3335
+
3336
+ export type LogarithmicScale<O extends LogarithmicScaleOptions = LogarithmicScaleOptions> = Scale<O>
3337
+ export declare const LogarithmicScale: ChartComponent & {
3338
+ prototype: LogarithmicScale;
3339
+ new <O extends LogarithmicScaleOptions = LogarithmicScaleOptions>(cfg: AnyObject): LogarithmicScale<O>;
3340
+ };
3341
+
3342
+ export type TimeScaleTimeOptions = {
3343
+ /**
3344
+ * Custom parser for dates.
3345
+ */
3346
+ parser: string | ((v: unknown) => number);
3347
+ /**
3348
+ * If defined, dates will be rounded to the start of this unit. See Time Units below for the allowed units.
3349
+ */
3350
+ round: false | TimeUnit;
3351
+ /**
3352
+ * If boolean and true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday.
3353
+ * If `number`, the index of the first day of the week (0 - Sunday, 6 - Saturday).
3354
+ * @default false
3355
+ */
3356
+ isoWeekday: boolean | number;
3357
+ /**
3358
+ * Sets how different time units are displayed.
3359
+ */
3360
+ displayFormats: {
3361
+ [key: string]: string;
3362
+ };
3363
+ /**
3364
+ * The format string to use for the tooltip.
3365
+ */
3366
+ tooltipFormat: string;
3367
+ /**
3368
+ * If defined, will force the unit to be a certain type. See Time Units section below for details.
3369
+ * @default false
3370
+ */
3371
+ unit: false | TimeUnit;
3372
+ /**
3373
+ * The minimum display format to be used for a time unit.
3374
+ * @default 'millisecond'
3375
+ */
3376
+ minUnit: TimeUnit;
3377
+ };
3378
+
3379
+ export type TimeScaleTickOptions = {
3380
+ /**
3381
+ * Ticks generation input values:
3382
+ * - 'auto': generates "optimal" ticks based on scale size and time options.
3383
+ * - 'data': generates ticks from data (including labels from data `{t|x|y}` objects).
3384
+ * - 'labels': generates ticks from user given `data.labels` values ONLY.
3385
+ * @see https://github.com/chartjs/Chart.js/pull/4507
3386
+ * @since 2.7.0
3387
+ * @default 'auto'
3388
+ */
3389
+ source: 'labels' | 'auto' | 'data';
3390
+ /**
3391
+ * The number of units between grid lines.
3392
+ * @default 1
3393
+ */
3394
+ stepSize: number;
3395
+ };
3396
+
3397
+ export type TimeScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> & {
3398
+ min: string | number;
3399
+ max: string | number;
3400
+ suggestedMin: string | number;
3401
+ suggestedMax: string | number;
3402
+ /**
3403
+ * Scale boundary strategy (bypassed by min/max time options)
3404
+ * - `data`: make sure data are fully visible, ticks outside are removed
3405
+ * - `ticks`: make sure ticks are fully visible, data outside are truncated
3406
+ * @since 2.7.0
3407
+ * @default 'data'
3408
+ */
3409
+ bounds: 'ticks' | 'data';
3410
+
3411
+ /**
3412
+ * If true, bar chart offsets are computed with skipped tick sizes
3413
+ * @since 3.8.0
3414
+ * @default false
3415
+ */
3416
+ offsetAfterAutoskip: boolean;
3417
+
3418
+ /**
3419
+ * options for creating a new adapter instance
3420
+ */
3421
+ adapters: {
3422
+ date: unknown;
3423
+ };
3424
+
3425
+ time: TimeScaleTimeOptions;
3426
+
3427
+ ticks: TimeScaleTickOptions;
3428
+ };
3429
+
3430
+ export interface TimeScale<O extends TimeScaleOptions = TimeScaleOptions> extends Scale<O> {
3431
+ format(value: number, format?: string): string;
3432
+ getDataTimestamps(): number[];
3433
+ getLabelTimestamps(): string[];
3434
+ normalize(values: number[]): number[];
3435
+ }
3436
+
3437
+ export declare const TimeScale: ChartComponent & {
3438
+ prototype: TimeScale;
3439
+ new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeScale<O>;
3440
+ };
3441
+
3442
+ export type TimeSeriesScale<O extends TimeScaleOptions = TimeScaleOptions> = TimeScale<O>
3443
+ export declare const TimeSeriesScale: ChartComponent & {
3444
+ prototype: TimeSeriesScale;
3445
+ new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeSeriesScale<O>;
3446
+ };
3447
+
3448
+ export type RadialTickOptions = TickOptions & {
3449
+ /**
3450
+ * The Intl.NumberFormat options used by the default label formatter
3451
+ */
3452
+ format: Intl.NumberFormatOptions;
3453
+
3454
+ /**
3455
+ * Maximum number of ticks and gridlines to show.
3456
+ * @default 11
3457
+ */
3458
+ maxTicksLimit: number;
3459
+
3460
+ /**
3461
+ * if defined and stepSize is not specified, the step size will be rounded to this many decimal places.
3462
+ */
3463
+ precision: number;
3464
+
3465
+ /**
3466
+ * User defined fixed step size for the scale.
3467
+ */
3468
+ stepSize: number;
3469
+
3470
+ /**
3471
+ * User defined number of ticks
3472
+ */
3473
+ count: number;
3474
+ }
3475
+
3476
+ export type RadialLinearScaleOptions = CoreScaleOptions & {
3477
+ animate: boolean;
3478
+
3479
+ startAngle: number;
3480
+
3481
+ angleLines: {
3482
+ /**
3483
+ * if true, angle lines are shown.
3484
+ * @default true
3485
+ */
3486
+ display: boolean;
3487
+ /**
3488
+ * Color of angled lines.
3489
+ * @default 'rgba(0, 0, 0, 0.1)'
3490
+ */
3491
+ color: Scriptable<Color, ScriptableScaleContext>;
3492
+ /**
3493
+ * Width of angled lines.
3494
+ * @default 1
3495
+ */
3496
+ lineWidth: Scriptable<number, ScriptableScaleContext>;
3497
+ /**
3498
+ * Length and spacing of dashes on angled lines. See MDN.
3499
+ * @default []
3500
+ */
3501
+ borderDash: Scriptable<number[], ScriptableScaleContext>;
3502
+ /**
3503
+ * Offset for line dashes. See MDN.
3504
+ * @default 0
3505
+ */
3506
+ borderDashOffset: Scriptable<number, ScriptableScaleContext>;
3507
+ };
3508
+
3509
+ /**
3510
+ * if true, scale will include 0 if it is not already included.
3511
+ * @default false
3512
+ */
3513
+ beginAtZero: boolean;
3514
+
3515
+ grid: Partial<GridLineOptions>;
3516
+
3517
+ /**
3518
+ * User defined minimum number for the scale, overrides minimum value from data.
3519
+ */
3520
+ min: number;
3521
+ /**
3522
+ * User defined maximum number for the scale, overrides maximum value from data.
3523
+ */
3524
+ max: number;
3525
+
3526
+ pointLabels: {
3527
+ /**
3528
+ * Background color of the point label.
3529
+ * @default undefined
3530
+ */
3531
+ backdropColor: Scriptable<Color, ScriptableScalePointLabelContext>;
3532
+ /**
3533
+ * Padding of label backdrop.
3534
+ * @default 2
3535
+ */
3536
+ backdropPadding: Scriptable<number | ChartArea, ScriptableScalePointLabelContext>;
3537
+
3538
+ /**
3539
+ * Border radius
3540
+ * @default 0
3541
+ * @since 3.8.0
3542
+ */
3543
+ borderRadius: Scriptable<number | BorderRadius, ScriptableScalePointLabelContext>;
3544
+
3545
+ /**
3546
+ * if true, point labels are shown. When `display: 'auto'`, the label is hidden if it overlaps with another label.
3547
+ * @default true
3548
+ */
3549
+ display: boolean | 'auto';
3550
+ /**
3551
+ * Color of label
3552
+ * @see Defaults.color
3553
+ */
3554
+ color: Scriptable<Color, ScriptableScalePointLabelContext>;
3555
+ /**
3556
+ */
3557
+ font: ScriptableAndScriptableOptions<Partial<FontSpec>, ScriptableScalePointLabelContext>;
3558
+
3559
+ /**
3560
+ * Callback function to transform data labels to point labels. The default implementation simply returns the current string.
3561
+ */
3562
+ callback: (label: string, index: number) => string | string[] | number | number[];
3563
+
3564
+ /**
3565
+ * Padding around the pointLabels
3566
+ * @default 5
3567
+ */
3568
+ padding: Scriptable<number, ScriptableScalePointLabelContext>;
3569
+
3570
+ /**
3571
+ * if true, point labels are centered.
3572
+ * @default false
3573
+ */
3574
+ centerPointLabels: boolean;
3575
+ };
3576
+
3577
+ /**
3578
+ * Adjustment used when calculating the maximum data value.
3579
+ */
3580
+ suggestedMax: number;
3581
+ /**
3582
+ * Adjustment used when calculating the minimum data value.
3583
+ */
3584
+ suggestedMin: number;
3585
+
3586
+ ticks: RadialTickOptions;
3587
+ };
3588
+
3589
+ export interface RadialLinearScale<O extends RadialLinearScaleOptions = RadialLinearScaleOptions> extends Scale<O> {
3590
+ xCenter: number;
3591
+ yCenter: number;
3592
+ setCenterPoint(leftMovement: number, rightMovement: number, topMovement: number, bottomMovement: number): void;
3593
+ getIndexAngle(index: number): number;
3594
+ getDistanceFromCenterForValue(value: number): number;
3595
+ getValueForDistanceFromCenter(distance: number): number;
3596
+ getPointPosition(index: number, distanceFromCenter: number): { x: number; y: number; angle: number };
3597
+ getPointPositionForValue(index: number, value: number): { x: number; y: number; angle: number };
3598
+ getPointLabelPosition(index: number): ChartArea;
3599
+ getBasePosition(index: number): { x: number; y: number; angle: number };
3600
+ }
3601
+ export declare const RadialLinearScale: ChartComponent & {
3602
+ prototype: RadialLinearScale;
3603
+ new <O extends RadialLinearScaleOptions = RadialLinearScaleOptions>(cfg: AnyObject): RadialLinearScale<O>;
3604
+ };
3605
+
3606
+ export interface CartesianScaleTypeRegistry {
3607
+ linear: {
3608
+ options: LinearScaleOptions;
3609
+ };
3610
+ logarithmic: {
3611
+ options: LogarithmicScaleOptions;
3612
+ };
3613
+ category: {
3614
+ options: CategoryScaleOptions;
3615
+ };
3616
+ time: {
3617
+ options: TimeScaleOptions;
3618
+ };
3619
+ timeseries: {
3620
+ options: TimeScaleOptions;
3621
+ };
3622
+ }
3623
+
3624
+ export interface RadialScaleTypeRegistry {
3625
+ radialLinear: {
3626
+ options: RadialLinearScaleOptions;
3627
+ };
3628
+ }
3629
+
3630
+ export interface ScaleTypeRegistry extends CartesianScaleTypeRegistry, RadialScaleTypeRegistry {
3631
+ }
3632
+
3633
+ export type ScaleType = keyof ScaleTypeRegistry;
3634
+
3635
+ export interface CartesianParsedData extends Point {
3636
+ // Only specified when stacked bars are enabled
3637
+ _stacks?: {
3638
+ // Key is the stack ID which is generally the axis ID
3639
+ [key: string]: {
3640
+ // Inner key is the datasetIndex
3641
+ [key: number]: number;
3642
+ }
3643
+ }
3644
+ }
3645
+
3646
+ interface BarParsedData extends CartesianParsedData {
3647
+ // Only specified if floating bars are show
3648
+ _custom?: {
3649
+ barStart: number;
3650
+ barEnd: number;
3651
+ start: number;
3652
+ end: number;
3653
+ min: number;
3654
+ max: number;
3655
+ }
3656
+ }
3657
+
3658
+ interface BubbleParsedData extends CartesianParsedData {
3659
+ // The bubble radius value
3660
+ _custom: number;
3661
+ }
3662
+
3663
+ interface RadialParsedData {
3664
+ r: number;
3665
+ }
3666
+
3667
+ export interface ChartTypeRegistry {
3668
+ bar: {
3669
+ chartOptions: BarControllerChartOptions;
3670
+ datasetOptions: BarControllerDatasetOptions;
3671
+ defaultDataPoint: number | [number, number] | null;
3672
+ metaExtensions: {};
3673
+ parsedDataType: BarParsedData,
3674
+ scales: keyof CartesianScaleTypeRegistry;
3675
+ };
3676
+ line: {
3677
+ chartOptions: LineControllerChartOptions;
3678
+ datasetOptions: LineControllerDatasetOptions & FillerControllerDatasetOptions;
3679
+ defaultDataPoint: ScatterDataPoint | number | null;
3680
+ metaExtensions: {};
3681
+ parsedDataType: CartesianParsedData;
3682
+ scales: keyof CartesianScaleTypeRegistry;
3683
+ };
3684
+ scatter: {
3685
+ chartOptions: ScatterControllerChartOptions;
3686
+ datasetOptions: ScatterControllerDatasetOptions;
3687
+ defaultDataPoint: ScatterDataPoint | number | null;
3688
+ metaExtensions: {};
3689
+ parsedDataType: CartesianParsedData;
3690
+ scales: keyof CartesianScaleTypeRegistry;
3691
+ };
3692
+ bubble: {
3693
+ chartOptions: unknown;
3694
+ datasetOptions: BubbleControllerDatasetOptions;
3695
+ defaultDataPoint: BubbleDataPoint;
3696
+ metaExtensions: {};
3697
+ parsedDataType: BubbleParsedData;
3698
+ scales: keyof CartesianScaleTypeRegistry;
3699
+ };
3700
+ pie: {
3701
+ chartOptions: PieControllerChartOptions;
3702
+ datasetOptions: PieControllerDatasetOptions;
3703
+ defaultDataPoint: PieDataPoint;
3704
+ metaExtensions: PieMetaExtensions;
3705
+ parsedDataType: number;
3706
+ scales: keyof CartesianScaleTypeRegistry;
3707
+ };
3708
+ doughnut: {
3709
+ chartOptions: DoughnutControllerChartOptions;
3710
+ datasetOptions: DoughnutControllerDatasetOptions;
3711
+ defaultDataPoint: DoughnutDataPoint;
3712
+ metaExtensions: DoughnutMetaExtensions;
3713
+ parsedDataType: number;
3714
+ scales: keyof CartesianScaleTypeRegistry;
3715
+ };
3716
+ polarArea: {
3717
+ chartOptions: PolarAreaControllerChartOptions;
3718
+ datasetOptions: PolarAreaControllerDatasetOptions;
3719
+ defaultDataPoint: number;
3720
+ metaExtensions: {};
3721
+ parsedDataType: RadialParsedData;
3722
+ scales: keyof RadialScaleTypeRegistry;
3723
+ };
3724
+ radar: {
3725
+ chartOptions: RadarControllerChartOptions;
3726
+ datasetOptions: RadarControllerDatasetOptions & FillerControllerDatasetOptions;
3727
+ defaultDataPoint: number | null;
3728
+ metaExtensions: {};
3729
+ parsedDataType: RadialParsedData;
3730
+ scales: keyof RadialScaleTypeRegistry;
3731
+ };
3732
+ }
3733
+
3734
+ export type ChartType = keyof ChartTypeRegistry;
3735
+
3736
+ export type ScaleOptionsByType<TScale extends ScaleType = ScaleType> =
3737
+ { [key in ScaleType]: { type: key } & ScaleTypeRegistry[key]['options'] }[TScale]
3738
+ ;
3739
+
3740
+ // Convenience alias for creating and manipulating scale options in user code
3741
+ export type ScaleOptions<TScale extends ScaleType = ScaleType> = DeepPartial<ScaleOptionsByType<TScale>>;
3742
+
3743
+ export type DatasetChartOptions<TType extends ChartType = ChartType> = {
3744
+ [key in TType]: {
3745
+ datasets: ChartTypeRegistry[key]['datasetOptions'];
3746
+ };
3747
+ };
3748
+
3749
+ export type ScaleChartOptions<TType extends ChartType = ChartType> = {
3750
+ scales: {
3751
+ [key: string]: ScaleOptionsByType<ChartTypeRegistry[TType]['scales']>;
3752
+ };
3753
+ };
3754
+
3755
+ export type ChartOptions<TType extends ChartType = ChartType> = Exclude<
3756
+ DeepPartial<
3757
+ CoreChartOptions<TType> &
3758
+ ElementChartOptions<TType> &
3759
+ PluginChartOptions<TType> &
3760
+ DatasetChartOptions<TType> &
3761
+ ScaleChartOptions<TType> &
3762
+ ChartTypeRegistry[TType]['chartOptions']
3763
+ >,
3764
+ DeepPartial<unknown[]>
3765
+ >;
3766
+
3767
+ export type DefaultDataPoint<TType extends ChartType> = DistributiveArray<ChartTypeRegistry[TType]['defaultDataPoint']>;
3768
+
3769
+ export type ParsedDataType<TType extends ChartType = ChartType> = ChartTypeRegistry[TType]['parsedDataType'];
3770
+
3771
+ export interface ChartDatasetProperties<TType extends ChartType, TData> {
3772
+ type?: TType;
3773
+ data: TData;
3774
+ }
3775
+
3776
+ export interface ChartDatasetPropertiesCustomTypesPerDataset<TType extends ChartType, TData> {
3777
+ type: TType;
3778
+ data: TData;
3779
+ }
3780
+
3781
+ export type ChartDataset<
3782
+ TType extends ChartType = ChartType,
3783
+ TData = DefaultDataPoint<TType>
3784
+ > = DeepPartial<
3785
+ { [key in ChartType]: { type: key } & ChartTypeRegistry[key]['datasetOptions'] }[TType]
3786
+ > & ChartDatasetProperties<TType, TData>;
3787
+
3788
+ export type ChartDatasetCustomTypesPerDataset<
3789
+ TType extends ChartType = ChartType,
3790
+ TData = DefaultDataPoint<TType>
3791
+ > = DeepPartial<
3792
+ { [key in ChartType]: { type: key } & ChartTypeRegistry[key]['datasetOptions'] }[TType]
3793
+ > & ChartDatasetPropertiesCustomTypesPerDataset<TType, TData>;
3794
+
3795
+ /**
3796
+ * TData represents the data point type. If unspecified, a default is provided
3797
+ * based on the chart type.
3798
+ * TLabel represents the label type
3799
+ */
3800
+ export interface ChartData<
3801
+ TType extends ChartType = ChartType,
3802
+ TData = DefaultDataPoint<TType>,
3803
+ TLabel = unknown
3804
+ > {
3805
+ labels?: TLabel[];
3806
+ xLabels?: TLabel[];
3807
+ yLabels?: TLabel[];
3808
+ datasets: ChartDataset<TType, TData>[];
3809
+ }
3810
+
3811
+ export interface ChartDataCustomTypesPerDataset<
3812
+ TType extends ChartType = ChartType,
3813
+ TData = DefaultDataPoint<TType>,
3814
+ TLabel = unknown
3815
+ > {
3816
+ labels?: TLabel[];
3817
+ xLabels?: TLabel[];
3818
+ yLabels?: TLabel[];
3819
+ datasets: ChartDatasetCustomTypesPerDataset<TType, TData>[];
3820
+ }
3821
+
3822
+ export interface ChartConfiguration<
3823
+ TType extends ChartType = ChartType,
3824
+ TData = DefaultDataPoint<TType>,
3825
+ TLabel = unknown
3826
+ > {
3827
+ type: TType;
3828
+ data: ChartData<TType, TData, TLabel>;
3829
+ options?: ChartOptions<TType> | undefined;
3830
+ plugins?: Plugin<TType>[];
3831
+ platform?: typeof BasePlatform;
3832
+ }
3833
+
3834
+ export interface ChartConfigurationCustomTypesPerDataset<
3835
+ TType extends ChartType = ChartType,
3836
+ TData = DefaultDataPoint<TType>,
3837
+ TLabel = unknown
3838
+ > {
3839
+ data: ChartDataCustomTypesPerDataset<TType, TData, TLabel>;
3840
+ options?: ChartOptions<TType> | undefined;
3841
+ plugins?: Plugin<TType>[];
3842
+ }