all files / chart/axis/ category-axis.js

100% Statements 68/68
95.83% Branches 46/48
100% Functions 16/16
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          1198×   2909× 2909× 2909× 2909×   3147× 3147× 3147× 2776×     371×   3147× 3147× 3147×   3117× 3117× 5278× 5044×     3117× 3117× 2801× 2801×     316×   3117× 3117× 3117×   2909× 2909× 2909× 2909× 2909× 292×   2909× 2909× 2909× 2909× 24912× 24912× 23986× 23986×     2909× 2909×     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", "../../common/utils/helper", "../utils/double-range", "../../common/utils/helper", "@syncfusion/ej2-base", "../axis/axis-helper"], function (require, exports, helper_1, double_range_1, helper_2, ej2_base_1, axis_helper_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Category = (function (_super) {
        __extends(Category, _super);
        function Category(chart) {
            return _super.call(this, chart) || this;
        }
        Category.prototype.calculateRangeAndInterval = function (size, axis) {
            this.calculateRange(axis);
            this.getActualRange(axis, size);
            this.applyRangePadding(axis, size);
            this.calculateVisibleLabels(axis);
        };
        Category.prototype.getActualRange = function (axis, size) {
            this.initializeDoubleRange(axis);
            axis.actualRange = {};
            if (!axis.interval) {
                axis.actualRange.interval = Math.max(1, Math.floor(axis.doubleRange.delta / helper_1.getActualDesiredIntervalsCount(size, axis)));
            }
            else {
                axis.actualRange.interval = Math.ceil(axis.interval);
            }
            axis.actualRange.min = axis.doubleRange.start;
            axis.actualRange.max = axis.doubleRange.end;
            axis.actualRange.delta = axis.doubleRange.delta;
        };
        Category.prototype.applyRangePadding = function (axis, size) {
            var isColumn;
            axis.series.forEach(function (element) {
                if (!isColumn) {
                    isColumn = (element.type.indexOf('Column') > -1 || element.type.indexOf('Bar') > -1) && !(axis.zoomFactor < 1 || axis.zoomPosition > 0) && ej2_base_1.isNullOrUndefined(axis.minimum) && ej2_base_1.isNullOrUndefined(axis.maximum);
                }
            });
            var ticks = ((axis.labelPlacement === 'BetweenTicks' || isColumn) && !this.chart.stockChart && this.chart.chartAreaType !== 'PolarRadar') ? 0.5 : 0;
            if (ticks > 0) {
                axis.actualRange.min -= ticks;
                axis.actualRange.max += ticks;
            }
            else {
                axis.actualRange.max += axis.actualRange.max ? 0 : 0.5;
            }
            axis.doubleRange = new double_range_1.DoubleRange(axis.actualRange.min, axis.actualRange.max);
            axis.actualRange.delta = axis.doubleRange.delta;
            this.calculateVisibleRange(size, axis);
        };
        Category.prototype.calculateVisibleLabels = function (axis) {
            axis.visibleLabels = [];
            axis.visibleRange.interval = axis.visibleRange.interval < 1 ? 1 : axis.visibleRange.interval;
            var tempInterval = Math.ceil(axis.visibleRange.min);
            var labelStyle;
            if (axis.zoomFactor < 1 || axis.zoomPosition > 0) {
                tempInterval = axis.visibleRange.min - (axis.visibleRange.min % axis.visibleRange.interval);
            }
            var position;
            axis.startLabel = axis.labels[Math.round(axis.visibleRange.min)];
            axis.endLabel = axis.labels[Math.floor(axis.visibleRange.max)];
            for (; tempInterval <= axis.visibleRange.max; tempInterval += axis.visibleRange.interval) {
                labelStyle = (ej2_base_1.extend({}, ej2_base_1.getValue('properties', axis.labelStyle), null, true));
                if (helper_2.withIn(tempInterval, axis.visibleRange) && axis.labels.length > 0) {
                    position = Math.round(tempInterval);
                    helper_1.triggerLabelRender(this.chart, position, axis.labels[position] ? axis.labels[position].toString() : '', labelStyle, axis);
                }
            }
            Eif (axis.getMaxLabelWidth) {
                axis.getMaxLabelWidth(this.chart);
            }
        };
        Category.prototype.getModuleName = function () {
            return 'Category';
        };
        Category.prototype.destroy = function () {
        };
        return Category;
    }(axis_helper_1.NiceInterval));
    exports.Category = Category;
});