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

97.33% Statements 73/75
94.59% Branches 35/37
100% Functions 13/13
97.22% Lines 70/72
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 99 100 101        74×   94× 94× 94× 94× 94× 94× 793× 793× 793× 793× 793× 793× 24× 24× 24×   793× 793× 793× 793× 793× 793× 769×     24×   793× 793× 762× 762× 762×   90× 90× 90× 90×   762×     31×       31× 31×     94×   94× 94× 94×   90× 772× 762× 762×     10×     90×     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 RangeAreaSeries = (function (_super) {
        __extends(RangeAreaSeries, _super);
        function RangeAreaSeries() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        RangeAreaSeries.prototype.render = function (series) {
            var point;
            var direction = '';
            var command = 'M';
            var closed = undefined;
            var visiblePoints = this.improveChartPerformance(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 (series.yAxis.isInversed) {
                    var temp = low;
                    low = high;
                    high = temp;
                }
                var lowPoint = helper_1.getPoint(point.xValue, low, series.xAxis, series.yAxis, series.chart.requireInvertedAxis);
                var highPoint = helper_1.getPoint(point.xValue, high, series.xAxis, series.yAxis, series.chart.requireInvertedAxis);
                point.symbolLocations.push(highPoint);
                point.symbolLocations.push(lowPoint);
                var rect = new helper_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 (!series.chart.requireInvertedAxis) {
                    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) + ' ');
                    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 helper_1.PathOption(name, series.interior, series.border.width, series.border.color, series.opacity, series.dashArray, direction);
            this.appendLinePath(options, series, '');
            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)) + ' ';
                }
                else {
                    break;
                }
            }
            return direction;
        };
        RangeAreaSeries.prototype.doAnimation = function (series) {
            var option = series.animation;
            this.doLinearAnimation(series, option);
        };
        RangeAreaSeries.prototype.getModuleName = function () {
            return 'RangeAreaSeries';
        };
        RangeAreaSeries.prototype.destroy = function (chart) {
        };
        return RangeAreaSeries;
    }(line_base_1.LineBase));
    exports.RangeAreaSeries = RangeAreaSeries;
});