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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 112× 1× 208× 208× 208× 208× 208× 1× 238× 238× 238× 238× 238× 238× 238× 14548× 238× 100× 138× 238× 238× 238× 238× 14974× 14974× 14396× 3140× 227× 227× 11256× 289× 202× 202× 578× 480× 474× 238× 238× 238× 208× 1× 232× 232× 1× 1× 11836× 11836× 143× 11693× 11330× 11330× 32× 32× 110× 110× 6× 6× 181× 181× 13× 13× 13× 13× 8× 8× 11836× 1× 3098× 12× 3086× 3086× 3086× 2775× 2775× 2775× 2775× 2775× 311× 3086× 1× 3360× 25× 3335× 3335× 3335× 3335× 1× 42339× 1× 1× 1× | /* 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 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); this.getActualRange(axis, size); this.applyRangePadding(axis, size); this.calculateVisibleLabels(axis); }; DateTimeCategory.prototype.calculateVisibleLabels = function (axis) { axis.visibleLabels = []; var labelStyle; var padding = axis.labelPlacement === 'BetweenTicks' ? 0.5 : 0; var previousIndex = 0; var isRangeNavigator = this.chart.getModuleName() === 'rangeNavigator'; this.axisSize = isRangeNavigator ? this.chart.availableSize : this.axisSize; if (isRangeNavigator || this.chart.stockChart) { axis.labels.sort(function (a, b) { return Number(a) - Number(b); }); } 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 || this.blazorCustomFormat(axis), type: helper_2.firstToLowerCase(axis.skeletonType), skeleton: this.getSkeleton(axis, null, null, this.chart.isBlazor) }); var i = (!isRangeNavigator && this.chart.stockChart) ? 1 : 0; var interval = axis.interval ? axis.interval : 1; for (; i < axis.labels.length; i += interval) { labelStyle = (ej2_base_1.extend({}, ej2_base_1.getValue('properties', axis.labelStyle), null, true)); if (this.chart.stockChart || isRangeNavigator) { if (axis.intervalType === 'Auto') { if ((((!isRangeNavigator && i === 1) || this.StartOfWeek(axis.labels.map(Number)[i], axis.labels.map(Number)[i - 1], axis, i, previousIndex)) || axis.isIndexed) && helper_2.withIn(i, 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); previousIndex = i; } } else if ((((!isRangeNavigator && i === 1) || !this.sameInterval(axis.labels.map(Number)[i], axis.labels.map(Number)[i - 1], axis.actualIntervalType, i)) || axis.isIndexed) && helper_2.withIn(i, axis.visibleRange)) { if ((!isRangeNavigator && i === 1) || this.isMaximum(i, previousIndex, axis)) { 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); previousIndex = i; } } } else { if (!this.sameInterval(axis.labels.map(Number)[i], axis.labels.map(Number)[i - 1], axis.actualIntervalType, i) || axis.isIndexed) { if (helper_2.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); } } } } axis.startLabel = axis.visibleLabels[0] ? axis.visibleLabels[0].text : ''; axis.endLabel = axis.visibleLabels[axis.visibleLabels.length - 1] ? axis.visibleLabels[axis.visibleLabels.length - 1].text : ''; if (axis.getMaxLabelWidth) { axis.getMaxLabelWidth(this.chart); } }; DateTimeCategory.prototype.blazorCustomFormat = function (axis) { Iif (this.chart.isBlazor && axis.actualIntervalType === 'Years') { return 'yyyy'; } else { return ''; } }; DateTimeCategory.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(', '); }; 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 'Quarter': sameValue = new Date(currentDate).getFullYear() === new Date(previousDate).getFullYear() && Math.floor(new Date(currentDate).getMonth() / 3) === Math.floor(new Date(previousDate).getMonth() / 3); break; case 'Months': sameValue = new Date(currentDate).getFullYear() === new Date(previousDate).getFullYear() && new Date(currentDate).getMonth() === new Date(previousDate).getMonth(); break; case 'Weeks': sameValue = new Date(currentDate).getFullYear() === new Date(previousDate).getFullYear() && new Date(currentDate).getMonth() === new Date(previousDate).getMonth() && Math.floor((new Date(currentDate).getDate() - 1) / 7) === Math.floor((new Date(previousDate).getDate() - 1) / 7); 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.StartOfWeek = function (currentDate, previousDate, axis, index, previousIndex) { if (index === 0) { return true; } var isMonday = false; var labelsCount = 30; if (axis.labels.length >= labelsCount) { var previousDay = new Date(previousDate); var currentday = new Date(currentDate); previousDay.setDate(previousDay.getDate() - previousDay.getDay()); currentday.setDate(currentday.getDate() - currentday.getDay()); isMonday = !(previousDay.getTime() === currentday.getTime()) && this.isMaximum(index, previousIndex, axis); } else { isMonday = this.isMaximum(index, previousIndex, axis); } return isMonday; }; DateTimeCategory.prototype.isMaximum = function (index, previousIndex, axis) { if (index === 0) { return true; } var axisLabelMaximumLength = 100; var pointX = helper_1.valueToCoefficient(index, axis) * axis.rect.width; var previousPointX = helper_1.valueToCoefficient(previousIndex, axis) * axis.rect.width; return (pointX - previousPointX >= (axis.labels.length >= 15 ? axisLabelMaximumLength : axisLabelMaximumLength / 2)); }; DateTimeCategory.prototype.getModuleName = function () { return 'DateTimeCategory'; }; DateTimeCategory.prototype.destroy = function () { }; return DateTimeCategory; }(category_axis_1.Category)); exports.DateTimeCategory = DateTimeCategory; }); |