all files / chart3d/axis/ logarithmic-axis.js

98.7% Statements 76/77
85.11% Branches 40/47
100% Functions 17/17
98.65% Lines 73/74
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          24×   48× 48× 48× 48×   48× 48× 48× 48× 48× 48× 48× 48× 48×   48× 48×   48× 48× 48× 48× 48× 48×   48×         38× 38× 38× 38× 152× 152×     152×   38×   48× 48× 48× 48× 48× 48× 48× 48×         48× 48× 48× 176× 176× 176× 176×     48× 48×     4177×          
/* 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", "../axis/double-axis", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-base"], function (require, exports, double_axis_1, helper_1, helper_2, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Logarithmic3D = (function (_super) {
        __extends(Logarithmic3D, _super);
        function Logarithmic3D(chart) {
            return _super.call(this, chart) || this;
        }
        Logarithmic3D.prototype.calculateRangeAndInterval = function (size, axis) {
            this.calculateRange(axis);
            this.getActualRange(axis, size);
            this.calculateVisibleRange(size, axis);
            this.calculateVisibleLabels(axis, this.chart);
        };
        Logarithmic3D.prototype.getActualRange = function (axis, size) {
            this.initializeDoubleRange(axis);
            this.min = this.min < 0 ? 0 : this.min;
            var logStart = helper_2.logBase(this.min, axis.logBase);
            logStart = isFinite(logStart) ? logStart : this.min;
            var logEnd = this.max === 1 ? 1 : helper_2.logBase(this.max, axis.logBase);
            logEnd = isFinite(logStart) ? logEnd : this.max;
            this.min = Math.floor(logStart / 1);
            var isRectSeries = axis.series && axis.series.some(function (item) {
                return (item.type.indexOf('Column') !== -1 || item.type.indexOf('Bar') !== -1);
            });
            Eif (isRectSeries) {
                this.min = (this.min <= 0) ? (+this.min - 1) : this.min;
            }
            this.max = Math.ceil(logEnd / 1);
            this.max = this.max === this.min ? this.max + 1 : this.max;
            axis.actualRange.interval = axis.interval || this.calculateLogNiceInterval(this.max - this.min, size, axis);
            axis.actualRange.min = this.min;
            axis.actualRange.max = this.max;
            axis.actualRange.delta = this.max - this.min;
        };
        Logarithmic3D.prototype.calculateVisibleRange = function (size, axis) {
            axis.visibleRange = {
                interval: axis.actualRange.interval, max: axis.actualRange.max,
                min: axis.actualRange.min, delta: axis.actualRange.delta
            };
        };
        Logarithmic3D.prototype.calculateLogNiceInterval = function (delta, size, axis) {
            var actualDesiredIntervalsCount = helper_1.getActualDesiredIntervalsCount(size, axis);
            var niceInterval = delta;
            var minInterval = Math.pow(axis.logBase, Math.floor(helper_2.logBase(niceInterval, 10)));
            for (var j = 0, len = axis.intervalDivs.length; j < len; j++) {
                var currentInterval = minInterval * axis.intervalDivs[j];
                Iif (actualDesiredIntervalsCount < (delta / currentInterval)) {
                    break;
                }
                niceInterval = currentInterval;
            }
            return niceInterval;
        };
        Logarithmic3D.prototype.calculateVisibleLabels = function (axis, chart) {
            var tempInterval = axis.visibleRange.min;
            axis.visibleLabels = [];
            var labelStyle;
            var value;
            var axisFormat = this.getFormat(axis);
            var isCustomFormat = axisFormat.match('{value}') !== null;
            var startValue = Math.pow(axis.logBase, axis.visibleRange.min);
            axis.format = chart.intl.getNumberFormat({
                format: isCustomFormat ? '' : axisFormat,
                useGrouping: chart.useGroupingSeparator,
                maximumFractionDigits: startValue < 1 ? 20 : 3
            });
            axis.startLabel = axis.format(startValue < 1 ? +startValue.toPrecision(1) : startValue);
            axis.endLabel = axis.format(Math.pow(axis.logBase, 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));
                Eif (helper_2.withIn(tempInterval, axis.visibleRange)) {
                    value = Math.pow(axis.logBase, tempInterval);
                    helper_1.triggerLabelRender(this.chart, tempInterval, this.formatValue(axis, isCustomFormat, axisFormat, value < 1 ? +value.toPrecision(1) : value), labelStyle, axis);
                }
            }
            Eif (axis.getMaxLabelWidth) {
                axis.getMaxLabelWidth(this.chart);
            }
        };
        Logarithmic3D.prototype.getModuleName = function () {
            return 'Logarithmic3D';
        };
        Logarithmic3D.prototype.destroy = function () {
        };
        return Logarithmic3D;
    }(double_axis_1.Double3D));
    exports.Logarithmic3D = Logarithmic3D;
});