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

97.33% Statements 73/75
86.76% Branches 59/68
100% Functions 15/15
97.22% Lines 70/72
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          95× 95× 95×   416× 416× 416× 2949× 2949×   416× 373×     2960× 2960× 2960×   2952× 2952× 2952× 258× 258×         258×       2952×     2952× 258× 258×     2694×   2952×   2952× 2952× 2949× 2949× 2949× 264×         264×             11× 11× 11×   11× 11× 11×           41538×   10×        
/* 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", "./column-base"], function (require, exports, helper_1, column_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var StackingBarSeries = (function (_super) {
        __extends(StackingBarSeries, _super);
        function StackingBarSeries() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.sideBySideInfo = [];
            return _this;
        }
        StackingBarSeries.prototype.render = function (series) {
            this.sideBySideInfo[series.index] = this.getSideBySideInfo(series);
            var stackedValue = series.stackedValues;
            for (var _i = 0, _a = series.points; _i < _a.length; _i++) {
                var pointStack = _a[_i];
                this.renderPoint(series, pointStack, this.sideBySideInfo[series.index], stackedValue);
            }
            if (series.visible) {
                this.renderMarker(series);
            }
        };
        StackingBarSeries.prototype.renderPoint = function (series, pointStack, sideBySideInfo, stackedValue) {
            pointStack.symbolLocations = [];
            pointStack.regions = [];
            if (pointStack.visible &&
                helper_1.withInRange(series.points[pointStack.index - 1], pointStack, series.points[pointStack.index + 1], series)) {
                var index = void 0;
                var startvalue = void 0;
                if (!series.visible && series.isLegendClicked) {
                    for (var i = series.index; i >= 0; i--) {
                        Iif (series.chart.visibleSeries[i].visible) {
                            index = series.chart.visibleSeries[i].index;
                            break;
                        }
                    }
                    startvalue = series.index > 0 && index !== undefined ?
                        series.chart.visibleSeries[index].stackedValues.endValues[pointStack.index] :
                        series.stackedValues.startValues[pointStack.index];
                }
                this.rect = this.getRectangle(pointStack.xValue + sideBySideInfo.start, (!series.visible && series.isLegendClicked) ?
                    startvalue : stackedValue.endValues[pointStack.index], pointStack.xValue + sideBySideInfo.end, (!series.visible
                    && series.isLegendClicked) ? startvalue : stackedValue.startValues[pointStack.index], series);
                if (series.chart.isTransposed && series.columnWidthInPixel) {
                    this.rect.width = series.columnWidthInPixel ? series.columnWidthInPixel : this.rect.height;
                    this.rect.x -= series.columnWidthInPixel / 2;
                }
                else {
                    this.rect.height = series.columnWidthInPixel ? series.columnWidthInPixel : this.rect.height;
                }
                this.rect.y = series.columnWidthInPixel ? series.chart.isTransposed ? this.rect.y : this.rect.y -
                    (series.columnWidthInPixel / 2) : this.rect.y;
                var argsData = this.triggerEvent(series, pointStack, series.interior, { width: series.visible ? series.border.width : 0, color: series.visible ? series.border.color : '' });
                if (!argsData.cancel) {
                    this.drawRectangle(series, pointStack, this.rect, argsData);
                    this.updateSymbolLocation(pointStack, this.rect, series);
                    if (series.columnFacet === 'Cylinder') {
                        var cylinderSeriesOption = {
                            'isColumn': false,
                            'stacking': series.type === 'StackingBar100',
                            'isLastSeries': true
                        };
                        this.drawCylinder(this.options, this.element, cylinderSeriesOption, this.rect, series);
                    }
                }
            }
        };
        StackingBarSeries.prototype.updateDirection = function (series, point) {
            var seriesCollection = [];
            for (var i = 0; i < series.yAxis.series.length; i++) {
                var stackSeries = series.yAxis.series[i];
                Eif (stackSeries.stackingGroup === series.stackingGroup) {
                    seriesCollection.push(stackSeries);
                }
            }
            for (var j = 0; j < seriesCollection.length; j++) {
                for (var i = 0; i < point.length; i++) {
                    this.renderPoint(seriesCollection[j], seriesCollection[j].points[point[i]], this.sideBySideInfo[series.index], seriesCollection[j].stackedValues);
                    Eif (series.marker && series.marker.visible) {
                        seriesCollection[j].chart.markerRender.renderMarker(seriesCollection[j], seriesCollection[j].points[point[i]], seriesCollection[j].points[point[i]].symbolLocations[0], null, true);
                    }
                    Eif (seriesCollection[j].marker.dataLabel.visible && seriesCollection[j].chart.dataLabelModule) {
                        seriesCollection[j].chart.dataLabelModule.commonId = seriesCollection[j].chart.element.id + '_Series_' + seriesCollection[j].index + '_Point_';
                        seriesCollection[j].chart.dataLabelModule.renderDataLabel(seriesCollection[j], seriesCollection[j].points[point[i]], null, seriesCollection[j].marker.dataLabel);
                    }
                }
            }
        };
        StackingBarSeries.prototype.destroy = function () {
        };
        StackingBarSeries.prototype.getModuleName = function () {
            return 'StackingBarSeries';
        };
        StackingBarSeries.prototype.doAnimation = function (series) {
            this.animate(series);
        };
        return StackingBarSeries;
    }(column_base_1.ColumnBase));
    exports.StackingBarSeries = StackingBarSeries;
});