@eclipse-scout/chart 22.0.39 → 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 (112) 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-dark.css.map +1 -1
  65. package/dist/eclipse-scout-chart-theme-e25b5923d4dba5f5ca7e.min.css +1 -0
  66. package/dist/eclipse-scout-chart-theme.css +1 -1
  67. package/dist/eclipse-scout-chart-theme.css.map +1 -1
  68. package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js +3 -0
  69. package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js.map +1 -0
  70. package/dist/eclipse-scout-chart.esm.js +6919 -0
  71. package/dist/eclipse-scout-chart.esm.js.map +1 -0
  72. package/dist/eclipse-scout-chart.js +683 -15122
  73. package/dist/eclipse-scout-chart.js.map +1 -1
  74. package/dist/file-list +8 -5
  75. package/dist/texts.json +17 -17
  76. package/package.json +21 -15
  77. package/src/chart/{AbstractChartRenderer.js → AbstractChartRenderer.ts} +31 -25
  78. package/src/chart/{AbstractSvgChartRenderer.js → AbstractSvgChartRenderer.ts} +78 -43
  79. package/src/chart/{Chart.js → Chart.ts} +153 -62
  80. package/src/chart/ChartAdapter.ts +27 -0
  81. package/src/chart/ChartEventMap.ts +27 -0
  82. package/src/chart/{ChartJsRenderer.js → ChartJsRenderer.ts} +367 -351
  83. package/src/chart/{ChartLayout.js → ChartLayout.ts} +9 -8
  84. package/src/chart/ChartModel.ts +21 -0
  85. package/src/chart/{FulfillmentChartRenderer.js → FulfillmentChartRenderer.ts} +21 -18
  86. package/src/chart/{SalesfunnelChartRenderer.js → SalesfunnelChartRenderer.ts} +96 -59
  87. package/src/chart/{SpeedoChartRenderer.js → SpeedoChartRenderer.ts} +61 -39
  88. package/src/chart/{VennAsync3Calculator.js → VennAsync3Calculator.ts} +37 -13
  89. package/src/chart/{VennChartRenderer.js → VennChartRenderer.ts} +58 -34
  90. package/src/chart/{VennCircle.js → VennCircle.ts} +22 -15
  91. package/src/chart/{VennCircleHelper.js → VennCircleHelper.ts} +15 -9
  92. package/src/form/fields/chartfield/{ChartField.js → ChartField.ts} +11 -5
  93. package/src/form/fields/chartfield/{ChartFieldAdapter.js → ChartFieldAdapter.ts} +3 -8
  94. package/src/form/fields/chartfield/ChartFieldModel.ts +16 -0
  95. package/src/index.ts +46 -0
  96. package/src/table/controls/{ChartTableControl.js → ChartTableControl.ts} +160 -120
  97. package/src/table/controls/{ChartTableControlAdapter.js → ChartTableControlAdapter.ts} +3 -4
  98. package/src/table/controls/ChartTableControlEventMap.ts +19 -0
  99. package/src/table/controls/{ChartTableControlLayout.js → ChartTableControlLayout.ts} +7 -5
  100. package/src/table/controls/ChartTableControlModel.ts +19 -0
  101. package/src/table/controls/{ChartTableUserFilter.js → ChartTableUserFilter.ts} +25 -12
  102. package/src/table/controls/ChartTableUserFilterModel.ts +19 -0
  103. package/src/tile/{ChartFieldTile.js → ChartFieldTile.ts} +14 -8
  104. package/src/tile/{ChartFieldTileAdapter.js → ChartFieldTileAdapter.ts} +3 -7
  105. package/src/tile/ChartFieldTileModel.ts +16 -0
  106. package/dist/eclipse-scout-chart-bc08151d11e1909eff6c.min.js +0 -3
  107. package/dist/eclipse-scout-chart-bc08151d11e1909eff6c.min.js.LICENSE.txt +0 -6
  108. package/dist/eclipse-scout-chart-bc08151d11e1909eff6c.min.js.map +0 -1
  109. package/dist/eclipse-scout-chart-theme-79622289bda68b525e3e.min.css +0 -1
  110. package/dist/eclipse-scout-chart-theme-dark-1de09c03e3dc40a9529a.min.css +0 -1
  111. package/src/chart/ChartAdapter.js +0 -30
  112. 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
  }
@@ -1021,14 +976,19 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1021
976
  if (dataPoints.length < 1) {
1022
977
  return;
1023
978
  }
979
+ let firstDataPoint = dataPoints[0],
980
+ chart = firstDataPoint.chart;
981
+ if (!chart.getDatasetMeta(firstDataPoint.datasetIndex).data[firstDataPoint.dataIndex]) {
982
+ return;
983
+ }
1024
984
  if (this._tooltip) {
1025
985
  this._tooltip.destroy();
1026
986
  this._tooltip = null;
1027
987
  }
1028
988
 
1029
- let tooltipOptions = tooltip.options || {},
1030
- tooltipCallbacks = tooltipOptions.callbacks || {},
1031
- tooltipTitle = tooltipCallbacks.title,
989
+ let tooltipOptions = tooltip.options || {} as TooltipOptions,
990
+ tooltipCallbacks = tooltipOptions.callbacks || {} as TooltipCallbacks<any>,
991
+ tooltipTitle = tooltipCallbacks.title as TooltipTitleGenerator,
1032
992
  tooltipItems = tooltipCallbacks.items,
1033
993
  tooltipLabel = tooltipCallbacks.label,
1034
994
  tooltipLabelValue = tooltipCallbacks.labelValue,
@@ -1042,14 +1002,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1042
1002
  tooltipText += arrays.ensure(tooltipItems(dataPoints, tooltipLabel, tooltipLabelValue, tooltipColor)).join('');
1043
1003
  }
1044
1004
 
1045
- let positionAndOffset = this._computeTooltipPositionAndOffset(dataPoints[0]),
1005
+ let positionAndOffset = this._computeTooltipPositionAndOffset(firstDataPoint),
1046
1006
  origin = graphics.offsetBounds(this.$canvas);
1047
1007
  origin.x += tooltip.caretX + positionAndOffset.offsetX;
1048
1008
  origin.y += tooltip.caretY + positionAndOffset.offsetY;
1049
1009
  origin.height = positionAndOffset.height;
1050
1010
 
