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

97.44% Statements 114/117
90.14% Branches 64/71
100% Functions 18/18
97.37% Lines 111/114
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          123× 123× 123×   139× 139× 139× 139× 139× 139× 139× 139× 913× 913× 913× 913× 913× 913× 24× 24× 24×   913× 913× 913× 913× 913× 913× 889×     24×   913× 913× 912× 912× 912× 912×   80× 80× 80× 80×   912×               139×   139× 139× 139× 52× 52×   139× 138×     80× 913× 912× 912× 912×         80×                                       41750×          
/* 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 RangeAreaSeries = (function (_super) {
        __extends(RangeAreaSeries, _super);
        function RangeAreaSeries() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.borderDirection = '';
            return _this;
        }
        RangeAreaSeries.prototype.render = function (series, xAxis, yAxis, inverted, pointAnimate, pointUpdate) {
            var point;
            var direction = '';
            var command = 'M';
            var closed = undefined;
            var borderWidth = series.border.width ? series.border.width : 0;
            var borderColor = series.border.color ? series.border.color : series.interior;
            var visiblePoints = this.enableComplexProperty(series);
            for (var i = 0, length_1 = visiblePoints.length; i < length_1; i++) {
                point = visiblePoints[i];
                point.symbolLocations = [];
                point.regions = [];
                var low = Math.min(point.low, point.high);
                var high = Math.max(point.low, point.high);
                if (yAxis.isAxisInverse) {
                    var temp = low;
                    low = high;
                    high = temp;
                }
                var lowPoint = helper_1.getPoint(point.xValue, low, xAxis, yAxis, inverted);
                var highPoint = helper_1.getPoint(point.xValue, high, xAxis, yAxis, inverted);
                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));
                if (!inverted) {
                    rect.x -= series.marker.width / 2;
                }
                else {
                    rect.y -= series.marker.width / 2;
                }
                point.regions.push(rect);
                if (point.visible && helper_1.withInRange(visiblePoints[point.index - 1], point, visiblePoints[point.index + 1], series)) {
                    direction = direction.concat(command + ' ' + (lowPoint.x) + ' ' + (lowPoint.y) + ' ');
                    this.borderDirection += (command + ' ' + (lowPoint.x) + ' ' + (lowPoint.y) + ' ');
                    closed = false;
                    if ((i + 1 < visiblePoints.length && !visiblePoints[i + 1].visible)
                        || i === visiblePoints.length - 1) {
                        direction = this.closeRangeAreaPath(visiblePoints, point, series, direction, i);
                        command = 'M';
                        direction = direction.concat(' ' + 'Z');
                        closed = true;
                    }
                    command = 'L';
                }
                else {
                    Iif (closed === false && i !== 0) {
                        direction = this.closeRangeAreaPath(visiblePoints, point, series, direction, i);
                        closed = true;
                    }
                    command = 'M';
                    point.symbolLocations = [];
                }
            }
            var name = series.category === 'Indicator' ? series.chart.element.id + '_Indicator_' + series.index + '_' + series.name :
                series.chart.element.id + '_Series_' + series.index;
            var options = new ej2_svg_base_1.PathOption(name, 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);
            }
        };
        RangeAreaSeries.prototype.closeRangeAreaPath = function (visiblePoints, point, series, direction, i) {
            for (var j = i; j >= 0; j--) {
                if (visiblePoints[j].visible && visiblePoints[j].symbolLocations[0]) {
                    point = visiblePoints[j];
                    direction += 'L' + ' ' + (point.symbolLocations[0].x) + ' ' + ((point.symbolLocations[0].y)) + ' ';
                    this.borderDirection += (j === i ? 'M' : 'L') + ' ' + (point.symbolLocations[0].x) + ' ' + ((point.symbolLocations[0].y)) + ' ';
                }
                else {
                    break;
                }
            }
            return direction;
        };
        RangeAreaSeries.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);
            }
        };
        RangeAreaSeries.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((startPathCommands.length - 1) / 2, 0, startPathCommands.slice(0, (startPathCommands.length - 1) / 2).pop(), startPathCommands.slice(0, ((startPathCommands.length - 1) / 2) + 1).pop());
                        }
                    }
                    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(1, 0, endPathCommands[0]);
                            endPathCommands.splice(endPathCommands.length - 2, 0, endPathCommands[endPathCommands.length - 2]);
                        }
                    }
                    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);
                }
            }
        };
        RangeAreaSeries.prototype.doAnimation = function (series) {
            var option = series.animation;
            this.doLinearAnimation(series, option);
        };
        RangeAreaSeries.prototype.getModuleName = function () {
            return 'RangeAreaSeries';
        };
        RangeAreaSeries.prototype.destroy = function () {
        };
        return RangeAreaSeries;
    }(line_base_1.LineBase));
    exports.RangeAreaSeries = RangeAreaSeries;
});