@eclipse-scout/chart 22.0.41 → 23.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +210 -0
  2. package/dist/d.ts/chart/AbstractChartRenderer.d.ts +48 -0
  3. package/dist/d.ts/chart/AbstractChartRenderer.d.ts.map +1 -0
  4. package/dist/d.ts/chart/AbstractSvgChartRenderer.d.ts +65 -0
  5. package/dist/d.ts/chart/AbstractSvgChartRenderer.d.ts.map +1 -0
  6. package/dist/d.ts/chart/Chart.d.ts +162 -0
  7. package/dist/d.ts/chart/Chart.d.ts.map +1 -0
  8. package/dist/d.ts/chart/ChartAdapter.d.ts +8 -0
  9. package/dist/d.ts/chart/ChartAdapter.d.ts.map +1 -0
  10. package/dist/d.ts/chart/ChartEventMap.d.ts +16 -0
  11. package/dist/d.ts/chart/ChartEventMap.d.ts.map +1 -0
  12. package/dist/d.ts/chart/ChartJsRenderer.d.ts +300 -0
  13. package/dist/d.ts/chart/ChartJsRenderer.d.ts.map +1 -0
  14. package/dist/d.ts/chart/ChartLayout.d.ts +8 -0
  15. package/dist/d.ts/chart/ChartLayout.d.ts.map +1 -0
  16. package/dist/d.ts/chart/ChartModel.d.ts +11 -0
  17. package/dist/d.ts/chart/ChartModel.d.ts.map +1 -0
  18. package/dist/d.ts/chart/FulfillmentChartRenderer.d.ts +22 -0
  19. package/dist/d.ts/chart/FulfillmentChartRenderer.d.ts.map +1 -0
  20. package/dist/d.ts/chart/SalesfunnelChartRenderer.d.ts +61 -0
  21. package/dist/d.ts/chart/SalesfunnelChartRenderer.d.ts.map +1 -0
  22. package/dist/d.ts/chart/SpeedoChartRenderer.d.ts +90 -0
  23. package/dist/d.ts/chart/SpeedoChartRenderer.d.ts.map +1 -0
  24. package/dist/d.ts/chart/VennAsync3Calculator.d.ts +32 -0
  25. package/dist/d.ts/chart/VennAsync3Calculator.d.ts.map +1 -0
  26. package/dist/d.ts/chart/VennChartRenderer.d.ts +36 -0
  27. package/dist/d.ts/chart/VennChartRenderer.d.ts.map +1 -0
  28. package/dist/d.ts/chart/VennCircle.d.ts +20 -0
  29. package/dist/d.ts/chart/VennCircle.d.ts.map +1 -0
  30. package/dist/d.ts/chart/VennCircleHelper.d.ts +13 -0
  31. package/dist/d.ts/chart/VennCircleHelper.d.ts.map +1 -0
  32. package/dist/d.ts/form/fields/chartfield/ChartField.d.ts +11 -0
  33. package/dist/d.ts/form/fields/chartfield/ChartField.d.ts.map +1 -0
  34. package/dist/d.ts/form/fields/chartfield/ChartFieldAdapter.d.ts +4 -0
  35. package/dist/d.ts/form/fields/chartfield/ChartFieldAdapter.d.ts.map +1 -0
  36. package/dist/d.ts/form/fields/chartfield/ChartFieldModel.d.ts +6 -0
  37. package/dist/d.ts/form/fields/chartfield/ChartFieldModel.d.ts.map +1 -0
  38. package/dist/d.ts/index.d.ts +31 -0
  39. package/dist/d.ts/index.d.ts.map +1 -0
  40. package/dist/d.ts/table/controls/ChartTableControl.d.ts +136 -0
  41. package/dist/d.ts/table/controls/ChartTableControl.d.ts.map +1 -0
  42. package/dist/d.ts/table/controls/ChartTableControlAdapter.d.ts +5 -0
  43. package/dist/d.ts/table/controls/ChartTableControlAdapter.d.ts.map +1 -0
  44. package/dist/d.ts/table/controls/ChartTableControlEventMap.d.ts +9 -0
  45. package/dist/d.ts/table/controls/ChartTableControlEventMap.d.ts.map +1 -0
  46. package/dist/d.ts/table/controls/ChartTableControlLayout.d.ts +8 -0
  47. package/dist/d.ts/table/controls/ChartTableControlLayout.d.ts.map +1 -0
  48. package/dist/d.ts/table/controls/ChartTableControlModel.d.ts +9 -0
  49. package/dist/d.ts/table/controls/ChartTableControlModel.d.ts.map +1 -0
  50. package/dist/d.ts/table/controls/ChartTableUserFilter.d.ts +29 -0
  51. package/dist/d.ts/table/controls/ChartTableUserFilter.d.ts.map +1 -0
  52. package/dist/d.ts/table/controls/ChartTableUserFilterModel.d.ts +11 -0
  53. package/dist/d.ts/table/controls/ChartTableUserFilterModel.d.ts.map +1 -0
  54. package/dist/d.ts/tile/ChartFieldTile.d.ts +14 -0
  55. package/dist/d.ts/tile/ChartFieldTile.d.ts.map +1 -0
  56. package/dist/d.ts/tile/ChartFieldTileAdapter.d.ts +4 -0
  57. package/dist/d.ts/tile/ChartFieldTileAdapter.d.ts.map +1 -0
  58. package/dist/d.ts/tile/ChartFieldTileModel.d.ts +6 -0
  59. package/dist/d.ts/tile/ChartFieldTileModel.d.ts.map +1 -0
  60. package/dist/eclipse-scout-chart-fae6f958a044232e659c.min.js +3 -0
  61. package/dist/eclipse-scout-chart-fae6f958a044232e659c.min.js.map +1 -0
  62. package/dist/eclipse-scout-chart-theme-dark-89bcf2022056cbf8e371.min.css +1 -0
  63. package/dist/eclipse-scout-chart-theme-dark.css +1 -1
  64. package/dist/eclipse-scout-chart-theme-e25b5923d4dba5f5ca7e.min.css +1 -0
  65. package/dist/eclipse-scout-chart-theme.css +1 -1
  66. package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js +3 -0
  67. package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js.map +1 -0
  68. package/dist/eclipse-scout-chart.esm.js +6919 -0
  69. package/dist/eclipse-scout-chart.esm.js.map +1 -0
  70. package/dist/eclipse-scout-chart.js +641 -15109
  71. package/dist/eclipse-scout-chart.js.map +1 -1
  72. package/dist/file-list +8 -5
  73. package/dist/texts.json +17 -17
  74. package/package.json +21 -15
  75. package/src/chart/{AbstractChartRenderer.js → AbstractChartRenderer.ts} +31 -25
  76. package/src/chart/{AbstractSvgChartRenderer.js → AbstractSvgChartRenderer.ts} +78 -43
  77. package/src/chart/{Chart.js → Chart.ts} +151 -61
  78. package/src/chart/ChartAdapter.ts +27 -0
  79. package/src/chart/ChartEventMap.ts +27 -0
  80. package/src/chart/{ChartJsRenderer.js → ChartJsRenderer.ts} +356 -350
  81. package/src/chart/{ChartLayout.js → ChartLayout.ts} +9 -8
  82. package/src/chart/ChartModel.ts +21 -0
  83. package/src/chart/{FulfillmentChartRenderer.js → FulfillmentChartRenderer.ts} +21 -18
  84. package/src/chart/{SalesfunnelChartRenderer.js → SalesfunnelChartRenderer.ts} +96 -59
  85. package/src/chart/{SpeedoChartRenderer.js → SpeedoChartRenderer.ts} +50 -36
  86. package/src/chart/{VennAsync3Calculator.js → VennAsync3Calculator.ts} +37 -13
  87. package/src/chart/{VennChartRenderer.js → VennChartRenderer.ts} +58 -34
  88. package/src/chart/{VennCircle.js → VennCircle.ts} +22 -15
  89. package/src/chart/{VennCircleHelper.js → VennCircleHelper.ts} +15 -9
  90. package/src/form/fields/chartfield/{ChartField.js → ChartField.ts} +11 -5
  91. package/src/form/fields/chartfield/{ChartFieldAdapter.js → ChartFieldAdapter.ts} +3 -8
  92. package/src/form/fields/chartfield/ChartFieldModel.ts +16 -0
  93. package/src/index.ts +46 -0
  94. package/src/table/controls/{ChartTableControl.js → ChartTableControl.ts} +160 -120
  95. package/src/table/controls/{ChartTableControlAdapter.js → ChartTableControlAdapter.ts} +3 -4
  96. package/src/table/controls/ChartTableControlEventMap.ts +19 -0
  97. package/src/table/controls/{ChartTableControlLayout.js → ChartTableControlLayout.ts} +7 -5
  98. package/src/table/controls/ChartTableControlModel.ts +19 -0
  99. package/src/table/controls/{ChartTableUserFilter.js → ChartTableUserFilter.ts} +25 -12
  100. package/src/table/controls/ChartTableUserFilterModel.ts +19 -0
  101. package/src/tile/{ChartFieldTile.js → ChartFieldTile.ts} +14 -8
  102. package/src/tile/{ChartFieldTileAdapter.js → ChartFieldTileAdapter.ts} +3 -7
  103. package/src/tile/ChartFieldTileModel.ts +16 -0
  104. package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js +0 -3
  105. package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js.LICENSE.txt +0 -6
  106. package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js.map +0 -1
  107. package/dist/eclipse-scout-chart-theme-79622289bda68b525e3e.min.css +0 -1
  108. package/dist/eclipse-scout-chart-theme-dark-1de09c03e3dc40a9529a.min.css +0 -1
  109. package/src/chart/ChartAdapter.js +0 -30
  110. package/src/index.js +0 -36
@@ -9,60 +9,18 @@
9
9
  * BSI Business Systems Integration AG - initial API and implementation
10
10
  */
11
11
  import {AbstractChartRenderer, Chart} from '../index';
12
- import ChartJs from 'chart.js/auto';
13
- import {arrays, colorSchemes, Event, graphics, numbers, objects, scout, strings, styles, tooltips} from '@eclipse-scout/core';
14
- import ChartDataLabels from 'chartjs-plugin-datalabels';
12
+ import {
13
+ ActiveElement, ArcElement, BarElement, BubbleDataPoint, CartesianScaleOptions, Chart as ChartJs, ChartArea, ChartConfiguration, ChartDataset, ChartEvent, ChartType as ChartJsType, Color, DefaultDataPoint, FontSpec, LegendElement,
14
+ LegendItem, LegendOptions, LinearScaleOptions, PointElement, PointHoverOptions, PointOptions, PointProps, RadialLinearScaleOptions, Scale, ScatterDataPoint, TooltipCallbacks, TooltipItem, TooltipLabelStyle, TooltipModel, TooltipOptions
15
+ } from 'chart.js';
16
+ import 'chart.js/auto'; // Import from auto to register charts
17
+ import {arrays, colorSchemes, graphics, numbers, objects, scout, strings, styles, Tooltip, tooltips} from '@eclipse-scout/core';
18
+ import ChartDataLabels, {Context} from 'chartjs-plugin-datalabels';
15
19
  import $ from 'jquery';
20
+ import {ChartAxis, ChartConfig, ChartData, ChartType, ClickObject, NumberFormatter} from './Chart';
16
21
 
17
22
  ChartJs.register(ChartDataLabels);
18
23
 
