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

100% Statements 73/73
100% Branches 44/44
100% Functions 13/13
100% Lines 70/70
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 97 98        71×   162× 162× 162× 162× 162× 162× 162×     162× 162× 162× 162× 162× 162× 162× 1269× 1269× 1269× 1170× 1170× 1170× 1170×     99× 90× 210× 210×   90× 70× 70×   90×       162×   162× 969× 969× 961× 961×       162× 162× 162×   10× 10×     20665×   969× 969× 2213× 501×     468×        
/* 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 StackingAreaSeries = (function (_super) {
        __extends(StackingAreaSeries, _super);
        function StackingAreaSeries() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        StackingAreaSeries.prototype.render = function (series, xAxis, yAxis, isInverted) {
            var polarAreaType = series.chart.chartAreaType === 'PolarRadar';
            var getCoordinate = polarAreaType ? helper_1.TransformToVisible : helper_1.getPoint;
            var lineDirection = '';
            var visiblePoints = series.points;
            var pointsLength = visiblePoints.length;
            var stackedvalue = series.stackedValues;
            var origin = polarAreaType ?
                Math.max(series.yAxis.visibleRange.min, stackedvalue.endValues[0]) :
                Math.max(series.yAxis.visibleRange.min, stackedvalue.startValues[0]);
            var border = series.border;
            var options;
            var startPoint = 0;
            var point1 = getCoordinate(visiblePoints[0].xValue, origin, xAxis, yAxis, isInverted, series);
            var point2;
            lineDirection = lineDirection.concat('M' + ' ' + (point1.x) + ' ' + (point1.y) + ' ');
            for (var i = 0; i < pointsLength; i++) {
                visiblePoints[i].symbolLocations = [];
                visiblePoints[i].regions = [];
                if (visiblePoints[i].visible && helper_1.withInRange(visiblePoints[i - 1], visiblePoints[i], visiblePoints[i + 1], series)) {
                    point1 = getCoordinate(visiblePoints[i].xValue, stackedvalue.endValues[i], xAxis, yAxis, isInverted, series);
                    lineDirection = lineDirection.concat('L' + ' ' + (point1.x) + ' ' + (point1.y) + ' ');
                    visiblePoints[i].symbolLocations.push(getCoordinate(visiblePoints[i].xValue, stackedvalue.endValues[i], xAxis, yAxis, isInverted, series));
                    visiblePoints[i].regions.push(new helper_1.Rect(visiblePoints[i].symbolLocations[0].x - series.marker.width, visiblePoints[i].symbolLocations[0].y - series.marker.height, 2 * series.marker.width, 2 * series.marker.height));
                }
                else {
                    if (series.emptyPointSettings.mode !== 'Drop') {
                        for (var j = i - 1; j >= startPoint; j--) {
                            point2 = getCoordinate(visiblePoints[j].xValue, stackedvalue.startValues[j], xAxis, yAxis, isInverted, series);
                            lineDirection = lineDirection.concat('L' + ' ' + (point2.x) + ' ' + (point2.y) + ' ');
                        }
                        if (visiblePoints[i + 1] && visiblePoints[i + 1].visible) {
                            point1 = getCoordinate(visiblePoints[i + 1].xValue, stackedvalue.startValues[i + 1], xAxis, yAxis, isInverted, series);
                            lineDirection = lineDirection.concat('M' + ' ' + (point1.x) + ' ' + (point1.y) + ' ');
                        }
                        startPoint = i + 1;
                    }
                }
            }
            if (series.chart.chartAreaType === 'PolarRadar' && visiblePoints.length > 1) {
                point1 = { 'x': series.points[0].xValue, 'y': stackedvalue.endValues[0] };
                point2 = getCoordinate(point1.x, point1.y, xAxis, yAxis, isInverted, series);
                lineDirection += ('L' + ' ' + (point2.x) + ' ' + (point2.y) + ' ');
            }
            for (var j = pointsLength - 1; j >= startPoint; j--) {
                var previousSeries = this.getPreviousSeries(series);
                if (previousSeries.emptyPointSettings.mode !== 'Drop' || !previousSeries.points[j].isEmpty) {
                    point2 = getCoordinate(visiblePoints[j].xValue, stackedvalue.startValues[j], xAxis, yAxis, isInverted, series);
                    lineDirection = lineDirection.concat(((j === (pointsLength - 1) && polarAreaType) ? 'M' : 'L')
                        + ' ' + (point2.x) + ' ' + (point2.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, lineDirection);
            this.appendLinePath(options, series, '');
            this.renderMarker(series);
        };
        StackingAreaSeries.prototype.doAnimation = function (series) {
            var option = series.animation;
            this.doLinearAnimation(series, option);
        };
        StackingAreaSeries.prototype.destroy = function (chart) {
        };
        StackingAreaSeries.prototype.getModuleName = function () {
            return 'StackingAreaSeries';
        };
        StackingAreaSeries.prototype.getPreviousSeries = function (series) {
            var seriesCollection = series.chart.visibleSeries;
            for (var i = 0, length_1 = seriesCollection.length; i < length_1; i++) {
                if (series.index === seriesCollection[i].index && i !== 0) {
                    return seriesCollection[i - 1];
                }
            }
            return seriesCollection[0];
        };
        return StackingAreaSeries;
    }(line_base_1.LineBase));
    exports.StackingAreaSeries = StackingAreaSeries;
});