@eclipse-scout/chart 22.0.41 → 23.1.1

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 (130) hide show
  1. package/LICENSE +277 -0
  2. package/README.md +4 -8
  3. package/dist/d.ts/chart/AbstractChartRenderer.d.ts +48 -0
  4. package/dist/d.ts/chart/AbstractChartRenderer.d.ts.map +1 -0
  5. package/dist/d.ts/chart/AbstractSvgChartRenderer.d.ts +65 -0
  6. package/dist/d.ts/chart/AbstractSvgChartRenderer.d.ts.map +1 -0
  7. package/dist/d.ts/chart/Chart.d.ts +162 -0
  8. package/dist/d.ts/chart/Chart.d.ts.map +1 -0
  9. package/dist/d.ts/chart/ChartAdapter.d.ts +8 -0
  10. package/dist/d.ts/chart/ChartAdapter.d.ts.map +1 -0
  11. package/dist/d.ts/chart/ChartEventMap.d.ts +16 -0
  12. package/dist/d.ts/chart/ChartEventMap.d.ts.map +1 -0
  13. package/dist/d.ts/chart/ChartJsRenderer.d.ts +299 -0
  14. package/dist/d.ts/chart/ChartJsRenderer.d.ts.map +1 -0
  15. package/dist/d.ts/chart/ChartLayout.d.ts +8 -0
  16. package/dist/d.ts/chart/ChartLayout.d.ts.map +1 -0
  17. package/dist/d.ts/chart/ChartModel.d.ts +11 -0
  18. package/dist/d.ts/chart/ChartModel.d.ts.map +1 -0
  19. package/dist/d.ts/chart/FulfillmentChartRenderer.d.ts +22 -0
  20. package/dist/d.ts/chart/FulfillmentChartRenderer.d.ts.map +1 -0
  21. package/dist/d.ts/chart/SalesfunnelChartRenderer.d.ts +61 -0
  22. package/dist/d.ts/chart/SalesfunnelChartRenderer.d.ts.map +1 -0
  23. package/dist/d.ts/chart/SpeedoChartRenderer.d.ts +90 -0
  24. package/dist/d.ts/chart/SpeedoChartRenderer.d.ts.map +1 -0
  25. package/dist/d.ts/chart/VennAsync3Calculator.d.ts +32 -0
  26. package/dist/d.ts/chart/VennAsync3Calculator.d.ts.map +1 -0
  27. package/dist/d.ts/chart/VennChartRenderer.d.ts +36 -0
  28. package/dist/d.ts/chart/VennChartRenderer.d.ts.map +1 -0
  29. package/dist/d.ts/chart/VennCircle.d.ts +20 -0
  30. package/dist/d.ts/chart/VennCircle.d.ts.map +1 -0
  31. package/dist/d.ts/chart/VennCircleHelper.d.ts +13 -0
  32. package/dist/d.ts/chart/VennCircleHelper.d.ts.map +1 -0
  33. package/dist/d.ts/form/fields/chartfield/ChartField.d.ts +11 -0
  34. package/dist/d.ts/form/fields/chartfield/ChartField.d.ts.map +1 -0
  35. package/dist/d.ts/form/fields/chartfield/ChartFieldAdapter.d.ts +4 -0
  36. package/dist/d.ts/form/fields/chartfield/ChartFieldAdapter.d.ts.map +1 -0
  37. package/dist/d.ts/form/fields/chartfield/ChartFieldModel.d.ts +6 -0
  38. package/dist/d.ts/form/fields/chartfield/ChartFieldModel.d.ts.map +1 -0
  39. package/dist/d.ts/index.d.ts +31 -0
  40. package/dist/d.ts/index.d.ts.map +1 -0
  41. package/dist/d.ts/table/controls/ChartTableControl.d.ts +136 -0
  42. package/dist/d.ts/table/controls/ChartTableControl.d.ts.map +1 -0
  43. package/dist/d.ts/table/controls/ChartTableControlAdapter.d.ts +5 -0
  44. package/dist/d.ts/table/controls/ChartTableControlAdapter.d.ts.map +1 -0
  45. package/dist/d.ts/table/controls/ChartTableControlEventMap.d.ts +9 -0
  46. package/dist/d.ts/table/controls/ChartTableControlEventMap.d.ts.map +1 -0
  47. package/dist/d.ts/table/controls/ChartTableControlLayout.d.ts +8 -0
  48. package/dist/d.ts/table/controls/ChartTableControlLayout.d.ts.map +1 -0
  49. package/dist/d.ts/table/controls/ChartTableControlModel.d.ts +9 -0
  50. package/dist/d.ts/table/controls/ChartTableControlModel.d.ts.map +1 -0
  51. package/dist/d.ts/table/controls/ChartTableUserFilter.d.ts +28 -0
  52. package/dist/d.ts/table/controls/ChartTableUserFilter.d.ts.map +1 -0
  53. package/dist/d.ts/table/controls/ChartTableUserFilterModel.d.ts +11 -0
  54. package/dist/d.ts/table/controls/ChartTableUserFilterModel.d.ts.map +1 -0
  55. package/dist/d.ts/tile/ChartFieldTile.d.ts +14 -0
  56. package/dist/d.ts/tile/ChartFieldTile.d.ts.map +1 -0
  57. package/dist/d.ts/tile/ChartFieldTileAdapter.d.ts +4 -0
  58. package/dist/d.ts/tile/ChartFieldTileAdapter.d.ts.map +1 -0
  59. package/dist/d.ts/tile/ChartFieldTileModel.d.ts +6 -0
  60. package/dist/d.ts/tile/ChartFieldTileModel.d.ts.map +1 -0
  61. package/dist/eclipse-scout-chart-fae6f958a044232e659c.min.js +3 -0
  62. package/dist/eclipse-scout-chart-fae6f958a044232e659c.min.js.map +1 -0
  63. package/dist/eclipse-scout-chart-theme-56ba6667e592ef147869.min.css +1 -0
  64. package/dist/eclipse-scout-chart-theme-dark-593955eea95984c5aa62.min.css +1 -0
  65. package/dist/eclipse-scout-chart-theme-dark.css +53 -59
  66. package/dist/eclipse-scout-chart-theme-dark.css.map +1 -1
  67. package/dist/eclipse-scout-chart-theme.css +41 -45
  68. package/dist/eclipse-scout-chart-theme.css.map +1 -1
  69. package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js +3 -0
  70. package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js.map +1 -0
  71. package/dist/eclipse-scout-chart.esm.js +6898 -0
  72. package/dist/eclipse-scout-chart.esm.js.map +1 -0
  73. package/dist/eclipse-scout-chart.js +737 -15226
  74. package/dist/eclipse-scout-chart.js.map +1 -1
  75. package/dist/file-list +8 -5
  76. package/dist/texts.json +17 -17
  77. package/package.json +22 -16
  78. package/src/chart/{AbstractChartRenderer.js → AbstractChartRenderer.ts} +36 -31
  79. package/src/chart/{AbstractSvgChartRenderer.js → AbstractSvgChartRenderer.ts} +82 -48
  80. package/src/chart/Chart.less +8 -8
  81. package/src/chart/{Chart.js → Chart.ts} +157 -68
  82. package/src/chart/ChartAdapter.ts +26 -0
  83. package/src/chart/ChartEventMap.ts +26 -0
  84. package/src/chart/{ChartJsRenderer.js → ChartJsRenderer.ts} +362 -357
  85. package/src/chart/{ChartLayout.js → ChartLayout.ts} +13 -13
  86. package/src/chart/ChartModel.ts +20 -0
  87. package/src/chart/{FulfillmentChartRenderer.js → FulfillmentChartRenderer.ts} +25 -23
  88. package/src/chart/{SalesfunnelChartRenderer.js → SalesfunnelChartRenderer.ts} +102 -66
  89. package/src/chart/{SpeedoChartRenderer.js → SpeedoChartRenderer.ts} +56 -43
  90. package/src/chart/{VennAsync3Calculator.js → VennAsync3Calculator.ts} +41 -18
  91. package/src/chart/{VennChartRenderer.js → VennChartRenderer.ts} +63 -40
  92. package/src/chart/VennCircle.ts +47 -0
  93. package/src/chart/{VennCircleHelper.js → VennCircleHelper.ts} +19 -14
  94. package/src/eclipse-scout-chart-theme-dark.less +7 -8
  95. package/src/eclipse-scout-chart-theme.less +7 -8
  96. package/src/form/fields/chartfield/ChartField.ts +44 -0
  97. package/src/form/fields/chartfield/ChartFieldAdapter.ts +13 -0
  98. package/src/form/fields/chartfield/ChartFieldModel.ts +15 -0
  99. package/src/index-dark.less +6 -7
  100. package/src/index.less +6 -7
  101. package/src/index.ts +45 -0
  102. package/src/style/colors-dark.less +7 -8
  103. package/src/style/colors.less +6 -7
  104. package/src/table/controls/ChartTableControl.less +6 -7
  105. package/src/table/controls/{ChartTableControl.js → ChartTableControl.ts} +164 -125
  106. package/src/table/controls/ChartTableControlAdapter.ts +18 -0
  107. package/src/table/controls/ChartTableControlEventMap.ts +18 -0
  108. package/src/table/controls/ChartTableControlLayout.ts +30 -0
  109. package/src/table/controls/ChartTableControlModel.ts +18 -0
  110. package/src/table/controls/ChartTableUserFilter.ts +84 -0
  111. package/src/table/controls/ChartTableUserFilterModel.ts +18 -0
  112. package/src/tile/ChartFieldTile.less +6 -7
  113. package/src/tile/ChartFieldTile.ts +51 -0
  114. package/src/tile/ChartFieldTileAdapter.ts +13 -0
  115. package/src/tile/ChartFieldTileModel.ts +15 -0
  116. package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js +0 -3
  117. package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js.LICENSE.txt +0 -6
  118. package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js.map +0 -1
  119. package/dist/eclipse-scout-chart-theme-79622289bda68b525e3e.min.css +0 -1
  120. package/dist/eclipse-scout-chart-theme-dark-1de09c03e3dc40a9529a.min.css +0 -1
  121. package/src/chart/ChartAdapter.js +0 -30
  122. package/src/chart/VennCircle.js +0 -41
  123. package/src/form/fields/chartfield/ChartField.js +0 -39
  124. package/src/form/fields/chartfield/ChartFieldAdapter.js +0 -19
  125. package/src/index.js +0 -36
  126. package/src/table/controls/ChartTableControlAdapter.js +0 -20
  127. package/src/table/controls/ChartTableControlLayout.js +0 -29
  128. package/src/table/controls/ChartTableUserFilter.js +0 -72
  129. package/src/tile/ChartFieldTile.js +0 -46
  130. package/src/tile/ChartFieldTileAdapter.js +0 -18
