all files / chart/series/ range-step-area-series.js

93.04% Statements 147/158
89.32% Branches 92/103
94.44% Functions 17/18
92.9% Lines 144/155
11 statements, 6 functions, 9 branches Ignored     
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          57× 57× 57× 57×   72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 72× 26×   72× 650× 650× 650× 650× 650× 650×         650× 650× 650× 650× 650× 650× 650× 649× 70× 70× 70× 70×   70× 70×   649× 579×   579×   579× 579×   70× 70×   70× 70×   649× 649× 649× 649×   70× 70× 70× 70× 70× 70×                 72× 72× 72× 54× 54×   72× 71×     70× 70× 70× 70× 70× 650× 649× 649× 649× 649×         649× 649×   649×   649× 649× 70×     579×           649×   70×                                           41538×          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "../../common/utils/helper", "@syncfusion/ej2-svg-base", "./line-base"], function (require, exports, helper_1, ej2_svg_base_1, line_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var RangeStepAreaSeries = (function (_super) {
        __extends(RangeStepAreaSeries, _super);
        function RangeStepAreaSeries() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.borderDirection = '';
            _this.prevPoint = null;
            return _this;
        }
        RangeStepAreaSeries.prototype.render = function (series, xAxis, yAxis, isInverted, pointAnimate, pointUpdate) {
            this.prevPoint = null;
            var point;
            var currentPoint;
            var secondPoint;
            var start = null;
            var direction = '';
            var lineLength = 0;
            var command = 'M';
            var closed = undefined;
            var low;
            var high;
            var borderWidth = series.border.width ? series.border.width : 0;
            var borderColor = series.border.color ? series.border.color : series.interior;
            var origin = Math.max(series.yAxis.visibleRange.min, 0);
            var visiblePoints = this.enableComplexProperty(series);
            if (xAxis.valueType === 'Category' && xAxis.labelPlacement === 'BetweenTicks') {
                lineLength = 0.5;
            }
            for (var i = 0, length_1 = visiblePoints.length; i < length_1; i++) {
                point = visiblePoints[i];
                point.symbolLocations = [];
                point.regions = [];
                low = Math.min(point.low, point.high);
                high = Math.max(point.low, point.high);
                Iif (yAxis.isAxisInverse) {
                    var temp = low;
                    low = high;
                    high = temp;
                }
                var lowPoint = helper_1.getPoint(point.xValue, low, xAxis, yAxis, isInverted);
                var highPoint = helper_1.getPoint(point.xValue, high, xAxis, yAxis, isInverted);
                point.symbolLocations.push(highPoint);
                point.symbolLocations.push(lowPoint);
                var rect = new ej2_svg_base_1.Rect(Math.min(lowPoint.x, highPoint.x), Math.min(lowPoint.y, highPoint.y), Math.max(Math.abs(highPoint.x - lowPoint.x), series.marker.width), Math.max(Math.abs(highPoint.y - lowPoint.y), series.marker.width));
                point.regions.push(rect);
                if (point.visible && helper_1.withInRange(visiblePoints[point.index - 1], point, visiblePoints[point.index + 1], series)) {
                    if (start === null) {
                        start = new helper_1.ChartLocation(point.xValue, 0);
                        currentPoint = helper_1.getPoint(point.xValue - lineLength, origin, xAxis, yAxis, isInverted);
                        direction += (command + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                        currentPoint = helper_1.getPoint(point.xValue - lineLength, point.high > point.low ? point.high
                            : point.low, xAxis, yAxis, isInverted);
                        direction += ('L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                        this.borderDirection += (command + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                    }
                    if (this.prevPoint != null) {
                        currentPoint = helper_1.getPoint(point.xValue, point.high > point.low ? point.high
                            : point.low, xAxis, yAxis, isInverted);
                        secondPoint = helper_1.getPoint(this.prevPoint.xValue, this.prevPoint.high > this.prevPoint.low ? this.prevPoint.high
                            : this.prevPoint.low, xAxis, yAxis, isInverted);
                        direction += (this.GetStepLineDirection(currentPoint, secondPoint, series.step, command, series, false));
                        this.borderDirection += (this.GetStepLineDirection(currentPoint, secondPoint, series.step, command, series, true));
                    }
                    else Eif (series.emptyPointSettings.mode === 'Gap') {
                        currentPoint = helper_1.getPoint(point.xValue, point.high > point.low ? point.high
                            : point.low, xAxis, yAxis, isInverted);
                        direction += command + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ';
                        this.borderDirection += command + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ';
                    }
                    closed = false;
                    command = ' L';
                    this.prevPoint = point;
                    if ((i + 1 < visiblePoints.length && !visiblePoints[i + 1].visible)
                        || i === visiblePoints.length - 1) {
                        direction = this.closeRangeStepAreaPath(visiblePoints, point, series, direction, i, xAxis, yAxis, isInverted);
                        command = 'M';
                        direction = direction.concat(' ' + 'Z ');
                        closed = true;
                        this.prevPoint = null;
                        start = null;
                    }
                }
                else {
                    Iif (closed === false && i !== 0) {
                        direction = this.closeRangeStepAreaPath(visiblePoints, point, series, direction, i, xAxis, yAxis, isInverted);
                        closed = true;
                    }
                    command = 'M';
                    point.symbolLocations = [];
                }
            }
            var options = new ej2_svg_base_1.PathOption(series.chart.element.id + '_Series_' + series.index, series.interior, 0, 'transparent', series.opacity, series.dashArray, direction);
            this[pointAnimate ? 'addPath' : 'appendLinePath'](options, series, '');
            if (series.border.width !== 0) {
                this[pointAnimate ? 'addPath' : 'appendLinePath'](new ej2_svg_base_1.PathOption(series.chart.element.id + '_Series_border_' + series.index, 'transparent', borderWidth, borderColor, 1, series.border.dashArray, this.borderDirection), series, '');
                this.borderDirection = '';
            }
            if (!pointUpdate) {
                this.renderMarker(series);
            }
        };
        RangeStepAreaSeries.prototype.closeRangeStepAreaPath = function (visiblePoints, point, series, direction, i, xAxis, yAxis, isInverted) {
            var currentPoint;
            var secondPoint;
            var low;
            var high;
            for (var j = i; j >= 0; j--) {
                if (visiblePoints[j].visible) {
                    point = visiblePoints[j];
                    low = Math.min(point.low, point.high);
                    high = Math.max(point.low, point.high);
                    Iif (yAxis.isAxisInverse) {
                        var temp = low;
                        low = high;
                        high = temp;
                    }
                    Eif (this.prevPoint != null) {
                        currentPoint = helper_1.getPoint(point.xValue, point.low < point.high ? point.low
                            : point.high, xAxis, yAxis, isInverted);
                        secondPoint = helper_1.getPoint(this.prevPoint.xValue, this.prevPoint.low < this.prevPoint.high ? this.prevPoint.low
                            : this.prevPoint.high, xAxis, yAxis, isInverted);
                        direction += (this.GetStepLineDirection(currentPoint, secondPoint, series.step === 'Right' ? 'Left' : (series.step === 'Left' ? 'Right' : series.step), 'L', series, false));
                        if (j === i) {
                            this.borderDirection += (this.GetStepLineDirection(currentPoint, secondPoint, series.step === 'Right' ? 'Left' : (series.step === 'Left' ? 'Right' : series.step), 'M', series, true));
                        }
                        else {
                            this.borderDirection += (this.GetStepLineDirection(currentPoint, secondPoint, series.step === 'Right' ? 'Left' : (series.step === 'Left' ? 'Right' : series.step), 'L', series, true));
                        }
                    }
                }
                else {
                    break;
                }
                this.prevPoint = point;
            }
            return direction;
        };
        RangeStepAreaSeries.prototype.updateDirection = function (series, point) {
            this.render(series, series.xAxis, series.yAxis, series.chart.requireInvertedAxis, false, true);
            var _loop_1 = function (i) {
                Eif (series.marker && series.marker.visible) {
                    series.points[point[i]].symbolLocations.map(function (location, index) {
                        series.chart.markerRender.renderMarker(series, series.points[point[i]], location, index, true);
                    });
                }
                Eif (series.marker.dataLabel.visible && series.chart.dataLabelModule) {
                    series.chart.dataLabelModule.commonId = series.chart.element.id + '_Series_' + series.index + '_Point_';
                    series.chart.dataLabelModule.renderDataLabel(series, series.points[point[i]], null, series.marker.dataLabel);
                }
            };
            for (var i = 0; i < point.length; i++) {
                _loop_1(i);
            }
        };
        RangeStepAreaSeries.prototype.addPath = function (options, series, clipRect) {
            var points = this.appendPathElement(options, series, clipRect);
            Eif (points.previousDirection !== '' && options.d !== '') {
                var startPathCommands = points.previousDirection.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/g);
                var endPathCommands = (options.d).match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/g);
                var maxLength = Math.max(startPathCommands.length, endPathCommands.length);
                var minLength = Math.min(startPathCommands.length, endPathCommands.length);
                if (startPathCommands.length < endPathCommands.length) {
                    for (var i = startPathCommands.length; i < endPathCommands.length; i++) {
                        if (endPathCommands.length !== startPathCommands.length) {
                            startPathCommands.splice((Math.floor((startPathCommands.length / 2)) - 1), 0, startPathCommands[Math.floor((startPathCommands.length / 2)) - 1], startPathCommands[Math.floor((startPathCommands.length / 2)) - 1]);
                            startPathCommands.splice((Math.floor((startPathCommands.length / 2)) + 2), 0, startPathCommands[Math.floor((startPathCommands.length / 2)) + 2], startPathCommands[Math.floor((startPathCommands.length / 2)) + 2]);
                        }
                    }
                    helper_1.animateAddPoints(points.element, options.d, series.chart.redraw, startPathCommands.join(' '), this.chart.duration);
                }
                else Eif (startPathCommands.length > endPathCommands.length) {
                    for (var i = minLength; i < maxLength; i++) {
                        if (endPathCommands.length !== startPathCommands.length) {
                            endPathCommands.splice(2, 0, endPathCommands[2]);
                            endPathCommands.splice(endPathCommands.length - 3, 0, endPathCommands[endPathCommands.length - 3]);
                        }
                    }
                    helper_1.animateAddPoints(points.element, endPathCommands.join(''), series.chart.redraw, points.previousDirection, this.chart.duration, options.d);
                }
                else {
                    helper_1.animateAddPoints(points.element, options.d, series.chart.redraw, points.previousDirection, this.chart.duration);
                }
            }
        };
        RangeStepAreaSeries.prototype.doAnimation = function (series) {
            var option = series.animation;
            this.doLinearAnimation(series, option);
        };
        RangeStepAreaSeries.prototype.getModuleName = function () {
            return 'RangeStepAreaSeries';
        };
        RangeStepAreaSeries.prototype.destroy = function () {
        };
        return RangeStepAreaSeries;
    }(line_base_1.LineBase));
    exports.RangeStepAreaSeries = RangeStepAreaSeries;
});