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 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 35× 1× 104× 104× 104× 104× 104× 1× 104× 104× 104× 32× 72× 104× 104× 462× 380× 374× 104× 104× 1× 462× 462× 104× 358× 120× 120× 104× 104× 106× 106× 10× 10× 10× 10× 8× 8× 462× 1× 20665× 1× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var 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 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"], function (require, exports, category_axis_1, helper_1, helper_2) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var DateTimeCategory = (function (_super) { __extends(DateTimeCategory, _super); function DateTimeCategory(chart) { return _super.call(this, chart) || this; } DateTimeCategory.prototype.calculateRangeAndInterval = function (size, axis) { this.axisSize = size; this.calculateRange(axis, size); this.getActualRange(axis, size); this.applyRangePadding(axis, size); this.calculateVisibleLabels(axis); }; DateTimeCategory.prototype.calculateVisibleLabels = function (axis) { axis.visibleLabels = []; var padding = axis.labelPlacement === 'BetweenTicks' ? 0.5 : 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) }); for (var i = 0; i < axis.labels.length; i++) { if (!this.sameInterval(axis.labels.map(Number)[i], axis.labels.map(Number)[i - 1], axis.actualIntervalType, i)) { if (helper_2.withIn(i - padding, axis.visibleRange)) { helper_1.triggerLabelRender(this.chart, i, axis.format(new Date(axis.labels.map(Number)[i])), axis.labelStyle, axis); } } } Eif (axis.getMaxLabelWidth) { axis.getMaxLabelWidth(this.chart); } }; DateTimeCategory.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; }; DateTimeCategory.prototype.getModuleName = function () { return 'DateTimeCategory'; }; DateTimeCategory.prototype.destroy = function (chart) { }; return DateTimeCategory; }(category_axis_1.Category)); exports.DateTimeCategory = DateTimeCategory; }); |