all files / chart/series/ pareto-series.js

100% Statements 68/68
93.33% Branches 28/30
100% Functions 18/18
100% Lines 65/65
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          26× 26× 26×   33× 33× 33× 33× 33× 33× 33× 33× 33× 33× 33× 33× 33× 33× 33× 33×   33× 33×   33×   33× 31×   31×                           31×     35×   34× 34× 34× 34× 34× 231×   34× 231× 231×   34×     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", "../series/chart-series", "./column-base", "../axis/axis", "./marker", "../../common/model/theme"], function (require, exports, chart_series_1, column_base_1, axis_1, marker_1, theme_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ParetoSeries = (function (_super) {
        __extends(ParetoSeries, _super);
        function ParetoSeries() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.paretoAxes = [];
            return _this;
        }
        ParetoSeries.prototype.initSeries = function (targetSeries, chart) {
            var series = new chart_series_1.Series(chart, 'series', targetSeries.properties, true);
            var colors = chart.palettes.length ? chart.palettes : theme_1.getSeriesColor(chart.theme);
            var count = colors.length;
            series.name = 'Pareto';
            series.yAxisName = targetSeries.yAxisName + '_CumulativeAxis';
            series.category = 'Pareto';
            targetSeries.category = 'Pareto';
            series.index = targetSeries.index + chart.series.length;
            series.type = 'Line';
            series.interior = series.fill = series.paretoOptions.fill ? series.paretoOptions.fill : colors[series.index % count];
            series.width = series.paretoOptions.width;
            series.dashArray = series.paretoOptions.dashArray;
            series.marker = series.paretoOptions.marker;
            Eif (series.marker && series.marker.visible) {
                series.marker.shape = series.marker.shape ? series.marker.shape : marker_1.markerShapes[chart.markerIndex % 10];
                chart.markerIndex++;
            }
            chart.visibleSeries.push(series);
            this.initAxis(targetSeries, series, chart);
        };
        ParetoSeries.prototype.initAxis = function (paretoSeries, targetSeries, chart) {
            var isExist = this.paretoAxes.some(function (currentAxis) {
                return currentAxis.name === targetSeries.yAxisName;
            });
            if (!isExist) {
                var secondaryAxis = (paretoSeries.yAxisName && chart.axes.length ? chart.axes.filter(function (axis) {
                    return axis.name === paretoSeries.yAxisName;
                })[0] : chart.primaryYAxis);
                var newAxis = new axis_1.Axis(chart, 'axes', {
                    name: targetSeries.yAxisName,
                    majorGridLines: {
                        width: 0
                    },
                    majorTickLines: secondaryAxis.majorTickLines,
                    lineStyle: secondaryAxis.lineStyle,
                    minimum: 0,
                    maximum: 100,
                    interval: 20,
                    rowIndex: secondaryAxis.rowIndex,
                    opposedPosition: true,
                    labelFormat: '{value}%'
                });
                this.paretoAxes.push(newAxis);
            }
        };
        ParetoSeries.prototype.render = function (series) {
            series.chart.columnSeriesModule.render(series);
        };
        ParetoSeries.prototype.performCumulativeCalculation = function (json, series) {
            var data = json;
            var sum = 0;
            var count = 0;
            var length = data.length;
            for (var i = 0; i < length; i++) {
                sum += data[i][series.yName];
            }
            for (var i = 0; i < length; i++) {
                count = count + data[i][series.yName];
                data[i][series.yName] = Number(((count / sum) * 100).toFixed(2));
            }
            return data;
        };
        ParetoSeries.prototype.doAnimation = function (series) {
            this.animate(series);
        };
        ParetoSeries.prototype.getModuleName = function () {
            return 'ParetoSeries';
        };
        ParetoSeries.prototype.destroy = function () {
        };
        return ParetoSeries;
    }(column_base_1.ColumnBase));
    exports.ParetoSeries = ParetoSeries;
});