@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.
- package/LICENSE +210 -0
- 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 +300 -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 +29 -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-dark-89bcf2022056cbf8e371.min.css +1 -0
- package/dist/eclipse-scout-chart-theme-dark.css +1 -1
- package/dist/eclipse-scout-chart-theme-dark.css.map +1 -1
- package/dist/eclipse-scout-chart-theme-e25b5923d4dba5f5ca7e.min.css +1 -0
- package/dist/eclipse-scout-chart-theme.css +1 -1
- 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 +6919 -0
- package/dist/eclipse-scout-chart.esm.js.map +1 -0
- package/dist/eclipse-scout-chart.js +683 -15122
- package/dist/eclipse-scout-chart.js.map +1 -1
- package/dist/file-list +8 -5
- package/dist/texts.json +17 -17
- package/package.json +21 -15
- package/src/chart/{AbstractChartRenderer.js → AbstractChartRenderer.ts} +31 -25
- package/src/chart/{AbstractSvgChartRenderer.js → AbstractSvgChartRenderer.ts} +78 -43
- package/src/chart/{Chart.js → Chart.ts} +153 -62
- package/src/chart/ChartAdapter.ts +27 -0
- package/src/chart/ChartEventMap.ts +27 -0
- package/src/chart/{ChartJsRenderer.js → ChartJsRenderer.ts} +367 -351
- package/src/chart/{ChartLayout.js → ChartLayout.ts} +9 -8
- package/src/chart/ChartModel.ts +21 -0
- package/src/chart/{FulfillmentChartRenderer.js → FulfillmentChartRenderer.ts} +21 -18
- package/src/chart/{SalesfunnelChartRenderer.js → SalesfunnelChartRenderer.ts} +96 -59
- package/src/chart/{SpeedoChartRenderer.js → SpeedoChartRenderer.ts} +61 -39
- package/src/chart/{VennAsync3Calculator.js → VennAsync3Calculator.ts} +37 -13
- package/src/chart/{VennChartRenderer.js → VennChartRenderer.ts} +58 -34
- package/src/chart/{VennCircle.js → VennCircle.ts} +22 -15
- package/src/chart/{VennCircleHelper.js → VennCircleHelper.ts} +15 -9
- package/src/form/fields/chartfield/{ChartField.js → ChartField.ts} +11 -5
- package/src/form/fields/chartfield/{ChartFieldAdapter.js → ChartFieldAdapter.ts} +3 -8
- package/src/form/fields/chartfield/ChartFieldModel.ts +16 -0
- package/src/index.ts +46 -0
- package/src/table/controls/{ChartTableControl.js → ChartTableControl.ts} +160 -120
- package/src/table/controls/{ChartTableControlAdapter.js → ChartTableControlAdapter.ts} +3 -4
- package/src/table/controls/ChartTableControlEventMap.ts +19 -0
- package/src/table/controls/{ChartTableControlLayout.js → ChartTableControlLayout.ts} +7 -5
- package/src/table/controls/ChartTableControlModel.ts +19 -0
- package/src/table/controls/{ChartTableUserFilter.js → ChartTableUserFilter.ts} +25 -12
- package/src/table/controls/ChartTableUserFilterModel.ts +19 -0
- package/src/tile/{ChartFieldTile.js → ChartFieldTile.ts} +14 -8
- package/src/tile/{ChartFieldTileAdapter.js → ChartFieldTileAdapter.ts} +3 -7
- package/src/tile/ChartFieldTileModel.ts +16 -0
- package/dist/eclipse-scout-chart-bc08151d11e1909eff6c.min.js +0 -3
- package/dist/eclipse-scout-chart-bc08151d11e1909eff6c.min.js.LICENSE.txt +0 -6
- package/dist/eclipse-scout-chart-bc08151d11e1909eff6c.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/index.js +0 -36
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010-
|
|
2
|
+
* Copyright (c) 2010-2022 BSI Business Systems Integration AG.
|
|
3
3
|
* All rights reserved. This program and the accompanying materials
|
|
4
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
5
5
|
* which accompanies this distribution, and is available at
|
|
6
|
-
*
|
|
6
|
+
* https://www.eclipse.org/legal/epl-v10.html
|
|
7
7
|
*
|
|
8
8
|
* Contributors:
|
|
9
9
|
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
10
|
*/
|
|
11
11
|
import {AbstractLayout} from '@eclipse-scout/core';
|
|
12
|
-
import {Chart} from '../index';
|
|
12
|
+
import {UpdateChartOptions, Chart} from '../index';
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export class ChartLayout extends AbstractLayout {
|
|
15
|
+
chart: Chart;
|
|
15
16
|
|
|
16
|
-
constructor(chart) {
|
|
17
|
+
constructor(chart: Chart) {
|
|
17
18
|
super();
|
|
18
19
|
this.chart = chart;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
layout($container) {
|
|
22
|
-
let opts = {
|
|
22
|
+
override layout($container: JQuery) {
|
|
23
|
+
let opts: UpdateChartOptions = {
|
|
23
24
|
requestAnimation: true,
|
|
24
25
|
debounce: Chart.DEFAULT_DEBOUNCE_TIMEOUT,
|
|
25
26
|
onlyUpdateData: true
|
|
26
27
|
};
|
|
27
28
|
// Don't request animations when the session is not ready or the chart was already updated once
|
|
28
|
-
if (!this.chart.session.ready || this.chart.
|
|
29
|
+
if (!this.chart.session.ready || this.chart._updatedOnce) {
|
|
29
30
|
opts.requestAnimation = false;
|
|
30
31
|
}
|
|
31
32
|
// Don't debounce while session is not yet ready. Otherwise, it might happen that the area to layout is not
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2010-2022 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
|
+
* https://www.eclipse.org/legal/epl-v10.html
|
|
7
|
+
*
|
|
8
|
+
* Contributors:
|
|
9
|
+
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
|
+
*/
|
|
11
|
+
import {WidgetModel} from '@eclipse-scout/core';
|
|
12
|
+
import {ChartConfig, ChartData, ClickObject} from './Chart';
|
|
13
|
+
|
|
14
|
+
export interface ChartModel extends WidgetModel {
|
|
15
|
+
data?: ChartData;
|
|
16
|
+
config?: ChartConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Default is [].
|
|
19
|
+
*/
|
|
20
|
+
checkedItems?: ClickObject[];
|
|
21
|
+
}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2010-
|
|
2
|
+
* Copyright (c) 2010-2022 BSI Business Systems Integration AG.
|
|
3
3
|
* All rights reserved. This program and the accompanying materials
|
|
4
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
5
5
|
* which accompanies this distribution, and is available at
|
|
6
|
-
*
|
|
6
|
+
* https://www.eclipse.org/legal/epl-v10.html
|
|
7
7
|
*
|
|
8
8
|
* Contributors:
|
|
9
9
|
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
10
|
*/
|
|
11
11
|
import {objects, scout} from '@eclipse-scout/core';
|
|
12
|
-
import {AbstractSvgChartRenderer} from '../index';
|
|
12
|
+
import {AbstractSvgChartRenderer, Chart} from '../index';
|
|
13
13
|
import $ from 'jquery';
|
|
14
|
+
import {UpdateChartOptions} from './Chart';
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
+
export class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
17
|
+
animationTriggered: boolean;
|
|
18
|
+
segmentSelectorForAnimation: string;
|
|
19
|
+
r: number;
|
|
20
|
+
fullR: number;
|
|
16
21
|
|
|
17
|
-
constructor(chart) {
|
|
22
|
+
constructor(chart: Chart) {
|
|
18
23
|
super(chart);
|
|
19
24
|
|
|
20
25
|
this.animationTriggered = false;
|
|
21
|
-
this.r;
|
|
22
|
-
|
|
23
26
|
this.segmentSelectorForAnimation = '.fulfillment-chart';
|
|
24
27
|
this.suppressLegendBox = true;
|
|
25
28
|
|
|
@@ -33,7 +36,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
33
36
|
chart.config = $.extend(true, {}, defaultConfig, chart.config);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
_validate() {
|
|
39
|
+
protected override _validate(): boolean {
|
|
37
40
|
let chartValueGroups = this.chart.data.chartValueGroups;
|
|
38
41
|
if (chartValueGroups.length !== 2 ||
|
|
39
42
|
chartValueGroups[0].values.length !== 1 ||
|
|
@@ -43,11 +46,11 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
43
46
|
return true;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
|
-
_renderInternal() {
|
|
49
|
+
protected override _renderInternal() {
|
|
47
50
|
// Calculate percentage
|
|
48
51
|
let chartData = this.chart.data;
|
|
49
|
-
let value = chartData.chartValueGroups[0].values[0];
|
|
50
|
-
let total = chartData.chartValueGroups[1].values[0];
|
|
52
|
+
let value = chartData.chartValueGroups[0].values[0] as number;
|
|
53
|
+
let total = chartData.chartValueGroups[1].values[0] as number;
|
|
51
54
|
|
|
52
55
|
this.fullR = (Math.min(this.chartBox.height, this.chartBox.width) / 2) - 2;
|
|
53
56
|
|
|
@@ -55,7 +58,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
55
58
|
this._renderPercentage(value, total);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
_renderPercentage(value, total) {
|
|
61
|
+
protected _renderPercentage(value: number, total: number) {
|
|
59
62
|
// arc segment
|
|
60
63
|
let arcClass = 'fulfillment-chart',
|
|
61
64
|
color = this.chart.data.chartValueGroups[0].colorHexValue,
|
|
@@ -104,7 +107,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
104
107
|
.text(percentage + '%');
|
|
105
108
|
|
|
106
109
|
if (this.chart.config.options.clickable) {
|
|
107
|
-
$arc.on('click', this._createClickObject(null, null), this.chart.
|
|
110
|
+
$arc.on('click', this._createClickObject(null, null), e => this.chart.handleValueClick(e.data));
|
|
108
111
|
}
|
|
109
112
|
if (!this.chart.config.options.autoColor && !chartGroupCss) {
|
|
110
113
|
$arc.attr('fill', color);
|
|
@@ -124,7 +127,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
|
|
127
|
-
pathSegment(start, end) {
|
|
130
|
+
pathSegment(start: number, end: number): string {
|
|
128
131
|
let s = start * 2 * Math.PI,
|
|
129
132
|
e = end * 2 * Math.PI,
|
|
130
133
|
pathString = '';
|
|
@@ -138,7 +141,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
138
141
|
return pathString;
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
_renderCirclePath(cssClass, id, radius) {
|
|
144
|
+
protected _renderCirclePath(cssClass: string, id: string, radius: number): JQuery<SVGElement> {
|
|
142
145
|
let chartGroupCss = this.chart.data.chartValueGroups[0].cssClass;
|
|
143
146
|
let color = this.chart.data.chartValueGroups[1].colorHexValue;
|
|
144
147
|
|
|
@@ -165,7 +168,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
165
168
|
return $path;
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
_renderInnerCircle() {
|
|
171
|
+
protected _renderInnerCircle() {
|
|
169
172
|
let radius = (this.fullR / 8) * 7.5,
|
|
170
173
|
radius2 = (this.fullR / 8) * 7.2;
|
|
171
174
|
|
|
@@ -178,7 +181,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
178
181
|
* Do not animate the removal of the chart if the chart data has been updated and the startValue option is set.
|
|
179
182
|
* If startValue is not set use default implementation.
|
|
180
183
|
*/
|
|
181
|
-
shouldAnimateRemoveOnUpdate(opts) {
|
|
184
|
+
override shouldAnimateRemoveOnUpdate(opts: UpdateChartOptions): boolean {
|
|
182
185
|
let startValue = objects.optProperty(this.chart, 'config', 'options', 'fulfillment', 'startValue');
|
|
183
186
|
if (!objects.isNullOrUndefined(startValue)) {
|
|
184
187
|
return false;
|
|
@@ -187,7 +190,7 @@ export default class FulfillmentChartRenderer extends AbstractSvgChartRenderer {
|
|
|
187
190
|
return super.shouldAnimateRemoveOnUpdate(opts);
|
|
188
191
|
}
|
|
189
192
|
|
|
190
|
-
_removeAnimated(afterRemoveFunc) {
|
|
193
|
+
protected override _removeAnimated(afterRemoveFunc: (chartAnimationStopping?: boolean) => void) {
|
|
191
194
|
if (this.animationTriggered) {
|
|
192
195
|
return;
|
|
193
196
|
}
|
|
@@ -9,24 +9,46 @@
|
|
|
9
9
|
* BSI Business Systems Integration AG - initial API and implementation
|
|
10
10
|
*/
|
|
11
11
|
import {objects, strings} from '@eclipse-scout/core';
|
|
12
|
-
import {AbstractSvgChartRenderer} from '../index';
|
|
12
|
+
import {AbstractSvgChartRenderer, Chart} from '../index';
|
|
13
13
|
import $ from 'jquery';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
import {ChartValueGroup, ClickObject} from './Chart';
|
|
15
|
+
import {LegendPositions} from './AbstractSvgChartRenderer';
|
|
16
|
+
|
|
17
|
+
export class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
18
|
+
segmentSelectorForAnimation: string;
|
|
19
|
+
widthThresholdMedium: number;
|
|
20
|
+
widthThresholdSmall: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Constants for "normalized mode"
|
|
24
|
+
* Width of a bar is calculated by multiplying this value with the previous bar's width
|
|
25
|
+
*/
|
|
26
|
+
barDeltaPercentage: number;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Factor to be multiplied with the last bar's width. This will create a funnel effect, because
|
|
30
|
+
* the last bar is considerably smaller than the other bars.
|
|
31
|
+
*/
|
|
32
|
+
lastBarAdditionalPercentage: number;
|
|
33
|
+
|
|
34
|
+
/** Percentage of the total width the last bar always has (delta might get smaller due to this constraint). */
|
|
35
|
+
lastBarMinWidthPercentage: number;
|
|
36
|
+
|
|
37
|
+
paddingBetweenLabel: number;
|
|
38
|
+
dataAnalyzeResult: AnalyzedData;
|
|
39
|
+
barHeight: number;
|
|
40
|
+
barAreaWidth: number;
|
|
41
|
+
centerX: number;
|
|
42
|
+
animationTriggered: boolean;
|
|
43
|
+
|
|
44
|
+
constructor(chart: Chart) {
|
|
18
45
|
super(chart);
|
|
19
46
|
|
|
20
47
|
this.segmentSelectorForAnimation = '.salesfunnel-chart-bar';
|
|
21
48
|
this.widthThresholdMedium = 400;
|
|
22
49
|
this.widthThresholdSmall = 200;
|
|
23
|
-
// Constants for "normalized mode"
|
|
24
|
-
// Width of a bar is calculated by multiplying this value with the previous bar's width
|
|
25
50
|
this.barDeltaPercentage = 0.95;
|
|
26
|
-
// Factor to be multiplied with the last bar's width. This will create a funnel effect, because
|
|
27
|
-
// the last bar is considerably smaller than the other bars.
|
|
28
51
|
this.lastBarAdditionalPercentage = 0.7;
|
|
29
|
-
// Percentage of the total width the last bar always has (delta might get smaller due to this constraint).
|
|
30
52
|
this.lastBarMinWidthPercentage = 0.4;
|
|
31
53
|
this.suppressLegendBox = true;
|
|
32
54
|
|
|
@@ -41,7 +63,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
41
63
|
chart.config = $.extend(true, {}, defaultConfig, chart.config);
|
|
42
64
|
}
|
|
43
65
|
|
|
44
|
-
_validate() {
|
|
66
|
+
protected override _validate(): boolean {
|
|
45
67
|
let chartData = this.chart.data;
|
|
46
68
|
let chartConfig = this.chart.config;
|
|
47
69
|
if (!chartData ||
|
|
@@ -56,20 +78,19 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
56
78
|
return true;
|
|
57
79
|
}
|
|
58
80
|
|
|
59
|
-
_renderInternal() {
|
|
81
|
+
protected override _renderInternal() {
|
|
60
82
|
let chartData = this.chart.data,
|
|
61
83
|
bars = chartData.chartValueGroups.length;
|
|
62
84
|
|
|
63
|
-
|
|
64
|
-
this.dataAnalyzeResult = this._analyzeData(chartData.chartValueGroups);
|
|
85
|
+
let conversionRateWidth = this._dynamicConversionRateWidth();
|
|
65
86
|
this.paddingBetweenLabel = 20;
|
|
87
|
+
this.dataAnalyzeResult = this._analyzeData(chartData.chartValueGroups);
|
|
66
88
|
this.barHeight = this.chartBox.height / bars;
|
|
67
|
-
this.barAreaHeight = this.barHeight * bars;
|
|
68
89
|
this.barAreaWidth = this.chartBox.width -
|
|
69
90
|
this.dataAnalyzeResult.maxLengthFirstValueRow -
|
|
70
91
|
(this.paddingBetweenLabel * this.dataAnalyzeResult.labelCount) -
|
|
71
92
|
this.dataAnalyzeResult.maxLengthSecondValueRow -
|
|
72
|
-
|
|
93
|
+
conversionRateWidth;
|
|
73
94
|
this.centerX = this.barAreaWidth / 2;
|
|
74
95
|
|
|
75
96
|
if (this.chart.config.options.salesfunnel.normalized) {
|
|
@@ -81,7 +102,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
81
102
|
this._addClipping('salesfunnel-chart-bar');
|
|
82
103
|
}
|
|
83
104
|
|
|
84
|
-
_renderBarsNormalized(chartValueGroups) {
|
|
105
|
+
protected _renderBarsNormalized(chartValueGroups: ChartValueGroup[]) {
|
|
85
106
|
let barCount = chartValueGroups.length;
|
|
86
107
|
let startPointX = this.barAreaWidth +
|
|
87
108
|
this.dataAnalyzeResult.maxLengthFirstValueRow +
|
|
@@ -124,23 +145,23 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
124
145
|
}
|
|
125
146
|
|
|
126
147
|
this._renderPolygon(renderPolyOptions);
|
|
127
|
-
this._renderLabel(chartValueGroups[i].values[0], false, i);
|
|
148
|
+
this._renderLabel(chartValueGroups[i].values[0] as number, false, i);
|
|
128
149
|
this._renderBarLabel(barLabel, i, renderPolyOptions.widthBottom);
|
|
129
150
|
let labelLineWidth = this.dataAnalyzeResult.maxLengthFirstValueRow + this.paddingBetweenLabel;
|
|
130
151
|
if (chartValueGroups[i].values.length > 1) {
|
|
131
|
-
this._renderLabel(chartValueGroups[i].values[1], true, i);
|
|
152
|
+
this._renderLabel(chartValueGroups[i].values[1] as number, true, i);
|
|
132
153
|
labelLineWidth += this.dataAnalyzeResult.maxLengthSecondValueRow + this.paddingBetweenLabel;
|
|
133
154
|
}
|
|
134
155
|
if (i > 0) {
|
|
135
156
|
this._renderLabelSeparatorLine(yCoord, labelLineWidth);
|
|
136
157
|
if (this.chart.config.options.salesfunnel.calcConversionRate) {
|
|
137
|
-
this._renderConversionRate(i, startPointX, this._calcConversionRate(chartValueGroups[i - 1].values[0], chartValueGroups[i].values[0]));
|
|
158
|
+
this._renderConversionRate(i, startPointX, this._calcConversionRate(chartValueGroups[i - 1].values[0] as number, chartValueGroups[i].values[0] as number));
|
|
138
159
|
}
|
|
139
160
|
}
|
|
140
161
|
}
|
|
141
162
|
}
|
|
142
163
|
|
|
143
|
-
_renderLabel(label, secondLabel, barIndexFromTop) {
|
|
164
|
+
protected _renderLabel(label: number, secondLabel: boolean, barIndexFromTop: number) {
|
|
144
165
|
if (label === null) {
|
|
145
166
|
return;
|
|
146
167
|
}
|
|
@@ -161,12 +182,12 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
161
182
|
}
|
|
162
183
|
if (this.chart.config.options.plugins.tooltip.enabled && this.chart.data.axes.length > 0) {
|
|
163
184
|
let desc = this.chart.data.axes[barIndexFromTop][secondLabel ? 1 : 0].label,
|
|
164
|
-
textBounds = this._measureText(label, labelClass);
|
|
185
|
+
textBounds = this._measureText('' + label, labelClass);
|
|
165
186
|
this._renderWireLabels(desc, $label, x - textBounds.width / 2, y - textBounds.height);
|
|
166
187
|
}
|
|
167
188
|
}
|
|
168
189
|
|
|
169
|
-
_renderWireLabels(label, $text
|
|
190
|
+
protected _renderWireLabels(label: string, $text: JQuery<SVGElement>, x1: number, y1: number) {
|
|
170
191
|
let legendPositions = {
|
|
171
192
|
x1: x1,
|
|
172
193
|
x2: x1 - 10,
|
|
@@ -174,7 +195,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
174
195
|
y2: y1 - 10,
|
|
175
196
|
v: -1,
|
|
176
197
|
h: -1
|
|
177
|
-
};
|
|
198
|
+
} as LegendPositions;
|
|
178
199
|
// calculate opening direction
|
|
179
200
|
let labelPositionFunc = (labelWidth, labelHeight) => {
|
|
180
201
|
if (legendPositions.y2 - labelHeight < 0) {
|
|
@@ -188,15 +209,15 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
188
209
|
legendPositions.autoPosition = true;
|
|
189
210
|
legendPositions.posFunc = labelPositionFunc;
|
|
190
211
|
let
|
|
191
|
-
legend = this._renderWireLegend(label, legendPositions, 'line-chart-wire-label',
|
|
212
|
+
legend = this._renderWireLegend(label, legendPositions, 'line-chart-wire-label', true),
|
|
192
213
|
mouseIn = legend.attachFunc.bind(legend),
|
|
193
214
|
mouseOut = legend.detachFunc.bind(legend);
|
|
194
215
|
legend.detachFunc();
|
|
195
|
-
$text.mouseenter
|
|
196
|
-
.mouseleave
|
|
216
|
+
$text.on('mouseenter', mouseIn)
|
|
217
|
+
.on('mouseleave', mouseOut);
|
|
197
218
|
}
|
|
198
219
|
|
|
199
|
-
_renderBarLabel(label, barIndexFromTop, barWidth) {
|
|
220
|
+
protected _renderBarLabel(label: string, barIndexFromTop: number, barWidth: number) {
|
|
200
221
|
let y = (barIndexFromTop * this.barHeight) + (this.barHeight / 2),
|
|
201
222
|
x = this.centerX,
|
|
202
223
|
labelClass = this._dynamicCssClass('salesfunnel-bar-label');
|
|
@@ -204,7 +225,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
204
225
|
this._renderLineLabel(x, y, label, labelClass, true);
|
|
205
226
|
}
|
|
206
227
|
|
|
207
|
-
_renderConversionRate(barIndexFromTop, startPointX, conversionRate) {
|
|
228
|
+
protected _renderConversionRate(barIndexFromTop: number, startPointX: number, conversionRate: number) {
|
|
208
229
|
if (conversionRate === undefined) {
|
|
209
230
|
return;
|
|
210
231
|
}
|
|
@@ -222,13 +243,12 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
222
243
|
}
|
|
223
244
|
}
|
|
224
245
|
|
|
225
|
-
_renderPolygon(renderPolyOptions) {
|
|
246
|
+
protected _renderPolygon(renderPolyOptions: PolyOptions): JQuery<SVGElement> {
|
|
226
247
|
let that = this,
|
|
227
248
|
points = this._calcPolygonPoints(true, this.animationDuration ? 0 : 1, renderPolyOptions.xStart, renderPolyOptions.yStart, renderPolyOptions.width, renderPolyOptions.widthBottom, this.barHeight - 1);
|
|
228
249
|
|
|
229
250
|
let $poly = this.$svg.appendSVG('polygon', renderPolyOptions.cssClass, '', renderPolyOptions.id)
|
|
230
251
|
.attr('points', points)
|
|
231
|
-
.attr('opacity', renderPolyOptions.opacity)
|
|
232
252
|
.data('xStart', renderPolyOptions.xStart)
|
|
233
253
|
.data('yStart', renderPolyOptions.yStart)
|
|
234
254
|
.data('widthBar', renderPolyOptions.width)
|
|
@@ -255,7 +275,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
255
275
|
}, this._createAnimationObjectWithTabIndexRemoval(expandFunc, this.animationDuration));
|
|
256
276
|
}
|
|
257
277
|
if (this.chart.config.options.clickable) {
|
|
258
|
-
$poly.on('click', renderPolyOptions.clickObject, this.chart.
|
|
278
|
+
$poly.on('click', renderPolyOptions.clickObject, e => this.chart.handleValueClick(e.data));
|
|
259
279
|
}
|
|
260
280
|
if (renderPolyOptions.fill) {
|
|
261
281
|
$poly.attr('fill', renderPolyOptions.fill);
|
|
@@ -264,7 +284,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
264
284
|
return $poly;
|
|
265
285
|
}
|
|
266
286
|
|
|
267
|
-
_calcPolygonPoints(expand, fxPos, xStart, yStart, width, widthBottom, height) {
|
|
287
|
+
protected _calcPolygonPoints(expand: boolean, fxPos: number, xStart: number, yStart: number, width: number, widthBottom: number, height: number): string {
|
|
268
288
|
let xOffsetTop = 0,
|
|
269
289
|
xOffsetBottom = 0;
|
|
270
290
|
if (expand) {
|
|
@@ -274,28 +294,25 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
274
294
|
xOffsetTop = (width / 2) - (width / 2 * fxPos);
|
|
275
295
|
xOffsetBottom = (widthBottom / 2) - (widthBottom / 2 * fxPos);
|
|
276
296
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
x4 = xStart - xOffsetBottom,
|
|
284
|
-
y4 = y3;
|
|
285
|
-
return x1 + ',' + y1 + ' ' + x2 + ',' + y2 + ' ' + x3 + ',' + y3 + ' ' + x4 + ',' + y4 + ' ';
|
|
297
|
+
return strings.join(' ',
|
|
298
|
+
(xStart - xOffsetTop) + ',' + yStart, // x1, y1
|
|
299
|
+
(xStart + xOffsetTop) + ',' + yStart, // x2, y2
|
|
300
|
+
(xStart + xOffsetBottom) + ',' + (yStart + height), // x3, y3
|
|
301
|
+
(xStart - xOffsetBottom) + ',' + (yStart + height) // x4, y4
|
|
302
|
+
);
|
|
286
303
|
}
|
|
287
304
|
|
|
288
|
-
_renderBarsAccordingToValues(chartValueGroups) {
|
|
305
|
+
protected _renderBarsAccordingToValues(chartValueGroups: ChartValueGroup[]) {
|
|
289
306
|
let widthPerN = (this.dataAnalyzeResult.maxValue ? this.barAreaWidth * 0.8 / this.dataAnalyzeResult.maxValue : 0),
|
|
290
307
|
startPointX = this.barAreaWidth + this.dataAnalyzeResult.maxLengthFirstValueRow + this.dataAnalyzeResult.maxLengthSecondValueRow + this.paddingBetweenLabel * this.dataAnalyzeResult.labelCount + 2 * this.paddingBetweenLabel,
|
|
291
308
|
barCount = chartValueGroups.length;
|
|
292
309
|
|
|
293
310
|
for (let i = 0; i < barCount; i++) {
|
|
294
|
-
let width = chartValueGroups[i].values[0] * widthPerN + this.barAreaWidth * 0.2,
|
|
311
|
+
let width = (chartValueGroups[i].values[0] as number) * widthPerN + this.barAreaWidth * 0.2,
|
|
295
312
|
barLabel = chartValueGroups[i].groupName,
|
|
296
313
|
yCoord = i * this.barHeight;
|
|
297
314
|
|
|
298
|
-
let renderPolyOptions = {
|
|
315
|
+
let renderPolyOptions: PolyOptions = {
|
|
299
316
|
xStart: this.centerX,
|
|
300
317
|
yStart: yCoord,
|
|
301
318
|
rect: true,
|
|
@@ -314,23 +331,23 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
314
331
|
}
|
|
315
332
|
|
|
316
333
|
this._renderPolygon(renderPolyOptions);
|
|
317
|
-
this._renderLabel(chartValueGroups[i].values[0], false, i);
|
|
334
|
+
this._renderLabel(chartValueGroups[i].values[0] as number, false, i);
|
|
318
335
|
this._renderBarLabel(barLabel, i, renderPolyOptions.widthBottom);
|
|
319
336
|
let labelLineWidth = this.dataAnalyzeResult.maxLengthFirstValueRow + this.paddingBetweenLabel;
|
|
320
337
|
if (chartValueGroups[i].values.length > 1) {
|
|
321
|
-
this._renderLabel(chartValueGroups[i].values[1], true, i);
|
|
338
|
+
this._renderLabel(chartValueGroups[i].values[1] as number, true, i);
|
|
322
339
|
labelLineWidth += this.dataAnalyzeResult.maxLengthSecondValueRow + this.paddingBetweenLabel;
|
|
323
340
|
}
|
|
324
341
|
if (i > 0) {
|
|
325
342
|
this._renderLabelSeparatorLine(yCoord, labelLineWidth);
|
|
326
343
|
if (this.chart.config.options.salesfunnel.calcConversionRate) {
|
|
327
|
-
this._renderConversionRate(i, startPointX, this._calcConversionRate(chartValueGroups[i - 1].values[0], chartValueGroups[i].values[0]));
|
|
344
|
+
this._renderConversionRate(i, startPointX, this._calcConversionRate(chartValueGroups[i - 1].values[0] as number, chartValueGroups[i].values[0] as number));
|
|
328
345
|
}
|
|
329
346
|
}
|
|
330
347
|
}
|
|
331
348
|
}
|
|
332
349
|
|
|
333
|
-
_renderLabelSeparatorLine(yCoord, labelLineWidth) {
|
|
350
|
+
protected _renderLabelSeparatorLine(yCoord: number, labelLineWidth: number) {
|
|
334
351
|
let $line = this.$svg.appendSVG('line', 'label-separator')
|
|
335
352
|
.attr('x1', this.barAreaWidth + this.paddingBetweenLabel)
|
|
336
353
|
.attr('y1', yCoord)
|
|
@@ -343,15 +360,15 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
343
360
|
}
|
|
344
361
|
}
|
|
345
362
|
|
|
346
|
-
_calcConversionRate(valueBefore, value) {
|
|
363
|
+
protected _calcConversionRate(valueBefore: number, value: number): number {
|
|
347
364
|
if (objects.isNullOrUndefined(valueBefore) || objects.isNullOrUndefined(value) || valueBefore === 0) {
|
|
348
365
|
return undefined;
|
|
349
366
|
}
|
|
350
367
|
return Math.round(value / valueBefore * 100);
|
|
351
368
|
}
|
|
352
369
|
|
|
353
|
-
_analyzeData(valueGroups) {
|
|
354
|
-
let result = {
|
|
370
|
+
protected _analyzeData(valueGroups: ChartValueGroup[]): AnalyzedData {
|
|
371
|
+
let result: AnalyzedData = {
|
|
355
372
|
labelCount: 0,
|
|
356
373
|
maxValue: null,
|
|
357
374
|
maxLengthFirstValueRow: 0,
|
|
@@ -366,20 +383,20 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
366
383
|
// only first value is relevant for bar
|
|
367
384
|
if (valueGroup.values.length > 0 && valueGroup.values[0]) {
|
|
368
385
|
if (result.maxValue === null) {
|
|
369
|
-
result.maxValue = valueGroup.values[0];
|
|
386
|
+
result.maxValue = valueGroup.values[0] as number;
|
|
370
387
|
} else {
|
|
371
|
-
result.maxValue = Math.max(result.maxValue, valueGroup.values[0]);
|
|
388
|
+
result.maxValue = Math.max(result.maxValue, valueGroup.values[0] as number);
|
|
372
389
|
}
|
|
373
|
-
result.maxLengthFirstValueRow = Math.max(result.maxLengthFirstValueRow, this._measureText(this.session.locale.decimalFormat.format(valueGroup.values[0]), labelClass).width);
|
|
390
|
+
result.maxLengthFirstValueRow = Math.max(result.maxLengthFirstValueRow, this._measureText(this.session.locale.decimalFormat.format(valueGroup.values[0] as number), labelClass).width);
|
|
374
391
|
}
|
|
375
392
|
if (valueGroup.values.length > 1 && valueGroup.values[1]) {
|
|
376
|
-
result.maxLengthSecondValueRow = Math.max(result.maxLengthSecondValueRow, this._measureText(this.session.locale.decimalFormat.format(valueGroup.values[1]), labelClass).width);
|
|
393
|
+
result.maxLengthSecondValueRow = Math.max(result.maxLengthSecondValueRow, this._measureText(this.session.locale.decimalFormat.format(valueGroup.values[1] as number), labelClass).width);
|
|
377
394
|
}
|
|
378
395
|
}
|
|
379
396
|
return result;
|
|
380
397
|
}
|
|
381
398
|
|
|
382
|
-
_removeAnimated(afterRemoveFunc) {
|
|
399
|
+
protected override _removeAnimated(afterRemoveFunc: (chartAnimationStopping?: boolean) => void) {
|
|
383
400
|
if (this.animationTriggered) {
|
|
384
401
|
return;
|
|
385
402
|
}
|
|
@@ -404,7 +421,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
404
421
|
});
|
|
405
422
|
}
|
|
406
423
|
|
|
407
|
-
_dynamicCssClass(cssClass) {
|
|
424
|
+
protected _dynamicCssClass(cssClass: string): string {
|
|
408
425
|
let small = '';
|
|
409
426
|
if (this.chartBox.width <= this.widthThresholdSmall) {
|
|
410
427
|
small = 'small';
|
|
@@ -414,7 +431,7 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
414
431
|
return strings.join(' ', cssClass, small);
|
|
415
432
|
}
|
|
416
433
|
|
|
417
|
-
_dynamicConversionRateWidth() {
|
|
434
|
+
protected _dynamicConversionRateWidth(): number {
|
|
418
435
|
if (!this.chart.config.options.salesfunnel.calcConversionRate) {
|
|
419
436
|
return 0; // don't show conversion rate
|
|
420
437
|
}
|
|
@@ -427,3 +444,23 @@ export default class SalesfunnelChartRenderer extends AbstractSvgChartRenderer {
|
|
|
427
444
|
return 100;
|
|
428
445
|
}
|
|
429
446
|
}
|
|
447
|
+
|
|
448
|
+
export type AnalyzedData = {
|
|
449
|
+
labelCount: number;
|
|
450
|
+
maxValue: number;
|
|
451
|
+
maxLengthFirstValueRow: number;
|
|
452
|
+
maxLengthSecondValueRow: number;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
export type PolyOptions = {
|
|
456
|
+
id?: string;
|
|
457
|
+
xStart: number;
|
|
458
|
+
yStart: number;
|
|
459
|
+
rect: boolean;
|
|
460
|
+
width: number;
|
|
461
|
+
widthBottom: number;
|
|
462
|
+
cssClass: string;
|
|
463
|
+
fill: string;
|
|
464
|
+
label: string;
|
|
465
|
+
clickObject: ClickObject;
|
|
466
|
+
};
|