all files / chart3d/axis/ date-time-category-axis.js

94.2% Statements 65/69
88.89% Branches 40/45
93.33% Functions 14/15
93.94% Lines 62/66
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          32×   66× 66× 66× 66× 66×   66× 66× 66× 66× 36×     30×   66×       66× 66× 244× 244×   204× 130×         66× 66×                 244× 244× 34×     210×   40× 40×   18×   18×   38×   38×   38×   38×   38×   38×   38×   38×     244×   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/category-axis", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-base"], function (require, exports, category_axis_1, helper_1, helper_2, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DateTimeCategory3D = (function (_super) {
        __extends(DateTimeCategory3D, _super);
        function DateTimeCategory3D(chart) {
            return _super.call(this, chart) || this;
        }
        DateTimeCategory3D.prototype.calculateRangeAndInterval = function (size, axis) {
            this.axisSize = size;
            this.calculateRange(axis);
            this.getActualRange(axis, size);
            this.applyRangePadding(axis, size);
            this.calculateVisibleLabels(axis);
        };
        DateTimeCategory3D.prototype.calculateVisibleLabels = function (axis) {
            axis.visibleLabels = [];
            var labelStyle;
            var padding = 0;
            if (axis.intervalType === 'Auto') {
                this.calculateDateTimeNiceInterval(axis, this.axisSize, parseInt(axis.labels[0], 10), parseInt(axis.labels[axis.labels.length - 1], 10));
            }
            else {
                axis.actualIntervalType = axis.intervalType;
            }
            axis.format = this.chart.intl.getDateFormat({
                format: axis.labelFormat || '', type: helper_2.firstToLowerCase(axis.skeletonType),
                skeleton: this.getSkeleton(axis)
            });
            var i = 0;
            for (; i < axis.labels.length; i++) {
                labelStyle = (ej2_base_1.extend({}, ej2_base_1.getValue('properties', axis.labelStyle), null, true));
                if (!this.sameInterval(axis.labels.map(Number)[i], axis.labels.map(Number)[i - 1], axis.actualIntervalType, i)
                    || axis.isIndexed) {
                    if (helper_1.withIn(i - padding, axis.visibleRange)) {
                        helper_1.triggerLabelRender(this.chart, i, (axis.isIndexed ? this.getIndexedAxisLabel(axis.labels[i], axis.format) :
                            axis.format(new Date(axis.labels.map(Number)[i]))), labelStyle, axis);
                    }
                }
            }
            Eif (axis.getMaxLabelWidth) {
                axis.getMaxLabelWidth(this.chart);
            }
        };
        DateTimeCategory3D.prototype.getIndexedAxisLabel = function (value, format) {
            var texts = value.split(',');
            for (var i = 0; i < texts.length; i++) {
                texts[i] = format(new Date(parseInt(texts[i], 10)));
            }
            return texts.join(', ');
        };
        DateTimeCategory3D.prototype.sameInterval = function (currentDate, previousDate, type, index) {
            var sameValue;
            if (index === 0) {
                sameValue = false;
            }
            else {
                switch (type) {
                    case 'Years':
                        sameValue = new Date(currentDate).getFullYear() === new Date(previousDate).getFullYear();
                        break;
                    case 'Months':
                        sameValue = new Date(currentDate).getFullYear() === new Date(previousDate).getFullYear() &&
                            new Date(currentDate).getMonth() === new Date(previousDate).getMonth();
                        break;
                    case 'Days':
                        sameValue = (Math.abs(currentDate - previousDate) < 24 * 60 * 60 * 1000 &&
                            new Date(currentDate).getDay() === new Date(previousDate).getDay());
                        break;
                    case 'Hours':
                        sameValue = (Math.abs(currentDate - previousDate) < 60 * 60 * 1000 &&
                            new Date(currentDate).getDay() === new Date(previousDate).getDay());
                        break;
                    case 'Minutes':
                        sameValue = (Math.abs(currentDate - previousDate) < 60 * 1000 &&
                            new Date(currentDate).getMinutes() === new Date(previousDate).getMinutes());
                        break;
                    case 'Seconds':
                        sameValue = (Math.abs(currentDate - previousDate) < 1000 &&
                            new Date(currentDate).getDay() === new Date(previousDate).getDay());
                        break;
                }
            }
            return sameValue;
        };
        DateTimeCategory3D.prototype.getModuleName = function () {
            return 'DateTimeCategory3D';
        };
        DateTimeCategory3D.prototype.destroy = function () {
        };
        return DateTimeCategory3D;
    }(category_axis_1.Category3D));
    exports.DateTimeCategory3D = DateTimeCategory3D;
});