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

100% Statements 76/76
100% Branches 35/35
100% Functions 12/12
100% Lines 73/73
9 statements, 5 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        39×   56× 56× 56× 56× 56× 56× 56× 56× 56× 56× 56× 56×     50×   56× 407× 407× 407× 407× 407× 374× 86× 86× 86× 86× 86×   374× 288× 288× 288×     86× 85× 85×   374× 374×   407× 30× 30× 30× 30×     56× 53× 53× 53× 53× 53× 53×   56× 56× 56×       20665×        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var 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 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", "./line-base"], function (require, exports, helper_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) {
            var currentPoint;
            var secondPoint;
            var start = null;
            var direction = '';
            var pointsLength = series.points.length;
            var origin = Math.max(series.yAxis.visibleRange.min, 0);
            var options;
            var point;
            var xValue;
            var lineLength;
            var prevPoint = null;
            if (xAxis.valueType === 'Category' && xAxis.labelPlacement === 'BetweenTicks') {
                lineLength = 0.5;
            }
            else {
                lineLength = 0;
            }
            for (var i = 0; i < pointsLength; i++) {
                point = series.points[i];
                xValue = point.xValue;
                point.symbolLocations = [];
                point.regions = [];
                if (point.visible && helper_1.withInRange(series.points[i - 1], point, series.points[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) + ' ');
                    }
                    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 += ('L' + ' ' +
                            (currentPoint.x) + ' ' + (secondPoint.y) + 'L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ');
                    }
                    else if (series.emptyPointSettings.mode === 'Gap') {
                        currentPoint = helper_1.getPoint(point.xValue, point.yValue, xAxis, yAxis, isInverted);
                        direction += 'L' + ' ' + (currentPoint.x) + ' ' + (currentPoint.y) + ' ';
                    }
                    this.storePointLocation(point, series, isInverted, helper_1.getPoint);
                    prevPoint = point;
                }
                if (series.points[i + 1] && !series.points[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) {
                start = { 'x': series.points[pointsLength - 1].xValue + lineLength, 'y': series.points[pointsLength - 1].yValue };
                secondPoint = helper_1.getPoint(start.x, start.y, xAxis, yAxis, isInverted);
                direction += ('L' + ' ' + (secondPoint.x) + ' ' + (secondPoint.y) + ' ');
                start = { 'x': series.points[pointsLength - 1].xValue + lineLength, 'y': origin };
                secondPoint = helper_1.getPoint(start.x, start.y, xAxis, yAxis, isInverted);
                direction += ('L' + ' ' + (secondPoint.x) + ' ' + (secondPoint.y) + ' ');
            }
            options = new helper_1.PathOption(series.chart.element.id + '_Series_' + series.index, series.interior, series.border.width, series.border.color, series.opacity, series.dashArray, direction);
            this.appendLinePath(options, series, '');
            this.renderMarker(series);
        };
        StepAreaSeries.prototype.doAnimation = function (series) {
            var option = series.animation;
            this.doLinearAnimation(series, option);
        };
        StepAreaSeries.prototype.destroy = function (chart) {
        };
        StepAreaSeries.prototype.getModuleName = function () {
            return 'StepAreaSeries';
        };
        return StepAreaSeries;
    }(line_base_1.LineBase));
    exports.StepAreaSeries = StepAreaSeries;
});