1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241 | 1×
1×
1×
1×
1710×
1×
42642×
428×
1×
21779×
4196×
1×
12002×
428×
1×
45770×
1×
39778×
1×
31×
19×
19×
1×
18×
18×
1×
99×
99×
99×
983×
983×
50×
99×
1×
25×
25×
25×
190×
190×
145×
145×
1×
184×
184×
184×
184×
184×
184×
184×
184×
184×
4×
184×
180×
1×
4×
4×
34×
4×
1×
4×
4×
3×
3×
3×
21×
21×
3×
3×
3×
3×
3×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
231×
231×
231×
231×
18×
213×
231×
230×
230×
1×
1×
1×
231×
231×
231×
1×
147×
147×
147×
147×
1×
3374×
3374×
2958×
2958×
2958×
2958×
1×
12248×
12248×
9263×
1×
230×
230×
1×
377×
377×
377×
377×
377×
377×
193×
193×
184×
184×
184×
2997×
2997×
2997×
184×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../../common/utils/helper", "../model/acc-base"], function (require, exports, ej2_base_1, helper_1, acc_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AccumulationBase = (function () {
function AccumulationBase(accumulation) {
this.accumulation = accumulation;
}
Object.defineProperty(AccumulationBase.prototype, "center", {
get: function () {
return this.pieCenter || (this.accumulation.visibleSeries[0].type === 'Pie' ?
this.accumulation.pieSeriesModule.pieBaseCenter : null);
},
set: function (value) {
this.pieCenter = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccumulationBase.prototype, "radius", {
get: function () {
return this.pieRadius !== undefined ? this.pieRadius :
this.accumulation.pieSeriesModule.pieBaseRadius;
},
set: function (value) {
this.pieRadius = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccumulationBase.prototype, "labelRadius", {
get: function () {
return this.pieLabelRadius !== undefined ? this.pieLabelRadius :
this.accumulation.pieSeriesModule.pieBaseLabelRadius;
},
set: function (value) {
this.pieLabelRadius = value;
},
enumerable: true,
configurable: true
});
AccumulationBase.prototype.isCircular = function () {
return this.accumulation.type === 'Pie';
};
AccumulationBase.prototype.isVariousRadius = function () {
return this.accumulation.pieSeriesModule.isRadiusMapped;
};
AccumulationBase.prototype.processExplode = function (event) {
if (event.target.id.indexOf('_Series_') > -1 || event.target.id.indexOf('_datalabel_') > -1) {
var pointIndex = helper_1.indexFinder(event.target.id).point;
if (isNaN(pointIndex) || (event.target.id.indexOf('_datalabel_') > -1 &&
this.accumulation.visibleSeries[0].points[pointIndex].labelPosition === 'Outside')) {
return null;
}
this.explodePoints(pointIndex, this.accumulation);
this.deExplodeAll(pointIndex, this.accumulation.enableAnimation ? 300 : 0);
}
};
AccumulationBase.prototype.invokeExplode = function () {
var series = this.accumulation.visibleSeries[0];
var duration = this.accumulation.enableAnimation ? 300 : 0;
for (var _i = 0, _a = series.points; _i < _a.length; _i++) {
var point = _a[_i];
if (point.isExplode && point.y !== 0) {
this.pointExplode(point.index, point, duration);
}
}
Iif (this.accumulation.accumulationSelectionModule && this.accumulation.selectionMode !== 'None' &&
this.accumulation.accumulationSelectionModule.selectedDataIndexes.length) {
for (var _b = 0, _c = this.accumulation.accumulationSelectionModule.selectedDataIndexes; _b < _c.length; _b++) {
var index = _c[_b];
this.explodePoints(index.point, this.accumulation, true);
this.deExplodeAll(index.point, duration);
}
}
};
AccumulationBase.prototype.deExplodeAll = function (index, animationDuration) {
var pointId = this.accumulation.element.id + '_Series_0_Point_';
var points = this.accumulation.visibleSeries[0].points;
for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
var currentPoint = points_1[_i];
if ((index !== currentPoint.index && !currentPoint.isSliced) || currentPoint.isClubbed) {
currentPoint.isExplode = false;
this.deExplodeSlice(currentPoint.index, pointId, animationDuration);
}
}
};
AccumulationBase.prototype.explodePoints = function (index, chart, explode, pointAnimation) {
if (explode === void 0) { explode = false; }
var series = chart.visibleSeries[0];
var points = series.points;
var point = acc_base_1.pointByIndex(index, points);
var explodePoints = true;
var duration = this.accumulation.enableAnimation ? 300 : 0;
Iif (ej2_base_1.isNullOrUndefined(point)) {
return null;
}
var clubPointsExploded = !explode &&
(point.isSliced || (series.clubbedPoints.length &&
points[points.length - 1].index === series.clubbedPoints[series.clubbedPoints.length - 1].index));
if (series.type === 'Pie' && (clubPointsExploded || point.isClubbed)) {
explodePoints = this.clubPointExplode(index, point, series, points, chart, duration, clubPointsExploded);
}
if (explodePoints && point.y !== 0) {
this.pointExplode(index, point, duration, explode, pointAnimation);
}
};
AccumulationBase.prototype.getSum = function (points) {
var total = 0;
points.map(function (point) {
total += point.visible ? point.y : 0;
});
return total;
};
AccumulationBase.prototype.clubPointExplode = function (index, point, series, points, chart, duration, clubPointsExploded) {
Iif (clubPointsExploded === void 0) { clubPointsExploded = false; }
if (point.isClubbed) {
chart.animateSeries = false;
points.splice(points.length - 1, 1);
series.clubbedPoints.map(function (point) {
point.visible = true;
point.isExplode = true;
});
chart.visibleSeries[0].points = points.concat(series.clubbedPoints);
this.deExplodeAll(index, duration);
series.sumOfPoints = this.getSum(chart.visibleSeries[0].points);
chart.refreshChart();
return false;
}
else Eif (clubPointsExploded || point.isSliced) {
chart.animateSeries = false;
points.splice(points.length - series.clubbedPoints.length, series.clubbedPoints.length);
var clubPoint = series.generateClubPoint();
clubPoint.index = points.length;
clubPoint.color = series.clubbedPoints[0].color;
points.push(clubPoint);
series.sumOfPoints = this.getSum(points);
this.deExplodeAll(index, duration);
clubPoint.isExplode = false;
chart.visibleSeries[0].points = points;
chart.refreshChart();
this.pointExplode(clubPoint.index, points[clubPoint.index], 0, true);
clubPoint.isExplode = false;
this.deExplodeSlice(clubPoint.index, chart.element.id + '_Series_0_Point_', duration);
Eif (point.isSliced) {
return false;
}
}
return true;
};
AccumulationBase.prototype.pointExplode = function (index, point, duration, explode, pointAnimation) {
var translate;
var pointId = this.accumulation.element.id + '_Series_0_Point_';
var chart = this.accumulation;
if (!this.isCircular()) {
translate = {
x: ((point.labelRegion && point.labelRegion.x < point.region.x) ? -chart.explodeDistance :
chart.explodeDistance), y: 0
};
}
else {
translate = helper_1.degreeToLocation(point.midAngle, chart.explodeDistance, this.center);
}
if (this.isExplode(pointId + index) || explode) {
point.isExplode = true;
this.explodeSlice(index, translate, pointId, this.center || { x: 0, y: 0 }, duration, pointAnimation);
}
else {
point.isExplode = false;
this.deExplodeSlice(index, pointId, duration);
}
};
AccumulationBase.prototype.isExplode = function (id) {
var element = helper_1.getElement(id);
var transform = element ? element.getAttribute('transform') : null;
return (element && (transform === 'translate(0, 0)' || transform === null || transform === 'translate(0)'));
};
AccumulationBase.prototype.deExplodeSlice = function (index, sliceId, animationDuration) {
var element = helper_1.getElement(sliceId + index);
var transform = element ? element.getAttribute('transform') : null;
Iif (this.accumulation.enableAnimation && element && transform &&
transform !== 'translate(0, 0)' && transform !== 'translate(0)') {
var result = transform.split('(')[1].split(')')[0].split(',');
this.performAnimation(index, sliceId, 0, 0, +result[0], +result[1] || 0, animationDuration, true);
}
else {
this.performAnimation(index, sliceId, 0, 0, 0, 0, animationDuration, true);
}
};
AccumulationBase.prototype.setTranslate = function (index, sliceId, position, transform) {
this.setElementTransform(sliceId + index, position);
if (this.accumulation.visibleSeries[0].dataLabel.visible) {
sliceId = this.accumulation.element.id + '_datalabel_Series_0_';
this.setElementTransform(sliceId + 'shape_' + index, position);
this.setElementTransform(sliceId + 'text_' + index, position + transform);
this.setElementTransform(sliceId + 'connector_' + index, position);
}
};
AccumulationBase.prototype.setElementTransform = function (id, position) {
var element = helper_1.getElement(id);
if (element) {
element.setAttribute('transform', position);
}
};
AccumulationBase.prototype.explodeSlice = function (index, translate, sliceId, center, animationDuration, pointAnimation) {
Iif (pointAnimation
&& helper_1.getElement(this.accumulation.element.id + '_Series_0_Point_' + index).getAttribute('transform')) {
this.setElementTransform(sliceId + index, "translate(" + (translate.x - center.x) + ", " + (translate.y - center.y) + ")");
}
else {
this.performAnimation(index, sliceId, 0, 0, translate.x - center.x, translate.y - center.y, animationDuration);
}
};
AccumulationBase.prototype.performAnimation = function (index, sliceId, startX, startY, endX, endY, duration, isReverse) {
var _this = this;
var chart = this.accumulation;
var values = sliceId.split('_');
var seriesIndex = parseInt(sliceId.split('_')[values.length - 3], 10);
var point = chart.visibleSeries[seriesIndex].points[index];
if (duration <= 0) {
this.setTranslate(index, sliceId, 'translate(' + (endX) + ', ' + (endY) + ')', point.transform);
return null;
}
var xValue;
var yValue;
new ej2_base_1.Animation({}).animate(ej2_base_1.createElement('div'), {
duration: duration,
progress: function (args) {
xValue = helper_1.linear(args.timeStamp, startX, endX, args.duration);
yValue = helper_1.linear(args.timeStamp, startY, endY, args.duration);
_this.setTranslate(index, sliceId, 'translate(' + (isReverse ? endX - xValue : xValue) + ', ' + (isReverse ? endY - yValue : yValue) + ')', point.transform);
},
end: function () {
_this.setTranslate(index, sliceId, 'translate(' + (isReverse ? startX : endX) + ', ' + (isReverse ? startX : endY) + ')', point.transform);
}
});
};
return AccumulationBase;
}());
exports.AccumulationBase = AccumulationBase;
});
|