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 | 1×
1×
1×
1×
2174×
2174×
1×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
2168×
37227×
37227×
37227×
37227×
37227×
34441×
34441×
34441×
2168×
1×
29747×
29747×
27721×
27721×
27721×
29747×
1×
3603×
3603×
3603×
3603×
3603×
1×
2760×
1119×
1×
214×
214×
214×
214×
214×
214×
214×
8535×
8400×
8400×
8400×
214×
214×
1×
41954×
41954×
41954×
41954×
1×
40×
40×
40×
40×
40×
40×
40×
40×
40×
2659×
2627×
2627×
472×
472×
2155×
2155×
40×
40×
1×
1×
| define(["require", "exports", "../../common/utils/helper", "@syncfusion/ej2-base"], function (require, exports, helper_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LineBase = (function () {
function LineBase(chartModule) {
this.chart = chartModule;
this.padding = 5;
}
LineBase.prototype.improveChartPerformance = function (series) {
var tempPoints = [];
var xVisibleRange = series.xAxis.visibleRange;
var yVisibleRange = series.yAxis.visibleRange;
var seriesPoints = series.points;
var areaBounds = series.clipRect;
var xTolerance = Math.abs(xVisibleRange.delta / areaBounds.width);
var yTolerance = Math.abs(yVisibleRange.delta / areaBounds.height);
var prevXValue = (seriesPoints[0] && seriesPoints[0].x > xTolerance) ? 0 : xTolerance;
var prevYValue = (seriesPoints[0] && seriesPoints[0].y > yTolerance) ? 0 : yTolerance;
var xVal = 0;
var yVal = 0;
var currentPoint;
for (var _i = 0, seriesPoints_1 = seriesPoints; _i < seriesPoints_1.length; _i++) {
var currentPoint_1 = seriesPoints_1[_i];
currentPoint_1.symbolLocations = [];
xVal = currentPoint_1.xValue ? currentPoint_1.xValue : xVisibleRange.min;
yVal = currentPoint_1.yValue ? currentPoint_1.yValue : yVisibleRange.min;
if (Math.abs(prevXValue - xVal) >= xTolerance || Math.abs(prevYValue - yVal) >= yTolerance) {
tempPoints.push(currentPoint_1);
prevXValue = xVal;
prevYValue = yVal;
}
}
return tempPoints;
};
LineBase.prototype.getLineDirection = function (firstPoint, secondPoint, series, isInverted, getPointLocation, startPoint) {
var direction = '';
if (firstPoint != null) {
var point1 = getPointLocation(firstPoint.xValue, firstPoint.yValue, series.xAxis, series.yAxis, isInverted, series);
var point2 = getPointLocation(secondPoint.xValue, secondPoint.yValue, series.xAxis, series.yAxis, isInverted, series);
direction = startPoint + ' ' + (point1.x) + ' ' + (point1.y) + ' ' +
'L' + ' ' + (point2.x) + ' ' + (point2.y) + ' ';
}
return direction;
};
LineBase.prototype.appendLinePath = function (options, series, clipRect) {
var htmlObject = series.chart.renderer.drawPath(options);
htmlObject.setAttribute('clip-path', clipRect);
series.pathElement = htmlObject;
series.seriesElement.appendChild(htmlObject);
series.isRectSeries = false;
};
LineBase.prototype.renderMarker = function (series) {
if (series.marker && series.marker.visible) {
series.chart.markerRender.render(series);
}
};
LineBase.prototype.doProgressiveAnimation = function (series, option) {
var animation = new ej2_base_1.Animation({});
var path = series.pathElement;
var strokeDashArray = path.getAttribute('stroke-dasharray');
var pathLength = series.pathElement.getTotalLength();
var currentTime;
path.style.visibility = 'hidden';
animation.animate(path, {
duration: option.duration,
delay: option.delay,
progress: function (args) {
if (args.timeStamp >= args.delay) {
path.style.visibility = 'visible';
currentTime = Math.abs(Math.round(((args.timeStamp - args.delay) * pathLength) / args.duration));
path.setAttribute('stroke-dasharray', currentTime + ',' + pathLength);
}
},
end: function (model) {
path.setAttribute('stroke-dasharray', strokeDashArray);
series.chart.trigger('animationComplete', { series: series });
}
});
};
LineBase.prototype.storePointLocation = function (point, series, isInverted, getLocation) {
var markerWidth = (series.marker && series.marker.width) ? series.marker.width : 0;
var markerHeight = (series.marker && series.marker.height) ? series.marker.height : 0;
point.symbolLocations.push(getLocation(point.xValue, point.yValue, series.xAxis, series.yAxis, isInverted, series));
point.regions.push(new helper_1.Rect(point.symbolLocations[0].x - markerWidth, point.symbolLocations[0].y - markerHeight, 2 * markerWidth, 2 * markerHeight));
};
LineBase.prototype.doLinearAnimation = function (series, animation) {
var clipRect = series.clipRectElement.childNodes[0].childNodes[0];
var effect = helper_1.getAnimationFunction('Linear');
var elementHeight = +clipRect.getAttribute('height');
var elementWidth = +clipRect.getAttribute('width');
var xCenter = +clipRect.getAttribute('x');
var yCenter = series.chart.requireInvertedAxis ? +clipRect.getAttribute('height') + +clipRect.getAttribute('y') :
+clipRect.getAttribute('y');
var value;
clipRect.style.visibility = 'hidden';
new ej2_base_1.Animation({}).animate(clipRect, {
duration: animation.duration,
delay: animation.delay,
progress: function (args) {
if (args.timeStamp >= args.delay) {
clipRect.style.visibility = 'visible';
if (series.chart.requireInvertedAxis) {
value = effect(args.timeStamp - args.delay, 0, elementHeight, args.duration);
clipRect.setAttribute('transform', 'translate(' + xCenter + ' ' + yCenter +
') scale(1,' + (value / elementHeight) + ') translate(' + (-xCenter) + ' ' + (-yCenter) + ')');
}
else {
value = effect(args.timeStamp - args.delay, 0, elementWidth, args.duration);
clipRect.setAttribute('transform', 'translate(' + xCenter + ' ' + yCenter +
') scale(' + (value / elementWidth) + ', 1) translate(' + (-xCenter) + ' ' + (-yCenter) + ')');
}
}
},
end: function (model) {
clipRect.setAttribute('transform', 'translate(0,0)');
series.chart.trigger('animationComplete', { series: series });
}
});
};
return LineBase;
}());
exports.LineBase = LineBase;
});
|