1051
1011
  this._tooltip = scout.create({
1052
- objectType: 'Tooltip',
1012
+ objectType: Tooltip,
1053
1013
  parent: this.chart,
1054
1014
  $anchor: this.$canvas,
1055
1015
  text: tooltipText,
@@ -1064,10 +1024,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1064
1024
  this._tooltip.$container
1065
1025
  .css('pointer-events', 'none');
1066
1026
 
1067
- let reposition = false;
1068
- if ((tooltipOptions.titleFont || {}).family) {
1027
+ let reposition = false,
1028
+ fontFamily = ((tooltipOptions.titleFont || {}) as FontSpec).family;
1029
+ if (fontFamily) {
1069
1030
  this._tooltip.$container
1070
- .css('--chart-tooltip-font-family', tooltipOptions.titleFont.family);
1031
+ .css('--chart-tooltip-font-family', fontFamily);
1071
1032
  reposition = true;
1072
1033
  }
1073
1034
 
@@ -1085,14 +1046,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1085
1046
  }
1086
1047
  }
1087
1048
 
1088
- _computeTooltipPositionAndOffset(tooltipItem) {
1089
- let tooltipPosition = 'top',
1090
- 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',
1091
1052
  offsetX = 0,
1092
1053
  offsetY = 0,
1093
1054
  height = 0;
1094
1055
 
1095
- let chart = tooltipItem.chart,
1056
+ let chart = tooltipItem.chart as ChartJsChart,
1096
1057
  datasetIndex = tooltipItem.datasetIndex,
1097
1058
  dataIndex = tooltipItem.dataIndex,
1098
1059
  config = chart.config,
@@ -1101,26 +1062,23 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1101
1062
  value = dataset.data[dataIndex];
1102
1063
 
1103
1064
  if (this._isHorizontalBar(config)) {
1104
- tooltipDirection = value < 0 ? 'left' : 'right';
1065
+ if (objects.isPlainObject(value) && objects.isArray(value.x) && value.x.length === 2) {
1066
+ let avg = (value.x[0] + value.x[1]) / 2;
1067
+ tooltipDirection = avg < 0 ? 'left' : 'right';
1068
+ } else {
1069
+ tooltipDirection = value < 0 ? 'left' : 'right';
1070
+ }
1105
1071
  } else if ((dataset.type || config.type) === Chart.Type.BAR) {
1106
1072
  tooltipPosition = value < 0 ? 'bottom' : 'top';
1107
1073
  } else if (scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1108
- // noinspection JSValidateTypes
1109
- /**
1110
- * @type ArcElement
1111
- */
1112
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1074
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as ArcElement).getProps(['startAngle', 'endAngle']);
1113
1075
  let startAngle = element.startAngle,
1114
1076
  endAngle = element.endAngle,
1115
1077
  angle = (startAngle + endAngle) / 2;
1116
1078
  tooltipPosition = (0 <= angle && angle < Math.PI) ? 'bottom' : 'top';
1117
1079
  tooltipDirection = (-Math.PI / 2 <= angle && angle < Math.PI / 2) ? 'right' : 'left';
1118
1080
  } else if (config.type === Chart.Type.RADAR) {
1119
- // noinspection JSValidateTypes
1120
- /**
1121
- * @type PointElement
1122
- */
1123
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1081
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as RadarPointElement).getProps(['angle']);
1124
1082
  let angle = element.angle;
1125
1083
  tooltipPosition = (0 <= angle && angle < Math.PI) ? 'bottom' : 'top';
1126
1084
  tooltipDirection = (-Math.PI / 2 <= angle && angle < Math.PI / 2) ? 'right' : 'left';
@@ -1132,11 +1090,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1132
1090
  }
1133
1091
 
1134
1092
  if (this._isHorizontalBar(config)) {
1135
- // noinspection JSValidateTypes
1136
- /**
1137
- * @type BarElement
1138
- */
1139
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1093
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as BarElement).getProps(['height', 'width']);
1140
1094
  height = element.height;
1141
1095
  let width = element.width,
1142
1096
  // golden ratio: (a + b) / a = a / b = PHI
@@ -1147,25 +1101,17 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1147
1101
  offsetY = -height / 2;
1148
1102
  offsetX = tooltipDirection === 'left' ? b : -b;
1149
1103
  } else if (scout.isOneOf(config.type, Chart.Type.LINE, Chart.Type.BUBBLE, Chart.Type.SCATTER, Chart.Type.RADAR) || dataset.type === Chart.Type.LINE) {
1150
- // noinspection JSValidateTypes
1151
- /**
1152
- * @type PointElement
1153
- */
1154
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1155
- 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,
1156
1106
  offset = options.hoverRadius + options.hoverBorderWidth;
1157
1107
  if (config.type === Chart.Type.BUBBLE) {
1158
- offset += value.r;
1108
+ offset += (value as BubbleDataPoint).r;
1159
1109
  }
1160
1110
 
1161
1111
  height = 2 * offset;
1162
1112
  offsetY = -offset;
1163
1113
  } else if (scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1164
- // noinspection JSValidateTypes
1165
- /**
1166
- * @type ArcElement
1167
- */
1168
- let element = chart.getDatasetMeta(datasetIndex).data[dataIndex];
1114
+ let element = (chart.getDatasetMeta(datasetIndex).data[dataIndex] as unknown as ArcElement).getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius']);
1169
1115
  let startAngle = element.startAngle,
1170
1116
  endAngle = element.endAngle,
1171
1117
  angle = (startAngle + endAngle) / 2,
@@ -1179,7 +1125,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1179
1125
  return {tooltipPosition, tooltipDirection, offsetX, offsetY, height};
1180
1126
  }
1181
1127
 