@@ -1,18 +1,51 @@
1
1
  /*
2
- * Copyright (c) 2010-2021 BSI Business Systems Integration AG.
3
- * All rights reserved. This program and the accompanying materials
4
- * are made available under the terms of the Eclipse Public License v1.0
5
- * which accompanies this distribution, and is available at
6
- * http://www.eclipse.org/legal/epl-v10.html
2
+ * Copyright (c) 2010, 2023 BSI Business Systems Integration AG
7
3
  *
8
- * Contributors:
9
- * BSI Business Systems Integration AG - initial API and implementation
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
10
9
  */
11
- import {arrays, DateColumn, icons, NumberColumn, objects, scout, scrollbars, strings, styles, TableControl, TableMatrix, tooltips} from '@eclipse-scout/core';
12
- import {Chart, ChartTableControlLayout, ChartTableUserFilter} from '../../index';
10
+ import {
11
+ arrays, Column, DateColumn, Event, EventListener, Icon, IconDesc, icons, InitModelOf, NumberColumn, objects, scout, scrollbars, strings, styles, Table, TableControl, TableMatrix, TableMatrixDateGroup, TableMatrixKeyAxis,
12
+ TableMatrixNumberGroup, TableMatrixResult, tooltips
13
+ } from '@eclipse-scout/core';
14
+ import {Chart, ChartTableControlEventMap, ChartTableControlLayout, ChartTableControlModel, ChartTableUserFilter} from '../../index';
13
15
  import $ from 'jquery';
