@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.
- package/LICENSE +277 -0
- package/README.md +4 -8
- package/dist/d.ts/chart/AbstractChartRenderer.d.ts +48 -0
- package/dist/d.ts/chart/AbstractChartRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/AbstractSvgChartRenderer.d.ts +65 -0
- package/dist/d.ts/chart/AbstractSvgChartRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/Chart.d.ts +162 -0
- package/dist/d.ts/chart/Chart.d.ts.map +1 -0
- package/dist/d.ts/chart/ChartAdapter.d.ts +8 -0
- package/dist/d.ts/chart/ChartAdapter.d.ts.map +1 -0
- package/dist/d.ts/chart/ChartEventMap.d.ts +16 -0
- package/dist/d.ts/chart/ChartEventMap.d.ts.map +1 -0
- package/dist/d.ts/chart/ChartJsRenderer.d.ts +299 -0
- package/dist/d.ts/chart/ChartJsRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/ChartLayout.d.ts +8 -0
- package/dist/d.ts/chart/ChartLayout.d.ts.map +1 -0
- package/dist/d.ts/chart/ChartModel.d.ts +11 -0
- package/dist/d.ts/chart/ChartModel.d.ts.map +1 -0
- package/dist/d.ts/chart/FulfillmentChartRenderer.d.ts +22 -0
- package/dist/d.ts/chart/FulfillmentChartRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/SalesfunnelChartRenderer.d.ts +61 -0
- package/dist/d.ts/chart/SalesfunnelChartRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/SpeedoChartRenderer.d.ts +90 -0
- package/dist/d.ts/chart/SpeedoChartRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/VennAsync3Calculator.d.ts +32 -0
- package/dist/d.ts/chart/VennAsync3Calculator.d.ts.map +1 -0
- package/dist/d.ts/chart/VennChartRenderer.d.ts +36 -0
- package/dist/d.ts/chart/VennChartRenderer.d.ts.map +1 -0
- package/dist/d.ts/chart/VennCircle.d.ts +20 -0
- package/dist/d.ts/chart/VennCircle.d.ts.map +1 -0
- package/dist/d.ts/chart/VennCircleHelper.d.ts +13 -0
- package/dist/d.ts/chart/VennCircleHelper.d.ts.map +1 -0
- package/dist/d.ts/form/fields/chartfield/ChartField.d.ts +11 -0
- package/dist/d.ts/form/fields/chartfield/ChartField.d.ts.map +1 -0
- package/dist/d.ts/form/fields/chartfield/ChartFieldAdapter.d.ts +4 -0
- package/dist/d.ts/form/fields/chartfield/ChartFieldAdapter.d.ts.map +1 -0
- package/dist/d.ts/form/fields/chartfield/ChartFieldModel.d.ts +6 -0
- package/dist/d.ts/form/fields/chartfield/ChartFieldModel.d.ts.map +1 -0
- package/dist/d.ts/index.d.ts +31 -0
- package/dist/d.ts/index.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableControl.d.ts +136 -0
- package/dist/d.ts/table/controls/ChartTableControl.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableControlAdapter.d.ts +5 -0
- package/dist/d.ts/table/controls/ChartTableControlAdapter.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableControlEventMap.d.ts +9 -0
- package/dist/d.ts/table/controls/ChartTableControlEventMap.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableControlLayout.d.ts +8 -0
- package/dist/d.ts/table/controls/ChartTableControlLayout.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableControlModel.d.ts +9 -0
- package/dist/d.ts/table/controls/ChartTableControlModel.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableUserFilter.d.ts +28 -0
- package/dist/d.ts/table/controls/ChartTableUserFilter.d.ts.map +1 -0
- package/dist/d.ts/table/controls/ChartTableUserFilterModel.d.ts +11 -0
- package/dist/d.ts/table/controls/ChartTableUserFilterModel.d.ts.map +1 -0
- package/dist/d.ts/tile/ChartFieldTile.d.ts +14 -0
- package/dist/d.ts/tile/ChartFieldTile.d.ts.map +1 -0
- package/dist/d.ts/tile/ChartFieldTileAdapter.d.ts +4 -0
- package/dist/d.ts/tile/ChartFieldTileAdapter.d.ts.map +1 -0
- package/dist/d.ts/tile/ChartFieldTileModel.d.ts +6 -0
- package/dist/d.ts/tile/ChartFieldTileModel.d.ts.map +1 -0
- package/dist/eclipse-scout-chart-fae6f958a044232e659c.min.js +3 -0
- package/dist/eclipse-scout-chart-fae6f958a044232e659c.min.js.map +1 -0
- package/dist/eclipse-scout-chart-theme-56ba6667e592ef147869.min.css +1 -0
- package/dist/eclipse-scout-chart-theme-dark-593955eea95984c5aa62.min.css +1 -0
- package/dist/eclipse-scout-chart-theme-dark.css +53 -59
- package/dist/eclipse-scout-chart-theme-dark.css.map +1 -1
- package/dist/eclipse-scout-chart-theme.css +41 -45
- package/dist/eclipse-scout-chart-theme.css.map +1 -1
- package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js +3 -0
- package/dist/eclipse-scout-chart.esm-2119cfea86a9d6f34a35.min.js.map +1 -0
- package/dist/eclipse-scout-chart.esm.js +6898 -0
- package/dist/eclipse-scout-chart.esm.js.map +1 -0
- package/dist/eclipse-scout-chart.js +737 -15226
- package/dist/eclipse-scout-chart.js.map +1 -1
- package/dist/file-list +8 -5
- package/dist/texts.json +17 -17
- package/package.json +22 -16
- package/src/chart/{AbstractChartRenderer.js → AbstractChartRenderer.ts} +36 -31
- package/src/chart/{AbstractSvgChartRenderer.js → AbstractSvgChartRenderer.ts} +82 -48
- package/src/chart/Chart.less +8 -8
- package/src/chart/{Chart.js → Chart.ts} +157 -68
- package/src/chart/ChartAdapter.ts +26 -0
- package/src/chart/ChartEventMap.ts +26 -0
- package/src/chart/{ChartJsRenderer.js → ChartJsRenderer.ts} +362 -357
- package/src/chart/{ChartLayout.js → ChartLayout.ts} +13 -13
- package/src/chart/ChartModel.ts +20 -0
- package/src/chart/{FulfillmentChartRenderer.js → FulfillmentChartRenderer.ts} +25 -23
- package/src/chart/{SalesfunnelChartRenderer.js → SalesfunnelChartRenderer.ts} +102 -66
- package/src/chart/{SpeedoChartRenderer.js → SpeedoChartRenderer.ts} +56 -43
- package/src/chart/{VennAsync3Calculator.js → VennAsync3Calculator.ts} +41 -18
- package/src/chart/{VennChartRenderer.js → VennChartRenderer.ts} +63 -40
- package/src/chart/VennCircle.ts +47 -0
- package/src/chart/{VennCircleHelper.js → VennCircleHelper.ts} +19 -14
- package/src/eclipse-scout-chart-theme-dark.less +7 -8
- package/src/eclipse-scout-chart-theme.less +7 -8
- package/src/form/fields/chartfield/ChartField.ts +44 -0
- package/src/form/fields/chartfield/ChartFieldAdapter.ts +13 -0
- package/src/form/fields/chartfield/ChartFieldModel.ts +15 -0
- package/src/index-dark.less +6 -7
- package/src/index.less +6 -7
- package/src/index.ts +45 -0
- package/src/style/colors-dark.less +7 -8
- package/src/style/colors.less +6 -7
- package/src/table/controls/ChartTableControl.less +6 -7
- package/src/table/controls/{ChartTableControl.js → ChartTableControl.ts} +164 -125
- package/src/table/controls/ChartTableControlAdapter.ts +18 -0
- package/src/table/controls/ChartTableControlEventMap.ts +18 -0
- package/src/table/controls/ChartTableControlLayout.ts +30 -0
- package/src/table/controls/ChartTableControlModel.ts +18 -0
- package/src/table/controls/ChartTableUserFilter.ts +84 -0
- package/src/table/controls/ChartTableUserFilterModel.ts +18 -0
- package/src/tile/ChartFieldTile.less +6 -7
- package/src/tile/ChartFieldTile.ts +51 -0
- package/src/tile/ChartFieldTileAdapter.ts +13 -0
- package/src/tile/ChartFieldTileModel.ts +15 -0
- package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js +0 -3
- package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js.LICENSE.txt +0 -6
- package/dist/eclipse-scout-chart-8eb9461c14872058f638.min.js.map +0 -1
- package/dist/eclipse-scout-chart-theme-79622289bda68b525e3e.min.css +0 -1
- package/dist/eclipse-scout-chart-theme-dark-1de09c03e3dc40a9529a.min.css +0 -1
- package/src/chart/ChartAdapter.js +0 -30
- package/src/chart/VennCircle.js +0 -41
- package/src/form/fields/chartfield/ChartField.js +0 -39
- package/src/form/fields/chartfield/ChartFieldAdapter.js +0 -19
- package/src/index.js +0 -36
- package/src/table/controls/ChartTableControlAdapter.js +0 -20
- package/src/table/controls/ChartTableControlLayout.js +0 -29
- package/src/table/controls/ChartTableUserFilter.js +0 -72
- package/src/tile/ChartFieldTile.js +0 -46
- package/src/tile/ChartFieldTileAdapter.js +0 -18
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010
|
|
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
|
-
* https://www.eclipse.org/legal/epl-v10.html
|
|
2
|
+
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
|
|
7
3
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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 {numbers, RoundingMode} from '@eclipse-scout/core';
|
|
12
|
-
import {AbstractSvgChartRenderer} from '../index';
|
|
10
|
+
import {EnumObject, numbers, RoundingMode} from '@eclipse-scout/core';
|
|
11
|
+
import {AbstractSvgChartRenderer, Chart} from '../index';
|
|
12
|
+
|
|
13
|
+
export class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
14
|
+
|
|
15
|
+
segmentSelectorForAnimation: string;
|
|
16
|
+
|
|
17
|
+
r: number;
|
|
18
|
+
scaleWeight: number;
|
|
19
|
+
my: number;
|
|
20
|
+
parts: number;
|
|
21
|
+
numSegmentsPerPart: number;
|
|
22
|
+
segmentWidth: number;
|
|
23
|
+
widthOfSegmentWithGap: number;
|
|
24
|
+
animationTriggered: boolean;
|
|
13
25
|
|
|
14
|
-
|
|
26
|
+
$filledParts: JQuery<SVGElement>[];
|
|
27
|
+
$pointer: JQuery<SVGElement>;
|
|
15
28
|
|
|
16
|
-
constructor(chart) {
|
|
29
|
+
constructor(chart: Chart) {
|
|
17
30
|
super(chart);
|
|
31
|
+
|
|
18
32
|
this.segmentSelectorForAnimation = '.pointer';
|
|
19
33
|
this.suppressLegendBox = true;
|
|
20
34
|
|
|
@@ -32,7 +46,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
32
46
|
LEFT: 'left',
|
|
33
47
|
CENTER: 'center',
|
|
34
48
|
RIGHT: 'right'
|
|
35
|
-
};
|
|
49
|
+
} as const;
|
|
36
50
|
|
|
37
51
|
static NUM_PARTS_GREEN_CENTER = 7;
|
|
38
52
|
static NUM_PARTS_GREEN_EDGE = 4;
|
|
@@ -47,7 +61,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
47
61
|
|
|
48
62
|
static SEGMENT_GAP = 0.0103; // space between two segments (lines)
|
|
49
63
|
|
|
50
|
-
_validate() {
|
|
64
|
+
protected override _validate(): boolean {
|
|
51
65
|
let chartData = this.chart.data;
|
|
52
66
|
let chartConfig = this.chart.config;
|
|
53
67
|
if (!chartData ||
|
|
@@ -61,11 +75,11 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
61
75
|
return true;
|
|
62
76
|
}
|
|
63
77
|
|
|
64
|
-
_renderInternal() {
|
|
78
|
+
protected override _renderInternal() {
|
|
65
79
|
let chartData = this.chart.data,
|
|
66
|
-
minValue = chartData.chartValueGroups[0].values[0],
|
|
67
|
-
maxValue = chartData.chartValueGroups[0].values[2],
|
|
68
|
-
value = chartData.chartValueGroups[0].values[1];
|
|
80
|
+
minValue = chartData.chartValueGroups[0].values[0] as number,
|
|
81
|
+
maxValue = chartData.chartValueGroups[0].values[2] as number,
|
|
82
|
+
value = chartData.chartValueGroups[0].values[1] as number;
|
|
69
83
|
|
|
70
84
|
// radius of the scale
|
|
71
85
|
this.r = Math.min(this.chartBox.height, this.chartBox.width / 2) * 0.7;
|
|
@@ -113,19 +127,19 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
113
127
|
|
|
114
128
|
this.$svg.addClass('speedo-chart-svg');
|
|
115
129
|
if (this.chart.config.options.clickable) {
|
|
116
|
-
this.$svg.on('click', this._createClickObject(null, null), this.chart.
|
|
130
|
+
this.$svg.on('click', this._createClickObject(null, null), e => this.chart.handleValueClick(e.data));
|
|
117
131
|
}
|
|
118
132
|
}
|
|
119
133
|
|
|
120
|
-
_getValuePercentage(value, minValue, maxValue) {
|
|
134
|
+
protected _getValuePercentage(value: number, minValue: number, maxValue: number): number {
|
|
121
135
|
return this._limitValue((value - minValue) / (maxValue - minValue), 1);
|
|
122
136
|
}
|
|
123
137
|
|
|
124
|
-
_getSegmentToPointAt(valuePercentage, numTotalSegments) {
|
|
138
|
+
protected _getSegmentToPointAt(valuePercentage: number, numTotalSegments: number): number {
|
|
125
139
|
return this._limitValue(Math.floor(valuePercentage * numTotalSegments), numTotalSegments - 1);
|
|
126
140
|
}
|
|
127
141
|
|
|
128
|
-
_limitValue(value, maxValue) {
|
|
142
|
+
protected _limitValue(value: number, maxValue: number): number {
|
|
129
143
|
value = Math.max(value, 0); // cannot be < 0
|
|
130
144
|
value = Math.min(value, maxValue); // cannot be > maxValue
|
|
131
145
|
return value;
|
|
@@ -134,7 +148,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
134
148
|
/**
|
|
135
149
|
* Gets the percentage value in range [0,1] of the specified segment.
|
|
136
150
|
*/
|
|
137
|
-
_getPercentageValueOfSegment(segmentIndexInPart, part) {
|
|
151
|
+
protected _getPercentageValueOfSegment(segmentIndexInPart: number, part: number): number {
|
|
138
152
|
// get the segment position
|
|
139
153
|
let pointerRange = this._calcSegmentPos(segmentIndexInPart, part);
|
|
140
154
|
|
|
@@ -148,7 +162,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
148
162
|
/**
|
|
149
163
|
* Renders the pointer line and registers animation to move the pointer and the corresponding filling of the segments
|
|
150
164
|
*/
|
|
151
|
-
_renderPointer(valuePercentage) {
|
|
165
|
+
protected _renderPointer(valuePercentage: number) {
|
|
152
166
|
this.$pointer = this.$svg.appendSVG('path', 'pointer')
|
|
153
167
|
.attr('d', this._pathPointer(0))
|
|
154
168
|
.attr('data-end', valuePercentage)
|
|
@@ -176,7 +190,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
176
190
|
/**
|
|
177
191
|
* renders a single segment line.
|
|
178
192
|
*/
|
|
179
|
-
_renderSegment(from, to, colorClass) {
|
|
193
|
+
protected _renderSegment(from: number, to: number, colorClass: string): JQuery<SVGElement> {
|
|
180
194
|
return this.$svg.appendSVG('path', 'speedo-chart-arc ' + colorClass)
|
|
181
195
|
.attr('id', 'ArcAxisWide' + this.chart.id)
|
|
182
196
|
.attr('fill', 'none')
|
|
@@ -184,7 +198,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
184
198
|
.attr('d', this._pathSegment(from, to));
|
|
185
199
|
}
|
|
186
200
|
|
|
187
|
-
_renderCirclePart(part) {
|
|
201
|
+
protected _renderCirclePart(part: number) {
|
|
188
202
|
let colorClass = this._getColorForPart(part);
|
|
189
203
|
// render 'empty' segments
|
|
190
204
|
for (let i = 0; i < this.numSegmentsPerPart; i++) {
|
|
@@ -196,7 +210,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
196
210
|
this.$filledParts.push(this._renderSegment(SpeedoChartRenderer.ARC_MIN, SpeedoChartRenderer.ARC_MIN, colorClass)); // 'filled' segments. invisible by default
|
|
197
211
|
}
|
|
198
212
|
|
|
199
|
-
_renderLegend(minValue, value, maxValue, groupName) {
|
|
213
|
+
protected _renderLegend(minValue: number, value: number, maxValue: number, groupName: string) {
|
|
200
214
|
let minMaxLegendFontSize = this.scaleWeight * 0.8,
|
|
201
215
|
padding = 5, // same as in AbstractChartRenderer#_renderWireLegend
|
|
202
216
|
labelYPos = this.my + padding,
|
|
@@ -210,7 +224,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
210
224
|
h: 1
|
|
211
225
|
},
|
|
212
226
|
minLegendValue = minValue ? this._formatValue(minValue) : 0,
|
|
213
|
-
legendValue = value ? this._formatValue(value) : 0,
|
|
227
|
+
legendValue = value ? this._formatValue(value) : '' + 0,
|
|
214
228
|
maxLegendValue = maxValue ? this._formatValue(maxValue) : 0;
|
|
215
229
|
|
|
216
230
|
// tooltip for min/max value
|
|
@@ -239,8 +253,8 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
239
253
|
};
|
|
240
254
|
mouseOut();
|
|
241
255
|
this.$svg
|
|
242
|
-
.mouseenter
|
|
243
|
-
.mouseleave
|
|
256
|
+
.on('mouseenter', mouseIn)
|
|
257
|
+
.on('mouseleave', mouseOut);
|
|
244
258
|
}
|
|
245
259
|
|
|
246
260
|
// actual value
|
|
@@ -254,7 +268,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
254
268
|
/**
|
|
255
269
|
* returns the part index for the specified valuePercentage. The valuePercentage must be in the range [0,1].
|
|
256
270
|
*/
|
|
257
|
-
_getPartForValue(valuePercentage) {
|
|
271
|
+
protected _getPartForValue(valuePercentage: number): number {
|
|
258
272
|
let part = Math.floor(valuePercentage * this.parts);
|
|
259
273
|
return this._limitValue(part, this.parts - 1);
|
|
260
274
|
}
|
|
@@ -266,7 +280,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
266
280
|
* 10 to 999 thousand: 123k
|
|
267
281
|
* >= 1 million: millions with max. two fraction digits -> 1.23M
|
|
268
282
|
*/
|
|
269
|
-
_formatValue(value) {
|
|
283
|
+
protected _formatValue(value: number): string {
|
|
270
284
|
if (value < SpeedoChartRenderer.TEN_THOUSAND) {
|
|
271
285
|
return this.session.locale.decimalFormat.format(value);
|
|
272
286
|
}
|
|
@@ -281,7 +295,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
281
295
|
/**
|
|
282
296
|
* Updates the pointer position to point to the specified valuePercentage in range [0,1].
|
|
283
297
|
*/
|
|
284
|
-
_updatePointer(valuePercentage) {
|
|
298
|
+
protected _updatePointer(valuePercentage: number) {
|
|
285
299
|
this.$pointer
|
|
286
300
|
.attr('d', this._pathPointer(valuePercentage))
|
|
287
301
|
.removeClass('red yellow light-green dark-green')
|
|
@@ -291,13 +305,13 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
291
305
|
/**
|
|
292
306
|
* Updates the filling of the 'filled' segments to be filled up to the specified valuePercentage in range [0,1].
|
|
293
307
|
*/
|
|
294
|
-
_updatePartsFill(valuePercentage) {
|
|
308
|
+
protected _updatePartsFill(valuePercentage: number) {
|
|
295
309
|
let from, to;
|
|
296
310
|
for (let part = 0; part < this.$filledParts.length; part++) {
|
|
297
|
-
from = this._calcSegmentPos(0, part
|
|
311
|
+
from = this._calcSegmentPos(0, part).from;
|
|
298
312
|
if ((part + 1) / this.parts < valuePercentage) {
|
|
299
313
|
// the current part is smaller than the value: completely filled part
|
|
300
|
-
to = this._calcSegmentPos(this.numSegmentsPerPart - 1, part
|
|
314
|
+
to = this._calcSegmentPos(this.numSegmentsPerPart - 1, part).to;
|
|
301
315
|
} else if (part / this.parts > valuePercentage) {
|
|
302
316
|
// the current part is bigger than the speedo-value: hide element
|
|
303
317
|
from = SpeedoChartRenderer.ARC_MIN;
|
|
@@ -315,7 +329,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
315
329
|
* @param segmentIndexInPart the index of the segment line within the part.
|
|
316
330
|
* @param part the part index.
|
|
317
331
|
*/
|
|
318
|
-
_calcSegmentPos(segmentIndexInPart, part) {
|
|
332
|
+
protected _calcSegmentPos(segmentIndexInPart: number, part: number): { from: number; to: number } {
|
|
319
333
|
let result = {
|
|
320
334
|
from: 0,
|
|
321
335
|
to: 0
|
|
@@ -326,7 +340,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
326
340
|
return result;
|
|
327
341
|
}
|
|
328
342
|
|
|
329
|
-
_getColorForPart(part) {
|
|
343
|
+
protected _getColorForPart(part: number): string {
|
|
330
344
|
let position = this.chart.config.options.speedo.greenAreaPosition;
|
|
331
345
|
switch (position) {
|
|
332
346
|
case SpeedoChartRenderer.Position.LEFT:
|
|
@@ -378,7 +392,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
378
392
|
/**
|
|
379
393
|
* calculates the path-values to be used in the 'd' attribute of the path tag for a segment.
|
|
380
394
|
*/
|
|
381
|
-
_pathSegment(start, end) {
|
|
395
|
+
protected _pathSegment(start: number, end: number): string {
|
|
382
396
|
let s = start * 2 * Math.PI,
|
|
383
397
|
e = end * 2 * Math.PI,
|
|
384
398
|
pathString = '';
|
|
@@ -398,7 +412,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
398
412
|
/**
|
|
399
413
|
* calculates the path-values to be used in the 'd' attribute of the path tag for the pointer
|
|
400
414
|
*/
|
|
401
|
-
_pathPointer(valuePercentage) {
|
|
415
|
+
protected _pathPointer(valuePercentage: number): string {
|
|
402
416
|
let point = SpeedoChartRenderer.ARC_RANGE * valuePercentage - SpeedoChartRenderer.ARC_MAX;
|
|
403
417
|
let s = point * 2 * Math.PI,
|
|
404
418
|
pointerOuterR = this.r - (1.4 * this.scaleWeight),
|
|
@@ -411,10 +425,7 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
411
425
|
return pathString;
|
|
412
426
|
}
|
|
413
427
|
|
|
414
|
-
|
|
415
|
-
* @override
|
|
416
|
-
*/
|
|
417
|
-
_removeAnimated(afterRemoveFunc) {
|
|
428
|
+
protected override _removeAnimated(afterRemoveFunc: (chartAnimationStopping?: boolean) => void) {
|
|
418
429
|
if (this.animationTriggered) {
|
|
419
430
|
return;
|
|
420
431
|
}
|
|
@@ -437,3 +448,5 @@ export default class SpeedoChartRenderer extends AbstractSvgChartRenderer {
|
|
|
437
448
|
});
|
|
438
449
|
}
|
|
439
450
|
}
|
|
451
|
+
|
|
452
|
+
export type GreenAreaPosition = EnumObject<typeof SpeedoChartRenderer.Position>;
|
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010
|
|
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
|
-
*
|
|
9
|
-
*
|
|
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 {Device} from '@eclipse-scout/core';
|
|
12
10
|
|
|
13
11
|
// place venn 3 by simulation
|
|
14
12
|
// find angle and distance (to a) and radius where "error" is minimal
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
import {VennCircle, VennCircleHelper} from '../index';
|
|
14
|
+
|
|
15
|
+
export class VennAsync3Calculator {
|
|
16
|
+
helper: VennCircleHelper;
|
|
17
|
+
venn1: VennCircle;
|
|
18
|
+
venn2: VennCircle;
|
|
19
|
+
venn3: VennCircle;
|
|
20
|
+
u: number;
|
|
21
|
+
v: number;
|
|
22
|
+
w: number;
|
|
23
|
+
uv: number;
|
|
24
|
+
uw: number;
|
|
25
|
+
vw: number;
|
|
26
|
+
uvw: number;
|
|
27
|
+
|
|
28
|
+
maxD: number;
|
|
29
|
+
dStep: number;
|
|
30
|
+
rStep: number;
|
|
31
|
+
alphaStep: number;
|
|
32
|
+
|
|
33
|
+
alphaBest: number;
|
|
34
|
+
dBest: number;
|
|
35
|
+
rBest: number;
|
|
36
|
+
errorBest: number;
|
|
37
|
+
callback: () => void;
|
|
38
|
+
cancelled: boolean;
|
|
39
|
+
|
|
40
|
+
constructor(helper: VennCircleHelper, venn1: VennCircle, venn2: VennCircle, venn3: VennCircle, u: number, v: number, w: number, uv: number, uw: number, vw: number, uvw: number, d12: number, d13: number, d23: number) {
|
|
18
41
|
// if circles are empty, they are drawn as small circle, so: adjust u v w to find better errors
|
|
19
42
|
if (u === 0 && uv === 0 && uw === 0 && uvw === 0) {
|
|
20
43
|
u = 1;
|
|
@@ -38,13 +61,13 @@ export default class VennAsync3Calculator {
|
|
|
38
61
|
this.vw = vw;
|
|
39
62
|
this.uvw = uvw;
|
|
40
63
|
|
|
41
|
-
|
|
64
|
+
/** step and ranges for loops */
|
|
42
65
|
this.maxD = this.venn1.r + 2 * this.venn2.r + 2 * this.venn1.r + this.helper.distR;
|
|
43
66
|
this.dStep = this.maxD / 30;
|
|
44
67
|
this.rStep = venn3.r / 4;
|
|
45
68
|
this.alphaStep = Math.PI / 30;
|
|
46
69
|
|
|
47
|
-
|
|
70
|
+
/** best vars (initialize with 0 so the optimizer knows that they are numbers) */
|
|
48
71
|
this.alphaBest = 0;
|
|
49
72
|
this.dBest = 0;
|
|
50
73
|
this.rBest = 0;
|
|
@@ -54,7 +77,7 @@ export default class VennAsync3Calculator {
|
|
|
54
77
|
this.cancelled = false;
|
|
55
78
|
}
|
|
56
79
|
|
|
57
|
-
start(callback) {
|
|
80
|
+
start(callback: () => void) {
|
|
58
81
|
this.callback = callback;
|
|
59
82
|
setTimeout(this._next.bind(this, 0));
|
|
60
83
|
}
|
|
@@ -63,7 +86,7 @@ export default class VennAsync3Calculator {
|
|
|
63
86
|
this.cancelled = true;
|
|
64
87
|
}
|
|
65
88
|
|
|
66
|
-
_end() {
|
|
89
|
+
protected _end() {
|
|
67
90
|
// set x and y and r of venn3
|
|
68
91
|
this.venn3.x = this.venn1.x + this.dBest * Math.cos(this.alphaBest);
|
|
69
92
|
this.venn3.y = this.venn1.y - this.dBest * Math.sin(this.alphaBest);
|
|
@@ -72,7 +95,7 @@ export default class VennAsync3Calculator {
|
|
|
72
95
|
this.callback();
|
|
73
96
|
}
|
|
74
97
|
|
|
75
|
-
_next(alpha) {
|
|
98
|
+
protected _next(alpha: number) {
|
|
76
99
|
if (!this.cancelled) {
|
|
77
100
|
// iterate
|
|
78
101
|
this._iteration(alpha);
|
|
@@ -91,7 +114,7 @@ export default class VennAsync3Calculator {
|
|
|
91
114
|
}
|
|
92
115
|
}
|
|
93
116
|
|
|
94
|
-
_iteration(alpha) {
|
|
117
|
+
protected _iteration(alpha: number) {
|
|
95
118
|
// optimize speed: no var lookup (should help the optimizer in general, and IE in particular)
|
|
96
119
|
let maxD = this.maxD,
|
|
97
120
|
dStep = this.dStep,
|
|
@@ -197,7 +220,7 @@ export default class VennAsync3Calculator {
|
|
|
197
220
|
this.errorBest = errorBest;
|
|
198
221
|
}
|
|
199
222
|
|
|
200
|
-
_error(u, total, a, aTotal) {
|
|
223
|
+
protected _error(u: number, total: number, a: number, aTotal: number): number {
|
|
201
224
|
// be brutal if basic error
|
|
202
225
|
if ((u === 0 && a !== 0) || (u !== 0 && a === 0)) {
|
|
203
226
|
return 1000;
|
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010
|
|
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
|
-
*
|
|
9
|
-
*
|
|
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 {AbstractSvgChartRenderer, VennAsync3Calculator, VennCircle, VennCircleHelper} from '../index';
|
|
10
|
+
import {AbstractSvgChartRenderer, Chart, VennAsync3Calculator, VennCircle, VennCircleHelper} from '../index';
|
|
12
11
|
import $ from 'jquery';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
import {ChartValueGroup} from './Chart';
|
|
13
|
+
import {LegendPositions} from './AbstractSvgChartRenderer';
|
|
14
|
+
|
|
15
|
+
export class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
16
|
+
animationTriggered: boolean;
|
|
17
|
+
|
|
18
|
+
data: ChartValueGroup[];
|
|
19
|
+
centerX: number;
|
|
20
|
+
centerY: number;
|
|
21
|
+
numberOfCircles: number;
|
|
22
|
+
readyToDraw: boolean;
|
|
23
|
+
wasCircle: boolean;
|
|
24
|
+
|
|
25
|
+
vennCircleHelper: VennCircleHelper;
|
|
26
|
+
async3Calculator: VennAsync3Calculator;
|
|
27
|
+
|
|
28
|
+
vennNumber1: VennCircle;
|
|
29
|
+
vennReal1: VennCircle;
|
|
30
|
+
vennNumber2: VennCircle;
|
|
31
|
+
vennReal2: VennCircle;
|
|
32
|
+
vennNumber3: VennCircle;
|
|
33
|
+
vennReal3: VennCircle;
|
|
34
|
+
|
|
35
|
+
$v1: JQuery<SVGElement>;
|
|
36
|
+
$v2: JQuery<SVGElement>;
|
|
37
|
+
$v3: JQuery<SVGElement>;
|
|
38
|
+
|
|
39
|
+
constructor(chart: Chart) {
|
|
17
40
|
super(chart);
|
|
18
41
|
this.animationTriggered = false;
|
|
19
42
|
this.suppressLegendBox = true;
|
|
@@ -28,7 +51,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
28
51
|
chart.config = $.extend(true, {}, defaultConfig, chart.config);
|
|
29
52
|
}
|
|
30
53
|
|
|
31
|
-
_validate() {
|
|
54
|
+
protected override _validate(): boolean {
|
|
32
55
|
let chartData = this.chart.data;
|
|
33
56
|
if (!chartData ||
|
|
34
57
|
chartData.axes.length !== 0 ||
|
|
@@ -39,12 +62,12 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
39
62
|
return true;
|
|
40
63
|
}
|
|
41
64
|
|
|
42
|
-
_renderInternal() {
|
|
65
|
+
protected override _renderInternal() {
|
|
43
66
|
this.centerX = this.width / 2;
|
|
44
67
|
this.centerY = this.height / 2;
|
|
45
68
|
|
|
46
69
|
if (this.centerX === 0 || this.centerY === 0) {
|
|
47
|
-
return
|
|
70
|
+
return;
|
|
48
71
|
}
|
|
49
72
|
|
|
50
73
|
// basic values
|
|
@@ -56,7 +79,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
56
79
|
maxR = Math.min(this.centerX, this.centerY),
|
|
57
80
|
minR = maxR / 15,
|
|
58
81
|
total = this.data.reduce((s, e) => {
|
|
59
|
-
return s +
|
|
82
|
+
return s + (e.values[0] as number);
|
|
60
83
|
}, 1);
|
|
61
84
|
|
|
62
85
|
this.vennCircleHelper = new VennCircleHelper(distR, maxR, minR, total);
|
|
@@ -112,16 +135,16 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
112
135
|
}
|
|
113
136
|
}
|
|
114
137
|
|
|
115
|
-
remove(requestAnimation, afterRemoveFunc) {
|
|
138
|
+
override remove(requestAnimation = false, afterRemoveFunc?: (chartAnimationStopping?: boolean) => void) {
|
|
116
139
|
this._cancelAsync3Calculator();
|
|
117
140
|
super.remove(requestAnimation, afterRemoveFunc);
|
|
118
141
|
}
|
|
119
142
|
|
|
120
143
|
// calculation
|
|
121
144
|
|
|
122
|
-
_calc1(v1) {
|
|
145
|
+
protected _calc1(v1: VennCircle) {
|
|
123
146
|
// set basic data
|
|
124
|
-
let a = this.data[0].values[0];
|
|
147
|
+
let a = this.data[0].values[0] as number;
|
|
125
148
|
|
|
126
149
|
// calc sizes
|
|
127
150
|
if (a > 0) {
|
|
@@ -138,11 +161,11 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
138
161
|
v1.addLabel(a, v1.x, v1.y);
|
|
139
162
|
}
|
|
140
163
|
|
|
141
|
-
_calc2(v1, v2, real) {
|
|
164
|
+
protected _calc2(v1: VennCircle, v2: VennCircle, real: boolean) {
|
|
142
165
|
// set basic data
|
|
143
|
-
let a = this.data[0].values[0];
|
|
144
|
-
let b = this.data[1].values[0];
|
|
145
|
-
let ab = this.data[2].values[0];
|
|
166
|
+
let a = this.data[0].values[0] as number;
|
|
167
|
+
let b = this.data[1].values[0] as number;
|
|
168
|
+
let ab = this.data[2].values[0] as number;
|
|
146
169
|
let d12;
|
|
147
170
|
|
|
148
171
|
if (real) {
|
|
@@ -199,15 +222,15 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
199
222
|
}
|
|
200
223
|
}
|
|
201
224
|
|
|
202
|
-
_calc3(v1, v2, v3, real, callback) {
|
|
225
|
+
protected _calc3(v1: VennCircle, v2: VennCircle, v3: VennCircle, real: boolean, callback: () => void) {
|
|
203
226
|
// set basic data
|
|
204
|
-
let a = this.data[0].values[0];
|
|
205
|
-
let b = this.data[1].values[0];
|
|
206
|
-
let c = this.data[2].values[0];
|
|
207
|
-
let ab = this.data[3].values[0];
|
|
208
|
-
let ac = this.data[4].values[0];
|
|
209
|
-
let bc = this.data[5].values[0];
|
|
210
|
-
let abc = this.data[6].values[0];
|
|
227
|
+
let a = this.data[0].values[0] as number;
|
|
228
|
+
let b = this.data[1].values[0] as number;
|
|
229
|
+
let c = this.data[2].values[0] as number;
|
|
230
|
+
let ab = this.data[3].values[0] as number;
|
|
231
|
+
let ac = this.data[4].values[0] as number;
|
|
232
|
+
let bc = this.data[5].values[0] as number;
|
|
233
|
+
let abc = this.data[6].values[0] as number;
|
|
211
234
|
|
|
212
235
|
let d12, d13, d23;
|
|
213
236
|
|
|
@@ -279,7 +302,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
279
302
|
}
|
|
280
303
|
}
|
|
281
304
|
|
|
282
|
-
_cancelAsync3Calculator() {
|
|
305
|
+
protected _cancelAsync3Calculator() {
|
|
283
306
|
if (this.async3Calculator) {
|
|
284
307
|
this.async3Calculator.cancel();
|
|
285
308
|
this.async3Calculator = null;
|
|
@@ -288,7 +311,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
288
311
|
|
|
289
312
|
// drawing
|
|
290
313
|
|
|
291
|
-
_draw(animated, real) {
|
|
314
|
+
protected _draw(animated: boolean, real: boolean) {
|
|
292
315
|
if (!this.rendered && !this.rendering) { // additional check, because this method might be called from a setTimeout()
|
|
293
316
|
return;
|
|
294
317
|
}
|
|
@@ -337,7 +360,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
337
360
|
}
|
|
338
361
|
|
|
339
362
|
// handling of circles
|
|
340
|
-
_createCircle(circleIndex, color, cssClass) {
|
|
363
|
+
protected _createCircle(circleIndex: number, color: string, cssClass: string): JQuery<SVGElement> {
|
|
341
364
|
let $circle = this.$svg.appendSVG('circle', 'venn-circle')
|
|
342
365
|
.attr('cx', this.centerX)
|
|
343
366
|
.attr('cy', this.centerY)
|
|
@@ -358,14 +381,14 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
358
381
|
}
|
|
359
382
|
|
|
360
383
|
if (this.chart.config.options.clickable) {
|
|
361
|
-
$circle.on('click', this._createClickObject(null, circleIndex), this.chart.
|
|
384
|
+
$circle.on('click', this._createClickObject(null, circleIndex), e => this.chart.handleValueClick(e.data));
|
|
362
385
|
}
|
|
363
386
|
|
|
364
387
|
return $circle;
|
|
365
388
|
}
|
|
366
389
|
|
|
367
390
|
// handling of venn, label and legend
|
|
368
|
-
_updateVenn(venn, animated) {
|
|
391
|
+
protected _updateVenn(venn: VennCircle, animated: boolean) {
|
|
369
392
|
// move circle
|
|
370
393
|
venn.$circle
|
|
371
394
|
.animateSVG('cx', this.centerX + venn.x, animated ? this.animationDuration : 0, null, true)
|
|
@@ -386,12 +409,12 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
386
409
|
y2: y2,
|
|
387
410
|
v: venn.legendV,
|
|
388
411
|
h: venn.legendH
|
|
389
|
-
};
|
|
412
|
+
} as LegendPositions;
|
|
390
413
|
|
|
391
414
|
this._renderWireLegend(venn.legend, legendPositions, 'venn-legend');
|
|
392
415
|
}
|
|
393
416
|
|
|
394
|
-
_drawLabel(text, dx, dy, animated) {
|
|
417
|
+
protected _drawLabel(text: number, dx: number, dy: number, animated: boolean) {
|
|
395
418
|
// draw label
|
|
396
419
|
let $label = this.$svg.appendSVG('text', 'venn-label')
|
|
397
420
|
.attr('x', this.centerX + dx)
|
|
@@ -407,7 +430,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
407
430
|
}
|
|
408
431
|
|
|
409
432
|
// handling of show/hide numbers
|
|
410
|
-
_show(event) {
|
|
433
|
+
protected _show(event: JQuery.MouseEventBase) {
|
|
411
434
|
if (this.numberOfCircles === 1) {
|
|
412
435
|
return; // Nothing to do for only one circle
|
|
413
436
|
}
|
|
@@ -418,7 +441,7 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
|
|
|
418
441
|
// check if true enter or just from one circle to another
|
|
419
442
|
let isCircle = toElement && $(toElement).hasClass('venn-circle');
|
|
420
443
|
if (this.wasCircle && isCircle) {
|
|
421
|
-
return
|
|
444
|
+
return;
|
|
422
445
|
}
|
|
423
446
|
this.wasCircle = isCircle;
|
|
424
447
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
|
|
3
|
+
*
|
|
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
|
|
9
|
+
*/
|
|
10
|
+
export class VennCircle {
|
|
11
|
+
labels: Label[];
|
|
12
|
+
$circle: JQuery<SVGElement>;
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
r: number;
|
|
16
|
+
legend: string;
|
|
17
|
+
legendR: number;
|
|
18
|
+
legendH: -1 | 1;
|
|
19
|
+
legendV: -1 | 1;
|
|
20
|
+
|
|
21
|
+
constructor($circle: JQuery<SVGElement>) {
|
|
22
|
+
this.$circle = $circle;
|
|
23
|
+
this.labels = [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setLegend(legend: string, horizontal: -1 | 1, vertical: -1 | 1, r?: number) {
|
|
27
|
+
this.legend = legend;
|
|
28
|
+
this.legendH = horizontal;
|
|
29
|
+
this.legendV = vertical;
|
|
30
|
+
this.legendR = r || this.r;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
addLabel(text: number, x: number, y: number) {
|
|
34
|
+
this.labels.push({
|
|
35
|
+
text: text,
|
|
36
|
+
x: x,
|
|
37
|
+
y: y
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type Label = {
|
|
43
|
+
text: number;
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
|