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

100% Statements 96/96
92.73% Branches 51/55
100% Functions 14/14
100% Lines 93/93
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          58×   86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 86× 13×     73×   86× 648× 648× 648× 648× 648× 611× 120× 120× 120× 120× 120× 120×   611× 491× 491× 491× 491×   120× 119× 119× 119×   611× 611×   648× 34× 34× 34× 34×     86× 83× 83× 83× 83× 83× 83× 83×       86× 86× 86× 34× 34×   86× 85×     11× 11×   11× 11× 11×           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 StepAreaSeries = (function (_super) {
        __extends(StepAreaSeries, _super);
        function StepAreaSeries() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        StepAreaSeries.prototype.render = function (series, xAxis, yAxis, isInverted, pointAnimate, pointUpdate) {
            var currentPoint;
            var secondPoint;
            var start = null;
            var direction = '';
            var visiblePoints = this.enableComplexProperty(series);
            var pointsLength = visiblePoints.length;
            var origin = Math.max(series.yAxis.visibleRange.min, 0);
            var point;
            var xValue;
            var lineLength;
            var prevPoint = null;
            var borderDirection = '';
            if (xAxis.valueType === 'Category' && xAxis.labelPlacement === 'BetweenTicks') {
                lineLength = 0.5;
            }
            else {
                lineLength = 0;
            }
            for (var i = 0; i < pointsLength; i++) {
                point = visiblePoints[i];
                xValue = point.xValue;
                point.symbolLocations = [];
                point.regions = [];
                if (point.visible && helper_1.withInRange(visiblePoints[i - 1], point, visiblePoints[i + 1], series)) {
                    if (start === null) {
                        start = new helper_1.ChartLocation(xValue, 0);
                        currentPoint = helper_1.getPoint(xValue - lineLength, origin, xAxis, yAxis, isInverted);
                        direction += ('M' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                        currentPoint = helper_1.getPoint(xValue - lineLength, point.yValue, xAxis, yAxis, isInverted);
                        direction += ('L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                        borderDirection += ('M' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                    }
                    if (prevPoint != null) {
                        currentPoint = helper_1.getPoint(point.xValue, point.yValue, xAxis, yAxis, isInverted);
                        secondPoint = helper_1.getPoint(prevPoint.xValue, prevPoint.yValue, xAxis, yAxis, isInverted);
                        direction = direction.concat(this.GetStepLineDirection(currentPoint, secondPoint, series.step, 'L', series));
                        borderDirection += (this.GetStepLineDirection(currentPoint, secondPoint, series.step, 'L', series, true));
                    }
                    else if (series.emptyPointSettings.mode === 'Gap') {
                        currentPoint = helper_1.getPoint(point.xValue, point.yValue, xAxis, yAxis, isInverted);
                        direction += 'L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ';
                        borderDirection += 'L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ';
                    }
                    this.storePointLocation(point, series, isInverted, helper_1.getPoint);
                    prevPoint = point;
                }
                if (visiblePoints[i + 1] && !visiblePoints[i + 1].visible && series.emptyPointSettings.mode !== 'Drop') {
                    currentPoint = helper_1.getPoint(xValue + lineLength, origin, xAxis, yAxis, isInverted);
                    direction += ('L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y));
                    start = null;
                    prevPoint = null;
                }
            }
            if ((pointsLength > 1) && direction !== '') {
                start = { 'x': visiblePoints[pointsLength - 1].xValue + lineLength, 'y': visiblePoints[pointsLength - 1].yValue };
                secondPoint = helper_1.getPoint(start.x, start.y, xAxis, yAxis, isInverted);
                direction += ('L' + ' ' + (secondPoint.x) + ' ' + (secondPoint.y) + ' ');
                borderDirection += ('L' + ' ' + (secondPoint.x) + ' ' + (secondPoint.y) + ' ');
                start = { 'x': visiblePoints[pointsLength - 1].xValue + lineLength, 'y': origin };
                secondPoint = helper_1.getPoint(start.x, start.y, xAxis, yAxis, isInverted);
                direction += ('L' + ' ' + (secondPoint.x) + ' ' + (secondPoint.y) + ' ');
            }
            else {
                direction = '';
            }
            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 ? 'addAreaPath' : 'appendLinePath'](options, series, '');
            if (series.border.width !== 0) {
                var options_1 = new ej2_svg_base_1.PathOption(series.chart.element.id + '_Series_border_' + series.index, 'transparent', series.border.width, series.border.color ? series.border.color : series.interior, 1, series.border.dashArray, borderDirection);
                this[pointAnimate ? 'addAreaPath' : 'appendLinePath'](options_1, series, '');
            }
            if (!pointUpdate) {
                this.renderMarker(series);
            }
        };
        StepAreaSeries.prototype.updateDirection = function (series, point) {
            this.render(series, series.xAxis, series.yAxis, series.chart.requireInvertedAxis, false, true);
            for (var i = 0; i < point.length; i++) {
                Eif (series.marker && series.marker.visible) {
                    series.chart.markerRender.renderMarker(series, series.points[point[i]], series.points[point[i]].symbolLocations[0], null, 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);
                }
            }
        };
        StepAreaSeries.prototype.doAnimation = function (series) {
            var option = series.animation;
            this.doLinearAnimation(series, option);
        };
        StepAreaSeries.prototype.destroy = function () {
        };
        StepAreaSeries.prototype.getModuleName = function () {
            return 'StepAreaSeries';
        };
        return StepAreaSeries;
    }(line_base_1.LineBase));
    exports.StepAreaSeries = StepAreaSeries;
});