14
-
15
- export default class ChartTableControl extends TableControl {
16
+ import {BubbleDataPoint, ChartData, ChartType as ChartJsType} from 'chart.js';
17
+ import {ChartConfig, ClickObject} from '../../chart/Chart';
18
+
19
+ export class ChartTableControl extends TableControl implements ChartTableControlModel {
20
+ declare model: ChartTableControlModel;
21
+ declare eventMap: ChartTableControlEventMap;
22
+ declare self: ChartTableControl;
23
+
24
+ chartAggregation: TableControlChartAggregation;
25
+ chartGroup1: TableControlChartGroup;
26
+ chartGroup2: TableControlChartGroup;
27
+ chartType: TableControlChartType;
28
+ oldChartType: TableControlChartType;
29
+ chart: Chart;
30
+ chartColorScheme: string;
31
+ xAxis: TableMatrixKeyAxis;
32
+ yAxis: TableMatrixKeyAxis;
33
+ dateGroup: (TableMatrixDateGroup | string)[][];
34
+
35
+ $chartSelect: JQuery;
36
+ $axisSelectContainer: JQuery;
37
+ $xAxisSelect: JQuery;
38
+ $yAxisSelect: JQuery;
39
+ $dataSelect: JQuery;
40
+ protected _chartTypeMap: Record<TableControlChartType, JQuery>;
41
+ protected _aggregationMap: Record<string, JQuery>;
42
+ protected _chartGroup1Map: Record<string, JQuery>;
43
+ protected _chartGroup2Map: Record<string, JQuery>;
44
+ protected _tableUpdatedHandler: (e: Event<Table>) => void;
45
+ protected _tableColumnStructureChangedHandler: () => void;
46
+ protected _chartValueClickedHandler: () => void;
47
+ protected _filterResetListener: EventListener;
48
+ protected _tableUpdatedTimeOutId: number;
16
49
 
17
50
  constructor() {
18
51
  super();
@@ -22,9 +55,10 @@ export default class ChartTableControl extends TableControl {
22
55
  };
23
56
  this.chartType = Chart.Type.BAR;
24
57
  this.oldChartType = null;
58
+ this.chart = null;
25
59
  this.chartColorScheme = 'chart-table-control';
26
60
 
27
- // chart config selection
61
+ /** chart config selection */
28
62
  this.$chartSelect = null;
29
63
  this.$xAxisSelect = null;
30
64
  this.$yAxisSelect = null;
@@ -43,39 +77,39 @@ export default class ChartTableControl extends TableControl {
43
77
  static DATE_GROUP_FLAG = 0x100;
44
78
  static MAX_AXIS_COUNT = 100;
45
79
 
46
- _init(model) {
80
+ protected override _init(model: InitModelOf<this>) {
47
81
  super._init(model);
48
82
  this.table.on('columnStructureChanged', this._tableColumnStructureChangedHandler);
49
83
 
50
- this.chart = scout.create('Chart', {
84
+ this.chart = scout.create(Chart, {
51
85
  parent: this
52
86
  });
53
87
  }
54
88
 
55
- _destroy() {
89
+ protected override _destroy() {
56
90
  this.table.off('columnStructureChanged', this._tableColumnStructureChangedHandler);
57
91
  super._destroy();
58
92
  }
59
93
 
60
- _computeEnabled(inheritAccessibility, parentEnabled) {
94
+ protected override _computeEnabled(inheritAccessibility: boolean, parentEnabled: boolean): boolean {
61
95
  if (!this._hasColumns() && !this.selected) {
62
96
  return false;
63
97
  }
64
98
  return super._computeEnabled(inheritAccessibility, parentEnabled);
65
99
  }
66
100
 
67
- _renderChart() {
101
+ protected _renderChart() {
68
102
  if (this.chart) {
69
103
  this.chart.render(this.$contentContainer);
70
104
  this.chart.$container.addClass(this.denseClass);
71
105
  }
72
106
  }
73
107
 
74
- _createLayout() {
108
+ protected override _createLayout(): ChartTableControlLayout {
75
109
  return new ChartTableControlLayout(this);
76
110
  }
77
111
 
78
- _renderChartType() {
112
+ protected _renderChartType() {
79
113
  this._selectChartType();
80
114
  this.$yAxisSelect.toggleClass('hide', this.chartType !== Chart.Type.BUBBLE);
81
115
  this.$yAxisSelect.toggleClass('animated', scout.isOneOf(Chart.Type.BUBBLE, this.chartType, this.oldChartType) && !!this.oldChartType);
@@ -94,22 +128,22 @@ export default class ChartTableControl extends TableControl {
94
128
  }
95
129
  }
96
130
 
97
- _selectChartType() {
131
+ protected _selectChartType() {
98
132
  objects.values(this._chartTypeMap).forEach($element => {
99
133
  $element.removeClass('selected');
100
134
  });
101
135
  this._chartTypeMap[this.chartType].addClass('selected');
102
136
  }
103
137
 
104
- _renderChartGroup1() {
138
+ protected _renderChartGroup1() {
105
139
  this._renderChartGroup(1);
106
140
  }
107
141
 
108
- _renderChartGroup2() {
142
+ protected _renderChartGroup2() {
109
143
  this._renderChartGroup(2);
110
144
  }
111
145
 
112
- _renderChartGroup(groupId) {
146
+ protected _renderChartGroup(groupId: 1 | 2) {
113
147
  if (!this._hasColumns()) {
114
148
  return;
115
149
  }
@@ -132,10 +166,10 @@ export default class ChartTableControl extends TableControl {
132
166
  }
133
167
  }
134
168
 
135
- _renderChartAggregation() {
169
+ protected _renderChartAggregation() {
136
170
  let $element = this._aggregationMap[this.chartAggregation.id || 'all'];
137
171
  if ($element) {
138
- $element.selectOne('selected');
172
+ $element.selectOne();
139
173
  $element
140
174
  .removeClass('data-sum')
141
175
  .removeClass('data-avg');
@@ -146,7 +180,7 @@ export default class ChartTableControl extends TableControl {
146
180
  }
147
181
  }
148
182
 
149
- _getAggregationCssClass() {
183
+ protected _getAggregationCssClass(): string {
150
184
  switch (this.chartAggregation.modifier) {
151
185
  case TableMatrix.NumberGroup.COUNT:
152
186
  return 'data-count';
@@ -159,8 +193,8 @@ export default class ChartTableControl extends TableControl {
159
193
  }
160
194
  }
161
195
 
162
- _renderChartSelect(cssClass, chartType, iconId) {
163
- let icon = scout.create('Icon', {
196
+ protected _renderChartSelect(cssClass: string, chartType: TableControlChartType, iconId: string) {
197
+ let icon = scout.create(Icon, {
164
198
  parent: this,
165
199
  iconDesc: iconId,
166
200
  cssClass: cssClass
@@ -181,13 +215,13 @@ export default class ChartTableControl extends TableControl {
181
215
 
182
216
  /**
183
217
  * Appends a chart selection divs to this.$contentContainer and sets the this.$chartSelect property.
184
- * */
185
- _renderChartSelectContainer() {
218
+ **/
219
+ protected _renderChartSelectContainer() {
186
220
  // create container
187
221
  this.$chartSelect = this.$contentContainer.appendDiv('chart-select');
188
222
 
189
223
  // create chart types for selection
190
- this._chartTypeMap = {};
224
+ this._chartTypeMap = {} as Record<TableControlChartType, JQuery>;
191
225
 
192
226
  let supportedChartTypes = this._getSupportedChartTypes();
193
227
 
@@ -208,7 +242,7 @@ export default class ChartTableControl extends TableControl {
208
242
  }
209
243
  }
210
244
 
211
- _getSupportedChartTypes() {
245
+ protected _getSupportedChartTypes(): TableControlChartType[] {
212
246
  return [
213
247
  Chart.Type.BAR,
214
248
  Chart.Type.BAR_HORIZONTAL,
@@ -218,13 +252,13 @@ export default class ChartTableControl extends TableControl {
218
252
  ];
219
253
  }
220
254
 
221
- _onClickChartType(event) {
255
+ protected _onClickChartType(event: JQuery.ClickEvent) {
222
256
  let $target = $(event.currentTarget),
223
257
  chartType = $target.data('chartType');
224
258
  this.setChartType(chartType);
225
259
  }
226
260
 
227
- _onClickChartGroup(event) {
261
+ protected _onClickChartGroup(event: JQuery.ClickEvent) {
228
262
  let $target = $(event.currentTarget),
229
263
  groupId = $target.parent().data('groupId'),
230
264
  column = $target.data('column'),
@@ -246,7 +280,7 @@ export default class ChartTableControl extends TableControl {
246
280
  this._setChartGroup(groupId, config);
247
281
  }
248
282
 
249
- _onClickAggregation(event) {
283
+ protected _onClickAggregation(event: JQuery.ClickEvent) {
250
284
  let $target = $(event.currentTarget);
251
285
  // update modifier
252
286
  let origModifier = $target.data('modifier');
@@ -262,7 +296,7 @@ export default class ChartTableControl extends TableControl {
262
296
  this._setChartAggregation(aggregation);
263
297
  }
264
298
 
265
- _nextDateModifier(modifier) {
299
+ protected _nextDateModifier(modifier: TableMatrixDateGroup): TableMatrixDateGroup {
266
300
  switch (modifier) {
267
301
  case TableMatrix.DateGroup.DATE:
268
302
  return TableMatrix.DateGroup.MONTH;
@@ -277,7 +311,7 @@ export default class ChartTableControl extends TableControl {
277
311
  }
278
312
  }
279
313
 
280
- _nextModifier(modifier) {
314
+ protected _nextModifier(modifier: TableMatrixNumberGroup): TableMatrixNumberGroup {
281
315
  switch (modifier) {
282
316
  case TableMatrix.NumberGroup.SUM:
283
317
  return TableMatrix.NumberGroup.AVG;
@@ -288,7 +322,7 @@ export default class ChartTableControl extends TableControl {
288
322
  }
289
323
  }
290
324
 
291
- _setChartAggregation(chartAggregation) {
325
+ protected _setChartAggregation(chartAggregation: TableControlChartAggregation) {
292
326
  if (chartAggregation === this.chartAggregation) {
293
327
  return;
294
328
  }
@@ -298,20 +332,20 @@ export default class ChartTableControl extends TableControl {
298
332
  }
299
333
  }
300
334
 
301
- _setChartGroup1(chartGroup) {
335
+ protected _setChartGroup1(chartGroup: TableControlChartGroup) {
302
336
  this._setChartGroup(1, chartGroup);
303
337
  }
304
338
 
305
- _setChartGroup2(chartGroup) {
339
+ protected _setChartGroup2(chartGroup: TableControlChartGroup) {
306
340
  this._setChartGroup(2, chartGroup);
307
341
  }
308
342
 
309
- _setChartGroup(groupId, chartGroup) {
343
+ protected _setChartGroup(groupId: 1 | 2, chartGroup: TableControlChartGroup) {
310
344
  let propertyName = 'chartGroup' + groupId;
311
345
  this._changeProperty(propertyName, chartGroup);
312
346
  }
313
347
 
314
- _changeProperty(prop, value) {
348
+ protected _changeProperty(prop: string, value: any) {
315
349
  if (value === this[prop]) {
316
350
  return;
317
351
  }
@@ -321,27 +355,27 @@ export default class ChartTableControl extends TableControl {
321
355
  }
322
356
  }
323
357
 
324
- setChartType(chartType) {
358
+ setChartType(chartType: TableControlChartType) {
325
359
  this.oldChartType = this.chartType;
326
360
  this.setProperty('chartType', chartType);
327
361
  }
328
362
 
329
- _hasColumns() {
363
+ protected _hasColumns(): boolean {
330
364
  return this.table.columns.length !== 0;
331
365
  }
332
366
 
333
- _axisCount(columnCount, column) {
334
- let i, tmpColumn;
335
- for (i = 0; i < columnCount.length; i++) {
367
+ protected _axisCount(columnCount: (number | Column<any>)[][], column: Column<any>): number {
368
+ let tmpColumn;
369
+ for (let i = 0; i < columnCount.length; i++) {
336
370
  tmpColumn = columnCount[i][0];
337
371
  if (tmpColumn === column) {
338
- return columnCount[i][1];
372
+ return columnCount[i][1] as number;
339
373
  }
340
374
  }
341
375
  return 0;
342
376
  }
343
377
 
344
- _plainAxisText(column, text) {
378
+ protected _plainAxisText(column: Column<any>, text: string): string {
345
379
  if (column.headerHtmlEnabled) {
346
380
  let plainText = strings.plainText(text);
347
381
  return plainText.replace(/\n/g, ' ');
@@ -349,7 +383,7 @@ export default class ChartTableControl extends TableControl {
349
383
  return text;
350
384
  }
351
385
 
352
- _renderContent($parent) {
386
+ protected override _renderContent($parent: JQuery) {
353
387
  this.$contentContainer = $parent.appendDiv('chart-container');
354
388
 
355
389
  // scrollbars
@@ -387,19 +421,19 @@ export default class ChartTableControl extends TableControl {
387
421
  this._drawChart();
388
422
  }
389
423
 
390
- _addListeners() {
424
+ protected _addListeners() {
391
425
  this.table.on('rowsInserted', this._tableUpdatedHandler);
392
426
  this.table.on('rowsDeleted', this._tableUpdatedHandler);
393
427
  this.table.on('allRowsDeleted', this._tableUpdatedHandler);
394
428
  this.chart.on('valueClick', this._chartValueClickedHandler);
395
429
  }
396
430
 
397
- _renderAxisSelectorsContainer() {
431
+ protected _renderAxisSelectorsContainer() {
398
432
  this.$axisSelectContainer = this.$contentContainer
399
433
  .appendDiv('axis-select-container');
400
434
  }
401
435
 
402
- _renderAxisSelectors() {
436
+ protected _renderAxisSelectors(): (number | Column<any>)[][] {
403
437
  // create container for x/y-axis
404
438
  this.$xAxisSelect = this.$axisSelectContainer
405
439
  .appendDiv('xaxis-select')
@@ -423,11 +457,11 @@ export default class ChartTableControl extends TableControl {
423
457
  this._chartGroup1Map = {};
424
458
  this._chartGroup2Map = {};
425
459
 
426
- // find best x and y axis: best is 9 different entries
460
+ // find best x- and y-axis: best is 9 different entries
427
461
  let matrix = new TableMatrix(this.table, this.session),
428
462
  columnCount = matrix.columnCount(false); // filterNumberColumns false: number columns will be filtered below
429
463
  columnCount.sort((a, b) => {
430
- return Math.abs(a[1] - 8) - Math.abs(b[1] - 8);
464
+ return Math.abs(a[1] as number - 8) - Math.abs(b[1] as number - 8);
431
465
  });
432
466
 
433
467
  let axisCount, enabled,
@@ -447,7 +481,7 @@ export default class ChartTableControl extends TableControl {
447
481
  // probably not a good idea, because with a lot of data, the chart fails to provide an oversight over the data
448
482
  // when the user must scroll and only sees a small part of the chart.
449
483
  if (column1 instanceof DateColumn) {
450
- // dates are always aggregated and thus we must not check if the chart has "too much data".
484
+ // dates are always aggregated, and thus we must not check if the chart has "too much data".
451
485
  enabled = true;
452
486
  } else {
453
487
  axisCount = this._axisCount(columnCount, column1);
@@ -551,7 +585,7 @@ export default class ChartTableControl extends TableControl {
551
585
  return columnCount;
552
586
  }
553
587
 
554
- _initializeSelection(columnCount) {
588
+ protected _initializeSelection(columnCount: (number | Column<any>)[][]) {
555
589
  let $axisColumns;
556
590
 
557
591
  if (!this.chartType) {
@@ -573,7 +607,7 @@ export default class ChartTableControl extends TableControl {
573
607
  }
574
608
  if (!this.chartGroup2 || !this.chartGroup2.id || !this._chartGroup2Map[this.chartGroup2.id]) {
575
609
  $axisColumns = this.$yAxisSelect.children(':not(.disabled)');
576
- this._setDefaultSelectionForGroup(2, columnCount, $axisColumns, 1 /* try to use the second column for the second group (if available). Otherwise the first column is used. */);
610
+ this._setDefaultSelectionForGroup(2, columnCount, $axisColumns, 1 /* try to use the second column for the second group (if available). Otherwise, the first column is used. */);
577
611
  }
578
612
  }
579
613
 
@@ -582,19 +616,19 @@ export default class ChartTableControl extends TableControl {
582
616
  * The implementation only considers columns that are part of the specified columnCount matrix and $candidates array.
583
617
  * From all these columns the last match that is lower or equal to the specified maxIndex is set as default chart group.
584
618
  *
585
- * @param {number} chartGroup The number of the chart group (1 or 2) for which the default column should be set.
586
- * @param {matrix} columnCount Column-count matrix as returned by TableMatrix#columnCount(). Holds possible grouping columns.
587
- * @param {array} $candidates jQuery array holding all axis columns that could be used as default.
588
- * @param {number} maxIndex The maximum column index to use as default column for the specified chartGroup.
619
+ * @param chartGroup The number of the chart group (1 or 2) for which the default column should be set.
620
+ * @param columnCount Column-count matrix as returned by TableMatrix#columnCount(). Holds possible grouping columns.
621
+ * @param $candidates jQuery array holding all axis columns that could be used as default.
622
+ * @param maxIndex The maximum column index to use as default column for the specified chartGroup.
589
623
  */
590
- _setDefaultSelectionForGroup(chartGroup, columnCount, $candidates, maxIndex) {
624
+ protected _setDefaultSelectionForGroup(chartGroup: 1 | 2, columnCount: (number | Column<any>)[][], $candidates: JQuery, maxIndex: number) {
591
625
  let col = this._getDefaultSelectedColumn(columnCount, $candidates, maxIndex);
592
626
  if (col) {
593
627
  this._setChartGroup(chartGroup, this._getDefaultChartGroup(col));
594
628
  }
595
629
  }
596
630
 
597
- _getDefaultSelectedColumn(columnCount, $candidates, maxIndex) {
631
+ protected _getDefaultSelectedColumn(columnCount: (number | Column<any>)[][], $candidates: JQuery, maxIndex: number): Column<any> {
598
632
  let matchCounter = 0,
599
633
  curColumn,
600
634
  result;
@@ -608,7 +642,7 @@ export default class ChartTableControl extends TableControl {
608
642
  return result;
609
643
  }
610
644
 
611
- _existsInAxisColumns($candidates, columnToSearch) {
645
+ protected _existsInAxisColumns($candidates: JQuery, columnToSearch: Column<any>): boolean {
612
646
  for (let i = 0; i < $candidates.length; i++) {
613
647
  if ($candidates.eq(i).data('column') === columnToSearch) {
614
648
  return true;
@@ -617,7 +651,7 @@ export default class ChartTableControl extends TableControl {
617
651
  return false;
618
652
  }
619
653
 
620
- _getDefaultChartGroup(column) {
654
+ protected _getDefaultChartGroup(column: Column<any>): TableControlChartGroup {
621
655
  let modifier;
622
656
  if (column instanceof DateColumn) {
623
657
  modifier = 256;
@@ -628,14 +662,14 @@ export default class ChartTableControl extends TableControl {
628
662
  };
629
663
  }
630
664
 
631
- _renderChartParts() {
665
+ protected _renderChartParts() {
632
666
  this._renderChartType();
633
667
  this._renderChartAggregation();
634
668
  this._renderChartGroup1();
635
669
  this._renderChartGroup2();
636
670
  }
637
671
 
638
- _drawChart() {
672
+ protected _drawChart() {
639
673
  if (!this._hasColumns()) {
640
674
  this._hideChart();
641
675
  return;
@@ -643,14 +677,14 @@ export default class ChartTableControl extends TableControl {
643
677
 
644
678
  let cube = this._calculateValues();
645
679
 
646
- if (cube.length) {
680
+ if (cube && cube.length) {
647
681
  this.chart.setVisible(true);
648
682
  } else {
649
683
  this._hideChart();
650
684
  return;
651
685
  }
652
686
 
653
- let config = {
687
+ let config: ChartConfig = {
654
688
  type: this.chartType,
655
689
  options: {
656
690
  handleResize: true,
@@ -676,19 +710,19 @@ export default class ChartTableControl extends TableControl {
676
710
  this.chart.setCheckedItems(checkedItems);
677
711
  }
678
712
 
679
- _hideChart() {
713
+ protected _hideChart() {
680
714
  this.chart.setConfig({
681
715
  type: this.chartType
682
716
  });
683
717
  this.chart.setVisible(false);
684
718
  }
685
719
 
686
- _getDatasetLabel() {
720
+ protected _getDatasetLabel(): string {
687
721
  let elem = this._aggregationMap[this.chartAggregation.id || 'all'];
688
722
  return (elem ? elem.text() : null) || this.session.text('ui.Value');
689
723
  }
690
724
 
691
- _calculateValues() {
725
+ protected _calculateValues(): TableMatrixResult {
692
726
  // build matrix
693
727
  let matrix = new TableMatrix(this.table, this.session);
694
728
 
@@ -713,27 +747,27 @@ export default class ChartTableControl extends TableControl {
713
747
 
714
748
  // return not possible to draw chart
715
749
  if (matrix.isEmpty() || !matrix.isMatrixValid()) {
716
- return false;
750
+ return;
717
751
  }
718
752
 
719
753
  // calculate matrix
720
754
  return matrix.calculate();
721
755
  }
722
756
 
723
- _getXAxis() {
757
+ protected _getXAxis(): TableMatrixKeyAxis {
724
758
  return this.xAxis;
725
759
  }
726
760
 
727
- _getYAxis() {
761
+ protected _getYAxis(): TableMatrixKeyAxis {
728
762
  return this.yAxis;
729
763
  }
730
764
 
731
- _computeData(iconClasses, cube) {
765
+ protected _computeData(iconClasses: string[], cube: TableMatrixResult): ChartData {
732
766
  let data = {
733
767
  datasets: [{
734
768
  label: this._getDatasetLabel()
735
769
  }]
736
- };
770
+ } as ChartData;
737
771
  if (!cube) {
738
772
  return data;
739
773
  }
@@ -781,7 +815,7 @@ export default class ChartTableControl extends TableControl {
781
815
  return data;
782
816
  }
783
817
 
784
- _computeBubbleData(iconClasses, cube) {
818
+ protected _computeBubbleData(iconClasses: string[], cube: TableMatrixResult): { value: BubbleDataPoint; deterministicKey: TableControlDeterministicKey }[] {
785
819
  if (!cube) {
786
820
  return [];
787
821
  }
@@ -826,7 +860,7 @@ export default class ChartTableControl extends TableControl {
826
860
  return segments;
827
861
  }
828
862
 
829
- _handleIconLabel(label, axis, iconClasses) {
863
+ protected _handleIconLabel(label: string, axis: TableMatrixKeyAxis, iconClasses: string[]): string {
830
864
  if (axis && axis.textIsIcon) {
831
865
  let icon = icons.parseIconId(label);
832
866
  if (icon && icon.isFontIcon()) {
@@ -837,7 +871,7 @@ export default class ChartTableControl extends TableControl {
837
871
  return label;
838
872
  }
839
873
 
840
- _adjustFont(config, iconClasses) {
874
+ protected _adjustFont(config: ChartConfig, iconClasses: string[]) {
841
875
  if (!config || !iconClasses) {
842
876
  return;
843
877
  }
@@ -888,7 +922,7 @@ export default class ChartTableControl extends TableControl {
888
922
  }
889
923
  }
890
924
 
891
- _adjustLabels(config) {
925
+ protected _adjustLabels(config: ChartConfig) {
892
926
  if (!config) {
893
927
  return;
894
928
  }
@@ -927,11 +961,11 @@ export default class ChartTableControl extends TableControl {
927
961
  }
928
962
  }
929
963
 
930
- _formatLabel(label, axis) {
964
+ protected _formatLabel(label: number | string, axis: TableMatrixKeyAxis): string {
931
965
  if (axis) {
932
966
  if (axis.column instanceof DateColumn) {
933
- label = label + axis.min;
934
- if (label !== parseInt(label) || (axis.length < 2 && (label < axis.min || label > axis.max))) {
967
+ label = label as number + axis.min;
968
+ if (label !== parseInt('' + label) || (axis.length < 2 && (label < axis.min || label > axis.max))) {
935
969
  return null;
936
970
  }
937
971
  }
@@ -942,7 +976,7 @@ export default class ChartTableControl extends TableControl {
942
976
  return null;
943
977
  }
944
978
  }
945
- label = axis.format(label);
979
+ label = axis.format(label as number);
946
980
  if (axis.textIsIcon) {
947
981
  let icon = icons.parseIconId(label);
948
982
  if (icon && icon.isFontIcon()) {
@@ -950,10 +984,10 @@ export default class ChartTableControl extends TableControl {
950
984
  }
951
985
  }
952
986
  }
953
- return label;
987
+ return '' + label;
954
988
  }
955
989
 
956
- _adjustConfig(config) {
990
+ protected _adjustConfig(config: ChartConfig) {
957
991
  if (!config) {
958
992
  return;
959
993
  }
@@ -970,7 +1004,7 @@ export default class ChartTableControl extends TableControl {
970
1004
  }
971
1005
  }
972
1006
 
973
- _adjustClickable(config) {
1007
+ protected _adjustClickable(config: ChartConfig) {
974
1008
  if (!config) {
975
1009
  return;
976
1010
  }
@@ -984,11 +1018,11 @@ export default class ChartTableControl extends TableControl {
984
1018
  }
985
1019
  }
986
1020
 
987
- _isChartClickable() {
1021
+ protected _isChartClickable(): boolean {
988
1022
  return true;
989
1023
  }
990
1024
 
991
- _adjustBubble(config) {
1025
+ protected _adjustBubble(config: ChartConfig) {
992
1026
  if (!config || this.chartType !== Chart.Type.BUBBLE) {
993
1027
  return;
994
1028
  }
@@ -999,7 +1033,7 @@ export default class ChartTableControl extends TableControl {
999
1033
  });
1000
1034
  }
1001
1035
 
1002
- _adjustPie(config) {
1036
+ protected _adjustPie(config: ChartConfig) {
1003
1037
  if (!config || this.chartType !== Chart.Type.PIE) {
1004
1038
  return;
1005
1039
  }
@@ -1041,7 +1075,7 @@ export default class ChartTableControl extends TableControl {
1041
1075
  });
1042
1076
  }
1043
1077
 
1044
- _adjustScales(config) {
1078
+ protected _adjustScales(config: ChartConfig) {
1045
1079
  if (!config) {
1046
1080
  return;
1047
1081
  }
@@ -1058,14 +1092,14 @@ export default class ChartTableControl extends TableControl {
1058
1092
  });
1059
1093
  }
1060
1094
 
1061
- _computeCheckedItems(deterministicKeys) {
1095
+ protected _computeCheckedItems(deterministicKeys: TableControlDeterministicKey[]): ClickObject[] {
1062
1096
  if (!deterministicKeys) {
1063
1097
  return [];
1064
1098
  }
1065
1099
 
1066
1100
  let xAxis = this._getXAxis(),
1067
1101
  yAxis = this._getYAxis(),
1068
- tableFilter = this.table.getFilter(ChartTableUserFilter.TYPE),
1102
+ tableFilter = this.table.getFilter(ChartTableUserFilter.TYPE) as ChartTableUserFilter,
1069
1103
  filters = [],
1070
1104
  checkedIndices = [];
1071
1105
 
@@ -1081,7 +1115,7 @@ export default class ChartTableControl extends TableControl {
1081
1115
  let datasetIndex = 0;
1082
1116
  if (this.chartType === Chart.Type.PIE) {
1083
1117
  let maxSegments = this.chart.config.options.maxSegments,
1084
- collapsedIndices = arrays.init(deterministicKeys.length - maxSegments).map((elem, idx) => idx + maxSegments);
1118
+ collapsedIndices = arrays.init(deterministicKeys.length - maxSegments, null).map((elem, idx) => idx + maxSegments);
1085
1119
  if (!arrays.containsAll(checkedIndices, collapsedIndices)) {
1086
1120
  arrays.remove(checkedIndices, maxSegments - 1);
1087
1121
  }
@@ -1104,18 +1138,18 @@ export default class ChartTableControl extends TableControl {
1104
1138
  return checkedItems;
1105
1139
  }
1106
1140
 
1107
- _onChartValueClick() {
1141
+ protected _onChartValueClick() {
1108
1142
  // prepare filter
1109
1143
  let filters = [];
1110
1144
  if (this.chart && this.chart.config.data) {
1111
1145
  let maxSegments = this.chart.config.options.maxSegments,
1112
1146
  dataset = this.chart.config.data.datasets[0],
1113
- getFilters = index => ({deterministicKey: dataset.deterministicKeys[index]});
1147
+ getFilters: (index: number) => { deterministicKey: TableControlDeterministicKey } | { deterministicKey: TableControlDeterministicKey }[] = index => ({deterministicKey: dataset.deterministicKeys[index]});
1114
1148
  if (this.chartType === Chart.Type.PIE) {
1115
1149
  getFilters = index => {
1116
- index = parseInt(index);
1150
+ index = parseInt('' + index);
1117
1151
  if (maxSegments && maxSegments === index + 1) {
1118
- return arrays.init(dataset.deterministicKeys.length - index).map((elem, idx) => ({deterministicKey: dataset.deterministicKeys[idx + index]}));
1152
+ return arrays.init(dataset.deterministicKeys.length - index, null).map((elem, idx) => ({deterministicKey: dataset.deterministicKeys[idx + index]}));
1119
1153
  }
1120
1154
  return {deterministicKey: dataset.deterministicKeys[index]};
1121
1155
  };
@@ -1130,7 +1164,7 @@ export default class ChartTableControl extends TableControl {
1130
1164
 
1131
1165
  // filter function
1132
1166
  if (filters.length) {
1133
- let filter = scout.create('ChartTableUserFilter', {
1167
+ let filter = scout.create(ChartTableUserFilter, {
1134
1168
  session: this.session,
1135
1169
  table: this.table,
1136
1170
  text: this.tooltipText,
@@ -1145,10 +1179,8 @@ export default class ChartTableControl extends TableControl {
1145
1179
  }
1146
1180
  }
1147
1181
 
1148
- _axisContentForColumn(column) {
1149
- let icon,
1150
- text = column.text;
1151
-
1182
+ protected _axisContentForColumn(column: Column<any>): { text: string; icon?: IconDesc } {
1183
+ let text = column.text;
1152
1184
  if (strings.hasText(text)) {
1153
1185
  return {
1154
1186
  text: text
@@ -1156,7 +1188,7 @@ export default class ChartTableControl extends TableControl {
1156
1188
  }
1157
1189
 
1158
1190
  if (column.headerIconId) {
1159
- icon = icons.parseIconId(column.headerIconId);
1191
+ let icon = icons.parseIconId(column.headerIconId);
1160
1192
  if (icon.isFontIcon()) {
1161
1193
  return {
1162
1194
  text: icon.iconCharacter,
@@ -1176,7 +1208,7 @@ export default class ChartTableControl extends TableControl {
1176
1208
  };
1177
1209
  }
1178
1210
 
1179
- _removeContent() {
1211
+ protected override _removeContent() {
1180
1212
  this._removeScrollbars();
1181
1213
  this.$contentContainer.remove();
1182
1214
  this.chart.remove();
@@ -1186,7 +1218,7 @@ export default class ChartTableControl extends TableControl {
1186
1218
  this.recomputeEnabled();
1187
1219
  }
1188
1220
 
1189
- _removeScrollbars() {
1221
+ protected _removeScrollbars() {
1190
1222
  this.$xAxisSelect.each((index, element) => {
1191
1223
  tooltips.uninstall($(element));
1192
1224
  });
@@ -1199,28 +1231,14 @@ export default class ChartTableControl extends TableControl {
1199
1231
  this._uninstallScrollbars();
1200
1232
  }
1201
1233
 
1202
- _removeListeners() {
1234
+ protected _removeListeners() {
1203
1235
  this.table.off('rowsInserted', this._tableUpdatedHandler);
1204
1236
  this.table.off('rowsDeleted', this._tableUpdatedHandler);
1205
1237
  this.table.off('allRowsDeleted', this._tableUpdatedHandler);
1206
1238
  this.chart.off('valueClick', this._chartValueClickedHandler);
1207
1239
  }
1208
1240
 
1209
- _pathSegment(mx, my, r, start, end) {
1210
- let s = start * 2 * Math.PI,
1211
- e = end * 2 * Math.PI,
1212
- pathString = '';
1213
-
1214
- pathString += 'M' + (mx + r * Math.sin(s)) + ',' + (my - r * Math.cos(s));
1215
- pathString += 'A' + r + ', ' + r;
1216
- pathString += (end - start < 0.5) ? ' 0 0,1 ' : ' 0 1,1 ';
1217
- pathString += (mx + r * Math.sin(e)) + ',' + (my - r * Math.cos(e));
1218
- pathString += 'L' + mx + ',' + my + 'Z';
1219
-
1220
- return pathString;
1221
- }
1222
-
1223
- _onTableUpdated(event) {
1241
+ protected _onTableUpdated(event?: Event<Table>) {
1224
1242
  if (this._tableUpdatedTimeOutId) {
1225
1243
  return;
1226
1244
  }
@@ -1239,10 +1257,31 @@ export default class ChartTableControl extends TableControl {
1239
1257
  });
1240
1258
  }
1241
1259
 
1242
- _onTableColumnStructureChanged() {
1260
+ protected _onTableColumnStructureChanged() {
1243
1261
  this.recomputeEnabled();
1244
1262
  if (this.contentRendered && this.selected) {
1245
1263
  this._onTableUpdated();
1246
1264
  }
1247
1265
  }
1248
1266
  }
1267
+
1268
+ export type TableControlChartType = typeof Chart.Type['BAR' | 'BAR_HORIZONTAL' | 'LINE' | 'PIE' | 'BUBBLE'];
1269
+
1270
+ export type TableControlChartAggregation = {
1271
+ id?: string;
1272
+ modifier?: TableMatrixNumberGroup;
1273
+ };
1274
+
1275
+ export type TableControlChartGroup = {
1276
+ id?: string;
1277
+ modifier?: TableMatrixNumberGroup | TableMatrixDateGroup;
1278
+ };
1279
+
1280
+ export type TableControlDeterministicKey = (number | string) | (number | string)[];
1281
+
1282
+ // extend chart.js
1283
+ declare module 'chart.js' {
1284
+ interface ChartDatasetProperties<TType extends ChartJsType, TData> {
1285
+ deterministicKeys?: TableControlDeterministicKey[];
1286
+ }
1287
+ }