1182
- _adjustGrid(config) {
1128
+ protected _adjustGrid(config: ChartConfig) {
1183
1129
  if (!config) {
1184
1130
  return;
1185
1131
  }
@@ -1190,7 +1136,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1190
1136
  this._adjustScalesXY(config);
1191
1137
  }
1192
1138
 
1193
- _adjustScalesR(config) {
1139
+ protected _adjustScalesR(config: ChartConfig) {
1194
1140
  if (!config || !config.type || !config.options) {
1195
1141
  return;
1196
1142
  }
@@ -1224,7 +1170,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1224
1170
  }
1225
1171
  }
1226
1172
 
1227
- _adjustScalesXY(config) {
1173
+ protected _adjustScalesXY(config: ChartConfig) {
1228
1174
  if (!config || !config.type || !config.options) {
1229
1175
  return;
1230
1176
  }
@@ -1263,7 +1209,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1263
1209
  this._adjustYAxis(config);
1264
1210
  }
1265
1211
 
1266
- _adjustXAxis(config) {
1212
+ protected _adjustXAxis(config: ChartConfig) {
1267
1213
  if (!config || !config.type || !config.options || !config.options.scales || !config.options.scales.x) {
1268
1214
  return;
1269
1215
  }
@@ -1302,7 +1248,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1302
1248
  scales.x.afterCalculateLabelRotation = this._xAxisFitter;
1303
1249
  }
1304
1250
 
1305
- _adjustYAxis(config) {
1251
+ protected _adjustYAxis(config: ChartConfig) {
1306
1252
  if (!config || !config.type || !config.options || !config.options.scales || !config.options.scales.y) {
1307
1253
  return;
1308
1254
  }
@@ -1339,11 +1285,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1339
1285
  scales.y.afterFit = this._yAxisFitter;
1340
1286
  }
1341
1287
 
1342
- _adjustPlugins(config) {
1288
+ protected _adjustPlugins(config: ChartConfig) {
1343
1289
  this._adjustPluginsDatalabels(config);
1344
1290
  }
1345
1291
 
1346
- _adjustPluginsDatalabels(config) {
1292
+ protected _adjustPluginsDatalabels(config: ChartConfig) {
1347
1293
  if (!config || !config.type || !config.options || !config.options.plugins || !config.options.plugins.datalabels || !config.options.plugins.datalabels.display) {
1348
1294
  return;
1349
1295
  }
@@ -1389,8 +1335,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1389
1335
 
1390
1336
  // the datalabels plugin stores its data on the chart in $datalabels (see EXPANDO_KEY in chartjs-plugin-datalabels)
1391
1337
  chart['$' + ChartDataLabels.id]._actives = inactiveElements;
1392
- // noinspection JSCheckFunctionSignatures
1393
- ChartDataLabels.afterEvent(chart);
1338
+ ChartDataLabels.afterEvent(chart, null, null);
1394
1339
  this._updatingDatalabels = false;
1395
1340
  },
1396
1341
  updateDatalabelsAndDefaultCallback = (animation, defaultCallback) => {
@@ -1447,44 +1392,45 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1447
1392
  }, plugins.datalabels);
1448
1393
  }
1449
1394
 
1450
- _formatLabel(label) {
1395
+ protected _formatLabel(label: number | string): string {
1451
1396
  return this._formatLabelMap(label, null, this._getNumberFormatter());
1452
1397
  }
1453
1398
 
1454
- _getNumberFormatter() {
1399
+ protected _getNumberFormatter(): NumberFormatter {
1455
1400
  if (this.chartJs && this.chartJs.config && this.chartJs.config.options) {
1456
1401
  return this.chartJs.config.options.numberFormatter;
1457
1402
  }
1458
1403
  }
1459
1404
 
1460
- _formatXLabel(label) {
1405
+ protected _formatXLabel(label: number | string): string {
1461
1406
  return this._formatLabelMap(label, this._getXLabelMap(), this._getNumberFormatter());
1462
1407
  }
1463
1408
 
1464
- _formatYLabel(label) {
1409
+ protected _formatYLabel(label: number | string): string {
1465
1410
  return this._formatLabelMap(label, this._getYLabelMap(), this._getNumberFormatter());
1466
1411
  }
1467
1412
 
1468
- _getXLabelMap() {
1413
+ protected _getXLabelMap(): Record<number | string, string> {
1469
1414
  return this._getLabelMap('xLabelMap');
1470
1415
  }
1471
1416
 
1472
- _getYLabelMap() {
1417
+ protected _getYLabelMap(): Record<number | string, string> {
1473
1418
  return this._getLabelMap('yLabelMap');
1474
1419
  }
1475
1420
 
1476
- _getLabelMap(identifier) {
1421
+ protected _getLabelMap(identifier): Record<number | string, string> {
1477
1422
  if (this.chartJs && this.chartJs.config && this.chartJs.config.options) {
1478
1423
  return this.chartJs.config.options[identifier];
1479
1424
  }
1480
1425
  }
1481
1426
 
1482
- _formatLabelMap(label, labelMap, numberFormatter) {
1427
+ protected _formatLabelMap(label: number | string, labelMap: Record<string, string>, numberFormatter: NumberFormatter): string {
1483
1428
  if (labelMap) {
1484
1429
  return labelMap[label];
1485
1430
  }
1431
+ // @ts-expect-error
1486
1432
  if (isNaN(label)) {
1487
- return label;
1433
+ return '' + label;
1488
1434
  }
1489
1435
  if (numberFormatter) {
1490
1436
  return numberFormatter(label, this._formatNumberLabel.bind(this));
@@ -1492,10 +1438,12 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1492
1438
  return this._formatNumberLabel(label);
1493
1439
  }
1494
1440
 
1495
- _formatNumberLabel(label) {
1441
+ protected _formatNumberLabel(label: number | string): string {
1442
+ // @ts-expect-error
1496
1443
  if (isNaN(label)) {
1497
- return label;
1444
+ return '' + label;
1498
1445
  }
1446
+ // @ts-expect-error
1499
1447
  let abs = Math.abs(label);
1500
1448
  let abbreviation = '';
1501
1449
  if (abs >= 1000000) {
@@ -1516,20 +1464,18 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1516
1464
  }
1517
1465
  }
1518
1466
  }
1467
+ // @ts-expect-error
1519
1468
  return this.session.locale.decimalFormat.format(Math.sign(label) * abs) + abbreviation;
1520
1469
  }
1521
1470
 
1522
- /**
1523
- * @param {Scale} xAxis
1524
- */
1525
- _fitXAxis(xAxis) {
1471
+ protected _fitXAxis(xAxis: Scale<CartesianScaleOptions>) {
1526
1472
  if (!xAxis || xAxis.labelRotation === 0) {
1527
1473
  return;
1528
1474
  }
1529
- let maxHeight = this.maxXAxesTicksHeigth,
1475
+ let maxHeight = this.maxXAxesTicksHeight,
1530
1476
  fontDefaults = ChartJs.defaults.font,
1531
- ticksDefaults = ChartJs.defaults.scale.ticks,
1532
- ticksFontDefaults = ticksDefaults.font || {},
1477
+ ticksDefaults = (ChartJs.defaults.scale as CartesianScaleOptions).ticks,
1478
+ ticksFontDefaults = (ticksDefaults.font || {}) as FontSpec,
1533
1479
  fontSize,
1534
1480
  maxRotation;
1535
1481
  if (this.chartJs) {
@@ -1539,7 +1485,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1539
1485
  }
1540
1486
  if (xAxis.options && xAxis.options.ticks) {
1541
1487
  maxRotation = xAxis.options.ticks.maxRotation;
1542
- let ticksFont = xAxis.options.ticks.font || {};
1488
+ let ticksFont = (xAxis.options.ticks.font || {}) as FontSpec;
1543
1489
  fontSize = ticksFont.size;
1544
1490
  }
1545
1491
  maxRotation = maxRotation || ticksDefaults.maxRotation;
@@ -1556,19 +1502,21 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1556
1502
  // => height = sin(labelRotation) * labelLength + sin(90° - labelRotation) * fontSize
1557
1503
  // <=> labelLength = (height - sin(90° - labelRotation) * fontSize) / sin(labelRotation)
1558
1504
  maxLabelLength = (maxHeight - (fontSize * Math.sin(((90 - labelRotation) / 180) * Math.PI))) / Math.sin((labelRotation / 180) * Math.PI);
1505
+ // @ts-expect-error
1559
1506
  let labelSizes = xAxis._labelSizes || {},
1560
1507
  widest = labelSizes.widest || {};
1561
1508
  if (widest.width > maxLabelLength) {
1562
1509
  let measureText = xAxis.ctx.measureText.bind(xAxis.ctx);
1563
1510
  xAxis.ticks.forEach(tick => {
1564
- tick.label = strings.truncateText(tick.label, maxLabelLength, measureText);
1511
+ tick.label = strings.truncateText(tick.label as string, maxLabelLength, measureText);
1565
1512
  });
1566
1513
  // reset label sizes, chart.js will recalculate them using the new truncated labels
1514
+ // @ts-expect-error
1567
1515
  xAxis._labelSizes = undefined;
1568
1516
  }
1569
1517
  }
1570
1518
 
1571
- _fitYAxis(yAxis) {
1519
+ protected _fitYAxis(yAxis: Scale<CartesianScaleOptions>) {
1572
1520
  if (!yAxis) {
1573
1521
  return;
1574
1522
  }
@@ -1580,23 +1528,20 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1580
1528
  if (yAxis.options && yAxis.options.grid) {
1581
1529
  tickLength = yAxis.options.grid.tickLength || 0;
1582
1530
  }
1531
+ // @ts-expect-error
1583
1532
  let labelSizes = yAxis._labelSizes || {},
1584
1533
  widest = labelSizes.widest || {};
1585
1534
  if (widest.width > yAxis.maxWidth - padding) {
1586
1535
  let horizontalSpace = yAxis.maxWidth - padding - tickLength,
1587
1536
  measureText = yAxis.ctx.measureText.bind(yAxis.ctx);
1588
1537
  yAxis.ticks.forEach(tick => {
1589
- tick.label = strings.truncateText(tick.label, horizontalSpace, measureText);
1538
+ tick.label = strings.truncateText(tick.label as string, horizontalSpace, measureText);
1590
1539
  });
1591
1540
  }
1592
1541
  }
1593
1542
 
1594
- _displayDatalabelsOnRadialChart(context) {
1595
- // noinspection JSValidateTypes
1596
- /**
1597
- * @type ArcElement
1598
- */
1599
- 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']);
1600
1545
  // Compute the biggest circle that fits inside sector/arc with center in the middle between inner and outer radius.
1601
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.
1602
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.
@@ -1611,13 +1556,13 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1611
1556
  return Math.min(diameter1, diameter2) > this.minRadialChartDatalabelSpace;
1612
1557
  }
1613
1558
 
1614
- _formatDatalabelsOnRadialChart(value, context) {
1559
+ protected _formatDatalabelsOnRadialChart(value: number, context: Context): string {
1615
1560
  let sum = this._computeSumOfVisibleElements(context),
1616
1561
  dataset = context.dataset,
1617
1562
  roundingError = 0,
1618
1563
  roundedResults = [];
1619
1564
  for (let i = 0; i < context.dataIndex + 1; i++) {
1620
- let result = dataset.data[i] / sum * 100 - roundingError,
1565
+ let result = (dataset.data[i] as number) / sum * 100 - roundingError,
1621
1566
  roundedResult = Math.round(result);
1622
1567
  roundingError = roundedResult - result;
1623
1568
  roundedResults.push(roundedResult + '%');
@@ -1625,32 +1570,33 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1625
1570
  return roundedResults[context.dataIndex];
1626
1571
  }
1627
1572
 
1628
- _computeSumOfVisibleElements(context) {
1573
+ protected _computeSumOfVisibleElements(context: Context): number {
1629
1574
  let dataset = context.dataset,
1630
1575
  chart = context.chart,
1631
1576
  sum = 0;
1632
1577
  for (let i = 0; i < dataset.data.length; i++) {
1633
1578
  if (chart.getDataVisibility(i)) {
1634
- sum += dataset.data[i];
1579
+ sum += dataset.data[i] as number;
1635
1580
  }
1636
1581
  }
1637
1582
  return sum;
1638
1583
  }
1639
1584
 
1640
- _formatDatalabels(value, context) {
1641
- if (context.chart.config.type === Chart.Type.BUBBLE) {
1642
- return this._formatLabel(value.z);
1643
- } else if (context.chart.config.type === Chart.Type.SCATTER) {
1644
- 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));
1645
1591
  }
1646
- return this._formatLabel(value);
1592
+ return this._formatLabel(value as number);
1647
1593
  }
1648
1594
 
1649
- _getBackgroundColorOfDataset(context) {
1650
- return context.dataset.backgroundColor;
1595
+ protected _getBackgroundColorOfDataset(context: Context): Color {
1596
+ return context.dataset.backgroundColor as Color;
1651
1597
  }
1652
1598
 
1653
- _adjustColors(config) {
1599
+ protected _adjustColors(config: ChartConfig) {
1654
1600
  this._adjustColorSchemeCssClass(config);
1655
1601
  this._adjustDatasetColors(config);
1656
1602
  this._adjustLegendColors(config);
@@ -1659,14 +1605,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1659
1605
  this._adjustPluginColors(config);
1660
1606
  }
1661
1607
 
1662
- _adjustColorSchemeCssClass(config) {
1608
+ protected _adjustColorSchemeCssClass(config: ChartConfig) {
1663
1609
  if (!config || !config.options) {
1664
1610
  return;
1665
1611
  }
1666
1612
  this.colorSchemeCssClass = colorSchemes.getCssClasses(config.options.colorScheme).join(' ');
1667
1613
  }
1668
1614
 
1669
- _adjustDatasetColors(config) {
1615
+ protected _adjustDatasetColors(config: ChartConfig) {
1670
1616
  if (!config || !config.data || !config.type) {
1671
1617
  return;
1672
1618
  }
@@ -1745,7 +1691,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1745
1691
  setProperty('pointHoverBackgroundColor', elem.uncheckedPointHoverBackgroundColor);
1746
1692
 
1747
1693
  let uncheckedPointRadius = arrays.init(datasetLength, ((config.options.elements || {}).point || {}).radius || ChartJs.defaults.elements.point.radius),
1748
- 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);
1749
1695
  setProperty('uncheckedPointRadius', uncheckedPointRadius);
1750
1696
  setProperty('checkedPointRadius', checkedPointRadius);
1751
1697
 
@@ -1759,14 +1705,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1759
1705
  }
1760
1706
  }
1761
1707
 
1762
- _computeDatasetColors(config, multipleColorsPerDataset) {
1708
+ protected _computeDatasetColors(config: ChartConfig, multipleColorsPerDataset: boolean): DatasetColors {
1763
1709
  if (!config || !config.data || !config.type) {
1764
1710
  return {};
1765
1711
  }
1766
1712
 
1767
1713
  let data = config.data,
1768
1714
  type = config.type,
1769
- colors = {};
1715
+ colors: DatasetColors = {};
1770
1716
 
1771
1717
  if (config.options && config.options.autoColor) {
1772
1718
  colors = this._computeDatasetColorsAutoColor(config, multipleColorsPerDataset);
@@ -1782,7 +1728,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1782
1728
  return colors;
1783
1729
  }
1784
1730
 
1785
- _computeDatasetColorsAutoColor(config, multipleColorsPerDataset) {
1731
+ protected _computeDatasetColorsAutoColor(config: ChartConfig, multipleColorsPerDataset: boolean): DatasetColors {
1786
1732
  if (!config || !config.data || !config.type || !config.options || !config.options.autoColor) {
1787
1733
  return {};
1788
1734
  }
@@ -1825,11 +1771,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1825
1771
  return colors;
1826
1772
  }
1827
1773
 
1828
- _computeBackgroundColor(type, index, checkable) {
1774
+ protected _computeBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1829
1775
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors)], 'fill').fill;
1830
1776
  }
1831
1777
 
1832
- _computeBorderColor(type, index) {
1778
+ protected _computeBorderColor(type: ChartType, index: number): string {
1833
1779
  let additionalProperties;
1834
1780
  if (scout.isOneOf(type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1835
1781
  additionalProperties = {stroke: this.firstOpaqueBackgroundColor};
@@ -1837,11 +1783,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1837
1783
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'stroke-color' + (index % this.numSupportedColors)], 'stroke', additionalProperties).stroke;
1838
1784
  }
1839
1785
 
1840
- _computeHoverBackgroundColor(type, index, checkable) {
1786
+ protected _computeHoverBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1841
1787
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors) + ' hover'], 'fill').fill;
1842
1788
  }
1843
1789
 
1844
- _computeHoverBorderColor(type, index) {
1790
+ protected _computeHoverBorderColor(type: ChartType, index: number): string {
1845
1791
  let additionalProperties;
1846
1792
  if (scout.isOneOf(type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
1847
1793
  additionalProperties = {stroke: this.firstOpaqueBackgroundColor};
@@ -1849,23 +1795,23 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1849
1795
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'stroke-color' + (index % this.numSupportedColors) + ' hover'], 'stroke', additionalProperties).stroke;
1850
1796
  }
1851
1797
 
1852
- _computeCheckedBackgroundColor(type, index, checkable) {
1798
+ protected _computeCheckedBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1853
1799
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors) + ' checked'], 'fill').fill;
1854
1800
  }
1855
1801
 
1856
- _computeCheckedHoverBackgroundColor(type, index, checkable) {
1802
+ protected _computeCheckedHoverBackgroundColor(type: ChartType, index: number, checkable: boolean): string {
1857
1803
  return styles.get([this.colorSchemeCssClass, type + '-chart' + (checkable ? ' checkable' : ''), 'elements', 'color' + (index % this.numSupportedColors) + ' hover checked'], 'fill').fill;
1858
1804
  }
1859
1805
 
1860
- _computeLegendColor(type, index) {
1806
+ protected _computeLegendColor(type: ChartType, index: number): string {
1861
1807
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'color' + (index % this.numSupportedColors) + ' legend'], 'fill').fill;
1862
1808
  }
1863
1809
 
1864
- _computePointHoverColor(type, index) {
1810
+ protected _computePointHoverColor(type: ChartType, index: number): string {
1865
1811
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'color' + (index % this.numSupportedColors) + ' point hover'], 'fill').fill;
1866
1812
  }
1867
1813
 
1868
- _computeDatasetColorsChartValueGroups(config, multipleColorsPerDataset) {
1814
+ protected _computeDatasetColorsChartValueGroups(config: ChartConfig, multipleColorsPerDataset: boolean): DatasetColors {
1869
1815
  if (!config || !config.type || !this.chart.data) {
1870
1816
  return {};
1871
1817
  }
@@ -1873,7 +1819,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1873
1819
  let type = config.type,
1874
1820
  checkable = config.options && config.options.checkable,
1875
1821
  transparent = config.options && config.options.transparent,
1876
- colors = {
1822
+ colors: DatasetColors = {
1877
1823
  backgroundColors: [],
1878
1824
  borderColors: [],
1879
1825
  hoverBackgroundColors: [],
@@ -1948,7 +1894,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1948
1894
  return colors;
1949
1895
  }
1950
1896
 
1951
- _adjustColorOpacity(color, opacity = 1) {
1897
+ protected _adjustColorOpacity(color: string, opacity = 1): string {
1952
1898
  if (!color || typeof color === 'function') {
1953
1899
  return color;
1954
1900
  }
@@ -1962,7 +1908,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1962
1908
  return color;
1963
1909
  }
1964
1910
 
1965
- _adjustRgbColorOpacity(rgbColor, opacity = 1) {
1911
+ protected _adjustRgbColorOpacity(rgbColor: string, opacity = 1): string {
1966
1912
  if (!rgbColor || rgbColor.indexOf('rgb') !== 0) {
1967
1913
  return rgbColor;
1968
1914
  }
@@ -1971,14 +1917,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1971
1917
  return 'rgba(' + rgba.red + ', ' + rgba.green + ', ' + rgba.blue + ', ' + rgba.alpha + ')';
1972
1918
  }
1973
1919
 
1974
- _adjustHexColorOpacity(hexColor, opacity = 1) {
1920
+ protected _adjustHexColorOpacity(hexColor: string, opacity = 1): string {
1975
1921
  if (!hexColor || hexColor.indexOf('#') !== 0 || !(hexColor.length === 4 || hexColor.length === 5 || hexColor.length === 7 || hexColor.length === 9)) {
1976
1922
  return hexColor;
1977
1923
  }
1978
1924
  return this._adjustRgbColorOpacity(styles.hexToRgb(hexColor), opacity);
1979
1925
  }
1980
1926
 
1981
- _adjustLegendColors(config) {
1927
+ protected _adjustLegendColors(config: ChartConfig) {
1982
1928
  if (!config || !config.type || !config.options) {
1983
1929
  return;
1984
1930
  }
@@ -1995,14 +1941,13 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1995
1941
  });
1996
1942
  }
1997
1943
 
1998
- _computeLabelColor(type) {
1944
+ protected _computeLabelColor(type: ChartType): string {
1999
1945
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'label'], 'fill').fill;
2000
1946
  }
2001
1947
 
2002
- _generateLegendLabels(chart) {
1948
+ protected _generateLegendLabels(chart: ChartJsChart): LegendItem[] {
2003
1949
  let config = chart.config,
2004
1950
  defaultTypeGenerateLabels;
2005
- // noinspection DuplicatedCode
2006
1951
  if (ChartJs.overrides[config.type] && ChartJs.overrides[config.type].plugins && ChartJs.overrides[config.type].plugins.legend && ChartJs.overrides[config.type].plugins.legend.labels) {
2007
1952
  defaultTypeGenerateLabels = ChartJs.overrides[config.type].plugins.legend.labels.generateLabels;
2008
1953
  }
@@ -2014,13 +1959,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2014
1959
  let data = config.data,
2015
1960
  measureText = chart.ctx.measureText.bind(chart.ctx),
2016
1961
  legend = chart.legend,
2017
- legendLabelOptions = ((legend || {}).options || {}).labels || {},
1962
+ legendProps = legend.getProps(['width', 'maxWidth']) as { width: number; maxWidth: number },
1963
+ legendLabelOptions = ((legend || {}).options || {}).labels || {} as LegendOptions<any>['labels'],
2018
1964
  boxWidth = legendLabelOptions.boxWidth || 0,
2019
1965
  padding = legendLabelOptions.padding || 0,
2020
1966
  horizontalSpace;
2021
1967
  if (scout.isOneOf(config.options.plugins.legend.position, Chart.Position.LEFT, Chart.Position.RIGHT)) {
2022
- if (legend.maxWidth || legend.width) {
2023
- 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);
2024
1970
  }
2025
1971
  horizontalSpace = Math.min(250, horizontalSpace || 0, this.$canvas.cssWidth() / 3);
2026
1972
 
@@ -2033,7 +1979,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2033
1979
  legendColor, borderColor, backgroundColor;
2034
1980
  if (dataset && scout.isOneOf((dataset.type || config.type), Chart.Type.LINE, Chart.Type.BAR, Chart.Type.RADAR, Chart.Type.BUBBLE, Chart.Type.SCATTER)) {
2035
1981
  legendColor = dataset.legendColor;
2036
- borderColor = this._adjustColorOpacity(dataset.borderColor, 1);
1982
+ borderColor = this._adjustColorOpacity(dataset.borderColor as string, 1);
2037
1983
  } else if (data.datasets.length && scout.isOneOf(config.type, Chart.Type.PIE, Chart.Type.DOUGHNUT, Chart.Type.POLAR_AREA)) {
2038
1984
  dataset = data.datasets[0];
2039
1985
  legendColor = Array.isArray(dataset.legendColor) ? dataset.legendColor[idx] : dataset.legendColor;
@@ -2052,7 +1998,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2052
1998
  return labels;
2053
1999
  }
2054
2000
 
2055
- _adjustScalesRColors(config) {
2001
+ protected _adjustScalesRColors(config: ChartConfig) {
2056
2002
  if (!config || !config.type || !config.options || !config.options.scales || !config.options.scales.r) {
2057
2003
  return;
2058
2004
  }
@@ -2074,19 +2020,19 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2074
2020
  });
2075
2021
  }
2076
2022
 
2077
- _computeLabelBackdropColor(type) {
2023
+ protected _computeLabelBackdropColor(type: ChartType): string {
2078
2024
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'label-backdrop'], 'fill', {fill: this.firstOpaqueBackgroundColor}).fill;
2079
2025
  }
2080
2026
 
2081
- _computeGridColor(type) {
2027
+ protected _computeGridColor(type: ChartType): string {
2082
2028
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'grid'], 'fill').fill;
2083
2029
  }
2084
2030
 
2085
- _computeScaleTicksColor(type) {
2031
+ protected _computeScaleTicksColor(type: ChartType): string {
2086
2032
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'scale-ticks'], 'fill').fill;
2087
2033
  }
2088
2034
 
2089
- _adjustScalesXYColors(config) {
2035
+ protected _adjustScalesXYColors(config: ChartConfig) {
2090
2036
  if (!config || !config.type || !config.options || !config.options.scales) {
2091
2037
  return;
2092
2038
  }
@@ -2120,11 +2066,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2120
2066
  });
2121
2067
  }
2122
2068
 
2123
- _computeAxisLabelColor(type) {
2069
+ protected _computeAxisLabelColor(type: ChartType): string {
2124
2070
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'axis-label'], 'fill').fill;
2125
2071
  }
2126
2072
 
2127
- _adjustPluginColors(config) {
2073
+ protected _adjustPluginColors(config: ChartConfig) {
2128
2074
  if (!config || !config.type || !config.options || !config.options.plugins) {
2129
2075
  return;
2130
2076
  }
@@ -2132,7 +2078,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2132
2078
  this._adjustPluginsDatalabelColors(config);
2133
2079
  }
2134
2080
 
2135
- _adjustPluginsDatalabelColors(config) {
2081
+ protected _adjustPluginsDatalabelColors(config: ChartConfig) {
2136
2082
  if (!config || !config.type || !config.options || !config.options.plugins || !config.options.plugins.datalabels) {
2137
2083
  return;
2138
2084
  }
@@ -2142,11 +2088,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2142
2088
  });
2143
2089
  }
2144
2090
 
2145
- _computeDatalabelColor(type) {
2091
+ protected _computeDatalabelColor(type: ChartType): string {
2146
2092
  return styles.get([this.colorSchemeCssClass, type + '-chart', 'elements', 'datalabel'], 'fill').fill;
2147
2093
  }
2148
2094
 
2149
- _adjustClickHandler(config) {
2095
+ protected _adjustClickHandler(config: ChartConfig) {
2150
2096
  if (!config || !config.options) {
2151
2097
  return;
2152
2098
  }
@@ -2174,12 +2120,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2174
2120
  }
2175
2121
  }
2176
2122
 
2177
- /**
2178
- * @param {object[]} items
2179
- * @param {number} items.index
2180
- * @param {number} items.datasetIndex
2181
- */
2182
- _onClick(event, items) {
2123
+ protected _onClick(event: ChartEvent, items: ActiveElement[]) {
2183
2124
  if (!items.length) {
2184
2125
  return;
2185
2126
  }
@@ -2191,33 +2132,25 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2191
2132
 
2192
2133
  let itemIndex = relevantItem.index,
2193
2134
  datasetIndex = relevantItem.datasetIndex,
2194
- clickObject = {
2135
+ clickObject: ClickObject = {
2195
2136
  datasetIndex: datasetIndex,
2196
2137
  dataIndex: itemIndex
2197
2138
  };
2198
2139
  if (scout.isOneOf(this.chartJs.config.type, Chart.Type.BUBBLE, Chart.Type.SCATTER)) {
2199
- let data = this.chartJs.config.data.datasets[datasetIndex].data[itemIndex];
2140
+ let data = this.chartJs.config.data.datasets[datasetIndex].data[itemIndex] as ScatterDataPoint | BubbleDataPoint;
2200
2141
  clickObject.xIndex = data.x;
2201
2142
  clickObject.yIndex = data.y;
2202
2143
  } else {
2203
2144
  clickObject.xIndex = itemIndex;
2204
2145
  }
2205
2146
 
2206
- let e = new Event();
2207
- e.data = clickObject;
2208
- e.originalEvent = event.native;
2209
- this.chart._onValueClick(e);
2147
+ this.chart.handleValueClick(clickObject, event.native);
2210
2148
  }
2211
2149
 
2212
2150
  /**
2213
2151
  * Selects the most relevant item. Default is the first item.
2214
- *
2215
- * @param {object[]} items
2216
- * @param {number} items.index
2217
- * @param {number} items.datasetIndex
2218
- * @private
2219
2152
  */
2220
- _selectRelevantItem(items) {
2153
+ protected _selectRelevantItem(items: ActiveElement[]): ActiveElement {
2221
2154
  let chartDatasets = this.chartJs.config.data.datasets;
2222
2155
  let relevantItem = items[0];
2223
2156
 
@@ -2225,7 +2158,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2225
2158
  // The smallest bubble, which is drawn in the foreground, is the most relevant item for the bubble chart.
2226
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)
2227
2160
  items.forEach(item => {
2228
- 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) {
2229
2162
  relevantItem = item;
2230
2163
  }
2231
2164
  });
@@ -2233,7 +2166,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2233
2166
  return relevantItem;
2234
2167
  }
2235
2168
 
2236
- _onHover(event, items) {
2169
+ protected _onHover(event: ChartEvent, items: ActiveElement[]) {
2237
2170
  if (!this.chartJs.config || !this.chartJs.config.type) {
2238
2171
  return;
2239
2172
  }
@@ -2263,7 +2196,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2263
2196
  }
2264
2197
  }
2265
2198
 
2266
- _onHoverPointer(event, items) {
2199
+ protected _onHoverPointer(event: ChartEvent, items: ActiveElement[]) {
2267
2200
  this._onHover(event, items);
2268
2201
  if (!this.rendered || this.removing) {
2269
2202
  return;
@@ -2275,7 +2208,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2275
2208
  }
2276
2209
  }
2277
2210
 
2278
- _onLegendClick(e, legendItem, legend) {
2211
+ protected _onLegendClick(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2279
2212
  if (!this.chartJs.config || !this.chartJs.config.type) {
2280
2213
  return;
2281
2214
  }
@@ -2288,10 +2221,10 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2288
2221
  let defaultLegendClick = defaultTypeLegendClick || ChartJs.defaults.plugins.legend.onClick;
2289
2222
  defaultLegendClick.call(this.chartJs, e, legendItem, legend);
2290
2223
  this._onLegendLeave(e, legendItem, legend);
2291
- this._onLegendHoverPointer(e, legendItem, true);
2224
+ this._onLegendHoverPointer(e, legendItem, legend);
2292
2225
  }
2293
2226
 
2294
- _onLegendHover(e, legendItem, legend) {
2227
+ protected _onLegendHover(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2295
2228
  let index = legendItem.datasetIndex,
2296
2229
  config = this.chartJs.config,
2297
2230
  type = config.type;
@@ -2314,7 +2247,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2314
2247
  this.legendHoverDatasets.push(index);
2315
2248
  }
2316
2249
 
2317
- _onLegendHoverPointer(e, legendItem, legend) {
2250
+ protected _onLegendHoverPointer(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2318
2251
  this._onLegendHover(e, legendItem, legend);
2319
2252
  if (!this.rendered || this.removing) {
2320
2253
  return;
@@ -2322,7 +2255,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2322
2255
  this.$canvas.css('cursor', 'pointer');
2323
2256
  }
2324
2257
 
2325
- _onLegendLeave(e, legendItem, legend) {
2258
+ protected _onLegendLeave(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2326
2259
  let index = legendItem.datasetIndex,
2327
2260
  config = this.chartJs.config,
2328
2261
  type = config.type;
@@ -2348,16 +2281,15 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2348
2281
  /**
2349
2282
  * Sets the hover background color as the datasets background color.
2350
2283
  * This little workaround is necessary for the line chart, which does not support a native hover effect.
2351
- * 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"
2352
2285
  * and can be restored with {@link _restoreBackgroundColor}.
2353
- * @param {Dataset} dataset
2354
2286
  */
2355
- _setHoverBackgroundColor(dataset) {
2287
+ protected _setHoverBackgroundColor(dataset: ChartDataset) {
2356
2288
  if (!dataset) {
2357
2289
  return;
2358
2290
  }
2359
2291
  // backup the old background color first
2360
- dataset.backgroundColorBackup = dataset.backgroundColor;
2292
+ dataset.backgroundColorBackup = dataset.backgroundColor as Color;
2361
2293
  // overwrite the current background color with the hover color
2362
2294
  dataset.backgroundColor = dataset.hoverBackgroundColor;
2363
2295
  this._adjustDatasetBorderWidths(dataset);
@@ -2366,9 +2298,8 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2366
2298
  /**
2367
2299
  * Restores the background color of a dataset or of all datasets,
2368
2300
  * if they were previously overwritten by {@link _setHoverBackgroundColor}.
2369
- * @param {Dataset} [dataset]
2370
2301
  */
2371
- _restoreBackgroundColor(dataset) {
2302
+ protected _restoreBackgroundColor(dataset?: ChartDataset) {
2372
2303
  if (dataset) {
2373
2304
  dataset.backgroundColor = dataset.backgroundColorBackup || dataset.backgroundColor;
2374
2305
  delete dataset.backgroundColorBackup;
@@ -2378,7 +2309,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2378
2309
  }
2379
2310
  }
2380
2311
 
2381
- _onLegendLeavePointer(e, legendItem, legend) {
2312
+ protected _onLegendLeavePointer(e: ChartEvent, legendItem: LegendItem, legend: LegendElement<any>) {
2382
2313
  this._onLegendLeave(e, legendItem, legend);
2383
2314
  if (!this.rendered || this.removing) {
2384
2315
  return;
@@ -2386,7 +2317,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2386
2317
  this.$canvas.css('cursor', 'default');
2387
2318
  }
2388
2319
 
2389
- _updateHoverStyle(datasetIndex, enabled) {
2320
+ protected _updateHoverStyle(datasetIndex: number, enabled: boolean) {
2390
2321
  let config = this.chartJs.config,
2391
2322
  type = config.type,
2392
2323
  mode,
@@ -2413,12 +2344,11 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2413
2344
  }));
2414
2345
  }
2415
2346
  if (elements && elements.length) {
2416
- // noinspection JSCheckFunctionSignatures
2417
2347
  this.chartJs.updateHoverStyle(elements, mode, enabled);
2418
2348
  }
2419
2349
  }
2420
2350
 
2421
- _adjustResizeHandler(config) {
2351
+ protected _adjustResizeHandler(config: ChartConfig) {
2422
2352
  if (!config || !config.options) {
2423
2353
  return;
2424
2354
  }
@@ -2428,17 +2358,17 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2428
2358
  }
2429
2359
  }
2430
2360
 
2431
- _onResize(chart, size) {
2361
+ protected _onResize(chart: ChartJsChart, size: { width: number; height: number }) {
2432
2362
  chart.update();
2433
2363
  this._adjustSize(chart.config, chart.chartArea);
2434
2364
  }
2435
2365
 
2436
- _adjustSize(config, chartArea) {
2366
+ protected _adjustSize(config: ChartConfig, chartArea: ChartArea) {
2437
2367
  this._adjustBubbleSizes(config, chartArea);
2438
2368
  this._adjustGridMaxMin(config, chartArea);
2439
2369
  }
2440
2370
 
2441
- _adjustBubbleSizes(config, chartArea) {
2371
+ protected _adjustBubbleSizes(config: ChartConfig, chartArea: ChartArea) {
2442
2372
  if (config.type !== Chart.Type.BUBBLE) {
2443
2373
  return;
2444
2374
  }
@@ -2446,7 +2376,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2446
2376
  let datasets = config.data.datasets;
2447
2377
  // Scale all bubbles so that the largest radius is equal to sizeOfLargestBubble and the smallest greater than or equal to minBubbleSize.
2448
2378
  // First reset all radii.
2449
- datasets.forEach(dataset => dataset.data.forEach(data => {
2379
+ datasets.forEach(dataset => dataset.data.forEach((data: BubbleDataPoint) => {
2450
2380
  if (!isNaN(data.z)) {
2451
2381
  data.r = Math.sqrt(data.z);
2452
2382
  }
@@ -2498,14 +2428,14 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2498
2428
  bubbleScalingFactor = minBubbleSize / minR;
2499
2429
  }
2500
2430
  }
2501
- datasets.forEach(dataset => dataset.data.forEach(data => {
2431
+ datasets.forEach(dataset => dataset.data.forEach((data: BubbleDataPoint) => {
2502
2432
  if (!objects.isNullOrUndefined(data.r)) {
2503
2433
  data.r = data.r * bubbleScalingFactor + bubbleRadiusOffset;
2504
2434
  }
2505
2435
  }));
2506
2436
  }
2507
2437
 
2508
- _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 {
2509
2439
  if (!datasets) {
2510
2440
  return;
2511
2441
  }
@@ -2577,7 +2507,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2577
2507
  };
2578
2508
  }
2579
2509
 
2580
- _calculateBoundary(value, roundingFunctionPositive, roundingFunctionNegative) {
2510
+ protected _calculateBoundary(value: number, roundingFunctionPositive: (number) => number, roundingFunctionNegative: (number) => number): number {
2581
2511
  let roundingFunction = roundingFunctionPositive;
2582
2512
  let changeValueSign = false;
2583
2513
  if (value < 0) {
@@ -2592,7 +2522,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2592
2522
  return value;
2593
2523
  }
2594
2524
 
2595
- _calculateBoundaryPositive(value, roundingFunction) {
2525
+ protected _calculateBoundaryPositive(value: number, roundingFunction: (number) => number): number {
2596
2526
  if (!(value > 0) || !roundingFunction) {
2597
2527
  return value;
2598
2528
  }
@@ -2612,7 +2542,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2612
2542
  return value;
2613
2543
  }
2614
2544
 
2615
- _adjustGridMaxMin(config, chartArea) {
2545
+ protected _adjustGridMaxMin(config: ChartConfig, chartArea: ChartArea) {
2616
2546
  if (!config || !config.type || !config.options || !config.options.adjustGridMaxMin || !config.options.scales || !chartArea) {
2617
2547
  return;
2618
2548
  }
@@ -2665,7 +2595,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2665
2595
  this._adjustAxisMaxMin(xAxis, maxXTicks, xBoundary);
2666
2596
  }
2667
2597
 
2668
- _computeBoundaryPointElement(config, identifier, space) {
2598
+ protected _computeBoundaryPointElement(config: ChartConfig, identifier: string, space: number): Boundary {
2669
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) {
2670
2600
  return;
2671
2601
  }
@@ -2679,7 +2609,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2679
2609
  let maxR = this._computeMaxMinValue(config, datasets, 'r', true).maxValue,
2680
2610
  padding = maxR;
2681
2611
  if (config.options.elements && config.options.elements.point && config.options.elements.point.hoverRadius) {
2682
- padding = padding + config.options.elements.point.hoverRadius;
2612
+ padding = padding + (config.options.elements.point.hoverRadius as number);
2683
2613
  }
2684
2614
 
2685
2615
  if (offset) {
@@ -2694,15 +2624,15 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2694
2624
  return boundary;
2695
2625
  }
2696
2626
 
2697
- _computeXBoundaryPointElement(config, width) {
2627
+ protected _computeXBoundaryPointElement(config: ChartConfig, width: number): Boundary {
2698
2628
  return this._computeBoundaryPointElement(config, 'x', width);
2699
2629
  }
2700
2630
 
2701
- _computeYBoundaryPointElement(config, height) {
2631
+ protected _computeYBoundaryPointElement(config: ChartConfig, height: number): Boundary {
2702
2632
  return this._computeBoundaryPointElement(config, 'y', height);
2703
2633
  }
2704
2634
 
2705
- _computeYBoundaries(config, height) {
2635
+ protected _computeYBoundaries(config: ChartConfig, height: number): { yBoundary?: Boundary; yBoundaryDiffType?: Boundary } {
2706
2636
  if (!config || !config.type) {
2707
2637
  return {};
2708
2638
  }
@@ -2744,7 +2674,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2744
2674
  };
2745
2675
  }
2746
2676
 
2747
- _adjustYAxisDiffType(config, datasets, datasetsDiffType) {
2677
+ protected _adjustYAxisDiffType(config: ChartConfig, datasets: ChartDataset[], datasetsDiffType: ChartDataset[]) {
2748
2678
  if (!config || !config.type || !datasets || !datasets.length || !datasetsDiffType || !datasetsDiffType.length) {
2749
2679
  return;
2750
2680
  }
@@ -2760,9 +2690,6 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2760
2690
  yAxisDiffType = $.extend(true, {}, yAxis);
2761
2691
  scales.yDiffType = yAxisDiffType;
2762
2692
 
2763
- yAxis.id = 'y';
2764
- yAxisDiffType.id = 'yDiffType';
2765
-
2766
2693
  if (config.data && config.data.datasets && config.data.datasets.length && config.data.datasets[0].type && config.data.datasets[0].type !== type) {
2767
2694
  yAxisDiffType.position = Chart.Position.LEFT;
2768
2695
  yAxis.position = Chart.Position.RIGHT;
@@ -2798,7 +2725,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2798
2725
  });
2799
2726
  }
2800
2727
 
2801
- _adjustAxisMaxMin(axis, maxTicks, maxMinValue) {
2728
+ protected _adjustAxisMaxMin(axis: LinearScaleOptions | RadialLinearScaleOptions, maxTicks: number, maxMinValue: Boundary) {
2802
2729
  if (!axis) {
2803
2730
  return;
2804
2731
  }
@@ -2817,7 +2744,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2817
2744
  axis.ticks.stepSize = this.onlyIntegers && maxRangeBetweenTwoTicks < 1 ? 1 : undefined;
2818
2745
  }
2819
2746
 
2820
- _remove(afterRemoveFunc) {
2747
+ protected override _remove(afterRemoveFunc: (chartAnimationStopping?: boolean) => void) {
2821
2748
  if (this.rendered && !this.removing) {
2822
2749
  this.removing = true;
2823
2750
  this.chartJs.destroy();
@@ -2829,3 +2756,92 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2829
2756
  this.removing = false;
2830
2757
  }
2831
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
+ }