19
- /**
20
- * @typedef CoreChartOptions
21
- * @property {number} [font.size]
22
- */
23
-
24
- /**
25
- * @typedef TickOptions
26
- * @property {number} maxRotation
27
- */
28
-
29
- /**
30
- * @typedef Scale
31
- * @property {number} labelRotation
32
- * @property {number} height
33
- * @property {object} _labelSizes
34
- * @property {object} _labelSizes.widest
35
- */
36
-
37
- /**
38
- * @typedef TooltipModel
39
- * @property {array} _tooltipItems
40
- */
41
-
42
- /**
43
- * @typedef ArcElement
44
- * @property {number} innerRadius
45
- * @property {number} outerRadius
46
- * @property {number} startAngle
47
- * @property {number} endAngle
48
- */
49
-
50
- /**
51
- * @typedef PointElement
52
- * @property {number} angle
53
- */
54
-
55
- /**
56
- * @typedef BarElement
57
- * @property {number} height
58
- * @property {number} width
59
- */
60
-
61
- /**
62
- * @typedef TooltipOptions
63
- * @property {string} titleFont.family
64
- */
65
-
66
24
  $.extend(true, ChartJs.defaults, {
67
25
  maintainAspectRatio: false,
68
26
  elements: {
@@ -87,7 +45,7 @@ $.extend(true, ChartJs.defaults, {
87
45
  legend: {
88
46
  labels: {
89
47
  usePointStyle: true,
90
- boxWidth: 7
48
+ boxHeight: 7
91
49
  }
92
50
  }
93
51
  }
@@ -112,44 +70,56 @@ $.extend(true, ChartJs.overrides, {
112
70
  let chartJsGlobalsInitialized = false;
113
71
  const PHI = (1 + Math.sqrt(5)) / 2; // golden ratio
114
72
 
115
- /**
116
- * @typedef Dataset
117
- * @property {string} [datasetId]
118
- * @property {array} [data]
119
- *
120
- * @property {array|string} [backgroundColor]
121
- * @property {array|string} [backgroundColorBackup]
122
- * @property {array|string} [hoverBackgroundColor]
123
- *
124
- * @property {array|string} [pointBackgroundColor]
125
- * @property {array|string} [pointHoverBackgroundColor]
126
- * @property {array|number} [pointRadius]
127
- *
128
- * @property {array|string} [uncheckedBackgroundColor]
129
- * @property {array|string} [uncheckedHoverBackgroundColor]
130
- * @property {array|string} [uncheckedPointBackgroundColor]
131
- * @property {array|string} [uncheckedPointHoverBackgroundColor]
132
- * @property {array|number} [uncheckedPointRadius]
133
- *
134
- * @property {array|string} [checkedBackgroundColor]
135
- * @property {array|string} [checkedHoverBackgroundColor]
136
- * @property {array|string} [checkedPointBackgroundColor]
137
- * @property {array|string} [checkedPointHoverBackgroundColor]
138
- * @property {array|number} [checkedPointRadius]
139
- *
140
- * @property {array|string} [legendColor]
141
- */
142
-
143
- export default class ChartJsRenderer extends AbstractChartRenderer {
144
-
73
+ export class ChartJsRenderer extends AbstractChartRenderer {
145
74
  static ARROW_LEFT_RIGHT = '\u2194';
146
75
  static ARROW_UP_DOWN = '\u2195';
147
76
 
148
- constructor(chart) {
77
+ chartJs: ChartJsChart;
78
+ onlyIntegers: boolean;
79
+ maxXAxesTicksHeight: number;
80
+ numSupportedColors: number;
81
+ colorSchemeCssClass: string;
82
+ minRadialChartDatalabelSpace: number;
83
+ resetDatasetAfterHover: boolean;
84
+ legendHoverDatasets: number[];
85
+ removing: boolean;
86
+
87
+ $canvas: JQuery<HTMLCanvasElement>;
88
+
89
+ protected _labelFormatter: LabelFormatter;
90
+ protected _xLabelFormatter: LabelFormatter;
91
+ protected _yLabelFormatter: LabelFormatter;
92
+ protected _xAxisFitter: AxisFitter;
93
+ protected _yAxisFitter: AxisFitter;
94
+ protected _radialChartDatalabelsDisplayHandler: DatalabelsDisplayHandler;
95
+ protected _radialChartDatalabelsFormatter: RadialChartDatalabelsFormatter;
96
+ protected _datalabelsFormatter: DatalabelsFormatter;
97
+ protected _datalabelBackgroundColorHandler: DatalabelBackgroundColorHandler;
98
+ protected _legendLabelGenerator: LegendLabelGenerator;
99
+ protected _clickHandler: ChartEventHandler;
100
+ protected _hoverHandler: ChartEventHandler;
101
+ protected _pointerHoverHandler: ChartEventHandler;
102
+ protected _legendClickHandler: LegendEventHandler;
103
+ protected _legendHoverHandler: LegendEventHandler;
104
+ protected _legendPointerHoverHandler: LegendEventHandler;
105
+ protected _legendLeaveHandler: LegendEventHandler;
106
+ protected _legendPointerLeaveHandler: LegendEventHandler;
107
+ protected _resizeHandler: ResizeHandler;
108
+ protected _tooltipTitleGenerator: TooltipTitleGenerator;
109
+ protected _tooltipItemsGenerator: TooltipItemsGenerator;
110
+ protected _tooltipLabelGenerator: TooltipLabelGenerator;
111
+ protected _tooltipLabelValueGenerator: TooltipLabelValueGenerator;
112
+ protected _tooltipLabelColorGenerator: TooltipLabelColorGenerator;
113
+ protected _tooltipRenderer: TooltipRenderer;
114
+ protected _tooltip: Tooltip;
115
+ protected _tooltipTimeoutId: number;
116
+ protected _updatingDatalabels: boolean;
117
+
118
+ constructor(chart: Chart) {
149
119
  super(chart);
150
120
  this.chartJs = null;
151
121
  this.onlyIntegers = true;
152
- this.maxXAxesTicksHeigth = 75;
122
+ this.maxXAxesTicksHeight = 75;
153
123
  this.numSupportedColors = 6;
154
124
  this.colorSchemeCssClass = '';
155
125
  this.minRadialChartDatalabelSpace = 25;
@@ -194,7 +164,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
194
164
  this._tooltipTimeoutId = null;
195
165
  }
196
166
 
197
- _validateChartData() {
167
+ protected override _validateChartData(): boolean {
198
168
  let chartDataValid = true;
199
169
  let chartData = this.chart && this.chart.data;
200
170
 
@@ -259,28 +229,21 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
259
229
  return chartConfigDataValid;
260
230
  }
261
231
 
262
- _render() {
232
+ protected override _render() {
263
233
  if (!this.$canvas) {
264
- this.$canvas = this.chart.$container.appendElement('<canvas>');
234
+ this.$canvas = this.chart.$container.appendElement('<canvas>') as JQuery<HTMLCanvasElement>;
265
235
  }
266
236
  this.firstOpaqueBackgroundColor = styles.getFirstOpaqueBackgroundColor(this.$canvas);
267
237
  if (!chartJsGlobalsInitialized) {
268
238
  ChartJs.defaults.font.family = this.$canvas.css('font-family');
269
239
  chartJsGlobalsInitialized = true;
270
240
  }
271
- /**
272
- * @property {number} options.bubble.sizeOfLargestBubble
273
- * @property {object} options.numberFormatter
274
- * @property {object} options.scaleLabelByTypeMap
275
- * @property {object} options.xLabelMap
276
- * @property {object} options.yLabelMap
277
- */
278
241
  let config = $.extend(true, {}, this.chart.config);
279
242
  this._adjustConfig(config);
280
243
  this._renderChart(config, true);
281
244
  }
282
245
 
283
- _renderChart(config, animated) {
246
+ protected _renderChart(config: ChartConfig, animated: boolean) {
284
247
  if (this.chartJs) {
285
248
  this.chartJs.destroy();
286
249
  }
@@ -291,17 +254,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
291
254
  }, config);
292
255
  config.options.animation.duration = animated ? this.animationDuration : 0;
293
256
 
294
- /**
295
- * @type {Chart}
296
- * @property {object} config
297
- * @property {object} chartArea
298
- */
299
- this.chartJs = new ChartJs(this.$canvas[0].getContext('2d'), config);
257
+ this.chartJs = new ChartJs(this.$canvas[0].getContext('2d'), config as ChartConfiguration) as ChartJsChart;
300
258
  this._adjustSize(this.chartJs.config, this.chartJs.chartArea);
301
259
  this.chartJs.update();
302
260
  }
303
261
 
304
- _updateData() {
262
+ protected override _updateData() {
305
263
  if (!this.chartJs) {
306
264
  return;
307
265
  }
@@ -313,10 +271,10 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
313
271
 
314
272
  // Transfer property from source object to target object:
315
273
  // 1. If the property is not set on the target object, copy it from source.
316
- // 2. If the property is not set on the source object, set it to undefined if setToUndefined = true. Otherwise empty the array if it is an array property or set it to undefined.
274
+ // 2. If the property is not set on the source object, set it to undefined if setToUndefined = true. Otherwise, empty the array if it is an array property or set it to undefined.
317
275
  // 3. If the property is not an array on the source or the target object, copy the property from the source to the target object.
318
276
  // 4. If the property is an array on both objects, do not update the array, but transfer the elements (update elements directly, use pop(), push() or splice() if one array is longer than the other).
319
- let transferProperty = (source, target, property, setToUndefined) => {
277
+ let transferProperty = (source: object, target: object, property: string, setToUndefined?) => {
320
278
  if (!source || !target || !property) {
321
279
  return;
322
280
  }
@@ -365,8 +323,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
365
323
  }
366
324
  };
367
325
 
368
- let findDataset = (datasets, datasetId) => arrays.find(datasets, dataset => dataset.datasetId === datasetId);
369
- let findDatasetIndex = (datasets, datasetId) => arrays.findIndex(datasets, dataset => dataset.datasetId === datasetId);
326
+ let findDataset = (datasets: ChartDataset[], datasetId) => arrays.find(datasets, dataset => dataset.datasetId === datasetId);
327
+ let findDatasetIndex = (datasets: ChartDataset[], datasetId) => arrays.findIndex(datasets, dataset => dataset.datasetId === datasetId);
370
328
 
371
329
  if (targetData && sourceData) {
372
330
  // Transfer properties from source to target, instead of overwriting the whole data object.
@@ -472,8 +430,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
472
430
  });
473
431
  let scales = this.chartJs.config.options.scales || {},
474
432
  axes = [scales.x || {}, scales.y || {}, scales.yDiffType || {}, scales.r || {}];
475
- axes.forEach(axis => {
476
- (axis.ticks || {}).stepSize = undefined;
433
+ axes.forEach((axis: LinearScaleOptions | RadialLinearScaleOptions) => {
434
+ (axis.ticks || {} as (LinearScaleOptions | RadialLinearScaleOptions)['ticks']).stepSize = undefined;
477
435
  });
478
436
 
479
437
  this.chartJs.update();
@@ -482,11 +440,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
482
440
  this.chartJs.update();
483
441
  }
484
442
 
485
- isDataUpdatable() {
443
+ override isDataUpdatable(): boolean {
486
444
  return true;
487
445
  }
488
446
 
489
- refresh() {
447
+ override refresh() {
490
448
  if (this.chartJs) {
491
449
  this.chartJs.update();
492
450
  } else {
@@ -494,13 +452,13 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
494
452
  }
495
453
  }
496
454
 
497
- _renderCheckedItems() {
455
+ protected override _renderCheckedItems() {
498
456
  if (this.chartJs && this._checkItems(this.chartJs.config)) {
499
457
  this.chartJs.update();
500
458
  }
501
459
  }
502
460
 
503
- _checkItems(config) {
461
+ protected _checkItems(config: ChartConfig): boolean {
504
462
  if (!config || !config.data) {
505
463
  return false;
506
464
  }
@@ -520,10 +478,10 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
520
478
  return 0;
521
479
  };
522
480
  let changed = 0;
523
- config.data.datasets.forEach((dataset, datasetIndex) => {
481
+ config.data.datasets.forEach((dataset: ChartDataset, datasetIndex) => {
524
482
  let checkedIndices = this.chart.checkedItems.filter(item => item.datasetIndex === datasetIndex)
525
483
  .map(item => item.dataIndex),
526
- uncheckedIndices = arrays.init(dataset.data.length).map((elem, idx) => idx);
484
+ uncheckedIndices = arrays.init(dataset.data.length, null).map((elem, idx) => idx);
527
485
  arrays.removeAll(uncheckedIndices, checkedIndices);
528
486
 
529
487
  changed = changed +
@@ -552,7 +510,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
552
510
  }
553
511
  }
554
512
 
555
- _adjustConfig(config) {
513
+ protected _adjustConfig(config: ChartConfig) {
556
514
  if (!config || !config.type) {
557
515
  return;
558
516
  }
@@ -569,7 +527,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
569
527
  this._adjustResizeHandler(config);
570
528
  }
571
529
 
572
- _adjustType(config) {
530
+ protected _adjustType(config: ChartConfig) {
573
531
  if (config.type === Chart.Type.COMBO_BAR_LINE) {
574
532
  config.type = Chart.Type.BAR;
575
533
 
@@ -585,7 +543,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
585
543
  }
586
544
  }
587
545
 
588
- _computeDatasets(chartData, config) {
546
+ protected _computeDatasets(chartData: ChartData, config: ChartConfig) {
589
547
  let labels = [],
590
548
  datasets = [];
591
549
 
@@ -607,22 +565,18 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
607
565
  data: $.extend(true, [], elem.values)
608
566
  }));
609
567
 
610
- /**
611
- * @type {object}
612
- * @property {Dataset[]} datasets
613
- */
614
568
  config.data = {
615
569
  labels: labels,
616
570
  datasets: datasets
617
571
  };
618
572
  }
619
573
 
620
- _isHorizontalBar(config) {
574
+ protected _isHorizontalBar(config: ChartConfig): boolean {
621
575
  return config && (config.type === Chart.Type.BAR_HORIZONTAL
622
576
  || (config.type === Chart.Type.BAR && config.options && config.options.indexAxis === 'y'));
623
577
  }
624
578
 
625
- _computeLabelMap(axis) {
579
+ protected _computeLabelMap(axis: ChartAxis[]): Record<number, string> {
626
580
  let labelMap = {};
627
581
  (axis || []).forEach((elem, idx) => {
628
582
  labelMap[idx] = elem.label;
@@ -630,7 +584,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
630
584
  return labelMap;
631
585
  }
632
586
 
633
- _adjustData(config) {
587
+ protected _adjustData(config: ChartConfig) {
634
588
  if (!config || !config.data || !config.type) {
635
589
  return;
636
590
  }
@@ -641,7 +595,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
641
595
  this._adjustOnlyIntegers(config);
642
596
  }
643
597
 
644
- _adjustBarBorderWidth(config) {
598
+ protected _adjustBarBorderWidth(config: ChartConfig) {
645
599
  if (!config || !config.data || !config.type || !scout.isOneOf(config.type, Chart.Type.BAR)) {
646
600
  return;
647
601
  }
@@ -655,7 +609,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
655
609
  });
656
610
  }
657
611
 
658
- _adjustDatasetBorderWidths(dataset) {
612
+ protected _adjustDatasetBorderWidths(dataset: ChartDataset) {
659
613
  this._adjustDatasetBorderWidth(dataset);
660
614
  this._adjustDatasetBorderWidth(dataset, true);
661
615
  }
@@ -664,10 +618,9 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
664
618
  * Sets the borderWidth to 0 if the backgroundColor and the borderColor are identical and backups the original value.
665
619
  * This method is idempotent as it restores the original state first and then applies its logic.
666
620
  *
667
- * @param {Dataset} dataset
668
- * @param {boolean?} hover whether hoverBorderWidth, hoverBackgroundColor and hoverBorderColor should be considered instead of borderWidth, backgroundColor and borderColor
621
+ * @param hover whether hoverBorderWidth, hoverBackgroundColor and hoverBorderColor should be considered instead of borderWidth, backgroundColor and borderColor
669
622
  */
670
- _adjustDatasetBorderWidth(dataset, hover) {
623
+ protected _adjustDatasetBorderWidth(dataset: ChartDataset, hover?: boolean) {
671
624
  if (!dataset) {
672
625
  return;
673
626
  }
@@ -675,7 +628,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
675
628
  borderWidthBackupIdentifier = hover ? 'hoverBorderWidthBackup' : 'borderWidthBackup',
676
629
  backgroundColorIdentifier = hover ? 'hoverBackgroundColor' : 'backgroundColor',
677
630
  borderColorIdentifier = hover ? 'hoverBorderColor' : 'borderColor';
678
- // restore original state if there is an backup
631
+ // restore original state if there is a backup
679
632
  if (dataset[borderWidthBackupIdentifier]) {
680
633
  dataset[borderWidthIdentifier] = dataset[borderWidthBackupIdentifier];
681
634
  delete dataset[borderWidthBackupIdentifier];
@@ -703,7 +656,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
703
656
  }
704
657
  let borderWidth = dataset[borderWidthIdentifier],
705
658
  length = borderWidth.length,
706
- borderWidthBackup = arrays.init(length);
659
+ borderWidthBackup = arrays.init(length, null);
707
660
  for (let i = 0; i < length; i++) {
708
661
  // it makes no difference if the backgroundColor/borderColor is not an array as a not-array-value is applied to every element by chart.js
709
662
  let backgroundColor = isBackgroundColorArray ? dataset[backgroundColorIdentifier][i] : dataset[backgroundColorIdentifier],
@@ -719,7 +672,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
719
672
  }
720
673
  }
721
674
 
722
- _adjustMaxSegments(config) {
675
+ protected _adjustMaxSegments(config: ChartConfig) {
723
676
  if (!config || !config.data || !config.type || !scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA, Chart.Type.RADAR)) {
724
677
  return;
725
678
  }
@@ -730,7 +683,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
730
683
  }
731
684
  config.data.datasets.forEach(elem => {
732
685
  let newData = elem.data.slice(0, maxSegments);
733
- newData[maxSegments - 1] = elem.data.slice(maxSegments - 1, elem.data.length).reduce((x, y) => {
686
+ newData[maxSegments - 1] = elem.data.slice(maxSegments - 1, elem.data.length).reduce((x: number, y: number) => {
734
687
  return x + y;
735
688
  }, 0);
736
689
  elem.data = newData;
@@ -742,7 +695,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
742
695
  config.data.maxSegmentsExceeded = true;
743
696
  }
744
697
 
745
- _isMaxSegmentsExceeded(config, index) {
698
+ protected _isMaxSegmentsExceeded(config: ChartConfig, index: number): boolean {
746
699
  if (!scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA, Chart.Type.RADAR)) {
747
700
  return false;
748
701
  }
@@ -760,12 +713,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
760
713
  * This allows the chart to render itself with correct dimensions and with no interfering from bubbles (very large bubbles make the chart grid itself smaller).
761
714
  * Later on in {@link _adjustBubbleSizes}, the bubble sizes will be calculated relative to the chart dimensions and the configured min/max sizes.
762
715
  */
763
- _adjustBubbleRadii(config) {
716
+ protected _adjustBubbleRadii(config: ChartConfig) {
764
717
  if (!config || !config.data || !config.type || config.type !== Chart.Type.BUBBLE) {
765
718
  return;
766
719
  }
767
720
 
768
- config.data.datasets.forEach(dataset => dataset.data.forEach(data => {
721
+ config.data.datasets.forEach(dataset => dataset.data.forEach((data: BubbleDataPoint) => {
769
722
  if (!isNaN(data.r)) {
770
723
  data.z = Math.pow(data.r, 2);
771
724
  }
@@ -773,7 +726,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
773
726
  }));
774
727
  }
775
728
 
776
- _adjustOnlyIntegers(config) {
729
+ protected _adjustOnlyIntegers(config: ChartConfig) {
777
730
  this.onlyIntegers = true;
778
731
 
779
732
  if (!config || !config.data || !config.type) {
@@ -781,13 +734,13 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
781
734
  }
782
735
 
783
736
  if (scout.isOneOf(config.type, Chart.Type.BUBBLE, Chart.Type.SCATTER)) {
784
- this.onlyIntegers = config.data.datasets.every(dataset => dataset.data.every(data => numbers.isInteger(data.x) && numbers.isInteger(data.y)));
737
+ this.onlyIntegers = config.data.datasets.every(dataset => dataset.data.every((data: ScatterDataPoint | BubbleDataPoint) => numbers.isInteger(data.x) && numbers.isInteger(data.y)));
785
738
  } else {
786
739
  this.onlyIntegers = config.data.datasets.every(dataset => dataset.data.every(data => numbers.isInteger(data)));
787
740
  }
788
741
  }
789
742
 
790
- _adjustTooltip(config) {
743
+ protected _adjustTooltip(config: ChartConfig) {
791
744
  if (!config) {
792
745
  return;
793
746
  }
@@ -816,12 +769,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
816
769
  tooltip.external = this._tooltipRenderer;
817
770
  }
818
771
 
819
- _generateTooltipTitle(tooltipItems) {
772
+ protected _generateTooltipTitle(tooltipItems: TooltipItem<any>[]): string | string[] {
820
773
  if (!tooltipItems || !tooltipItems.length) {
821
774
  return '';
822
775
  }
823
776
  let tooltipItem = tooltipItems[0],
824
- chart = tooltipItem.chart,
777
+ chart = tooltipItem.chart as ChartJsChart,
825
778
  config = chart.config,
826
779
  dataset = tooltipItem.dataset,
827
780
  title = [];
@@ -829,33 +782,35 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
829
782
  let xAxis = config.options.scales.x,
830
783
  yAxis = config.options.scales.y,
831
784
  axisLabels = this._getAxisLabels(config);
832
- let xTickLabel = xAxis.ticks.callback(dataset.data[tooltipItem.dataIndex].x);
785
+ // @ts-expect-error
786
+ let xTickLabel = xAxis.ticks.callback(dataset.data[tooltipItem.dataIndex].x, null, null) as string;
833
787
  if (xTickLabel) {
834
788
  title.push(this._createTooltipAttribute(axisLabels.x, strings.encode(xTickLabel), true));
835
789
  }
836
- let yTickLabel = yAxis.ticks.callback(dataset.data[tooltipItem.dataIndex].y);
790
+ // @ts-expect-error
791
+ let yTickLabel = yAxis.ticks.callback(dataset.data[tooltipItem.dataIndex].y, null, null) as string;
837
792
  if (yTickLabel) {
838
793
  title.push(this._createTooltipAttribute(axisLabels.y, strings.encode(yTickLabel), true));
839
794
  }
840
795
  } else if (scout.isOneOf(config.type, Chart.Type.SCATTER)) {
841
796
  // nop, scatter has the title in the items table
842
797
  } else {
843
- let label = chart.data.labels[tooltipItem.dataIndex];
798
+ let label = chart.data.labels[tooltipItem.dataIndex] as string;
844
799
  title.push(this._createTooltipAttribute(config.options.reformatLabels ? this._formatLabel(label) : label, '', true));
845
800
  }
846
801
  return title;
847
802
  }
848
803
 
849
- _getAxisLabels(config) {
804
+ protected _getAxisLabels(config: ChartConfig): { x: string; y: string } {
850
805
  let xAxisLabel = config.options.scales.x.title.text,
851
806
  yAxisLabel = config.options.scales.y.title.text;
852
- xAxisLabel = this._resolveAxisLabel(xAxisLabel, ChartJsRenderer.ARROW_LEFT_RIGHT);
853
- yAxisLabel = this._resolveAxisLabel(yAxisLabel, '&nbsp;' + ChartJsRenderer.ARROW_UP_DOWN + '&nbsp;');
807
+ xAxisLabel = this._resolveAxisLabel(xAxisLabel as string, ChartJsRenderer.ARROW_LEFT_RIGHT);
808
+ yAxisLabel = this._resolveAxisLabel(yAxisLabel as string, '&nbsp;' + ChartJsRenderer.ARROW_UP_DOWN + '&nbsp;');
854
809
 
855
810
  return {x: xAxisLabel, y: yAxisLabel};
856
811
  }
857
812
 
858
- _resolveAxisLabel(axisLabel, defaultLabel = '') {
813
+ protected _resolveAxisLabel(axisLabel: string | (() => string), defaultLabel = ''): string {
859
814
  if (objects.isFunction(axisLabel)) {
860
815
  axisLabel = axisLabel();
861
816
  axisLabel = objects.isString(axisLabel) ? axisLabel : '';
@@ -863,12 +818,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
863
818
  return axisLabel ? strings.encode(axisLabel) : defaultLabel;
864
819
  }
865
820
 
866
- _generateTooltipItems(tooltipItems, tooltipLabel, tooltipLabelValue, tooltipColor) {
821
+ protected _generateTooltipItems(tooltipItems: TooltipItem<any>[], tooltipLabel: TooltipLabelGenerator, tooltipLabelValue: TooltipLabelValueGenerator, tooltipColor: TooltipLabelColorGenerator): string {
867
822
  if (!tooltipItems || !tooltipItems.length) {
868
823
  return '';
869
824
  }
870
825
  let tooltipItem = tooltipItems[0],
871
- chart = tooltipItem.chart,
826
+ chart = tooltipItem.chart as ChartJsChart,
872
827
  config = chart.config,
873
828
  xAxisValues = false,
874
829
  yAxisValues = false,
@@ -877,11 +832,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
877
832
  tooltipItems.forEach(tooltipItem => {
878
833
  let {label, labelValue, labelColor} = this._getItemDetails(tooltipItem, tooltipLabel, tooltipLabelValue, tooltipColor);
879
834
  if (scout.isOneOf(config.type, Chart.Type.SCATTER)) {
880
- xAxisValues |= objects.isString(labelValue.x);
881
- yAxisValues |= objects.isString(labelValue.y);
882
- itemsText += this._createTooltipScatterAttribute(label, labelValue.x, labelValue.y, false, labelColor);
835
+ let {x, y} = labelValue as { x: string; y: string };
836
+ xAxisValues ||= objects.isString(x);
837
+ yAxisValues ||= objects.isString(y);
838
+ itemsText += this._createTooltipScatterAttribute(label, x, y, false, labelColor);
883
839
  } else {
884
- itemsText += this._createTooltipAttribute(label, labelValue, false, labelColor);
840
+ itemsText += this._createTooltipAttribute(label, labelValue as string, false, labelColor);
885
841
  }
886
842
  });
887
843
 
@@ -892,8 +848,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
892
848
  tableHeader += this._createTooltipScatterAttribute('',
893
849
  xAxisValues ? axisLabels.x : '', // do not show axis label if no values are shown
894
850
  yAxisValues ? axisLabels.y : '', // do not show axis label if no values are shown
895
- true,
896
- null);
851
+ true);
897
852
  let tableFooter = '</tbody></table>';
898
853
  itemsText = strings.box(tableHeader, itemsText, tableFooter);
899
854
  }
@@ -901,7 +856,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
901
856
  return itemsText;
902
857
  }
903
858
 
904
- _getItemDetails(tooltipItem, tooltipLabel, tooltipLabelValue, tooltipColor) {
859
+ protected _getItemDetails(tooltipItem: TooltipItem<any>, tooltipLabel: TooltipLabelGenerator, tooltipLabelValue: TooltipLabelValueGenerator, tooltipColor: TooltipLabelColorGenerator)
860
+ : { label: string; labelValue: string | { x: string; y: string }; labelColor: string } {
905
861
  let label, labelValue, labelColor;
906
862
  if (objects.isFunction(tooltipLabel)) {
907
863
  label = tooltipLabel(tooltipItem);
@@ -918,12 +874,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
918
874
  return {label, labelValue, labelColor};
919
875
  }
920
876
 
921
- _generateTooltipLabel(tooltipItem) {
877
+ protected _generateTooltipLabel(tooltipItem: TooltipItem<any>): string {
922
878
  return strings.encode(tooltipItem.dataset.label);
923
879
  }
924
880
 
925
- _generateTooltipLabelValue(tooltipItem) {
926
- let config = tooltipItem.chart.config,
881
+ protected _generateTooltipLabelValue(tooltipItem: TooltipItem<any>): string | { x: string; y: string } {
882
+ let config = tooltipItem.chart.config as ChartConfiguration,
927
883
  dataset = tooltipItem.dataset;
928
884
  if (config.type === Chart.Type.BUBBLE) {
929
885
  return strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex].z));
@@ -936,8 +892,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
936
892
  return strings.encode(this._formatLabel(dataset.data[tooltipItem.dataIndex]));
937
893
  }
938
894
 
939
- _generateTooltipLabelColor(tooltipItem) {
940
- let config = tooltipItem.chart.config,
895
+ protected _generateTooltipLabelColor(tooltipItem: TooltipItem<any>): TooltipLabelStyle {
896
+ let config = tooltipItem.chart.config as ChartConfiguration,
941
897
  dataset = tooltipItem.dataset,
942
898
  legendColor, backgroundColor, borderColor, index;
943
899
  if (scout.isOneOf((dataset.type || config.type), Chart.Type.LINE, Chart.Type.BAR, Chart.Type.BAR_HORIZONTAL, Chart.Type.RADAR, Chart.Type.BUBBLE, Chart.Type.SCATTER)) {
@@ -957,7 +913,6 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
957
913
  let tooltipLabelColor = legendColor || backgroundColor || borderColor;
958
914
  if (!tooltipLabelColor || objects.isFunction(tooltipLabelColor)) {
959
915
  let defaultTypeTooltipLabelColor;
960
- // noinspection DuplicatedCode
961
916
  if (ChartJs.overrides[config.type] && ChartJs.overrides[config.type].plugins && ChartJs.overrides[config.type].plugins.tooltip && ChartJs.overrides[config.type].plugins.tooltip.callbacks) {
962
917
  defaultTypeTooltipLabelColor = ChartJs.overrides[config.type].plugins.tooltip.callbacks.labelColor;
963
918
  }
@@ -966,10 +921,10 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
966
921
  }
967
922
  return {
968
923
  backgroundColor: tooltipLabelColor
969
- };
924
+ } as TooltipLabelStyle;
970
925
  }
971
926
 
972
- _createTooltipAttribute(label, value, isTitle, color) {
927
+ protected _createTooltipAttribute(label: string, value: string, isTitle: boolean, color?: string): string {
973
928
  let cssClass = isTitle ? 'attribute title' : 'attribute';
974
929
  return '<div class="' + cssClass + '">' +
975
930
  (color ? '<div class="color" style="background-color:' + color + '"></div>' : '') +
@@ -978,7 +933,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
978
933
  '</div>';
979
934
  }
980
935
 
981
- _createTooltipScatterAttribute(label, xValue, yValue, isTitle, color) {
936
+ protected _createTooltipScatterAttribute(label: string, xValue: string, yValue: string, isTitle: boolean, color?: string): string {
982
937
  let cssClass = isTitle ? 'attribute title' : 'attribute';
983
938
  return '<tr class="' + cssClass + '">' +
984
939
  '<td class="color-cell">' +
@@ -990,8 +945,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
990
945
  '</tr>';
991
946
  }
992
947
 
993
- _renderTooltip(context) {
994
- let isHideTooltip = context.tooltip.opacity === 0 || context.tooltip._tooltipItems.length < 1;
948
+ protected _renderTooltip(context: { chart: ChartJs; tooltip: TooltipModel<any> }) {
949
+ let isHideTooltip = context.tooltip.opacity === 0 || context.tooltip.dataPoints.length < 1;
995
950
  if (isHideTooltip) {
996
951
  if (this._tooltipTimeoutId) {
997
952
  clearTimeout(this._tooltipTimeoutId);
@@ -1012,7 +967,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1012
967
  }
1013
968
  }
1014
969
 
1015
- _renderTooltipLater(context) {
970
+ protected _renderTooltipLater(context: { chart: ChartJs; tooltip: TooltipModel<any> }) {
1016
971
  if (!this.rendered || this.removing) {
1017
972
  return;
1018
973
  }
@@ -1031,9 +986,9 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1031
986
  this._tooltip = null;
1032
987
  }
1033
988
 
1034
- let tooltipOptions = tooltip.options || {},
1035
- tooltipCallbacks = tooltipOptions.callbacks || {},
1036
- tooltipTitle = tooltipCallbacks.title,
989
+ let tooltipOptions = tooltip.options || {} as TooltipOptions,
990
+ tooltipCallbacks = tooltipOptions.callbacks || {} as TooltipCallbacks<any>,
991
+ tooltipTitle = tooltipCallbacks.title as TooltipTitleGenerator,
1037
992
  tooltipItems = tooltipCallbacks.items,
1038
993
  tooltipLabel = tooltipCallbacks.label,
1039
994
  tooltipLabelValue = tooltipCallbacks.labelValue,
@@ -1054,7 +1009,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1054
1009
  origin.height = positionAndOffset.height;
1055
1010
 
1056
1011
  this._tooltip = scout.create({
1057
- objectType: 'Tooltip',
1012
+ objectType: Tooltip,
1058
1013
  parent: this.chart,
1059
1014
  $anchor: this.$canvas,
1060
1015
  text: tooltipText,
@@ -1069,10 +1024,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1069
1024
  this._tooltip.$container
1070
1025
  .css('pointer-events', 'none');
1071
1026
 
1072
- let reposition = false;
1073
- if ((tooltipOptions.titleFont || {}).family) {
1027
+ let reposition = false,
1028
+ fontFamily = ((tooltipOptions.titleFont || {}) as FontSpec).family;
1029
+ if (fontFamily) {
1074
1030
  this._tooltip.$container
1075
- .css('--chart-tooltip-font-family', tooltipOptions.titleFont.family);
1031
+ .css('--chart-tooltip-font-family', fontFamily);
1076
1032
  reposition = true;
1077
1033
  }
1078
1034
 
@@ -1090,14 +1046,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1090
1046
  }
1091
1047
  }
1092
1048
 
1093
- _computeTooltipPositionAndOffset(tooltipItem) {
1094
- let tooltipPosition = 'top',
1095
- tooltipDirection = 'right',
1049
+ protected _computeTooltipPositionAndOffset(tooltipItem: TooltipItem<any>): { tooltipPosition: 'top' | 'bottom'; tooltipDirection: 'left' | 'right'; offsetX: number; offsetY: number; height: number } {
1050
+ let tooltipPosition: 'top' | 'bottom' = 'top',
1051
+ tooltipDirection: 'left' | 'right' = 'right',
1096
1052
  offsetX = 0,
1097
1053
  offsetY = 0,
1098
1054
  height = 0;
1099
1055
 
1100
- let chart = tooltipItem.chart,
1056
+ let chart = tooltipItem.chart as ChartJsChart,
1101
1057
  datasetIndex = tooltipItem.datasetIndex,
1102
1058
  dataIndex = tooltipItem.dataIndex,
1103
1059
  config = chart.config,
@@ -1106,7 +1062,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1106
1062
  value = dataset.data[dataIndex];
1107
1063
 
1108
1064
  if (this._isHorizontalBar(config)) {
1109
- if (value && objects.isArray(value.x) && value.x.length === 2) {
1065
+ if (objects.isPlainObject(value) && objects.isArray(value.x) && value.x.length === 2) {
1110
1066
  let avg = (value.x[0] + value.x[1]) / 2;
1111
1067
  tooltipDirection = avg < 0 ? 'left' : 'right';
1112
1068
  } else {
@@ -1115,22 +1071,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1115
1071
  } else if ((dataset.type || config.type) === Chart.Type.BAR) {
1116
1072
  tooltipPosition = value < 0 ? 'bottom' : 'top';
1117
1073
  } else if (scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1118
- // noinspection JSValidateTypes
1119
- /**
1120
- * @type ArcElement
1121
- */
1122
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1074
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as ArcElement).getProps(['startAngle', 'endAngle']);
1123
1075
  let startAngle = element.startAngle,
1124
1076
  endAngle = element.endAngle,
1125
1077
  angle = (startAngle + endAngle) / 2;
1126
1078
  tooltipPosition = (0 <= angle && angle < Math.PI) ? 'bottom' : 'top';
1127
1079
  tooltipDirection = (-Math.PI / 2 <= angle && angle < Math.PI / 2) ? 'right' : 'left';
1128
1080
  } else if (config.type === Chart.Type.RADAR) {
1129
- // noinspection JSValidateTypes
1130
- /**
1131
- * @type PointElement
1132
- */
1133
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1081
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as RadarPointElement).getProps(['angle']);
1134
1082
  let angle = element.angle;
1135
1083
  tooltipPosition = (0 <= angle && angle < Math.PI) ? 'bottom' : 'top';
1136
1084
  tooltipDirection = (-Math.PI / 2 <= angle && angle < Math.PI / 2) ? 'right' : 'left';
@@ -1142,11 +1090,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1142
1090
  }
1143
1091
 
1144
1092
  if (this._isHorizontalBar(config)) {
1145
- // noinspection JSValidateTypes
1146
- /**
1147
- * @type BarElement
1148
- */
1149
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1093
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as BarElement).getProps(['height', 'width']);
1150
1094
  height = element.height;
1151
1095
  let width = element.width,
1152
1096
  // golden ratio: (a + b) / a = a / b = PHI
@@ -1157,25 +1101,17 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1157
1101
  offsetY = -height / 2;
1158
1102
  offsetX = tooltipDirection === 'left' ? b : -b;
1159
1103
  } else if (scout.isOneOf(config.type, Chart.Type.LINE, Chart.Type.BUBBLE, Chart.Type.SCATTER, Chart.Type.RADAR) || dataset.type === Chart.Type.LINE) {
1160
- // noinspection JSValidateTypes
1161
- /**
1162
- * @type PointElement
1163
- */
1164
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1165
- let options = element.options,
1104
+ let element = chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as PointElement;
1105
+ let options = element.options as unknown as PointHoverOptions,
1166
1106
  offset = options.hoverRadius + options.hoverBorderWidth;
1167
1107
  if (config.type === Chart.Type.BUBBLE) {
1168
- offset += value.r;
1108
+ offset += (value as BubbleDataPoint).r;
1169
1109
  }
1170
1110
 
1171
1111
  height = 2 * offset;
1172
1112
  offsetY = -offset;
1173
1113
  } else if (scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1174
- // noinspection JSValidateTypes
1175
- /**
1176
- * @type ArcElement
1177
- */
1178
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1114
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as ArcElement).getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius']);
1179
1115
  let startAngle = element.startAngle,
1180
1116
  endAngle = element.endAngle,
1181
1117
  angle = (startAngle + endAngle) / 2,
@@ -1189,7 +1125,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1189
1125
  return {tooltipPosition, tooltipDirection, offsetX, offsetY, height};
1190
1126
  }
1191
1127
 
1192
- _adjustGrid(config) {
1128
+ protected _adjustGrid(config: ChartConfig) {
1193
1129
  if (!config) {
1194
1130
  return;
1195
1131
  }
@@ -1200,7 +1136,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1200
1136
  this._adjustScalesXY(config);
1201
1137
  }
1202
1138
 
1203
- _adjustScalesR(config) {
1139
+ protected _adjustScalesR(config: ChartConfig) {
1204
1140
  if (!config || !config.type || !config.options) {
1205
1141
  return;
1206
1142
  }
@@ -1234,7 +1170,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1234
1170
  }
1235
1171
  }
1236
1172
 
1237
- _adjustScalesXY(config) {
1173
+ protected _adjustScalesXY(config: ChartConfig) {
1238
1174
  if (!config || !config.type || !config.options) {
1239
1175
  return;
1240
1176
  }
@@ -1273,7 +1209,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1273
1209
  this._adjustYAxis(config);
1274
1210
  }
1275
1211
 
1276
- _adjustXAxis(config) {
1212
+ protected _adjustXAxis(config: ChartConfig) {
1277
1213
  if (!config || !config.type || !config.options || !config.options.scales || !config.options.scales.x) {
1278
1214
  return;
1279
1215
  }
@@ -1312,7 +1248,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1312
1248
  scales.x.afterCalculateLabelRotation = this._xAxisFitter;
1313
1249
  }
1314
1250
 
1315
- _adjustYAxis(config) {
1251
+ protected _adjustYAxis(config: ChartConfig) {
1316
1252
  if (!config || !config.type || !config.options || !config.options.scales || !config.options.scales.y) {
1317
1253
  return;
1318
1254
  }
@@ -1349,11 +1285,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1349
1285
  scales.y.afterFit = this._yAxisFitter;
1350
1286
  }
1351
1287
 
1352
- _adjustPlugins(config) {
1288
+ protected _adjustPlugins(config: ChartConfig) {
1353
1289
  this._adjustPluginsDatalabels(config);
1354
1290
  }
1355
1291
 
1356
- _adjustPluginsDatalabels(config) {
1292
+ protected _adjustPluginsDatalabels(config: ChartConfig) {
1357
1293
  if (!config || !config.type || !config.options || !config.options.plugins || !config.options.plugins.datalabels || !config.options.plugins.datalabels.display) {
1358
1294
  return;
1359
1295
  }
@@ -1399,8 +1335,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1399
1335
 
1400
1336
  // the datalabels plugin stores its data on the chart in $datalabels (see EXPANDO_KEY in chartjs-plugin-datalabels)
1401
1337
  chart['$' + ChartDataLabels.id]._actives = inactiveElements;
1402
- // noinspection JSCheckFunctionSignatures
1403
- ChartDataLabels.afterEvent(chart);
1338
+ ChartDataLabels.afterEvent(chart, null, null);
1404
1339
  this._updatingDatalabels = false;
1405
1340
  },
1406
1341
  updateDatalabelsAndDefaultCallback = (animation, defaultCallback) => {
@@ -1457,44 +1392,45 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1457
1392
  }, plugins.datalabels);
1458
1393
  }
1459
1394
 
1460
- _formatLabel(label) {
1395
+ protected _formatLabel(label: number | string): string {
1461
1396
  return this._formatLabelMap(label, null, this._getNumberFormatter());
1462
1397
  }
1463
1398
 
1464
- _getNumberFormatter() {
1399
+ protected _getNumberFormatter(): NumberFormatter {
1465
1400
  if (this.chartJs && this.chartJs.config && this.chartJs.config.options) {
1466
1401
  return this.chartJs.config.options.numberFormatter;
1467
1402
  }
1468
1403
  }
1469
1404
 
1470
- _formatXLabel(label) {
1405
+ protected _formatXLabel(label: number | string): string {
1471
1406
  return this._formatLabelMap(label, this._getXLabelMap(), this._getNumberFormatter());
1472
1407
  }
1473
1408
 
1474
- _formatYLabel(label) {
1409
+ protected _formatYLabel(label: number | string): string {
1475
1410
  return this._formatLabelMap(label, this._getYLabelMap(), this._getNumberFormatter());
1476
1411
  }
1477
1412
 
1478
- _getXLabelMap() {
1413
+ protected _getXLabelMap(): Record<number | string, string> {
1479
1414
  return this._getLabelMap('xLabelMap');
1480
1415
  }
1481
1416
 
1482
- _getYLabelMap() {
1417
+ protected _getYLabelMap(): Record<number | string, string> {
1483
1418
  return this._getLabelMap('yLabelMap');
1484
1419
  }
1485
1420
 
1486
- _getLabelMap(identifier) {
1421
+ protected _getLabelMap(identifier): Record<number | string, string> {
1487
1422
  if (this.chartJs && this.chartJs.config && this.chartJs.config.options) {
1488
1423
  return this.chartJs.config.options[identifier];
1489
1424
  }
1490
1425
  }
1491
1426
 
1492
- _formatLabelMap(label, labelMap, numberFormatter) {
1427
+ protected _formatLabelMap(label: number | string, labelMap: Record<string, string>, numberFormatter: NumberFormatter): string {
1493
1428
  if (labelMap) {
1494
1429
  return labelMap[label];
1495
1430
  }
1431
+ // @ts-expect-error
1496
1432
  if (isNaN(label)) {
1497
- return label;
1433
+ return '' + label;
1498
1434
  }
1499
1435
  if (numberFormatter) {
1500
1436
  return numberFormatter(label, this._formatNumberLabel.bind(this));
@@ -1502,10 +1438,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1502
1438
  return this._formatNumberLabel(label);
1503
1439
  }
1504
1440
 
1505
- _formatNumberLabel(label) {
1441
+ protected _formatNumberLabel(label: number | string): string {
1442
+ // @ts-expect-error
1506
1443
  if (isNaN(label)) {
1507
- return label;
1444
+ return '' + label;
1508
1445
  }
1446
+ // @ts-expect-error
1509
1447
  let abs = Math.abs(label);
1510
1448
  let abbreviation = '';
1511
1449
  if (abs >= 1000000) {
@@ -1526,20 +1464,18 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1526
1464
  }
1527
1465
  }
1528
1466
  }
1467
+ // @ts-expect-error
1529
1468
  return this.session.locale.decimalFormat.format(Math.sign(label) * abs) + abbreviation;
1530
1469
  }
1531
1470
 
1532
- /**
1533
- * @param {Scale} xAxis
1534
- */
1535
- _fitXAxis(xAxis) {
1471
+ protected _fitXAxis(xAxis: Scale<CartesianScaleOptions>) {
1536
1472
  if (!xAxis || xAxis.labelRotation === 0) {
1537
1473
  return;
1538
1474
  }
1539
- let maxHeight = this.maxXAxesTicksHeigth,
1475
+ let maxHeight = this.maxXAxesTicksHeight,
1540
1476
  fontDefaults = ChartJs.defaults.font,
1541
- ticksDefaults = ChartJs.defaults.scale.ticks,
1542
- ticksFontDefaults = ticksDefaults.font || {},
1477
+ ticksDefaults = (ChartJs.defaults.scale as CartesianScaleOptions).ticks,
1478
+ ticksFontDefaults = (ticksDefaults.font || {}) as FontSpec,
1543
1479
  fontSize,
1544
1480
  maxRotation;
1545
1481
  if (this.chartJs) {
@@ -1549,7 +1485,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1549
1485
  }
1550
1486
  if (xAxis.options && xAxis.options.ticks) {
1551
1487
  maxRotation = xAxis.options.ticks.maxRotation;
1552
- let ticksFont = xAxis.options.ticks.font || {};
1488
+ let ticksFont = (xAxis.options.ticks.font || {}) as FontSpec;
1553
1489
  fontSize = ticksFont.size;
1554
1490
  }
1555
1491
  maxRotation = maxRotation || ticksDefaults.maxRotation;
@@ -1566,19 +1502,21 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1566
1502
  // => height = sin(labelRotation) * labelLength + sin(90° - labelRotation) * fontSize
1567
1503
  // <=> labelLength = (height - sin(90° - labelRotation) * fontSize) / sin(labelRotation)
1568
1504
  maxLabelLength = (maxHeight - (fontSize * Math.sin(((90 - labelRotation) / 180) * Math.PI))) / Math.sin((labelRotation / 180) * Math.PI);
1505
+ // @ts-expect-error
1569
1506
  let labelSizes = xAxis._labelSizes || {},
1570
1507
  widest = labelSizes.widest || {};
1571
1508
  if (widest.width > maxLabelLength) {
1572
1509
  let measureText = xAxis.ctx.measureText.bind(xAxis.ctx);
1573
1510
  xAxis.ticks.forEach(tick => {
1574
- tick.label = strings.truncateText(tick.label, maxLabelLength, measureText);
1511
+ tick.label = strings.truncateText(tick.label as string, maxLabelLength, measureText);
1575
1512
  });
1576
1513
  // reset label sizes, chart.js will recalculate them using the new truncated labels
1514
+ // @ts-expect-error
1577
1515
  xAxis._labelSizes = undefined;
1578
1516
  }
1579
1517
  }
1580
1518
 
1581
- _fitYAxis(yAxis) {
1519
+ protected _fitYAxis(yAxis: Scale<CartesianScaleOptions>) {
1582
1520
  if (!yAxis) {
1583
1521
  return;
1584
1522
  }
@@ -1590,23 +1528,20 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1590
1528
  if (yAxis.options && yAxis.options.grid) {
1591
1529
  tickLength = yAxis.options.grid.tickLength || 0;
1592
1530
  }
1531
+ // @ts-expect-error
1593
1532
  let labelSizes = yAxis._labelSizes || {},
1594
1533
  widest = labelSizes.widest || {};
1595
1534
  if (widest.width > yAxis.maxWidth - padding) {
1596
1535
  let horizontalSpace = yAxis.maxWidth - padding - tickLength,
1597
1536
  measureText = yAxis.ctx.measureText.bind(yAxis.ctx);
1598
1537
  yAxis.ticks.forEach(tick => {
1599
- tick.label = strings.truncateText(tick.label, horizontalSpace, measureText);
1538
+ tick.label = strings.truncateText(tick.label as string, horizontalSpace, measureText);
1600
1539
  });
1601
1540
  }
1602
1541
  }
1603
1542
 
1604
- _displayDatalabelsOnRadialChart(context) {
1605
- // noinspection JSValidateTypes
1606
- /**
1607
- * @type ArcElement
1608
- */
1609
- let element = context.chart.getDatasetMeta(context.datasetIndex).data[context.dataIndex];
1543
+ protected _displayDatalabelsOnRadialChart(context: Context): boolean {
1544
+ let element = (context.chart.getDatasetMeta(context.datasetIndex).data[context.dataIndex] as unknown as ArcElement).getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius']);
1610
1545
  // Compute the biggest circle that fits inside sector/arc with center in the middle between inner and outer radius.
1611
1546
  // First compute a circle C1 that touches the straight boundaries of the sector/arc. Then compute a circle C2 that touches the inner and the outer radius.
1612
1547
  // The smaller one of these two circles is the biggest possible circle that fits inside sector/arc with center in the middle between inner and outer radius.
@@ -1621,13 +1556,13 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1621
1556
  return Math.min(diameter1, diameter2) > this.minRadialChartDatalabelSpace;
1622
1557
  }
1623
1558
 
1624
- _formatDatalabelsOnRadialChart(value, context) {
1559
+ protected _formatDatalabelsOnRadialChart(value: number, context: Context): string {
1625
1560
  let sum = this._computeSumOfVisibleElements(context),
1626
1561
  dataset = context.dataset,
1627
1562
  roundingError = 0,
1628
1563
  roundedResults = [];
1629
1564
  for (let i = 0; i < context.dataIndex + 1; i++) {
1630
- let result = dataset.data[i] / sum * 100 - roundingError,
1565
+ let result = (dataset.data[i] as number) / sum * 100 - roundingError,
1631
1566
  roundedResult = Math.round(result);
1632
1567
  roundingError = roundedResult - result;
1633
1568
  roundedResults.push(roundedResult + '%');
@@ -1635,32 +1570,33 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1635
1570
  return roundedResults[context.dataIndex];
1636
1571
  }
1637
1572
 
1638
- _computeSumOfVisibleElements(context) {
1573
+ protected _computeSumOfVisibleElements(context: Context): number {
1639
1574
  let dataset = context.dataset,
1640
1575
  chart = context.chart,
1641
1576
  sum = 0;
1642
1577
  for (let i = 0; i < dataset.data.length; i++) {
1643
1578
  if (chart.getDataVisibility(i)) {
1644
- sum += dataset.data[i];
1579
+ sum += dataset.data[i] as number;
1645
1580
  }
1646
1581
  }
1647
1582
  return sum;
1648
1583
  }
1649
1584
 
1650
- _formatDatalabels(value, context) {
1651
- if (context.chart.config.type === Chart.Type.BUBBLE) {
1652
- return this._formatLabel(value.z);
1653
- } else if (context.chart.config.type === Chart.Type.SCATTER) {
1654
- return strings.join(' / ', this._formatLabel(value.x), this._formatLabel(value.y));
1585
+ protected _formatDatalabels(value: number | ScatterDataPoint | BubbleDataPoint, context: Context): string {
1586
+ let config = context.chart.config as ChartConfiguration;
1587
+ if (config.type === Chart.Type.BUBBLE) {
1588
+ return this._formatLabel((value as BubbleDataPoint).z);
1589
+ } else if (config.type === Chart.Type.SCATTER) {
1590
+ return strings.join(' / ', this._formatLabel((value as ScatterDataPoint).x), this._formatLabel((value as ScatterDataPoint).y));
1655
1591
  }
1656
- return this._formatLabel(value);
1592
+ return this._formatLabel(value as number);
1657
1593
  }
1658
1594
 
1659
- _getBackgroundColorOfDataset(context) {
1660
- return context.dataset.backgroundColor;
1595
+ protected _getBackgroundColorOfDataset(context: Context): Color {
1596
+ return context.dataset.backgroundColor as Color;
1661
1597
  }
1662
1598
 
1663
- _adjustColors(config) {
1599
+ protected _adjustColors(config: ChartConfig) {
1664
1600
  this._adjustColorSchemeCssClass(config);
1665
1601
  this._adjustDatasetColors(config);
1666
1602
  this._adjustLegendColors(config);
@@ -1669,14 +1605,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1669
1605
  this._adjustPluginColors(config);
1670
1606
  }
1671
1607
 
1672
- _adjustColorSchemeCssClass(config) {
1608
+ protected _adjustColorSchemeCssClass(config: ChartConfig) {
1673
1609
  if (!config || !config.options) {
1674
1610
  return;
1675
1611
  }
1676
1612
  this.colorSchemeCssClass = colorSchemes.getCssClasses(config.options.colorScheme).join(' ');
1677
1613
  }
1678
1614
 
1679
- _adjustDatasetColors(config) {
1615
+ protected _adjustDatasetColors(config: ChartConfig) {
1680
1616
  if (!config || !config.data || !config.type) {
1681
1617
  return;
1682
1618
  }
@@ -1755,7 +1691,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1755
1691
  setProperty('pointHoverBackgroundColor', elem.uncheckedPointHoverBackgroundColor);
1756
1692
 
1757
1693
  let uncheckedPointRadius = arrays.init(datasetLength, ((config.options.elements || {}).point || {}).radius || ChartJs.defaults.elements.point.radius),
1758
- checkedPointRadius = arrays.init(datasetLength, (((config.options.elements || {}).point || {}).hoverRadius || ChartJs.defaults.elements.point.hoverRadius) - 1);
1694
+ checkedPointRadius = arrays.init(datasetLength, (((config.options.elements || {}).point || {}).hoverRadius || ChartJs.defaults.elements.point.hoverRadius) as number - 1);
1759
1695
  setProperty('uncheckedPointRadius', uncheckedPointRadius);
1760
1696
  setProperty('checkedPointRadius', checkedPointRadius);
1761
1697
 
@@ -1769,14 +1705,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1769
1705
  }
1770
1706
  }
1771
1707
 
1772
- _computeDatasetColors(config, multipleColorsPerDataset) {
1708
+ protected _computeDatasetColors(config: ChartConfig, multipleColorsPerDataset: boolean): DatasetColors {
1773
1709
  if (!config || !config.data || !config.type) {
1774
1710
  return {};
1775
1711
  }
1776
1712
 
1777
1713
  let data = config.data,
1778
1714
  type = config.type,
1779
- colors = {};
1715
+ colors: DatasetColors = {};
1780
1716
 
1781
1717
  if (config.options && config.options.autoColor) {
1782
1718
  colors = this._computeDatasetColorsAutoColor(config, multipleColorsPerDataset);
@@ -1792,7 +1728,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1792
1728
  return colors;
1793
1729
  }
1794
1730
 
1795
- _computeDatasetColorsAutoColor(config, multipleColorsPerDataset) {
1731
+ protected _computeDatasetColorsAutoColor(config: ChartConfig, multipleColorsPerDataset: boolean): DatasetColors {
1796
1732
  if (!config || !config.data || !config.type || !config.options || !config.options.autoColor) {
1797
1733
  return {};
1798
1734
  }
@@ -1835,11 +1771,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1835
1771
  return colors;
1836
1772
  }
1837
1773
 
1838
- _computeBackgroundColor(type, index, checkable) {
1774
+ protected _computeBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1839
1775
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors)], 'fill').fill;
1840
1776
  }
1841
1777
 
1842
- _computeBorderColor(type, index) {
1778
+ protected _computeBorderColor(type: ChartType, index: number): string {
1843
1779
  let additionalProperties;
1844
1780
  if (scout.isOneOf(type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1845
1781
  additionalProperties = {stroke: this.firstOpaqueBackgroundColor};
@@ -1847,11 +1783,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1847
1783
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'stroke-color' + (index % this.numSupportedColors)], 'stroke', additionalProperties).stroke;
1848
1784
  }
1849
1785
 
1850
- _computeHoverBackgroundColor(type, index, checkable) {
1786
+ protected _computeHoverBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1851
1787
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors) + ' hover'], 'fill').fill;
1852
1788
  }
1853
1789
 
1854
- _computeHoverBorderColor(type, index) {
1790
+ protected _computeHoverBorderColor(type: ChartType, index: number): string {
1855
1791
  let additionalProperties;
1856
1792
  if (scout.isOneOf(type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1857
1793
  additionalProperties = {stroke: this.firstOpaqueBackgroundColor};
@@ -1859,23 +1795,23 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1859
1795
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'stroke-color' + (index % this.numSupportedColors) + ' hover'], 'stroke', additionalProperties).stroke;
1860
1796
  }
1861
1797
 
1862
- _computeCheckedBackgroundColor(type, index, checkable) {
1798
+ protected _computeCheckedBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1863
1799
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors) + ' checked'], 'fill').fill;
1864
1800
  }
1865
1801
 
1866
- _computeCheckedHoverBackgroundColor(type, index, checkable) {
1802
+ protected _computeCheckedHoverBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1867
1803
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors) + ' hover checked'], 'fill').fill;
1868
1804
  }
1869
1805
 
1870
- _computeLegendColor(type, index) {
1806
+ protected _computeLegendColor(type: ChartType, index: number): string {
1871
1807
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'color' + (index % this.numSupportedColors) + ' legend'], 'fill').fill;
1872
1808
  }
1873
1809
 
1874
- _computePointHoverColor(type, index) {
1810
+ protected _computePointHoverColor(type: ChartType, index: number): string {
1875
1811
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'color' + (index % this.numSupportedColors) + ' point hover'], 'fill').fill;
1876
1812
  }
1877
1813
 
1878
- _computeDatasetColorsChartValueGroups(config, multipleColorsPerDataset) {
1814
+ protected _computeDatasetColorsChartValueGroups(config: ChartConfig, multipleColorsPerDataset: boolean): DatasetColors {
1879
1815
  if (!config || !config.type || !this.chart.data) {
1880
1816
  return {};
1881
1817
  }
@@ -1883,7 +1819,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1883
1819
  let type = config.type,
1884
1820
  checkable = config.options && config.options.checkable,
1885
1821
  transparent = config.options && config.options.transparent,
1886
- colors = {
1822
+ colors: DatasetColors = {
1887
1823
  backgroundColors: [],
1888
1824
  borderColors: [],
1889
1825
  hoverBackgroundColors: [],
@@ -1958,7 +1894,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1958
1894
  return colors;
1959
1895
  }
1960
1896
 
1961
- _adjustColorOpacity(color, opacity = 1) {
1897
+ protected _adjustColorOpacity(color: string, opacity = 1): string {
1962
1898
  if (!color || typeof color === 'function') {
1963
1899
  return color;
1964
1900
  }
@@ -1972,7 +1908,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1972
1908
  return color;
1973
1909
  }
1974
1910
 
1975
- _adjustRgbColorOpacity(rgbColor, opacity = 1) {
1911
+ protected _adjustRgbColorOpacity(rgbColor: string, opacity = 1): string {
1976
1912
  if (!rgbColor || rgbColor.indexOf('rgb') !== 0) {
1977
1913
  return rgbColor;
1978
1914
  }
@@ -1981,14 +1917,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1981
1917
  return 'rgba(' + rgba.red + ', ' + rgba.green + ', ' + rgba.blue + ', ' + rgba.alpha + ')';
1982
1918
  }
1983
1919
 
1984
- _adjustHexColorOpacity(hexColor, opacity = 1) {
1920
+ protected _adjustHexColorOpacity(hexColor: string, opacity = 1): string {
1985
1921
  if (!hexColor || hexColor.indexOf('#') !== 0 || !(hexColor.length === 4 || hexColor.length === 5 || hexColor.length === 7 || hexColor.length === 9)) {
1986
1922
  return hexColor;
1987
1923
  }
1988
1924
  return this._adjustRgbColorOpacity(styles.hexToRgb(hexColor), opacity);
1989
1925
  }
1990
1926
 
1991
- _adjustLegendColors(config) {
1927
+ protected _adjustLegendColors(config: ChartConfig) {
1992
1928
  if (!config || !config.type || !config.options) {
1993
1929
  return;
1994
1930
  }
@@ -2005,14 +1941,13 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2005
1941
  });
2006
1942
  }
2007
1943
 
2008
- _computeLabelColor(type) {
1944
+ protected _computeLabelColor(type: ChartType): string {
2009
1945
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'label'], 'fill').fill;
2010
1946
  }
2011
1947
 
2012
- _generateLegendLabels(chart) {
1948
+ protected _generateLegendLabels(chart: ChartJsChart): LegendItem[] {
2013
1949
  let config = chart.config,
2014
1950
  defaultTypeGenerateLabels;
2015
- // noinspection DuplicatedCode
2016
1951
  if (ChartJs.overrides[config.type] && ChartJs.overrides[config.type].plugins && ChartJs.overrides[config.type].plugins.legend && ChartJs.overrides[config.type].plugins.legend.labels) {
2017
1952
  defaultTypeGenerateLabels = ChartJs.overrides[config.type].plugins.legend.labels.generateLabels;
2018
1953
  }
@@ -2024,13 +1959,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2024
1959
  let data = config.data,
2025
1960
  measureText = chart.ctx.measureText.bind(chart.ctx),
2026
1961
  legend = chart.legend,
2027
- legendLabelOptions = ((legend || {}).options || {}).labels || {},
1962
+ legendProps = legend.getProps(['width', 'maxWidth']) as { width: number; maxWidth: number },
1963
+ legendLabelOptions = ((legend || {}).options || {}).labels || {} as LegendOptions<any>['labels'],
2028
1964
  boxWidth = legendLabelOptions.boxWidth || 0,
2029
1965
  padding = legendLabelOptions.padding || 0,
2030
1966
  horizontalSpace;
2031
1967
  if (scout.isOneOf(config.options.plugins.legend.position, Chart.Position.LEFT, Chart.Position.RIGHT)) {
2032
- if (legend.maxWidth || legend.width) {
2033
- horizontalSpace = Math.max((legend.maxWidth || legend.width) - boxWidth - 2 * padding, 0);
1968
+ if (legendProps.maxWidth || legend.width) {
1969
+ horizontalSpace = Math.max((legendProps.maxWidth || legend.width) - boxWidth - 2 * padding, 0);
2034
1970
  }
2035
1971
  horizontalSpace = Math.min(250, horizontalSpace || 0, this.$canvas.cssWidth() / 3);
2036
1972
 
@@ -2043,7 +1979,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2043
1979
  legendColor, borderColor, backgroundColor;
2044
1980
  if (dataset && scout.isOneOf((dataset.type || config.type), Chart.Type.LINE, Chart.Type.BAR, Chart.Type.RADAR, Chart.Type.BUBBLE, Chart.Type.SCATTER)) {
2045
1981
  legendColor = dataset.legendColor;
2046
- borderColor = this._adjustColorOpacity(dataset.borderColor, 1);
1982
+ borderColor = this._adjustColorOpacity(dataset.borderColor as string, 1);
2047
1983
  } else if (data.datasets.length && scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
2048
1984
  dataset = data.datasets[0];
2049
1985
  legendColor = Array.isArray(dataset.legendColor) ? dataset.legendColor[idx] : dataset.legendColor;
@@ -2062,7 +1998,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2062
1998
  return labels;
2063
1999
  }
2064
2000
 
2065
- _adjustScalesRColors(config) {
2001
+ protected _adjustScalesRColors(config: ChartConfig) {
2066
2002
  if (!config || !config.type || !config.options || !config.options.scales || !config.options.scales.r) {
2067
2003
  return;
2068
2004
  }
@@ -2084,19 +2020,19 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2084
2020
  });
2085
2021
  }
2086
2022
 
2087
- _computeLabelBackdropColor(type) {
2023
+ protected _computeLabelBackdropColor(type: ChartType): string {
2088
2024
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'label-backdrop'], 'fill', {fill: this.firstOpaqueBackgroundColor}).fill;
2089
2025
  }
2090
2026
 
2091
- _computeGridColor(type) {
2027
+ protected _computeGridColor(type: ChartType): string {
2092
2028
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'grid'], 'fill').fill;
2093
2029
  }
2094
2030
 
2095
- _computeScaleTicksColor(type) {
2031
+ protected _computeScaleTicksColor(type: ChartType): string {
2096
2032
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'scale-ticks'], 'fill').fill;
2097
2033
  }
2098
2034
 
2099
- _adjustScalesXYColors(config) {
2035
+ protected _adjustScalesXYColors(config: ChartConfig) {
2100
2036
  if (!config || !config.type || !config.options || !config.options.scales) {
2101
2037
  return;
2102
2038
  }
@@ -2130,11 +2066,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2130
2066
  });
2131
2067
  }
2132
2068
 
2133
- _computeAxisLabelColor(type) {
2069
+ protected _computeAxisLabelColor(type: ChartType): string {
2134
2070
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'axis-label'], 'fill').fill;
2135
2071
  }
2136
2072
 
2137
- _adjustPluginColors(config) {
2073
+ protected _adjustPluginColors(config: ChartConfig) {
2138
2074
  if (!config || !config.type || !config.options || !config.options.plugins) {
2139
2075
  return;
2140
2076
  }
@@ -2142,7 +2078,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2142
2078
  this._adjustPluginsDatalabelColors(config);
2143
2079
  }
2144
2080
 
2145
- _adjustPluginsDatalabelColors(config) {
2081
+ protected _adjustPluginsDatalabelColors(config: ChartConfig) {
2146
2082
  if (!config || !config.type || !config.options || !config.options.plugins || !config.options.plugins.datalabels) {
2147
2083
  return;
2148
2084
  }
@@ -2152,11 +2088,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2152
2088
  });
2153
2089
  }
2154
2090
 
2155
- _computeDatalabelColor(type) {
2091
+ protected _computeDatalabelColor(type: ChartType): string {
2156
2092
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'datalabel'], 'fill').fill;
2157
2093
  }
2158
2094
 
2159
- _adjustClickHandler(config) {
2095
+ protected _adjustClickHandler(config: ChartConfig) {
2160
2096
  if (!config || !config.options) {
2161
2097
  return;
2162
2098
  }
@@ -2184,12 +2120,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2184
2120
  }
2185
2121
  }
2186
2122
 
2187
- /**
2188
- * @param {object[]} items
2189
- * @param {number} items.index
2190
- * @param {number} items.datasetIndex
2191
- */
2192
- _onClick(event, items) {
2123
+ protected _onClick(event: ChartEvent, items: ActiveElement[]) {
2193
2124
  if (!items.length) {
2194
2125
  return;
2195
2126
  }
@@ -2201,33 +2132,25 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2201
2132
 
2202
2133
  let itemIndex = relevantItem.index,
2203
2134
  datasetIndex = relevantItem.datasetIndex,
2204
- clickObject = {
2135
+ clickObject: ClickObject = {
2205
2136
  datasetIndex: datasetIndex,
2206
2137
  dataIndex: itemIndex
2207
2138
  };
2208
2139
  if (scout.isOneOf(this.chartJs.config.type, Chart.Type.BUBBLE, Chart.Type.SCATTER)) {
2209
- let data = this.chartJs.config.data.datasets[datasetIndex].data[itemIndex];
2140
+ let data = this.chartJs.config.data.datasets[datasetIndex].data[itemIndex] as ScatterDataPoint | BubbleDataPoint;
2210
2141
  clickObject.xIndex = data.x;
2211
2142
  clickObject.yIndex = data.y;
2212
2143
  } else {
2213
2144
  clickObject.xIndex = itemIndex;
2214
2145
  }
2215
2146
 
2216
- let e = new Event();
2217
- e.data = clickObject;
2218
- e.originalEvent = event.native;
2219
- this.chart._onValueClick(e);
2147
+ this.chart.handleValueClick(clickObject, event.native);
2220
2148
  }
2221
2149
 
2222
2150
  /**
2223
2151
  * Selects the most relevant item. Default is the first item.
2224
- *
2225
- * @param {object[]} items
2226
- * @param {number} items.index
2227
- * @param {number} items.datasetIndex
2228
- * @private
2229
2152
  */
2230
- _selectRelevantItem(items) {
2153
+ protected _selectRelevantItem(items: ActiveElement[]): ActiveElement {
2231
2154
  let chartDatasets = this.chartJs.config.data.datasets;
2232
2155
  let relevantItem = items[0];
2233
2156
 
@@ -2235,7 +2158,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2235
2158
  // The smallest bubble, which is drawn in the foreground, is the most relevant item for the bubble chart.
2236
2159
  // If two bubbles are the same size, we choose the one which comes later in the array (bubble with array index n + 1 is draw in front of bubble with array index n)
2237
2160
  items.forEach(item => {
2238
- if (chartDatasets[item.datasetIndex].data[item.index].z <= chartDatasets[relevantItem.datasetIndex].data[relevantItem.index].z) {
2161
+ if ((chartDatasets[item.datasetIndex].data[item.index] as BubbleDataPoint).z <= (chartDatasets[relevantItem.datasetIndex].data[relevantItem.index] as BubbleDataPoint).z) {
2239
2162
  relevantItem = item;
2240
2163
  }
2241
2164
  });
@@ -2243,7 +2166,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2243
2166
  return relevantItem;
2244
2167
  }
2245
2168
 
2246
- _onHover(event, items) {
2169
+ protected _onHover(event: ChartEvent, items: ActiveElement[]) {
2247
2170
  if (!this.chartJs.config || !this.chartJs.config.type) {
2248
2171
  return;
2249
2172
  }
@@ -2273,7 +2196,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2273
2196
  }
2274
2197
  }
2275
2198
 
2276
- _onHoverPointer(event, items) {
2199
+ protected _onHoverPointer(event: ChartEvent, items: ActiveElement[]) {
2277
2200
  this._onHover(event, items);
2278
2201
  if (!this.rendered || this.removing) {
2279
2202
  return;
@@ -2285,7 +2208,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2285
2208
  }
2286
2209
  }
2287
2210
 
2288
- _onLegendClick(e, legendItem, legend) {
2211
+ protected _onLegendClick(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2289
2212
  if (!this.chartJs.config || !this.chartJs.config.type) {
2290
2213
  return;
2291
2214
  }
@@ -2298,10 +2221,10 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2298
2221
  let defaultLegendClick = defaultTypeLegendClick || ChartJs.defaults.plugins.legend.onClick;
2299
2222
  defaultLegendClick.call(this.chartJs, e, legendItem, legend);
2300
2223
  this._onLegendLeave(e, legendItem, legend);
2301
- this._onLegendHoverPointer(e, legendItem, true);
2224
+ this._onLegendHoverPointer(e, legendItem, legend);
2302
2225
  }
2303
2226
 
2304
- _onLegendHover(e, legendItem, legend) {
2227
+ protected _onLegendHover(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2305
2228
  let index = legendItem.datasetIndex,
2306
2229
  config = this.chartJs.config,
2307
2230
  type = config.type;
@@ -2324,7 +2247,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2324
2247
  this.legendHoverDatasets.push(index);
2325
2248
  }
2326
2249
 
2327
- _onLegendHoverPointer(e, legendItem, legend) {
2250
+ protected _onLegendHoverPointer(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2328
2251
  this._onLegendHover(e, legendItem, legend);
2329
2252
  if (!this.rendered || this.removing) {
2330
2253
  return;
@@ -2332,7 +2255,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2332
2255
  this.$canvas.css('cursor', 'pointer');
2333
2256
  }
2334
2257
 
2335
- _onLegendLeave(e, legendItem, legend) {
2258
+ protected _onLegendLeave(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2336
2259
  let index = legendItem.datasetIndex,
2337
2260
  config = this.chartJs.config,
2338
2261
  type = config.type;
@@ -2358,16 +2281,15 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2358
2281
  /**
2359
2282
  * Sets the hover background color as the datasets background color.
2360
2283
  * This little workaround is necessary for the line chart, which does not support a native hover effect.
2361
- * The previous background color will be backuped on the dataset property "backgroundColorBackup"
2284
+ * The previous background color will be backed up on the dataset property "backgroundColorBackup"
2362
2285
  * and can be restored with {@link _restoreBackgroundColor}.
2363
- * @param {Dataset} dataset
2364
2286
  */
2365
- _setHoverBackgroundColor(dataset) {
2287
+ protected _setHoverBackgroundColor(dataset: ChartDataset) {
2366
2288
  if (!dataset) {
2367
2289
  return;
2368
2290
  }
2369
2291
  // backup the old background color first
2370
- dataset.backgroundColorBackup = dataset.backgroundColor;
2292
+ dataset.backgroundColorBackup = dataset.backgroundColor as Color;
2371
2293
  // overwrite the current background color with the hover color
2372
2294
  dataset.backgroundColor = dataset.hoverBackgroundColor;
2373
2295
  this._adjustDatasetBorderWidths(dataset);
@@ -2376,9 +2298,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2376
2298
  /**
2377
2299
  * Restores the background color of a dataset or of all datasets,
2378
2300
  * if they were previously overwritten by {@link _setHoverBackgroundColor}.
2379
- * @param {Dataset} [dataset]
2380
2301
  */
2381
- _restoreBackgroundColor(dataset) {
2302
+ protected _restoreBackgroundColor(dataset?: ChartDataset) {
2382
2303
  if (dataset) {
2383
2304
  dataset.backgroundColor = dataset.backgroundColorBackup || dataset.backgroundColor;
2384
2305
  delete dataset.backgroundColorBackup;
@@ -2388,7 +2309,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2388
2309
  }
2389
2310
  }
2390
2311
 
2391
- _onLegendLeavePointer(e, legendItem, legend) {
2312
+ protected _onLegendLeavePointer(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2392
2313
  this._onLegendLeave(e, legendItem, legend);
2393
2314
  if (!this.rendered || this.removing) {
2394
2315
  return;
@@ -2396,7 +2317,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2396
2317
  this.$canvas.css('cursor', 'default');
2397
2318
  }
2398
2319
 
2399
- _updateHoverStyle(datasetIndex, enabled) {
2320
+ protected _updateHoverStyle(datasetIndex: number, enabled: boolean) {
2400
2321
  let config = this.chartJs.config,
2401
2322
  type = config.type,
2402
2323
  mode,
@@ -2423,12 +2344,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2423
2344
  }));
2424
2345
  }
2425
2346
  if (elements && elements.length) {
2426
- // noinspection JSCheckFunctionSignatures
2427
2347
  this.chartJs.updateHoverStyle(elements, mode, enabled);
2428
2348
  }
2429
2349
  }
2430
2350
 
2431
- _adjustResizeHandler(config) {
2351
+ protected _adjustResizeHandler(config: ChartConfig) {
2432
2352
  if (!config || !config.options) {
2433
2353
  return;
2434
2354
  }
@@ -2438,17 +2358,17 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2438
2358
  }
2439
2359
  }
2440
2360
 
2441
- _onResize(chart, size) {
2361
+ protected _onResize(chart: ChartJsChart, size: { width: number; height: number }) {
2442
2362
  chart.update();
2443
2363
  this._adjustSize(chart.config, chart.chartArea);
2444
2364
  }
2445
2365
 
2446
- _adjustSize(config, chartArea) {
2366
+ protected _adjustSize(config: ChartConfig, chartArea: ChartArea) {
2447
2367
  this._adjustBubbleSizes(config, chartArea);
2448
2368
  this._adjustGridMaxMin(config, chartArea);
2449
2369
  }
2450
2370
 
2451
- _adjustBubbleSizes(config, chartArea) {
2371
+ protected _adjustBubbleSizes(config: ChartConfig, chartArea: ChartArea) {
2452
2372
  if (config.type !== Chart.Type.BUBBLE) {
2453
2373
  return;
2454
2374
  }
@@ -2456,7 +2376,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2456
2376
  let datasets = config.data.datasets;
2457
2377
  // Scale all bubbles so that the largest radius is equal to sizeOfLargestBubble and the smallest greater than or equal to minBubbleSize.
2458
2378
  // First reset all radii.
2459
- datasets.forEach(dataset => dataset.data.forEach(data => {
2379
+ datasets.forEach(dataset => dataset.data.forEach((data: BubbleDataPoint) => {
2460
2380
  if (!isNaN(data.z)) {
2461
2381
  data.r = Math.sqrt(data.z);
2462
2382
  }
@@ -2508,14 +2428,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2508
2428
  bubbleScalingFactor = minBubbleSize / minR;
2509
2429
  }
2510
2430
  }
2511
- datasets.forEach(dataset => dataset.data.forEach(data => {
2431
+ datasets.forEach(dataset => dataset.data.forEach((data: BubbleDataPoint) => {
2512
2432
  if (!objects.isNullOrUndefined(data.r)) {
2513
2433
  data.r = data.r * bubbleScalingFactor + bubbleRadiusOffset;
2514
2434
  }
2515
2435
  }));
2516
2436
  }
2517
2437
 
2518
- _computeMaxMinValue(config, datasets, identifier, exact, boundRange, padding, space) {
2438
+ protected _computeMaxMinValue(config: ChartConfig, datasets: ChartDataset[], identifier?: string, exact?: boolean, boundRange?: boolean, padding?: number, space?: number): Boundary {
2519
2439
  if (!datasets) {
2520
2440
  return;
2521
2441
  }
@@ -2587,7 +2507,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2587
2507
  };
2588
2508
  }
2589
2509
 
2590
- _calculateBoundary(value, roundingFunctionPositive, roundingFunctionNegative) {
2510
+ protected _calculateBoundary(value: number, roundingFunctionPositive: (number) => number, roundingFunctionNegative: (number) => number): number {
2591
2511
  let roundingFunction = roundingFunctionPositive;
2592
2512
  let changeValueSign = false;
2593
2513
  if (value < 0) {
@@ -2602,7 +2522,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2602
2522
  return value;
2603
2523
  }
2604
2524
 
2605
- _calculateBoundaryPositive(value, roundingFunction) {
2525
+ protected _calculateBoundaryPositive(value: number, roundingFunction: (number) => number): number {
2606
2526
  if (!(value > 0) || !roundingFunction) {
2607
2527
  return value;
2608
2528
  }
@@ -2622,7 +2542,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2622
2542
  return value;
2623
2543
  }
2624
2544
 
2625
- _adjustGridMaxMin(config, chartArea) {
2545
+ protected _adjustGridMaxMin(config: ChartConfig, chartArea: ChartArea) {
2626
2546
  if (!config || !config.type || !config.options || !config.options.adjustGridMaxMin || !config.options.scales || !chartArea) {
2627
2547
  return;
2628
2548
  }
@@ -2675,7 +2595,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2675
2595
  this._adjustAxisMaxMin(xAxis, maxXTicks, xBoundary);
2676
2596
  }
2677
2597
 
2678
- _computeBoundaryPointElement(config, identifier, space) {
2598
+ protected _computeBoundaryPointElement(config: ChartConfig, identifier: string, space: number): Boundary {
2679
2599
  if (!config || !config.type || !scout.isOneOf(config.type, Chart.Type.BUBBLE, Chart.Type.SCATTER) || !config.data || !config.options || !config.options.scales || !(identifier === 'x' || identifier === 'y') || !space) {
2680
2600
  return;
2681
2601
  }
@@ -2689,7 +2609,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2689
2609
  let maxR = this._computeMaxMinValue(config, datasets, 'r', true).maxValue,
2690
2610
  padding = maxR;
2691
2611
  if (config.options.elements && config.options.elements.point && config.options.elements.point.hoverRadius) {
2692
- padding = padding + config.options.elements.point.hoverRadius;
2612
+ padding = padding + (config.options.elements.point.hoverRadius as number);
2693
2613
  }
2694
2614
 
2695
2615
  if (offset) {
@@ -2704,15 +2624,15 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2704
2624
  return boundary;
2705
2625
  }
2706
2626
 
2707
- _computeXBoundaryPointElement(config, width) {
2627
+ protected _computeXBoundaryPointElement(config: ChartConfig, width: number): Boundary {
2708
2628
  return this._computeBoundaryPointElement(config, 'x', width);
2709
2629
  }
2710
2630
 
2711
- _computeYBoundaryPointElement(config, height) {
2631
+ protected _computeYBoundaryPointElement(config: ChartConfig, height: number): Boundary {
2712
2632
  return this._computeBoundaryPointElement(config, 'y', height);
2713
2633
  }
2714
2634
 
2715
- _computeYBoundaries(config, height) {
2635
+ protected _computeYBoundaries(config: ChartConfig, height: number): { yBoundary?: Boundary; yBoundaryDiffType?: Boundary } {
2716
2636
  if (!config || !config.type) {
2717
2637
  return {};
2718
2638
  }
@@ -2754,7 +2674,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2754
2674
  };
2755
2675
  }
2756
2676
 
2757
- _adjustYAxisDiffType(config, datasets, datasetsDiffType) {
2677
+ protected _adjustYAxisDiffType(config: ChartConfig, datasets: ChartDataset[], datasetsDiffType: ChartDataset[]) {
2758
2678
  if (!config || !config.type || !datasets || !datasets.length || !datasetsDiffType || !datasetsDiffType.length) {
2759
2679
  return;
2760
2680
  }
@@ -2770,9 +2690,6 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2770
2690
  yAxisDiffType = $.extend(true, {}, yAxis);
2771
2691
  scales.yDiffType = yAxisDiffType;
2772
2692
 
2773
- yAxis.id = 'y';
2774
- yAxisDiffType.id = 'yDiffType';
2775
-
2776
2693
  if (config.data && config.data.datasets && config.data.datasets.length && config.data.datasets[0].type && config.data.datasets[0].type !== type) {
2777
2694
  yAxisDiffType.position = Chart.Position.LEFT;
2778
2695
  yAxis.position = Chart.Position.RIGHT;
@@ -2808,7 +2725,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2808
2725
  });
2809
2726
  }
2810
2727
 
2811
- _adjustAxisMaxMin(axis, maxTicks, maxMinValue) {
2728
+ protected _adjustAxisMaxMin(axis: LinearScaleOptions | RadialLinearScaleOptions, maxTicks: number, maxMinValue: Boundary) {
2812
2729
  if (!axis) {
2813
2730
  return;
2814
2731
  }
@@ -2827,7 +2744,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2827
2744
  axis.ticks.stepSize = this.onlyIntegers && maxRangeBetweenTwoTicks < 1 ? 1 : undefined;
2828
2745
  }
2829
2746
 
2830
- _remove(afterRemoveFunc) {
2747
+ protected override _remove(afterRemoveFunc: (chartAnimationStopping?: boolean) => void) {
2831
2748
  if (this.rendered && !this.removing) {
2832
2749
  this.removing = true;
2833
2750
  this.chartJs.destroy();
@@ -2839,3 +2756,92 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2839
2756
  this.removing = false;
2840
2757
  }
2841
2758
  }
2759
+
2760
+ type LabelFormatter = (label: number | string) => string;
2761
+ type AxisFitter = (axis: Scale<CartesianScaleOptions>) => void;
2762
+ type DatalabelsDisplayHandler = (context: Context) => boolean;
2763
+ type DatalabelsFormatter = (value: number | ScatterDataPoint | BubbleDataPoint, context: Context) => string;
2764
+ type DatalabelBackgroundColorHandler = (context: Context) => Color;
2765
+ type RadialChartDatalabelsFormatter = (value: number, context: Context) => string;
2766
+ type LegendLabelGenerator = (chart: ChartJsChart) => LegendItem[];
2767
+ type ChartEventHandler = (event: ChartEvent, items: ActiveElement[]) => void;
2768
+ type LegendEventHandler = (e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) => void;
2769
+ type ResizeHandler = (chart: ChartJsChart | ChartJs, size: { width: number; height: number }) => void;
2770
+ type TooltipTitleGenerator = (tooltipItems: TooltipItem<any>[]) => string | string[];
2771
+ type TooltipItemsGenerator = (tooltipItems: TooltipItem<any>[], tooltipLabel: TooltipLabelGenerator, tooltipLabelValue: TooltipLabelValueGenerator, tooltipColor: TooltipLabelColorGenerator) => string;
2772
+ type TooltipLabelGenerator = (tooltipItem: TooltipItem<any>) => string | string[];
2773
+ type TooltipLabelValueGenerator = (tooltipItem: TooltipItem<any>) => string | { x: string; y: string };
2774
+ type TooltipLabelColorGenerator = (tooltipItem: TooltipItem<any>) => TooltipLabelStyle;
2775
+ type TooltipRenderer = (context: { chart: ChartJs; tooltip: TooltipModel<any> }) => void;
2776
+
2777
+ type DatasetColors = {
2778
+ backgroundColors?: string[];
2779
+ borderColors?: string[];
2780
+ hoverBackgroundColors?: string[];
2781
+ hoverBorderColors?: string[];
2782
+ checkedBackgroundColors?: string[];
2783
+ checkedHoverBackgroundColors?: string[];
2784
+ legendColors?: string[];
2785
+ pointHoverColors?: string[];
2786
+ datalabelColor?: string;
2787
+ };
2788
+
2789
+ type Boundary = { maxValue: number; minValue: number };
2790
+
2791
+ // extend chart.js
2792
+
2793
+ type ChartJsChart = Omit<ChartJs, 'config'> & {
2794
+ config: ChartConfig;
2795
+ legend?: LegendElement<any>;
2796
+ };
2797
+
2798
+ declare module 'chart.js' {
2799
+ interface ChartData<TType extends ChartJsType = ChartJsType, TData = DefaultDataPoint<TType>, TLabel = unknown> {
2800
+ maxSegmentsExceeded?: boolean;
2801
+ }
2802
+
2803
+ interface ChartDatasetProperties<TType extends ChartJsType, TData> {
2804
+ datasetId?: string;
2805
+ yAxisID?: 'y' | 'yDiffType';
2806
+
2807
+ pointBackgroundColor?: Color;
2808
+ pointHoverBackgroundColor?: Color;
2809
+ pointRadius?: number;
2810
+ legendColor?: Color;
2811
+
2812
+ checkedBackgroundColor?: Color;
2813
+ checkedHoverBackgroundColor?: Color;
2814
+ checkedPointBackgroundColor?: Color;
2815
+ checkedPointHoverBackgroundColor?: Color;
2816
+ checkedPointRadius?: number;
2817
+
2818
+ uncheckedBackgroundColor?: Color;
2819
+ uncheckedHoverBackgroundColor?: Color;
2820
+ uncheckedPointBackgroundColor?: Color;
2821
+ uncheckedPointHoverBackgroundColor?: Color;
2822
+ uncheckedPointRadius?: number;
2823
+
2824
+ backgroundColorBackup?: Color;
2825
+ }
2826
+
2827
+ interface BubbleDataPoint {
2828
+ z: number;
2829
+ }
2830
+
2831
+ interface TooltipOptions<TType extends ChartJsType = ChartJsType> {
2832
+ cssClass?: string;
2833
+ }
2834
+
2835
+ interface TooltipCallbacks<TType extends ChartJsType, Model = TooltipModel<TType>, Item = TooltipItem<TType>> {
2836
+ items: TooltipItemsGenerator;
2837
+ labelValue: TooltipLabelValueGenerator;
2838
+ }
2839
+ }
2840
+
2841
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
2842
+ interface RadarPointElement<T extends RadarProps = RadarProps, O extends PointOptions = PointOptions> extends PointElement<T, O> {
2843
+ }
2844
+
2845
+ interface RadarProps extends PointProps {
2846
+ angle: number;
2847
+ }