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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498 | 1×
1×
1×
1×
670×
1×
742×
742×
742×
27×
1×
742×
742×
1×
742×
742×
742×
742×
742×
727×
727×
1×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
742×
34×
708×
1×
707×
742×
9×
9×
9×
9×
9×
9×
9×
742×
10412×
10412×
10412×
10412×
10412×
3240×
3240×
3240×
3240×
3240×
3240×
9×
9×
9×
9×
9×
10412×
45×
10367×
10367×
3231×
3231×
7136×
10367×
7588×
7588×
7588×
7588×
7588×
7588×
460×
460×
460×
460×
460×
742×
1×
10421×
1605×
8816×
8816×
8816×
1×
5379×
5379×
1×
3258×
1155×
2103×
1588×
3258×
1×
3718×
3718×
1×
742×
742×
742×
742×
742×
742×
616×
616×
19570×
10076×
10076×
616×
1×
742×
742×
742×
742×
742×
742×
674×
674×
10114×
10114×
10114×
10114×
674×
1×
20190×
20190×
20190×
20190×
20190×
1×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
1292×
58×
58×
58×
58×
58×
1234×
1234×
1292×
1292×
1292×
1292×
11×
11×
1292×
1286×
782×
782×
782×
782×
782×
782×
782×
782×
782×
782×
1×
1×
782×
81×
58×
58×
58×
58×
58×
58×
58×
8×
50×
48×
2×
58×
58×
58×
58×
7×
58×
9×
9×
9×
1×
58×
12×
46×
46×
26×
20×
12×
81×
782×
782×
47×
12×
6×
4×
2×
6×
35×
735×
504×
436×
1×
41×
1×
1177×
1×
742×
742×
742×
742×
742×
742×
742×
742×
742×
1250×
1250×
1250×
7×
1243×
1250×
1250×
9×
1241×
1250×
9×
1241×
1250×
1250×
16×
58×
58×
58×
58×
58×
42×
42×
16×
58×
1234×
1234×
742×
1×
1250×
1250×
1×
1250×
1250×
1×
742×
742×
1250×
1×
653×
653×
1×
1×
| define(["require", "exports", "../utils/helper-common", "../utils/helper-axis-renderer", "../model/theme", "@syncfusion/ej2-base"], function (require, exports, helper_common_1, helper_axis_renderer_1, theme_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AxisRenderer = (function () {
function AxisRenderer(gauge) {
this.gauge = gauge;
}
AxisRenderer.prototype.drawAxisOuterLine = function (axis, index, element, gauge) {
var background = axis.background;
this.setRangeColor(axis);
if (background !== null) {
helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_AxisOuterLine_' + index, background, 0, 'transparent', null, '0', helper_common_1.getPathArc(gauge.midPoint, 0, 360, (Math.min(axis.rect.width, axis.rect.height) / 2)), '', 'pointer-events:none;'), element, gauge);
}
};
AxisRenderer.prototype.checkAngles = function (axis) {
axis.startAngle = axis.startAngle >= 360 ? 360 : axis.startAngle <= -360 ? -360 : axis.startAngle;
axis.endAngle = axis.endAngle >= 360 ? 360 : axis.endAngle <= -360 ? -360 : axis.endAngle;
};
AxisRenderer.prototype.drawAxisLine = function (axis, index, element, gauge) {
var startAngle = axis.startAngle;
var endAngle = axis.endAngle;
var color = axis.lineStyle.color || this.gauge.themeStyle.lineColor;
var pointerEvent = gauge.enableRangeDrag ? 'none' : 'auto';
if (axis.lineStyle.width > 0 && this.gauge.allowComponentRender) {
startAngle = !helper_common_1.isCompleteAngle(startAngle, endAngle) ? startAngle : [0, endAngle = 360][0];
helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_AxisLine_' + index, 'transparent', axis.lineStyle.width, color, null, axis.lineStyle.dashArray, helper_common_1.getPathArc(gauge.midPoint, startAngle - 90, endAngle - 90, axis.currentRadius), '', gauge.allowLoadingAnimation ? "visibility: hidden; pointer-events:" + pointerEvent + ";" : "pointer-events:" + pointerEvent + ";"), element, gauge);
}
};
AxisRenderer.prototype.drawAxisLabels = function (axis, index, element, gauge) {
var labelElement = gauge.renderer.createGroup({
id: gauge.element.id + '_Axis_Labels_' + index, style: gauge.allowLoadingAnimation ? 'visibility: hidden;' : 'pointer-events:auto;'
});
var min = axis.visibleRange.min;
var max = axis.visibleRange.max;
var labelCollection = axis.visibleLabels;
var location;
var textWidth;
var textHeight;
var labelsVisible = true;
var currentTextWidth;
var currentTextHeight;
var previousLocation;
var currentLocation;
var lastLabelLocation;
var lastLabelAngle;
var lastLabelAnchor;
var lastTextWidth;
var lastTextHeight;
var style = axis.labelStyle;
var anchor;
var angle;
var label;
var radius = axis.currentRadius;
var checkLabelOpposed = 0;
checkLabelOpposed = (style.position === 'Inside' && axis.majorTicks.position === 'Outside' &&
axis.minorTicks.position === 'Outside') || (style.position === 'Outside' &&
axis.minorTicks.position === 'Inside' && axis.majorTicks.position === 'Inside') ?
axis.lineStyle.width + axis.currentRadius / 20 :
(style.position === axis.majorTicks.position ? axis.currentRadius / 20 : axis.currentRadius / 40);
var labelPadding = axis.labelStyle.shouldMaintainPadding ? 10 : checkLabelOpposed;
var color = style.font.color || this.gauge.themeStyle.labelColor;
if (style.position === 'Outside') {
radius += (axis.nearSize - (axis.maxLabelSize.height + axis.lineStyle.width / 2)) + (labelPadding / 2);
}
else if (style.position === 'Cross') {
radius = radius - (axis.maxLabelSize.height / 4) - axis.labelStyle.offset;
}
else {
radius -= (axis.farSize - (axis.maxLabelSize.height + axis.lineStyle.width / 2) + (style.autoAngle ? labelPadding : 0));
}
if (axis.hideIntersectingLabel) {
lastLabelAngle = Math.round(helper_common_1.getAngleFromValue(labelCollection[labelCollection.length - 1].value, max, min, axis.startAngle, axis.endAngle, axis.direction === 'ClockWise'));
lastLabelLocation = helper_common_1.getLocationFromAngle(lastLabelAngle, radius, gauge.midPoint);
lastLabelAnchor = this.findAnchor(lastLabelLocation, style, lastLabelAngle, labelCollection[labelCollection.length - 1]);
lastTextWidth = (!axis.showLastLabel && (helper_common_1.isCompleteAngle(axis.startAngle, axis.endAngle)) && (style.hiddenLabel !== 'First')) ?
labelCollection[0].size.width : labelCollection[labelCollection.length - 1].size.width;
lastTextHeight = (!axis.showLastLabel && (helper_common_1.isCompleteAngle(axis.startAngle, axis.endAngle)) && (style.hiddenLabel !== 'First')) ?
(!style.autoAngle ? labelCollection[0].size.height : labelCollection[0].size.width) :
(!style.autoAngle ? labelCollection[labelCollection.length - 1].size.height :
labelCollection[labelCollection.length - 1].size.width);
lastTextHeight = lastTextHeight - this.offsetAxisLabelsize(lastLabelAngle, lastTextHeight);
lastLabelLocation = this.getAxisLabelStartPosition(lastLabelLocation, lastTextWidth, lastLabelAnchor);
}
for (var i = 0, length_1 = labelCollection.length; i < length_1; i++) {
label = labelCollection[i];
angle = Math.round(helper_common_1.getAngleFromValue(label.value, max, min, axis.startAngle, axis.endAngle, axis.direction === 'ClockWise'));
location = helper_common_1.getLocationFromAngle(angle, radius, gauge.midPoint);
anchor = this.findAnchor(location, style, angle, label);
if (axis.hideIntersectingLabel) {
currentLocation = helper_common_1.getLocationFromAngle(angle, radius, gauge.midPoint);
currentTextWidth = label.size.width;
currentTextHeight = !style.autoAngle ? label.size.height : currentTextWidth;
currentTextHeight = currentTextHeight - this.offsetAxisLabelsize(angle, currentTextHeight);
currentLocation = this.getAxisLabelStartPosition(currentLocation, currentTextWidth, anchor);
if (i === 0) {
previousLocation = helper_common_1.getLocationFromAngle(angle, radius, gauge.midPoint);
textWidth = label.size.width;
textHeight = !style.autoAngle ? label.size.height : textWidth;
textHeight = textHeight - this.offsetAxisLabelsize(angle, textHeight);
previousLocation = this.getAxisLabelStartPosition(previousLocation, textWidth, anchor);
}
}
if ((i === 0 && style.hiddenLabel === 'First') || (i === (length_1 - 1) && style.hiddenLabel === 'Last')) {
continue;
}
var textFont = {
size: style.font.size || this.gauge.themeStyle.fontSize,
color: style.font.color,
fontFamily: style.font.fontFamily || this.gauge.themeStyle.labelFontFamily,
fontWeight: style.font.fontWeight || this.gauge.themeStyle.fontWeight,
fontStyle: style.font.fontStyle,
opacity: style.font.opacity
};
if (axis.hideIntersectingLabel && (i !== 0)) {
var lastlabel = ((i !== (labelCollection.length - 1)) && ((helper_common_1.isCompleteAngle(axis.startAngle, axis.endAngle) ||
axis.showLastLabel))) ? this.FindAxisLabelCollision(lastLabelLocation, lastTextWidth, lastTextHeight, currentLocation, currentTextWidth, currentTextHeight) : true;
labelsVisible = (this.FindAxisLabelCollision(previousLocation, textWidth, textHeight, currentLocation, currentTextWidth, currentTextHeight) && lastlabel);
}
else {
labelsVisible = true;
}
if (labelsVisible || (i === labelCollection.length - 1)) {
label.text = (!axis.showLastLabel && ((helper_common_1.isCompleteAngle(axis.startAngle, axis.endAngle) && style.hiddenLabel !== 'First') ||
!labelsVisible)
&& axis.hideIntersectingLabel && (i === (length_1 - 1))) ? '' : label.text;
label.text = (axis.showLastLabel && axis.hideIntersectingLabel && helper_common_1.isCompleteAngle(axis.startAngle, axis.endAngle)
&& (i === 0)) ? '' : label.text;
var labelTextElement = helper_common_1.textElement(new helper_common_1.TextOption(gauge.element.id + '_Axis_' + index + '_Label_' + i, location.x, location.y, anchor, label.text, style.autoAngle ? 'rotate(' + (angle + 90) + ',' + (location.x) + ',' + location.y + ')' : '', 'auto'), textFont, style.useRangeColor ? helper_axis_renderer_1.getRangeColor(label.value, axis.ranges, color) : color, labelElement, 'pointer-events:auto;');
labelTextElement.setAttribute('aria-label', label.text);
labelTextElement.setAttribute('role', 'region');
if (axis.hideIntersectingLabel) {
textWidth = label.size.width;
textHeight = !style.autoAngle ? label.size.height : textWidth;
textHeight = textHeight - this.offsetAxisLabelsize(angle, textHeight);
previousLocation.x = currentLocation.x;
previousLocation.y = currentLocation.y;
}
}
}
element.appendChild(labelElement);
};
AxisRenderer.prototype.findAnchor = function (location, style, angle, label) {
if (style.autoAngle) {
return 'middle';
}
var anchor = style.position === 'Inside' ?
((angle > 120 && angle < 240) ? 'start' : ((300 < angle || angle < 60) ? 'end' : 'middle')) :
((angle > 120 && angle < 240) ? 'end' : ((300 < angle || angle < 60) ? 'start' : 'middle'));
location.y += style.position === 'Inside' ?
((angle >= 240 && angle <= 300) ? (label.size.height / 2) :
(angle >= 60 && angle <= 120) ? 0 : label.size.height / 4) :
((angle >= 240 && angle <= 300) ? 0 :
(angle >= 60 && angle <= 120) ? label.size.height / 2 : label.size.height / 4);
return anchor;
};
AxisRenderer.prototype.FindAxisLabelCollision = function (previousLocation, previousWidth, previousHeight, currentLocation, currentWidth, currentHeight) {
var labelVisisble = ((previousLocation.x > (currentLocation.x + (currentWidth))) ||
((previousLocation.x + (previousWidth)) < (currentLocation.x)) ||
((previousLocation.y + (previousHeight)) < (currentLocation.y)) ||
((previousLocation.y) > (currentLocation.y + (currentHeight))));
return labelVisisble;
};
AxisRenderer.prototype.getAxisLabelStartPosition = function (actualLocation, textWidth, anchorPosition) {
if (anchorPosition === 'end') {
actualLocation.x = actualLocation.x - textWidth;
}
else if (anchorPosition === 'middle') {
actualLocation.x = actualLocation.x - (textWidth / 2);
}
return actualLocation;
};
AxisRenderer.prototype.offsetAxisLabelsize = function (angle, size) {
var finalSize = ((angle >= 20 && angle <= 60) || (angle >= 120 && angle <= 160) || (angle >= 200 && angle <= 240) ||
(angle >= 300 && angle <= 340)) ? size / 5 : 0;
return finalSize;
};
AxisRenderer.prototype.drawMinorTickLines = function (axis, index, element, gauge) {
var minorTickElements = gauge.renderer.createGroup({
id: gauge.element.id + '_Axis_MinorTickLines_' + index
});
var minorLineStyle = axis.minorTicks;
var minorInterval = minorLineStyle.interval !== null ?
minorLineStyle.interval : (axis.visibleRange.interval / 2);
var isRangeColor = minorLineStyle.useRangeColor;
var color = minorLineStyle.color || this.gauge.themeStyle.minorTickColor;
if (minorLineStyle.width && minorLineStyle.height && minorInterval) {
var j = 0;
for (var i = axis.visibleRange.min, max = axis.visibleRange.max; i <= max; i += minorInterval) {
if (this.majorValues.indexOf(+i.toFixed(3)) < 0) {
var tickElement = helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_Axis_Minor_TickLine_' + index + '_' + j++, 'transparent', minorLineStyle.width, isRangeColor ? helper_axis_renderer_1.getRangeColor(i, axis.ranges, color) : color, null, minorLineStyle.dashArray, this.calculateTicks(i, minorLineStyle, axis), '', gauge.allowLoadingAnimation ? 'visibility: hidden;pointer-events: auto;' : 'pointer-events:auto;'), minorTickElements, gauge);
tickElement.setAttribute('data-interval', i.toString());
}
}
element.appendChild(minorTickElements);
}
};
AxisRenderer.prototype.drawMajorTickLines = function (axis, index, element, gauge) {
var majorTickElements = gauge.renderer.createGroup({
id: gauge.element.id + '_Axis_MajorTickLines_' + index
});
var majorLineStyle = axis.majorTicks;
var isRangeColor = majorLineStyle.useRangeColor;
this.majorValues = [];
var color = majorLineStyle.color || this.gauge.themeStyle.majorTickColor;
if (majorLineStyle.width && majorLineStyle.height && axis.visibleRange.interval) {
var j = 0;
for (var i = axis.visibleRange.min, max = axis.visibleRange.max, interval = axis.visibleRange.interval; i <= max; i += interval) {
this.majorValues.push(+i.toFixed(3));
var tickElement = helper_common_1.appendPath(new helper_common_1.PathOption(gauge.element.id + '_Axis_Major_TickLine_' + index + '_' + j, 'transparent', majorLineStyle.width, isRangeColor ? helper_axis_renderer_1.getRangeColor(i, axis.ranges, color) : color, null, majorLineStyle.dashArray, this.calculateTicks(i, majorLineStyle, axis), '', gauge.allowLoadingAnimation ? 'visibility: hidden;pointer-events:auto;' : 'pointer-events:auto;'), majorTickElements, gauge);
tickElement.setAttribute('data-interval', i.toString());
j++;
}
element.appendChild(majorTickElements);
}
};
AxisRenderer.prototype.calculateTicks = function (value, options, axis) {
var axisLineWidth = (axis.lineStyle.width / 2) + options.offset;
var angle = helper_common_1.getAngleFromValue(value, axis.visibleRange.max, axis.visibleRange.min, axis.startAngle, axis.endAngle, axis.direction === 'ClockWise');
var start = helper_common_1.getLocationFromAngle(angle, axis.currentRadius +
(options.position === 'Outside' ? axisLineWidth : options.position === 'Cross' ?
options.height / 2 - options.offset : -axisLineWidth), this.gauge.midPoint);
var end = helper_common_1.getLocationFromAngle(angle, axis.currentRadius +
(options.position === 'Outside' ? axisLineWidth : options.position === 'Cross' ?
options.height / 2 - options.offset : -axisLineWidth) +
(options.position === 'Outside' ? options.height : -options.height), this.gauge.midPoint);
return 'M ' + start.x + ' ' + start.y + ' L ' + end.x + ' ' + end.y + ' ';
};
AxisRenderer.prototype.drawRangePath = function (axis, range, startWidth, endWidth, rangeIndex, index, rangeElement, colorIndex) {
var startValue;
var direction;
var endValue;
var location = this.gauge.midPoint;
var startAngle;
var endAngle;
var isClockWise = axis.direction === 'ClockWise';
var min = axis.visibleRange.min;
var max = axis.visibleRange.max;
var roundedStartAngle;
var roundedEndAngle;
var oldStart;
var oldEnd;
var gradientRangeColor;
if (range.isLinearCircularGradient) {
var rangeSplitValue = ((range.end - range.start) / range.linearGradient.colorStop.length);
var rangeStart = range.linearGradient.colorStop.length > 1 ?
(range.start + (rangeSplitValue * (colorIndex))) : range.start;
var rangeEnd = range.linearGradient.colorStop.length > 1 ? (rangeStart + rangeSplitValue) : range.end;
startValue = Math.min(Math.max(rangeStart, min), rangeEnd);
endValue = Math.min(Math.max(rangeStart, rangeEnd), max);
}
else {
startValue = Math.min(Math.max(range.start, min), range.end);
endValue = Math.min(Math.max(range.start, range.end), max);
}
startAngle = helper_common_1.getAngleFromValue(startValue, max, min, axis.startAngle, axis.endAngle, isClockWise);
endAngle = helper_common_1.getAngleFromValue(endValue, max, min, axis.startAngle, axis.endAngle, isClockWise);
var isAngleCross360 = (startAngle > endAngle);
if (axis.rangeGap != null && axis.rangeGap > 0 && range.start !== range.end
|| (!ej2_base_1.isNullOrUndefined(range.linearGradient) && !range.isLinearCircularGradient
&& (colorIndex === (!ej2_base_1.isNullOrUndefined(range.linearGradient.colorStop) && range.linearGradient.colorStop.length - 1)))) {
startAngle = (rangeIndex === 0 && !axis.startAndEndRangeGap) ? startAngle :
colorIndex === 0 && range.isLinearCircularGradient ? axis.direction === 'AntiClockWise' ?
startAngle - (axis.rangeGap / Math.PI) :
startAngle + (axis.rangeGap / Math.PI) : !range.isLinearCircularGradient
? (axis.direction === 'AntiClockWise' ? startAngle - (axis.rangeGap / Math.PI) : startAngle + (axis.rangeGap / Math.PI)) : startAngle;
endAngle = (rangeIndex === axis.ranges.length - 1 && !axis.startAndEndRangeGap) ? endAngle :
!ej2_base_1.isNullOrUndefined(range.linearGradient) && colorIndex === range.linearGradient.colorStop.length - 1
&& range.isLinearCircularGradient ?
axis.direction === 'AntiClockWise' ? endAngle + (axis.rangeGap / Math.PI) :
endAngle - (axis.rangeGap / Math.PI) : !range.isLinearCircularGradient ?
(axis.direction === 'AntiClockWise' ? endAngle + (axis.rangeGap / Math.PI) : endAngle - (axis.rangeGap / Math.PI)) : endAngle;
}
if (this.gauge.allowComponentRender) {
if ((startValue !== endValue) && (isAngleCross360 ? startAngle < (endAngle + 360) : (startAngle < endAngle)) && ((range.start >= min && range.end <= max) || (range.end >= min && range.start <= max))) {
endAngle = isClockWise ? endAngle : [startAngle, startAngle = endAngle][0];
endWidth = isClockWise ? endWidth : [startWidth, startWidth = endWidth][0];
var radius = typeof range.roundedCornerRadius === 'string' ? parseFloat(range.roundedCornerRadius) : range.roundedCornerRadius;
var process = (radius * 0.25);
var degreeValue = helper_common_1.getDegree(startAngle, endAngle);
oldStart = ((((range.currentRadius - (startWidth / 2)) * ((startAngle * Math.PI) / 180) -
(radius / process)) / (range.currentRadius - (startWidth / 2))) * 180) / Math.PI;
oldEnd = ((((range.currentRadius - (endWidth / 2)) * ((endAngle * Math.PI) / 180) +
(radius / process)) / (range.currentRadius - (endWidth / 2))) * 180) / Math.PI;
roundedStartAngle = ((((range.currentRadius) * ((startAngle * Math.PI) / 180) +
(degreeValue < (range.roundedCornerRadius / 2) && range.isLinearCircularGradient
? degreeValue <= 1 ? 0 : (radius / 4) : radius)) / (range.currentRadius)) * 180) / Math.PI;
roundedEndAngle = ((((range.currentRadius) * ((endAngle * Math.PI) / 180) -
(degreeValue < (range.roundedCornerRadius / 2) && range.isLinearCircularGradient
? degreeValue <= 1 ? 0 : (radius / 4) : radius)) / (range.currentRadius)) * 180) / Math.PI;
if (roundedStartAngle > roundedEndAngle && (roundedStartAngle - roundedEndAngle) <= radius) {
roundedStartAngle = startAngle;
roundedEndAngle = endAngle;
}
if (this.gauge.gradientModule && ((!ej2_base_1.isNullOrUndefined(range.linearGradient)
&& !ej2_base_1.isNullOrUndefined(range.linearGradient.colorStop)) || (!ej2_base_1.isNullOrUndefined(range.radialGradient)
&& !ej2_base_1.isNullOrUndefined(range.radialGradient.colorStop)))) {
if (range.isLinearCircularGradient) {
endAngle -= helper_common_1.isCompleteAngle(startAngle, endAngle) ? 0.0001 : 0;
var degree = helper_common_1.getDegree(startAngle, endAngle);
var rangeColorLength = range.linearGradient.colorStop.length;
var degreeRange = ((axis.startAngle === axis.endAngle ?
(axis.startAngle === 0 && axis.endAngle === 0 ? 360 : axis.startAngle) :
(axis.endAngle - axis.startAngle)) - degree * (rangeColorLength - 1));
var degreeRangeValue = void 0;
Iif (degreeRange <= 360 && degreeRange >= 270) {
degreeRangeValue = 270;
}
else if (degreeRange <= 270 && degreeRange >= 180) {
degreeRangeValue = 180;
}
else if (degreeRange <= 180 && degreeRange >= 90) {
degreeRangeValue = 90;
}
else Iif (degreeRange <= 90 && degreeRange >= 0) {
degreeRangeValue = 0;
}
var gradientDegree = axis.direction === 'AntiClockWise' ?
(axis.startAngle === axis.endAngle ? 0 : axis.startAngle) + degree * ((rangeColorLength - 1) - colorIndex)
: axis.startAngle + degree * (colorIndex);
var gradientAngle = axis.startAngle < axis.endAngle ? axis.direction === 'AntiClockWise'
? axis.ranges.length > 1 ? rangeIndex === 0 ? (360 - (axis.startAngle
+ (degree * (colorIndex)))) : (axis.startAngle + (degree * (colorIndex + 1))) :
axis.startAngle + (degreeRangeValue + degree * ((rangeColorLength - 1) - colorIndex)) : axis.startAngle
+ (degree * (colorIndex)) : axis.endAngle === 360 || axis.startAngle === axis.endAngle
? axis.direction === 'AntiClockWise' ? axis.startAngle === axis.endAngle ?
(axis.startAngle === 0 && axis.endAngle === 0 ? 0 : 360) - axis.startAngle +
degreeRangeValue + (degree * ((rangeColorLength - 1) - colorIndex))
: degree * ((rangeColorLength - 1) - colorIndex) : degree * (colorIndex) :
gradientDegree < 360 ? gradientDegree : gradientDegree - 360;
range.gradientAngle = rangeIndex === 0 ? axis.rangeGap ? gradientAngle + axis.rangeGap
: gradientAngle : axis.rangeGap > 0 ? axis.ranges[rangeIndex - 1]['gradientAngle'] + axis.rangeGap
: axis.ranges[rangeIndex - 1]['gradientAngle'];
if (axis.direction === 'AntiClockWise' && (axis.ranges.length > 1
? colorIndex === rangeColorLength - 1 : colorIndex === 0)) {
range.gradientAntiAngle = gradientAngle;
}
if (rangeIndex !== 0) {
gradientAngle = axis.direction === 'AntiClockWise' ? axis.ranges.length > 1 ?
axis.ranges[rangeIndex - 1]['gradientAntiAngle'] - gradientAngle + axis.startAngle :
axis.ranges[rangeIndex - 1]['gradientAntiAngle'] + gradientAngle :
range.gradientAngle + gradientAngle - axis.startAngle;
range.gradientAngle = axis.rangeGap != null && axis.rangeGap > 0 ? colorIndex === rangeColorLength - 1 ?
gradientAngle + axis.ranges[rangeIndex - 1]['gradientAngle'] : gradientAngle : gradientAngle;
if (axis.direction === 'AntiClockWise' && (axis.ranges.length > 1
? colorIndex === rangeColorLength - 1 : colorIndex === 0)) {
range.gradientAntiAngle = gradientAngle;
}
}
if (gradientAngle > 45 && gradientAngle <= 115
|| (gradientAngle >= 0 && gradientAngle <= 45 && (rangeColorLength - 1) <= 2)) {
direction = axis.direction === 'AntiClockWise' ? 'bottom' : 'top';
}
else Iif (gradientAngle > 115 && gradientAngle < 170) {
direction = axis.direction === 'AntiClockWise' ? 'left' : 'right';
}
else if (gradientAngle >= 170 && gradientAngle <= 280) {
direction = axis.direction === 'AntiClockWise' ? 'top' : 'bottom';
}
else if (gradientAngle > 280 && gradientAngle <= 360
|| (gradientAngle >= 0 && gradientAngle <= 45 && (rangeColorLength - 1) >= 2)) {
direction = axis.direction === 'AntiClockWise' ? 'right' : 'left';
}
}
gradientRangeColor = this.gauge.gradientModule.getGradientColorString(range, colorIndex, direction, rangeIndex);
}
range.rangeColor = gradientRangeColor ? gradientRangeColor : range.rangeColor;
if (range.roundedCornerRadius) {
if (range.isLinearCircularGradient && range.linearGradient.colorStop.length > 1) {
if (colorIndex === 0 || colorIndex === range.linearGradient.colorStop.length - 1) {
if (axis.direction === 'ClockWise') {
this.roundedRangeAppendPathCalculation(range, rangeIndex, index, startWidth, endWidth, rangeElement, (colorIndex === range.linearGradient.colorStop.length - 1
? Math.floor(startAngle) : Math.floor(roundedStartAngle)), (colorIndex !== 0 ? Math.ceil(roundedEndAngle) : Math.ceil(endAngle)), ((colorIndex === range.linearGradient.colorStop.length - 1) ? startAngle : oldStart), (colorIndex !== 0 ? oldEnd : endAngle), location, colorIndex);
}
else {
this.roundedRangeAppendPathCalculation(range, rangeIndex, index, startWidth, endWidth, rangeElement, (colorIndex === 0 ? Math.floor(startAngle) : Math.floor(roundedStartAngle)), (colorIndex === range.linearGradient.colorStop.length - 1
? Math.ceil(endAngle) : Math.ceil(roundedEndAngle)), ((colorIndex === 0) ? startAngle : oldStart), (colorIndex === range.linearGradient.colorStop.length - 1 ? endAngle : oldEnd), location, colorIndex);
}
}
else {
this.rangeAppendPathCalculation(range, rangeIndex, index, startWidth, endWidth, rangeElement, Math.floor(startAngle), Math.ceil(endAngle), colorIndex);
}
}
else {
this.roundedRangeAppendPathCalculation(range, rangeIndex, index, startWidth, endWidth, rangeElement, Math.floor(roundedStartAngle), Math.ceil(roundedEndAngle), oldStart, oldEnd, location, colorIndex);
}
}
else {
this.rangeAppendPathCalculation(range, rangeIndex, index, startWidth, endWidth, rangeElement, Math.floor(startAngle), Math.ceil(endAngle), colorIndex);
}
}
else if ((range.start === range.end) && ((range.start >= min && range.end <= max) || (range.end >= min && range.start <= max))) {
this.rangeAppendPathCalculation(range, rangeIndex, index, startWidth, endWidth, rangeElement, Math.floor(startAngle), Math.ceil(endAngle), colorIndex);
}
}
};
AxisRenderer.prototype.roundedRangeAppendPathCalculation = function (range, rangeIndex, index, startWidth, endWidth, rangeElement, roundedStartAngle, roundedEndAngle, oldStart, oldEnd, location, colorIndex) {
range.pathElement.push(helper_common_1.appendPath(new helper_common_1.PathOption((!range.isLinearCircularGradient ? this.gauge.element.id + '_Axis_' + index + '_Range_' + rangeIndex
: this.gauge.element.id + '_Axis_' + index + '_Range_' + rangeIndex + '_Circular_' + colorIndex), range.rangeColor, 0, range.rangeColor, range.opacity, '0', helper_common_1.getRoundedPathArc(location, Math.floor(roundedStartAngle), Math.ceil(roundedEndAngle), oldStart, oldEnd, range.currentRadius, startWidth, endWidth, range, this.gauge.axes[index]), '', ''), rangeElement, this.gauge));
};
AxisRenderer.prototype.rangeAppendPathCalculation = function (range, rangeIndex, index, startWidth, endWidth, rangeElement, startAngle, endAngle, colorIndex) {
range.pathElement.push(helper_common_1.appendPath(new helper_common_1.PathOption(!range.isLinearCircularGradient ? this.gauge.element.id + '_Axis_' + index + '_Range_' +
rangeIndex : this.gauge.element.id + '_Axis_' + index + '_Range_' +
rangeIndex + '_Circular_' + colorIndex, range.rangeColor, 0, range.rangeColor, range.opacity, '0', helper_common_1.getPathArc(this.gauge.midPoint, Math.floor(startAngle), Math.ceil(endAngle), range.currentRadius, startWidth, endWidth, range, this.gauge.axes[index]), '', ''), rangeElement, this.gauge));
};
AxisRenderer.prototype.drawAxisRange = function (axis, index, element) {
var _this = this;
var ele = (document.getElementById(this.gauge.element.id + '_Axis_Ranges_ ' + index));
var rangeElement = (ele) ? document.getElementById(this.gauge.element.id + '_Axis_Ranges_ ' + index) :
this.gauge.renderer.createGroup({ id: this.gauge.element.id + '_Axis_Ranges_' + index,
style: this.gauge.allowLoadingAnimation ? 'opacity: 0;' : '' });
var startWidth;
var startEndDifference;
var endWidth;
var previousEndWidth;
var previousStartWidth;
axis.ranges.map(function (range, rangeIndex) {
range.isLinearCircularGradient = !ej2_base_1.isNullOrUndefined(_this.gauge.gradientModule)
&& !ej2_base_1.isNullOrUndefined(range.linearGradient) && ej2_base_1.isNullOrUndefined(range.linearGradient.startValue)
&& ej2_base_1.isNullOrUndefined(range.linearGradient.endValue) && !ej2_base_1.isNullOrUndefined(range.linearGradient.colorStop);
range.pathElement = [];
if (!ej2_base_1.isNullOrUndefined(range.offset) && range.offset.length > 0) {
range.currentDistanceFromScale = helper_common_1.stringToNumber(range.offset, axis.currentRadius);
}
else {
range.currentDistanceFromScale = range.offset;
}
_this.calculateRangeRadius(axis, range);
if (!ej2_base_1.isNullOrUndefined(range.startWidth) && range.startWidth.length > 0) {
startWidth = helper_common_1.toPixel(range.startWidth, range.currentRadius);
}
else {
startWidth = range.startWidth;
}
if (!ej2_base_1.isNullOrUndefined(range.endWidth) && range.endWidth.length > 0) {
endWidth = helper_common_1.toPixel(range.endWidth, range.currentRadius);
}
else {
endWidth = range.endWidth;
}
range.currentRadius = _this.calculateRangeRadiusWithPosition(axis, range, startWidth);
if (range.isLinearCircularGradient) {
for (var i = 0; i < range.linearGradient.colorStop.length; i++) {
Eif (i <= (range.linearGradient.colorStop.length - 1)) {
previousEndWidth = i === 0 ? endWidth : previousEndWidth;
previousStartWidth = i === 0 ? startWidth : previousStartWidth;
startEndDifference = (Math.abs(previousStartWidth - previousEndWidth) / (range.linearGradient.colorStop.length));
if (i > 0) {
startWidth = endWidth;
endWidth = previousStartWidth > previousEndWidth ? startWidth - startEndDifference
: startWidth + startEndDifference;
}
else {
endWidth = previousStartWidth > previousEndWidth ? startWidth - startEndDifference
: startWidth + startEndDifference;
}
}
else {
startWidth = previousStartWidth > previousEndWidth ? startWidth - startEndDifference
: startWidth + startEndDifference;
endWidth = (previousEndWidth);
}
_this.drawRangePath(axis, range, startWidth, endWidth, rangeIndex, index, rangeElement, i);
}
}
else {
Eif (!(range.start === range.end && axis.direction === 'AntiClockWise' && axis.startAngle === axis.endAngle)) {
_this.drawRangePath(axis, range, startWidth, endWidth, rangeIndex, index, rangeElement, null);
}
}
});
element.appendChild(rangeElement);
};
AxisRenderer.prototype.calculateRangeRadius = function (axis, range) {
var radius = range.radius !== null ? range.radius : '100%';
range.currentRadius = helper_common_1.stringToNumber(radius, axis.currentRadius);
};
AxisRenderer.prototype.calculateRangeRadiusWithPosition = function (axis, range, startWidth) {
var actualRadius = !ej2_base_1.isNullOrUndefined(range.position) && range.position !== 'Auto' && ej2_base_1.isNullOrUndefined(range.radius) ?
(range.position === 'Outside' ? (range.currentRadius + axis.lineStyle.width / 2 + range.currentDistanceFromScale) :
range.position === 'Inside' ? (range.currentRadius - axis.lineStyle.width / 2 - range.currentDistanceFromScale) :
(range.currentRadius + startWidth / 2 - range.currentDistanceFromScale)) : range.currentRadius;
return actualRadius;
};
AxisRenderer.prototype.setRangeColor = function (axis) {
var rangeColors = theme_1.getRangePalette(this.gauge.theme);
axis.ranges.map(function (range, index) {
range.rangeColor = range.color ? range.color : rangeColors[index % rangeColors.length];
});
};
AxisRenderer.prototype.destroy = function () {
this.gauge = null;
this.majorValues = [];
};
return AxisRenderer;
}());
exports.AxisRenderer = AxisRenderer;
});
|