1 |
|
2 |
|
3 |
|
4 | import { __assign, __extends } from "tslib";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import { ValueAxis, ValueAxisDataItem } from "./ValueAxis";
|
12 | import { List } from "../../core/utils/List";
|
13 | import { Dictionary } from "../../core/utils/Dictionary";
|
14 | import { DateAxisBreak } from "./DateAxisBreak";
|
15 | import { registry } from "../../core/Registry";
|
16 | import * as $time from "../../core/utils/Time";
|
17 | import * as $type from "../../core/utils/Type";
|
18 | import * as $iter from "../../core/utils/Iterator";
|
19 | import * as $math from "../../core/utils/Math";
|
20 | import * as $array from "../../core/utils/Array";
|
21 | import * as $object from "../../core/utils/Object";
|
22 | import * as $utils from "../../core/utils/Utils";
|
23 | import { OrderedListTemplate } from "../../core/utils/SortedList";
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | var DateAxisDataItem = (function (_super) {
|
36 | __extends(DateAxisDataItem, _super);
|
37 | |
38 |
|
39 |
|
40 | function DateAxisDataItem() {
|
41 | var _this = _super.call(this) || this;
|
42 | _this.className = "DateAxisDataItem";
|
43 | _this.applyTheme();
|
44 | _this.values.date = {};
|
45 | _this.values.endDate = {};
|
46 | return _this;
|
47 | }
|
48 | Object.defineProperty(DateAxisDataItem.prototype, "date", {
|
49 | |
50 |
|
51 |
|
52 | get: function () {
|
53 | return this.dates["date"];
|
54 | },
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 | set: function (date) {
|
61 | this.setDate("date", date);
|
62 | this.value = date.getTime();
|
63 | },
|
64 | enumerable: true,
|
65 | configurable: true
|
66 | });
|
67 | Object.defineProperty(DateAxisDataItem.prototype, "endDate", {
|
68 | |
69 |
|
70 |
|
71 | get: function () {
|
72 | return this.dates["endDate"];
|
73 | },
|
74 | |
75 |
|
76 |
|
77 |
|
78 |
|
79 | set: function (date) {
|
80 | this.setDate("endDate", date);
|
81 | this.endValue = date.getTime();
|
82 | },
|
83 | enumerable: true,
|
84 | configurable: true
|
85 | });
|
86 | return DateAxisDataItem;
|
87 | }(ValueAxisDataItem));
|
88 | export { DateAxisDataItem };
|
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 | var DateAxis = (function (_super) {
|
127 | __extends(DateAxis, _super);
|
128 | |
129 |
|
130 |
|
131 | function DateAxis() {
|
132 | var _this =
|
133 |
|
134 | _super.call(this) || this;
|
135 | _this._gapBreaks = false;
|
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 |
|
184 |
|
185 | _this.gridIntervals = new List();
|
186 | |
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | _this.groupIntervals = new List();
|
221 | |
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 | _this.dateFormats = new Dictionary();
|
248 | |
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | _this.periodChangeDateFormats = new Dictionary();
|
268 | |
269 |
|
270 |
|
271 | _this._baseIntervalReal = { timeUnit: "day", count: 1 };
|
272 | |
273 |
|
274 | _this._prevSeriesTime = {};
|
275 | |
276 |
|
277 |
|
278 |
|
279 |
|
280 | _this._minDifference = {};
|
281 | |
282 |
|
283 |
|
284 | _this._firstWeekDay = 1;
|
285 | |
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | _this.groupMin = {};
|
293 | |
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | _this.groupMax = {};
|
301 | _this.className = "DateAxis";
|
302 | _this.setPropertyValue("markUnitChange", true);
|
303 | _this.snapTooltip = true;
|
304 | _this.tooltipPosition = "pointer";
|
305 | _this.setPropertyValue("groupData", false);
|
306 | _this.groupCount = 200;
|
307 | _this.events.on("parentset", _this.getDFFormatter, _this, false);
|
308 |
|
309 |
|
310 |
|
311 | _this.gridIntervals.pushAll([
|
312 | { timeUnit: "millisecond", count: 1 },
|
313 | { timeUnit: "millisecond", count: 5 },
|
314 | { timeUnit: "millisecond", count: 10 },
|
315 | { timeUnit: "millisecond", count: 50 },
|
316 | { timeUnit: "millisecond", count: 100 },
|
317 | { timeUnit: "millisecond", count: 500 },
|
318 | { timeUnit: "second", count: 1 },
|
319 | { timeUnit: "second", count: 5 },
|
320 | { timeUnit: "second", count: 10 },
|
321 | { timeUnit: "second", count: 30 },
|
322 | { timeUnit: "minute", count: 1 },
|
323 | { timeUnit: "minute", count: 5 },
|
324 | { timeUnit: "minute", count: 10 },
|
325 | { timeUnit: "minute", count: 15 },
|
326 | { timeUnit: "minute", count: 30 },
|
327 | { timeUnit: "hour", count: 1 },
|
328 | { timeUnit: "hour", count: 3 },
|
329 | { timeUnit: "hour", count: 6 },
|
330 | { timeUnit: "hour", count: 12 },
|
331 | { timeUnit: "day", count: 1 },
|
332 | { timeUnit: "day", count: 2 },
|
333 | { timeUnit: "day", count: 3 },
|
334 | { timeUnit: "day", count: 4 },
|
335 | { timeUnit: "day", count: 5 },
|
336 | { timeUnit: "week", count: 1 },
|
337 | { timeUnit: "month", count: 1 },
|
338 | { timeUnit: "month", count: 2 },
|
339 | { timeUnit: "month", count: 3 },
|
340 | { timeUnit: "month", count: 6 },
|
341 | { timeUnit: "year", count: 1 },
|
342 | { timeUnit: "year", count: 2 },
|
343 | { timeUnit: "year", count: 5 },
|
344 | { timeUnit: "year", count: 10 },
|
345 | { timeUnit: "year", count: 50 },
|
346 | { timeUnit: "year", count: 100 },
|
347 | { timeUnit: "year", count: 200 },
|
348 | { timeUnit: "year", count: 500 },
|
349 | { timeUnit: "year", count: 1000 },
|
350 | { timeUnit: "year", count: 2000 },
|
351 | { timeUnit: "year", count: 5000 },
|
352 | { timeUnit: "year", count: 10000 },
|
353 | { timeUnit: "year", count: 100000 }
|
354 | ]);
|
355 | _this.groupIntervals.pushAll([
|
356 | { timeUnit: "millisecond", count: 1 },
|
357 | { timeUnit: "millisecond", count: 10 },
|
358 | { timeUnit: "millisecond", count: 100 },
|
359 | { timeUnit: "second", count: 1 },
|
360 | { timeUnit: "second", count: 10 },
|
361 | { timeUnit: "minute", count: 1 },
|
362 | { timeUnit: "minute", count: 10 },
|
363 | { timeUnit: "hour", count: 1 },
|
364 | { timeUnit: "day", count: 1 },
|
365 | { timeUnit: "week", count: 1 },
|
366 | { timeUnit: "month", count: 1 },
|
367 | { timeUnit: "year", count: 1 }
|
368 | ]);
|
369 |
|
370 | _this.axisFieldName = "date";
|
371 |
|
372 | _this.applyTheme();
|
373 | return _this;
|
374 | }
|
375 | |
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 | DateAxis.prototype.fillRule = function (dataItem) {
|
385 | var value = dataItem.value;
|
386 | var axis = dataItem.component;
|
387 | var gridInterval = axis._gridInterval;
|
388 | var gridDuration = $time.getDuration(gridInterval.timeUnit, gridInterval.count);
|
389 | if (Math.round((value - axis.min) / gridDuration) / 2 == Math.round(Math.round((value - axis.min) / gridDuration) / 2)) {
|
390 | dataItem.axisFill.__disabled = true;
|
391 | }
|
392 | else {
|
393 | dataItem.axisFill.__disabled = false;
|
394 | }
|
395 | };
|
396 | |
397 |
|
398 |
|
399 |
|
400 | DateAxis.prototype.applyInternalDefaults = function () {
|
401 | _super.prototype.applyInternalDefaults.call(this);
|
402 |
|
403 | if (!this.dateFormats.hasKey("millisecond")) {
|
404 | this.dateFormats.setKey("millisecond", this.language.translate("_date_millisecond"));
|
405 | }
|
406 | if (!this.dateFormats.hasKey("second")) {
|
407 | this.dateFormats.setKey("second", this.language.translate("_date_second"));
|
408 | }
|
409 | if (!this.dateFormats.hasKey("minute")) {
|
410 | this.dateFormats.setKey("minute", this.language.translate("_date_minute"));
|
411 | }
|
412 | if (!this.dateFormats.hasKey("hour")) {
|
413 | this.dateFormats.setKey("hour", this.language.translate("_date_hour"));
|
414 | }
|
415 | if (!this.dateFormats.hasKey("day")) {
|
416 | this.dateFormats.setKey("day", this.language.translate("_date_day"));
|
417 | }
|
418 | if (!this.dateFormats.hasKey("week")) {
|
419 | this.dateFormats.setKey("week", this.language.translate("_date_day"));
|
420 | }
|
421 | if (!this.dateFormats.hasKey("month")) {
|
422 | this.dateFormats.setKey("month", this.language.translate("_date_month"));
|
423 | }
|
424 | if (!this.dateFormats.hasKey("year")) {
|
425 | this.dateFormats.setKey("year", this.language.translate("_date_year"));
|
426 | }
|
427 | if (!this.periodChangeDateFormats.hasKey("millisecond")) {
|
428 | this.periodChangeDateFormats.setKey("millisecond", this.language.translate("_date_millisecond"));
|
429 | }
|
430 | if (!this.periodChangeDateFormats.hasKey("second")) {
|
431 | this.periodChangeDateFormats.setKey("second", this.language.translate("_date_second"));
|
432 | }
|
433 | if (!this.periodChangeDateFormats.hasKey("minute")) {
|
434 | this.periodChangeDateFormats.setKey("minute", this.language.translate("_date_minute"));
|
435 | }
|
436 | if (!this.periodChangeDateFormats.hasKey("hour")) {
|
437 | this.periodChangeDateFormats.setKey("hour", this.language.translate("_date_day"));
|
438 | }
|
439 | if (!this.periodChangeDateFormats.hasKey("day")) {
|
440 | this.periodChangeDateFormats.setKey("day", this.language.translate("_date_day"));
|
441 | }
|
442 | if (!this.periodChangeDateFormats.hasKey("week")) {
|
443 | this.periodChangeDateFormats.setKey("week", this.language.translate("_date_day"));
|
444 | }
|
445 | if (!this.periodChangeDateFormats.hasKey("month")) {
|
446 | this.periodChangeDateFormats.setKey("month", this.language.translate("_date_month") + " " + this.language.translate("_date_year"));
|
447 | }
|
448 | };
|
449 | |
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | DateAxis.prototype.createDataItem = function () {
|
456 | return new DateAxisDataItem();
|
457 | };
|
458 | |
459 |
|
460 |
|
461 |
|
462 |
|
463 | DateAxis.prototype.createAxisBreak = function () {
|
464 | return new DateAxisBreak();
|
465 | };
|
466 | |
467 |
|
468 |
|
469 |
|
470 |
|
471 | DateAxis.prototype.validateDataItems = function () {
|
472 |
|
473 | var start = this.start;
|
474 | var end = this.end;
|
475 | var baseDuration = this.baseDuration;
|
476 | var periodCount = (this.max - this.min) / baseDuration;
|
477 | this._firstWeekDay = this.getFirstWeekDay();
|
478 | this.getDFFormatter();
|
479 | _super.prototype.validateDataItems.call(this);
|
480 | var mainBaseDuration = $time.getDuration(this.mainBaseInterval.timeUnit, this.mainBaseInterval.count);
|
481 | this.maxZoomFactor = Math.max(1, (this.max - this.min) / mainBaseDuration);
|
482 | this._deltaMinMax = this.baseDuration / 2;
|
483 |
|
484 | var newPeriodCount = (this.max - this.min) / baseDuration;
|
485 | start = start + (end - start) * (1 - periodCount / newPeriodCount);
|
486 | this.zoom({ start: start, end: end }, false, true);
|
487 | };
|
488 | |
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 | DateAxis.prototype.handleSelectionExtremesChange = function () {
|
495 | };
|
496 | |
497 |
|
498 |
|
499 |
|
500 |
|
501 | DateAxis.prototype.calculateZoom = function () {
|
502 | var _this = this;
|
503 | _super.prototype.calculateZoom.call(this);
|
504 | var difference = this.adjustDifference(this._minZoomed, this._maxZoomed);
|
505 | var dataSetChanged = false;
|
506 |
|
507 | if (this.groupData && $type.hasValue(difference)) {
|
508 | var mainBaseInterval = this.mainBaseInterval;
|
509 | var modifiedDifference = difference + (this.startLocation + (1 - this.endLocation)) * this.baseDuration;
|
510 | var groupInterval = void 0;
|
511 | if (this.groupInterval) {
|
512 | groupInterval = __assign({}, this.groupInterval);
|
513 | }
|
514 | else {
|
515 | groupInterval = this.chooseInterval(0, modifiedDifference, this.groupCount, this.groupIntervals);
|
516 | if ($time.getDuration(groupInterval.timeUnit, groupInterval.count) < $time.getDuration(mainBaseInterval.timeUnit, mainBaseInterval.count)) {
|
517 | groupInterval = __assign({}, mainBaseInterval);
|
518 | }
|
519 | }
|
520 | this._groupInterval = groupInterval;
|
521 | var newId = groupInterval.timeUnit + groupInterval.count;
|
522 | if (this._currentDataSetId != newId) {
|
523 | this._currentDataSetId = newId;
|
524 | this.dispatch("groupperiodchanged");
|
525 | }
|
526 | this.series.each(function (series) {
|
527 | if (series.baseAxis == _this) {
|
528 | if (series.setDataSet(_this._currentDataSetId)) {
|
529 | dataSetChanged = true;
|
530 | }
|
531 | }
|
532 | });
|
533 | }
|
534 | var gridInterval = this.chooseInterval(0, difference, this._gridCount);
|
535 | if ($time.getDuration(gridInterval.timeUnit, gridInterval.count) < this.baseDuration) {
|
536 | gridInterval = __assign({}, this.baseInterval);
|
537 | }
|
538 | this._gridInterval = gridInterval;
|
539 | this._nextGridUnit = $time.getNextUnit(gridInterval.timeUnit);
|
540 |
|
541 | this._intervalDuration = $time.getDuration(gridInterval.timeUnit, gridInterval.count);
|
542 | this._gridDate = $time.round(new Date(this.minZoomed - $time.getDuration(gridInterval.timeUnit, gridInterval.count)), gridInterval.timeUnit, gridInterval.count, this._firstWeekDay, this._df.utc, new Date(this.min), this._df.timezoneMinutes, this._df.timezone);
|
543 |
|
544 | $iter.each(this.series.iterator(), function (series) {
|
545 | if (series.baseAxis == _this) {
|
546 | var field_1 = series.getAxisField(_this);
|
547 | var minZoomed = $time.round(new Date(_this._minZoomed + _this.baseDuration * 0.05), _this.baseInterval.timeUnit, _this.baseInterval.count, _this._firstWeekDay, _this._df.utc, undefined, _this._df.timezoneMinutes, _this._df.timezone).getTime();
|
548 | var minZoomedStr = minZoomed.toString();
|
549 | var startDataItem = series.dataItemsByAxis.getKey(_this.uid).getKey(minZoomedStr + series.currentDataSetId);
|
550 | var startIndex = 0;
|
551 | if (_this.start != 0) {
|
552 | if (startDataItem) {
|
553 | startDataItem = _this.findFirst(startDataItem, minZoomed, field_1);
|
554 | startIndex = startDataItem.index;
|
555 | }
|
556 | else {
|
557 | startIndex = series.dataItems.findClosestIndex(_this._minZoomed, function (x) { return x[field_1]; }, "left");
|
558 | }
|
559 | }
|
560 |
|
561 | var baseInterval = _this.baseInterval;
|
562 | var maxZoomed = $time.add($time.round(new Date(_this._maxZoomed), baseInterval.timeUnit, baseInterval.count, _this._firstWeekDay, _this._df.utc, undefined, _this._df.timezoneMinutes, _this._df.timezone), baseInterval.timeUnit, baseInterval.count, _this._df.utc).getTime();
|
563 | var maxZoomedStr = maxZoomed.toString();
|
564 | var endDataItem = series.dataItemsByAxis.getKey(_this.uid).getKey(maxZoomedStr + series.currentDataSetId);
|
565 | var endIndex = series.dataItems.length;
|
566 | if (_this.end != 1) {
|
567 | if (endDataItem) {
|
568 | endIndex = endDataItem.index;
|
569 | }
|
570 | else {
|
571 | maxZoomed -= 1;
|
572 | endIndex = series.dataItems.findClosestIndex(maxZoomed, function (x) { return x[field_1]; }, "right");
|
573 |
|
574 |
|
575 | endIndex++;
|
576 |
|
577 | }
|
578 | }
|
579 | if (series.max(_this) < minZoomed) {
|
580 | series.startIndex = series.dataItems.length;
|
581 | series.endIndex = series.dataItems.length;
|
582 | series.outOfRange = true;
|
583 | }
|
584 | else if (series.min(_this) > maxZoomed) {
|
585 | series.startIndex = 0;
|
586 | series.endIndex = 0;
|
587 | series.outOfRange = true;
|
588 | }
|
589 | else {
|
590 | series.outOfRange = false;
|
591 | series.startIndex = startIndex;
|
592 | series.endIndex = endIndex;
|
593 | }
|
594 |
|
595 | if (!dataSetChanged && series.dataRangeInvalid) {
|
596 | series.validateDataRange();
|
597 | }
|
598 | }
|
599 | });
|
600 | };
|
601 | DateAxis.prototype.findFirst = function (dataItem, time, key) {
|
602 | var index = dataItem.index;
|
603 | if (index > 0) {
|
604 | var series = dataItem.component;
|
605 | var previousDataItem = series.dataItems.getIndex(index - 1);
|
606 | var previousDate = previousDataItem[key];
|
607 | if (!previousDate || previousDate.getTime() < time) {
|
608 | return dataItem;
|
609 | }
|
610 | else {
|
611 | return this.findFirst(previousDataItem, time, key);
|
612 | }
|
613 | }
|
614 | else {
|
615 | return dataItem;
|
616 | }
|
617 | };
|
618 | |
619 |
|
620 |
|
621 |
|
622 |
|
623 | DateAxis.prototype.validateData = function () {
|
624 | _super.prototype.validateData.call(this);
|
625 | if (!$type.isNumber(this.baseInterval.count)) {
|
626 | this.baseInterval.count = 1;
|
627 | }
|
628 | };
|
629 | Object.defineProperty(DateAxis.prototype, "minDifference", {
|
630 | |
631 |
|
632 |
|
633 | get: function () {
|
634 | var _this = this;
|
635 | var minDifference = Number.MAX_VALUE;
|
636 | this.series.each(function (series) {
|
637 | if (minDifference > _this._minDifference[series.uid]) {
|
638 | minDifference = _this._minDifference[series.uid];
|
639 | }
|
640 | });
|
641 | if (minDifference == Number.MAX_VALUE || minDifference == 0) {
|
642 | minDifference = $time.getDuration("day");
|
643 | }
|
644 | return minDifference;
|
645 | },
|
646 | enumerable: true,
|
647 | configurable: true
|
648 | });
|
649 | |
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 | DateAxis.prototype.seriesDataChangeUpdate = function (series) {
|
657 | this._minDifference[series.uid] = Number.MAX_VALUE;
|
658 | };
|
659 | |
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 | DateAxis.prototype.postProcessSeriesDataItems = function (series) {
|
666 | var _this = this;
|
667 | this._firstWeekDay = this.getFirstWeekDay();
|
668 | if (series) {
|
669 | this.seriesGroupUpdate(series);
|
670 | }
|
671 | else {
|
672 | this.series.each(function (series) {
|
673 | _this.seriesGroupUpdate(series);
|
674 | });
|
675 | }
|
676 | this.addEmptyUnitsBreaks();
|
677 | };
|
678 | DateAxis.prototype.seriesGroupUpdate = function (series) {
|
679 | var _this = this;
|
680 | if (JSON.stringify(series._baseInterval[this.uid]) != JSON.stringify(this.mainBaseInterval)) {
|
681 | series._baseInterval[this.uid] = this.mainBaseInterval;
|
682 | series.mainDataSet.each(function (dataItem) {
|
683 | _this.postProcessSeriesDataItem(dataItem);
|
684 | });
|
685 | if (this.groupData) {
|
686 | this.groupSeriesData(series);
|
687 | }
|
688 | }
|
689 | };
|
690 | |
691 |
|
692 |
|
693 |
|
694 |
|
695 |
|
696 | DateAxis.prototype.groupSeriesData = function (series) {
|
697 | var _this = this;
|
698 | if (series.baseAxis == this && series.dataItems.length > 0 && !series.dataGrouped) {
|
699 | series.bulletsContainer.removeChildren();
|
700 |
|
701 | var intervals_1 = [];
|
702 | var mainBaseInterval = this.mainBaseInterval;
|
703 | var mainIntervalDuration_1 = $time.getDuration(mainBaseInterval.timeUnit, mainBaseInterval.count);
|
704 | this.groupIntervals.each(function (interval) {
|
705 | var intervalDuration = $time.getDuration(interval.timeUnit, interval.count);
|
706 | if ((intervalDuration > mainIntervalDuration_1 && intervalDuration < (_this.max - _this.min)) || _this.groupInterval) {
|
707 | intervals_1.push(interval);
|
708 | }
|
709 | });
|
710 | if (series._dataSets) {
|
711 | series._dataSets.each(function (key, dataItems) {
|
712 | dataItems.each(function (dataItem) {
|
713 | dataItem.dispose();
|
714 | });
|
715 | dataItems.clear();
|
716 | });
|
717 | series._dataSets.clear();
|
718 | }
|
719 | series.dataGrouped = true;
|
720 | $array.each(intervals_1, function (interval) {
|
721 |
|
722 | var key = "date" + _this.axisLetter;
|
723 |
|
724 | var dataSetId = interval.timeUnit + interval.count;
|
725 |
|
726 | var dataSet = new OrderedListTemplate(series.mainDataSet.template.clone());
|
727 | series.dataSets.setKey(dataSetId, dataSet);
|
728 | var dataItems = series.mainDataSet;
|
729 | var previousTime = Number.NEGATIVE_INFINITY;
|
730 | var i = 0;
|
731 | var newDataItem;
|
732 | var dataFields = [];
|
733 | $object.each(series.dataFields, function (dfkey, df) {
|
734 | var dfk = dfkey;
|
735 | if (dfk != key && dfk.indexOf("Show") == -1) {
|
736 | dataFields.push(dfk);
|
737 | }
|
738 | });
|
739 | var roundedDate;
|
740 | dataItems.each(function (dataItem) {
|
741 | var date = dataItem.getDate(key);
|
742 | if (date) {
|
743 | var time = date.getTime();
|
744 | roundedDate = $time.round(new Date(time), interval.timeUnit, interval.count, _this._df.firstDayOfWeek, _this._df.utc, undefined, _this._df.timezoneMinutes, _this._df.timezone);
|
745 | var currentTime = roundedDate.getTime();
|
746 |
|
747 | if (previousTime < currentTime) {
|
748 | if (newDataItem && series._adapterO) {
|
749 | $array.each(dataFields, function (vkey) {
|
750 | newDataItem.values[vkey].value = series._adapterO.apply("groupDataItem", {
|
751 | dataItem: newDataItem,
|
752 | interval: interval,
|
753 | dataField: vkey,
|
754 | date: roundedDate,
|
755 | value: newDataItem.values[vkey].value
|
756 | }).value;
|
757 | newDataItem.values[vkey].workingValue = newDataItem.values[vkey].value;
|
758 | });
|
759 | }
|
760 | newDataItem = dataSet.create();
|
761 | newDataItem.dataContext = {};
|
762 | newDataItem.setWorkingLocation("dateX", series.dataItems.template.locations.dateX, 0);
|
763 | newDataItem.setWorkingLocation("openDateX", series.dataItems.template.locations.openDateX, 0);
|
764 | newDataItem.setWorkingLocation("dateY", series.dataItems.template.locations.dateY, 0);
|
765 | newDataItem.setWorkingLocation("openDateY", series.dataItems.template.locations.openDateY, 0);
|
766 | newDataItem.component = series;
|
767 |
|
768 | newDataItem.setDate(key, roundedDate);
|
769 | newDataItem._index = i;
|
770 | i++;
|
771 | $array.each(dataFields, function (vkey) {
|
772 |
|
773 | var dvalues = dataItem.values[vkey];
|
774 | if (dvalues) {
|
775 | var value = dvalues.value;
|
776 | if (series._adapterO) {
|
777 | value = series._adapterO.apply("groupValue", {
|
778 | dataItem: dataItem,
|
779 | interval: interval,
|
780 | dataField: vkey,
|
781 | date: roundedDate,
|
782 | value: value
|
783 | }).value;
|
784 | }
|
785 | var values = newDataItem.values[vkey];
|
786 | if ($type.isNumber(value)) {
|
787 | values.value = value;
|
788 | values.workingValue = value;
|
789 | values.open = value;
|
790 | values.close = value;
|
791 | values.low = value;
|
792 | values.high = value;
|
793 | values.sum = value;
|
794 | values.average = value;
|
795 | values.count = 1;
|
796 | }
|
797 | else {
|
798 | values.count = 0;
|
799 | }
|
800 | }
|
801 | });
|
802 | _this.postProcessSeriesDataItem(newDataItem, interval);
|
803 | $object.each(series.propertyFields, function (key, fieldValue) {
|
804 | var f = key;
|
805 | var value = dataItem.properties[key];
|
806 | if ($type.hasValue(value)) {
|
807 | newDataItem.hasProperties = true;
|
808 | newDataItem.setProperty(f, value);
|
809 | }
|
810 | });
|
811 | newDataItem.groupDataItems = [dataItem];
|
812 | previousTime = currentTime;
|
813 | }
|
814 | else {
|
815 | if (newDataItem) {
|
816 | $array.each(dataFields, function (vkey) {
|
817 | var groupFieldName = series.groupFields[vkey];
|
818 | var dvalues = dataItem.values[vkey];
|
819 | if (dvalues) {
|
820 | var value = dvalues.value;
|
821 | if (series._adapterO) {
|
822 | value = series._adapterO.apply("groupValue", {
|
823 | dataItem: dataItem,
|
824 | interval: interval,
|
825 | dataField: vkey,
|
826 | date: roundedDate,
|
827 | value: value
|
828 | }).value;
|
829 | }
|
830 | if ($type.isNumber(value)) {
|
831 | var values = newDataItem.values[vkey];
|
832 | if (!$type.isNumber(values.open)) {
|
833 | values.open = value;
|
834 | }
|
835 | values.close = value;
|
836 | if (values.low > value || !$type.isNumber(values.low)) {
|
837 | values.low = value;
|
838 | }
|
839 | if (values.high < value || !$type.isNumber(values.high)) {
|
840 | values.high = value;
|
841 | }
|
842 | if ($type.isNumber(values.sum)) {
|
843 | values.sum += value;
|
844 | }
|
845 | else {
|
846 | values.sum = value;
|
847 | }
|
848 | values.count++;
|
849 | values.average = values.sum / values.count;
|
850 | if ($type.isNumber(values[groupFieldName])) {
|
851 | values.value = values[groupFieldName];
|
852 | values.workingValue = values.value;
|
853 | }
|
854 | }
|
855 | }
|
856 | });
|
857 | $utils.copyProperties(dataItem.properties, newDataItem.properties);
|
858 | $object.each(series.propertyFields, function (key, fieldValue) {
|
859 | var f = key;
|
860 | var value = dataItem.properties[key];
|
861 | if ($type.hasValue(value)) {
|
862 | newDataItem.hasProperties = true;
|
863 | newDataItem.setProperty(f, value);
|
864 | }
|
865 | });
|
866 | newDataItem.groupDataItems.push(dataItem);
|
867 | }
|
868 | }
|
869 | }
|
870 | if (newDataItem) {
|
871 | $utils.copyProperties(dataItem.dataContext, newDataItem.dataContext);
|
872 | }
|
873 | });
|
874 | if (newDataItem && series._adapterO) {
|
875 | $array.each(dataFields, function (vkey) {
|
876 | newDataItem.values[vkey].value = series._adapterO.apply("groupDataItem", {
|
877 | dataItem: newDataItem,
|
878 | interval: interval,
|
879 | dataField: vkey,
|
880 | date: roundedDate,
|
881 | value: newDataItem.values[vkey].value
|
882 | }).value;
|
883 | newDataItem.values[vkey].workingValue = newDataItem.values[vkey].value;
|
884 | });
|
885 | }
|
886 | });
|
887 | this.calculateZoom();
|
888 | }
|
889 | };
|
890 | |
891 |
|
892 |
|
893 | DateAxis.prototype.getDFFormatter = function () {
|
894 | this._df = this.dateFormatter;
|
895 | };
|
896 | |
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 | DateAxis.prototype.postProcessSeriesDataItem = function (dataItem, interval) {
|
904 | var _this = this;
|
905 |
|
906 | var intervalID = "";
|
907 | if (interval) {
|
908 | intervalID = interval.timeUnit + interval.count;
|
909 | }
|
910 | else {
|
911 | interval = this.mainBaseInterval;
|
912 | }
|
913 | var series = dataItem.component;
|
914 | var dataItemsByAxis = series.dataItemsByAxis.getKey(this.uid);
|
915 | $object.each(dataItem.dates, function (key) {
|
916 | var date = dataItem.getDate(key);
|
917 | var time = date.getTime();
|
918 | var startDate = $time.round(new Date(time), interval.timeUnit, interval.count, _this._firstWeekDay, _this._df.utc, undefined, _this._df.timezoneMinutes, _this._df.timezone);
|
919 | var startTime = startDate.getTime();
|
920 | var endDate = $time.add(new Date(startTime), interval.timeUnit, interval.count, _this._df.utc);
|
921 | dataItem.setCalculatedValue(key, startTime, "open");
|
922 | dataItem.setCalculatedValue(key, endDate.getTime(), "close");
|
923 | dataItemsByAxis.setKey(startTime + intervalID, dataItem);
|
924 | });
|
925 | };
|
926 | |
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 | DateAxis.prototype.addEmptyUnitsBreaks = function () {
|
938 | var _this = this;
|
939 | if (this.skipEmptyPeriods && $type.isNumber(this.min) && $type.isNumber(this.max)) {
|
940 | var timeUnit = this.baseInterval.timeUnit;
|
941 | var count = this.baseInterval.count;
|
942 | if (this._axisBreaks) {
|
943 | this._axisBreaks.clear();
|
944 | }
|
945 | var date = $time.round(new Date(this.min), timeUnit, count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
946 | var axisBreak = void 0;
|
947 | var _loop_1 = function () {
|
948 | $time.add(date, timeUnit, count, this_1._df.utc);
|
949 | var startTime = date.getTime();
|
950 | var startTimeStr = startTime.toString();
|
951 | var hasData = $iter.contains(this_1.series.iterator(), function (series) {
|
952 | return !!series.dataItemsByAxis.getKey(_this.uid).getKey(startTimeStr + series.currentDataSetId);
|
953 | });
|
954 |
|
955 | if (!hasData) {
|
956 | if (!axisBreak) {
|
957 | axisBreak = this_1.axisBreaks.create();
|
958 | axisBreak.startDate = new Date(startTime);
|
959 | this_1._gapBreaks = true;
|
960 | }
|
961 | }
|
962 | else {
|
963 |
|
964 | if (axisBreak) {
|
965 |
|
966 | axisBreak.endDate = new Date(startTime - 1);
|
967 | axisBreak = undefined;
|
968 | }
|
969 | }
|
970 | };
|
971 | var this_1 = this;
|
972 | while (date.getTime() < this.max - this.baseDuration) {
|
973 | _loop_1();
|
974 | }
|
975 | }
|
976 | };
|
977 | |
978 |
|
979 |
|
980 |
|
981 |
|
982 | DateAxis.prototype.fixAxisBreaks = function () {
|
983 | var _this = this;
|
984 | _super.prototype.fixAxisBreaks.call(this);
|
985 | var axisBreaks = this._axisBreaks;
|
986 | if (axisBreaks) {
|
987 | if (axisBreaks.length > 0) {
|
988 |
|
989 | axisBreaks.each(function (axisBreak) {
|
990 | var breakGridCount = Math.ceil(_this._gridCount * (Math.min(_this.end, axisBreak.endPosition) - Math.max(_this.start, axisBreak.startPosition)) / (_this.end - _this.start));
|
991 | axisBreak.gridInterval = _this.chooseInterval(0, axisBreak.adjustedEndValue - axisBreak.adjustedStartValue, breakGridCount);
|
992 | var gridDate = $time.round(new Date(axisBreak.adjustedStartValue), axisBreak.gridInterval.timeUnit, axisBreak.gridInterval.count, _this._firstWeekDay, _this._df.utc, undefined, _this._df.timezoneMinutes, _this._df.timezone);
|
993 | if (gridDate.getTime() > axisBreak.startDate.getTime()) {
|
994 | $time.add(gridDate, axisBreak.gridInterval.timeUnit, axisBreak.gridInterval.count, _this._df.utc);
|
995 | }
|
996 | axisBreak.gridDate = gridDate;
|
997 | });
|
998 | }
|
999 | }
|
1000 | };
|
1001 | |
1002 |
|
1003 |
|
1004 | DateAxis.prototype.getFirstWeekDay = function () {
|
1005 | if (this._df) {
|
1006 | return this._df.firstDayOfWeek;
|
1007 | }
|
1008 | return 1;
|
1009 | };
|
1010 | |
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 | DateAxis.prototype.getGridDate = function (date, intervalCount) {
|
1020 | var timeUnit = this._gridInterval.timeUnit;
|
1021 | var realIntervalCount = this._gridInterval.count;
|
1022 |
|
1023 | $time.round(date, timeUnit, 1, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
1024 | var prevTimestamp = date.getTime();
|
1025 | var newDate = $time.copy(date);
|
1026 |
|
1027 | var timestamp = $time.add(newDate, timeUnit, intervalCount, this._df.utc).getTime();
|
1028 |
|
1029 | var axisBreak = this.isInBreak(timestamp);
|
1030 | if (axisBreak && axisBreak.endDate) {
|
1031 | newDate = new Date(axisBreak.endDate.getTime());
|
1032 | $time.round(newDate, timeUnit, realIntervalCount, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
1033 | if (newDate.getTime() < axisBreak.endDate.getTime()) {
|
1034 | $time.add(newDate, timeUnit, realIntervalCount, this._df.utc);
|
1035 | }
|
1036 | timestamp = newDate.getTime();
|
1037 | }
|
1038 |
|
1039 | var durationBreaksRemoved = this.adjustDifference(prevTimestamp, timestamp);
|
1040 |
|
1041 | var countBreaksRemoved = Math.round(durationBreaksRemoved / $time.getDuration(timeUnit));
|
1042 |
|
1043 | if (countBreaksRemoved < realIntervalCount) {
|
1044 | return this.getGridDate(date, intervalCount + realIntervalCount);
|
1045 | }
|
1046 | return newDate;
|
1047 | };
|
1048 | |
1049 |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 | DateAxis.prototype.getBreaklessDate = function (axisBreak, timeUnit, count) {
|
1059 | var date = new Date(axisBreak.endValue);
|
1060 | $time.round(date, timeUnit, count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
1061 | $time.add(date, timeUnit, count, this._df.utc);
|
1062 | var timestamp = date.getTime();
|
1063 | axisBreak = this.isInBreak(timestamp);
|
1064 | if (axisBreak) {
|
1065 | return this.getBreaklessDate(axisBreak, timeUnit, count);
|
1066 | }
|
1067 | return date;
|
1068 | };
|
1069 | |
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 | DateAxis.prototype.validateAxisElements = function () {
|
1076 | var _this = this;
|
1077 | if ($type.isNumber(this.max) && $type.isNumber(this.min)) {
|
1078 | this.calculateZoom();
|
1079 |
|
1080 | var timestamp = this._gridDate.getTime();
|
1081 | var timeUnit = this._gridInterval.timeUnit;
|
1082 | var intervalCount = this._gridInterval.count;
|
1083 | var prevGridDate = $time.copy(this._gridDate);
|
1084 | var dataItemsIterator_1 = this._dataItemsIterator;
|
1085 | this.resetIterators();
|
1086 | var _loop_2 = function () {
|
1087 | var date = this_2.getGridDate($time.copy(prevGridDate), intervalCount);
|
1088 | timestamp = date.getTime();
|
1089 | var endDate = $time.copy(date);
|
1090 | endDate = $time.add(endDate, timeUnit, intervalCount, this_2._df.utc);
|
1091 | var format = this_2.dateFormats.getKey(timeUnit);
|
1092 | if (this_2.markUnitChange && prevGridDate) {
|
1093 | if ($time.checkChange(date, prevGridDate, this_2._nextGridUnit, this_2._df.utc)) {
|
1094 | if (timeUnit !== "year") {
|
1095 | format = this_2.periodChangeDateFormats.getKey(timeUnit);
|
1096 | }
|
1097 | }
|
1098 | }
|
1099 | var text = this_2._df.format(date, format);
|
1100 | var dataItem = dataItemsIterator_1.find(function (x) { return x.text === text; });
|
1101 | if (dataItem.__disabled) {
|
1102 | dataItem.__disabled = false;
|
1103 | }
|
1104 | this_2.appendDataItem(dataItem);
|
1105 | dataItem.axisBreak = undefined;
|
1106 | dataItem.date = date;
|
1107 | dataItem.endDate = endDate;
|
1108 | dataItem.text = text;
|
1109 | this_2.validateDataElement(dataItem);
|
1110 | prevGridDate = date;
|
1111 | };
|
1112 | var this_2 = this;
|
1113 | while (timestamp <= this._maxZoomed) {
|
1114 | _loop_2();
|
1115 | }
|
1116 |
|
1117 | var renderer_1 = this.renderer;
|
1118 | if (this._axisBreaks) {
|
1119 | $iter.each(this._axisBreaks.iterator(), function (axisBreak) {
|
1120 | if (axisBreak.breakSize > 0) {
|
1121 | var timeUnit_1 = axisBreak.gridInterval.timeUnit;
|
1122 | var intervalCount_1 = axisBreak.gridInterval.count;
|
1123 |
|
1124 | if ($math.getDistance(axisBreak.startPoint, axisBreak.endPoint) > renderer_1.minGridDistance * 4) {
|
1125 | var timestamp_1 = axisBreak.gridDate.getTime();
|
1126 | var prevGridDate_1;
|
1127 | var count = 0;
|
1128 | var _loop_3 = function () {
|
1129 | var date = $time.copy(axisBreak.gridDate);
|
1130 | timestamp_1 = $time.add(date, timeUnit_1, intervalCount_1 * count, _this._df.utc).getTime();
|
1131 | count++;
|
1132 | if (timestamp_1 > axisBreak.adjustedStartValue && timestamp_1 < axisBreak.adjustedEndValue) {
|
1133 | var endDate = $time.copy(date);
|
1134 | endDate = $time.add(endDate, timeUnit_1, intervalCount_1, _this._df.utc);
|
1135 | var format = _this.dateFormats.getKey(timeUnit_1);
|
1136 | if (_this.markUnitChange && prevGridDate_1) {
|
1137 | if ($time.checkChange(date, prevGridDate_1, _this._nextGridUnit, _this._df.utc)) {
|
1138 | if (timeUnit_1 !== "year") {
|
1139 | format = _this.periodChangeDateFormats.getKey(timeUnit_1);
|
1140 | }
|
1141 | }
|
1142 | }
|
1143 | var text_1 = _this._df.format(date, format);
|
1144 | var dataItem = dataItemsIterator_1.find(function (x) { return x.text === text_1; });
|
1145 | if (dataItem.__disabled) {
|
1146 | dataItem.__disabled = false;
|
1147 | }
|
1148 |
|
1149 | _this.appendDataItem(dataItem);
|
1150 | dataItem.axisBreak = axisBreak;
|
1151 | axisBreak.dataItems.moveValue(dataItem);
|
1152 | dataItem.date = date;
|
1153 | dataItem.endDate = endDate;
|
1154 | dataItem.text = text_1;
|
1155 | prevGridDate_1 = date;
|
1156 | _this.validateDataElement(dataItem);
|
1157 | }
|
1158 | };
|
1159 | while (timestamp_1 <= axisBreak.adjustedMax) {
|
1160 | _loop_3();
|
1161 | }
|
1162 | }
|
1163 | }
|
1164 | });
|
1165 | }
|
1166 | }
|
1167 | };
|
1168 | |
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 | DateAxis.prototype.validateDataElement = function (dataItem) {
|
1175 | dataItem.itemIndex = this._axisItemCount;
|
1176 | this._axisItemCount++;
|
1177 | if ($type.isNumber(this.max) && $type.isNumber(this.min)) {
|
1178 | var renderer = this.renderer;
|
1179 | var timestamp = dataItem.value;
|
1180 | var endTimestamp = dataItem.endValue;
|
1181 | if (!$type.isNumber(endTimestamp)) {
|
1182 | endTimestamp = timestamp;
|
1183 | }
|
1184 | var position = this.valueToPosition(timestamp);
|
1185 | var endPosition = this.valueToPosition(endTimestamp);
|
1186 | var fillEndPosition = endPosition;
|
1187 | if (!dataItem.isRange && this._gridInterval.count > this.baseInterval.count) {
|
1188 | endPosition = position + (endPosition - position) / (this._gridInterval.count / this.baseInterval.count);
|
1189 | }
|
1190 | dataItem.position = position;
|
1191 | var tick = dataItem.tick;
|
1192 | if (tick && !tick.disabled) {
|
1193 | renderer.updateTickElement(tick, position, endPosition);
|
1194 | }
|
1195 | var grid = dataItem.grid;
|
1196 | if (grid && !grid.disabled) {
|
1197 | renderer.updateGridElement(grid, position, endPosition);
|
1198 | }
|
1199 | var fill = dataItem.axisFill;
|
1200 | if (fill && !fill.disabled) {
|
1201 | renderer.updateFillElement(fill, position, fillEndPosition);
|
1202 | if (!dataItem.isRange) {
|
1203 | this.fillRule(dataItem);
|
1204 | }
|
1205 | }
|
1206 | var mask = dataItem.mask;
|
1207 | if (mask) {
|
1208 | renderer.updateFillElement(mask, position, endPosition);
|
1209 | }
|
1210 | if (dataItem.bullet) {
|
1211 | renderer.updateBullet(dataItem.bullet, position, endPosition);
|
1212 | }
|
1213 | var label = dataItem.label;
|
1214 | if (label && !label.disabled) {
|
1215 | var location_1 = label.location;
|
1216 | if (location_1 == 0) {
|
1217 | if (this._gridInterval.count == 1 && this._gridInterval.timeUnit != "week" && !dataItem.isRange) {
|
1218 | location_1 = 0.5;
|
1219 | }
|
1220 | else {
|
1221 | location_1 = 0;
|
1222 | }
|
1223 | }
|
1224 | renderer.updateLabelElement(label, position, endPosition, location_1);
|
1225 | }
|
1226 | }
|
1227 | };
|
1228 | Object.defineProperty(DateAxis.prototype, "baseDuration", {
|
1229 | |
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 | get: function () {
|
1235 | return $time.getDuration(this.baseInterval.timeUnit, this.baseInterval.count);
|
1236 | },
|
1237 | enumerable: true,
|
1238 | configurable: true
|
1239 | });
|
1240 | |
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 | DateAxis.prototype.adjustMinMax = function (min, max) {
|
1250 | return { min: min, max: max, step: this.baseDuration };
|
1251 | };
|
1252 | |
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 | DateAxis.prototype.fixMin = function (value) {
|
1259 |
|
1260 | var interval = this.baseInterval;
|
1261 | var startTime = $time.round(new Date(value), interval.timeUnit, interval.count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone).getTime();
|
1262 | var endTime = $time.add(new Date(startTime), interval.timeUnit, interval.count, this._df.utc).getTime();
|
1263 | return startTime + (endTime - startTime) * this.startLocation;
|
1264 | };
|
1265 | |
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 | DateAxis.prototype.fixMax = function (value) {
|
1272 |
|
1273 | var interval = this.baseInterval;
|
1274 | var startTime = $time.round(new Date(value), interval.timeUnit, interval.count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone).getTime();
|
1275 | var endTime = $time.add(new Date(startTime), interval.timeUnit, interval.count, this._df.utc).getTime();
|
1276 | return startTime + (endTime - startTime) * this.endLocation;
|
1277 | };
|
1278 | |
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 | DateAxis.prototype.chooseInterval = function (index, duration, gridCount, intervals) {
|
1289 | if (!intervals) {
|
1290 | intervals = this.gridIntervals;
|
1291 | }
|
1292 | var gridInterval = intervals.getIndex(index);
|
1293 | var intervalDuration = $time.getDuration(gridInterval.timeUnit, gridInterval.count);
|
1294 | var lastIndex = intervals.length - 1;
|
1295 | if (index >= lastIndex) {
|
1296 | return __assign({}, intervals.getIndex(lastIndex));
|
1297 | }
|
1298 | var count = Math.ceil(duration / intervalDuration);
|
1299 | if (duration < intervalDuration && index > 0) {
|
1300 | return __assign({}, intervals.getIndex(index - 1));
|
1301 | }
|
1302 | if (count <= gridCount) {
|
1303 | return __assign({}, intervals.getIndex(index));
|
1304 | }
|
1305 | else {
|
1306 | if (index + 1 < intervals.length) {
|
1307 | return this.chooseInterval(index + 1, duration, gridCount, intervals);
|
1308 | }
|
1309 | else {
|
1310 | return __assign({}, intervals.getIndex(index));
|
1311 | }
|
1312 | }
|
1313 | };
|
1314 | |
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 | DateAxis.prototype.formatLabel = function (value) {
|
1321 | return this._df.format(value);
|
1322 | };
|
1323 | |
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 | DateAxis.prototype.dateToPosition = function (date) {
|
1330 | return this.valueToPosition(date.getTime());
|
1331 | };
|
1332 | |
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 | DateAxis.prototype.anyToPosition = function (date) {
|
1339 | if (date instanceof Date) {
|
1340 | return this.dateToPosition(date);
|
1341 | }
|
1342 | else {
|
1343 | return this.valueToPosition(date);
|
1344 | }
|
1345 | };
|
1346 | |
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 | DateAxis.prototype.dateToPoint = function (date) {
|
1353 | var position = this.dateToPosition(date);
|
1354 | var point = this.renderer.positionToPoint(position);
|
1355 | var angle = this.renderer.positionToAngle(position);
|
1356 | return { x: point.x, y: point.y, angle: angle };
|
1357 | };
|
1358 | |
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 | DateAxis.prototype.anyToPoint = function (date) {
|
1365 | if (date instanceof Date) {
|
1366 | return this.dateToPoint(date);
|
1367 | }
|
1368 | else {
|
1369 | return this.valueToPoint(date);
|
1370 | }
|
1371 | };
|
1372 | |
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 | DateAxis.prototype.positionToDate = function (position) {
|
1379 | return new Date(this.positionToValue(position));
|
1380 | };
|
1381 | |
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 | DateAxis.prototype.getPositionX = function (dataItem, key, location, stackKey, range) {
|
1391 | var value = this.getTimeByLocation(dataItem, key, location);
|
1392 |
|
1393 | if (!$type.isNumber(value)) {
|
1394 | value = this.baseValue;
|
1395 | }
|
1396 | var position = this.valueToPosition(value);
|
1397 | if (range) {
|
1398 | position = $math.fitToRange(position, range.start, range.end);
|
1399 | }
|
1400 | return position;
|
1401 | };
|
1402 | |
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 | DateAxis.prototype.getPositionY = function (dataItem, key, location, stackKey, range) {
|
1412 | var value = this.getTimeByLocation(dataItem, key, location);
|
1413 | var stack = dataItem.getValue("valueX", "stack");
|
1414 | if (!$type.isNumber(value)) {
|
1415 | value = this.baseValue;
|
1416 | }
|
1417 | var position = this.valueToPosition(value + stack);
|
1418 | if (range) {
|
1419 | position = $math.fitToRange(position, range.start, range.end);
|
1420 | }
|
1421 | return position;
|
1422 | };
|
1423 | |
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 | DateAxis.prototype.getAngle = function (dataItem, key, location, stackKey, range) {
|
1436 | var value = this.getTimeByLocation(dataItem, key, location);
|
1437 | var stack = dataItem.getValue(stackKey, "stack");
|
1438 | if (!$type.isNumber(value)) {
|
1439 | value = this.baseValue;
|
1440 | }
|
1441 | var position = this.valueToPosition(value + stack);
|
1442 | if (range) {
|
1443 | position = $math.fitToRange(position, range.start, range.end);
|
1444 | }
|
1445 | return this.positionToAngle(position);
|
1446 | };
|
1447 | |
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 | DateAxis.prototype.getTimeByLocation = function (dataItem, key, location) {
|
1458 | if (!$type.hasValue(key)) {
|
1459 | return;
|
1460 | }
|
1461 | if (!$type.isNumber(location)) {
|
1462 | location = dataItem.workingLocations[key];
|
1463 | if (!$type.isNumber(location)) {
|
1464 | location = 0;
|
1465 | }
|
1466 | }
|
1467 | var startTime = dataItem.values[key]["open"];
|
1468 | var endTime = dataItem.values[key]["close"];
|
1469 | var workingValue = dataItem.values[key].workingValue;
|
1470 | var value = dataItem.values[key].value;
|
1471 | var difference = value - workingValue;
|
1472 | startTime -= difference;
|
1473 | endTime -= difference;
|
1474 | if ($type.isNumber(startTime) && $type.isNumber(endTime)) {
|
1475 | return startTime + (endTime - startTime) * location;
|
1476 | }
|
1477 | };
|
1478 | |
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 | DateAxis.prototype.processSeriesDataItem = function (dataItem, axisLetter) {
|
1486 | var series = dataItem.component;
|
1487 | var time;
|
1488 | var date = dataItem["date" + axisLetter];
|
1489 | if ($type.isNumber(this.timezoneOffset)) {
|
1490 | date.setTime(date.getTime() + (date.getTimezoneOffset() - this.timezoneOffset) * 60000);
|
1491 | dataItem.setValue("date" + axisLetter, date.getTime(), 0);
|
1492 | }
|
1493 | else if ($type.hasValue(this.timezone)) {
|
1494 | date = $time.setTimezone(date, this.timezone);
|
1495 | dataItem.setValue("date" + axisLetter, date.getTime(), 0);
|
1496 | dataItem["date" + axisLetter] = date;
|
1497 | }
|
1498 | if (date) {
|
1499 | time = date.getTime();
|
1500 | }
|
1501 | else {
|
1502 | return;
|
1503 | }
|
1504 | var openDate = dataItem["openDate" + axisLetter];
|
1505 | var prevSeriesTime = this._prevSeriesTime[series.uid];
|
1506 | var openTime;
|
1507 | if (openDate) {
|
1508 | openTime = openDate.getTime();
|
1509 | }
|
1510 | if ($type.isNumber(openTime)) {
|
1511 | var difference = Math.abs(time - openTime);
|
1512 | if (this._minDifference[series.uid] > difference) {
|
1513 | this._minDifference[series.uid] = difference;
|
1514 | }
|
1515 | }
|
1516 | var differece = time - prevSeriesTime;
|
1517 | if (differece > 0) {
|
1518 | if (this._minDifference[series.uid] > differece) {
|
1519 | this._minDifference[series.uid] = differece;
|
1520 | }
|
1521 | }
|
1522 | this._prevSeriesTime[series.uid] = time;
|
1523 | if (series._baseInterval[this.uid]) {
|
1524 | this.postProcessSeriesDataItem(dataItem);
|
1525 | }
|
1526 | };
|
1527 | |
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 | DateAxis.prototype.updateAxisBySeries = function () {
|
1534 | _super.prototype.updateAxisBySeries.call(this);
|
1535 | var baseInterval = this.chooseInterval(0, this.minDifference, 1);
|
1536 |
|
1537 | if (this.minDifference >= $time.getDuration("day", 27) && baseInterval.timeUnit == "week") {
|
1538 | baseInterval.timeUnit = "month";
|
1539 | baseInterval.count = 1;
|
1540 | }
|
1541 | if (baseInterval.timeUnit == "month") {
|
1542 | if (this.minDifference >= $time.getDuration("day", 29 * 2) && baseInterval.count == 1) {
|
1543 | baseInterval.count = 2;
|
1544 | }
|
1545 | if (this.minDifference >= $time.getDuration("day", 29 * 3) && baseInterval.count == 2) {
|
1546 | baseInterval.count = 3;
|
1547 | }
|
1548 | if (this.minDifference >= $time.getDuration("day", 29 * 6) && baseInterval.count == 5) {
|
1549 | baseInterval.count = 6;
|
1550 | }
|
1551 | }
|
1552 |
|
1553 | if (this.minDifference >= $time.getDuration("hour", 23) && baseInterval.timeUnit == "hour") {
|
1554 | baseInterval.timeUnit = "day";
|
1555 | baseInterval.count = 1;
|
1556 | }
|
1557 | if (this.minDifference >= $time.getDuration("week", 1) - $time.getDuration("hour", 1) && baseInterval.timeUnit == "day") {
|
1558 | baseInterval.timeUnit = "week";
|
1559 | baseInterval.count = 1;
|
1560 | }
|
1561 | if (this.minDifference >= $time.getDuration("year", 1) - $time.getDuration("day", 1.01) && baseInterval.timeUnit == "month") {
|
1562 | baseInterval.timeUnit = "year";
|
1563 | baseInterval.count = 1;
|
1564 | }
|
1565 | this._baseIntervalReal = baseInterval;
|
1566 | this._mainBaseInterval = baseInterval;
|
1567 |
|
1568 | };
|
1569 | Object.defineProperty(DateAxis.prototype, "baseInterval", {
|
1570 | |
1571 |
|
1572 |
|
1573 | get: function () {
|
1574 | if (this._groupInterval) {
|
1575 | return this._groupInterval;
|
1576 | }
|
1577 | else if (this._baseInterval) {
|
1578 | return this._baseInterval;
|
1579 | }
|
1580 | else {
|
1581 | return this._baseIntervalReal;
|
1582 | }
|
1583 | },
|
1584 | |
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 |
|
1595 |
|
1596 |
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 |
|
1603 | set: function (timeInterval) {
|
1604 | if (JSON.stringify(this._baseInterval) != JSON.stringify(timeInterval)) {
|
1605 | this._baseInterval = timeInterval;
|
1606 | this._mainBaseInterval = timeInterval;
|
1607 | if (!$type.isNumber(timeInterval.count)) {
|
1608 | timeInterval.count = 1;
|
1609 | }
|
1610 | this.invalidate();
|
1611 | this.postProcessSeriesDataItems();
|
1612 | }
|
1613 | },
|
1614 | enumerable: true,
|
1615 | configurable: true
|
1616 | });
|
1617 | Object.defineProperty(DateAxis.prototype, "mainBaseInterval", {
|
1618 | |
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 | get: function () {
|
1625 | if (this._baseInterval) {
|
1626 | return this._baseInterval;
|
1627 | }
|
1628 | else if (this._mainBaseInterval) {
|
1629 | return this._mainBaseInterval;
|
1630 | }
|
1631 | else {
|
1632 | return this._baseIntervalReal;
|
1633 | }
|
1634 | },
|
1635 | enumerable: true,
|
1636 | configurable: true
|
1637 | });
|
1638 | Object.defineProperty(DateAxis.prototype, "skipEmptyPeriods", {
|
1639 | |
1640 |
|
1641 |
|
1642 | get: function () {
|
1643 | return this.getPropertyValue("skipEmptyPeriods");
|
1644 | },
|
1645 | |
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 | set: function (value) {
|
1669 | if (value) {
|
1670 | var breakTemplate = this.axisBreaks.template;
|
1671 | breakTemplate.startLine.disabled = true;
|
1672 | breakTemplate.endLine.disabled = true;
|
1673 | breakTemplate.fillShape.disabled = true;
|
1674 | breakTemplate.breakSize = 0;
|
1675 | }
|
1676 | else {
|
1677 | if (this._gapBreaks) {
|
1678 | this.axisBreaks.clear();
|
1679 | this._gapBreaks = false;
|
1680 | }
|
1681 | }
|
1682 | if (this.setPropertyValue("skipEmptyPeriods", value)) {
|
1683 | this.invalidate();
|
1684 | this.postProcessSeriesDataItems();
|
1685 | this.invalidateSeries();
|
1686 | }
|
1687 | },
|
1688 | enumerable: true,
|
1689 | configurable: true
|
1690 | });
|
1691 | Object.defineProperty(DateAxis.prototype, "tooltipDateFormat", {
|
1692 | |
1693 |
|
1694 |
|
1695 | get: function () {
|
1696 | return this.getPropertyValue("tooltipDateFormat");
|
1697 | },
|
1698 | |
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 | set: function (value) {
|
1706 | this.setPropertyValue("tooltipDateFormat", value);
|
1707 | },
|
1708 | enumerable: true,
|
1709 | configurable: true
|
1710 | });
|
1711 | Object.defineProperty(DateAxis.prototype, "markUnitChange", {
|
1712 | |
1713 |
|
1714 |
|
1715 | get: function () {
|
1716 | return this.getPropertyValue("markUnitChange");
|
1717 | },
|
1718 | |
1719 |
|
1720 |
|
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 | set: function (value) {
|
1726 | if (this.setPropertyValue("markUnitChange", value)) {
|
1727 | this.invalidateData();
|
1728 | }
|
1729 | },
|
1730 | enumerable: true,
|
1731 | configurable: true
|
1732 | });
|
1733 | |
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 | DateAxis.prototype.getTooltipText = function (position) {
|
1745 | var text;
|
1746 | var date = this.positionToDate(position);
|
1747 | date = $time.round(date, this.baseInterval.timeUnit, this.baseInterval.count, this._firstWeekDay, this._df.utc, new Date(this.min), this._df.timezoneMinutes, this._df.timezone);
|
1748 | this.tooltipDate = date;
|
1749 | if ($type.hasValue(this.tooltipDateFormat)) {
|
1750 | text = this._df.format(date, this.tooltipDateFormat, ["day", "month", "week", "year"].indexOf(this.baseInterval.timeUnit) == -1);
|
1751 | }
|
1752 | else {
|
1753 | var dateFormat = this.dateFormats.getKey(this.baseInterval.timeUnit);
|
1754 | if (dateFormat) {
|
1755 | text = this._df.format(date, dateFormat);
|
1756 | }
|
1757 | else {
|
1758 | text = this.getPositionLabel(position);
|
1759 | }
|
1760 | }
|
1761 | if (!this._adapterO) {
|
1762 | return text;
|
1763 | }
|
1764 | else {
|
1765 | return this._adapterO.apply("getTooltipText", text);
|
1766 | }
|
1767 | };
|
1768 | |
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 | DateAxis.prototype.roundPosition = function (position, location, axisLocation) {
|
1777 | var baseInterval = this.baseInterval;
|
1778 | var timeUnit = baseInterval.timeUnit;
|
1779 | var count = baseInterval.count;
|
1780 | var date = this.positionToDate(position);
|
1781 | $time.round(date, timeUnit, count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
1782 | if (location > 0) {
|
1783 | $time.add(date, timeUnit, location * count, this._df.utc);
|
1784 | }
|
1785 | if (axisLocation > 0 && axisLocation < 1) {
|
1786 | date.setTime(date.getTime() + this.baseDuration * axisLocation);
|
1787 | }
|
1788 | if (this.isInBreak(date.getTime())) {
|
1789 | while (date.getTime() < this.max) {
|
1790 | $time.add(date, timeUnit, count, this._df.utc);
|
1791 | if (!this.isInBreak(date.getTime())) {
|
1792 | break;
|
1793 | }
|
1794 | }
|
1795 | }
|
1796 | return this.dateToPosition(date);
|
1797 | };
|
1798 | |
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 |
|
1806 | DateAxis.prototype.getCellStartPosition = function (position) {
|
1807 | return this.roundPosition(position, 0);
|
1808 | };
|
1809 | |
1810 |
|
1811 |
|
1812 |
|
1813 |
|
1814 |
|
1815 |
|
1816 |
|
1817 | DateAxis.prototype.getCellEndPosition = function (position) {
|
1818 | return this.roundPosition(position, 1);
|
1819 |
|
1820 | };
|
1821 | |
1822 |
|
1823 |
|
1824 |
|
1825 |
|
1826 |
|
1827 |
|
1828 |
|
1829 |
|
1830 |
|
1831 |
|
1832 |
|
1833 |
|
1834 | DateAxis.prototype.getSeriesDataItem = function (series, position, findNearest) {
|
1835 | var value = this.positionToValue(position);
|
1836 | var location = 0.5;
|
1837 | if (this.axisLetter == "Y") {
|
1838 | location = series.dataItems.template.locations.dateY;
|
1839 | }
|
1840 | else {
|
1841 | location = series.dataItems.template.locations.dateX;
|
1842 | }
|
1843 | var deltaValue = value - location * this.baseDuration;
|
1844 | var date = $time.round(new Date(value), this.baseInterval.timeUnit, this.baseInterval.count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
1845 | var nextDate = $time.round(new Date(value + this.baseDuration), this.baseInterval.timeUnit, this.baseInterval.count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
1846 | if (nextDate.getTime() > date.getTime()) {
|
1847 | if (Math.abs(nextDate.getTime() - deltaValue) < Math.abs(deltaValue - date.getTime())) {
|
1848 | date = nextDate;
|
1849 | }
|
1850 | }
|
1851 | var dataItemsByAxis = series.dataItemsByAxis.getKey(this.uid);
|
1852 | var dataItem = dataItemsByAxis.getKey(date.getTime() + series.currentDataSetId);
|
1853 |
|
1854 | if (!dataItem && findNearest) {
|
1855 | var key_1;
|
1856 | if (this.axisLetter == "Y") {
|
1857 | key_1 = "dateY";
|
1858 | }
|
1859 | else {
|
1860 | key_1 = "dateX";
|
1861 | }
|
1862 | dataItem = series.dataItems.getIndex(series.dataItems.findClosestIndex(date.getTime(), function (x) {
|
1863 | if (x[key_1]) {
|
1864 | return x[key_1].getTime();
|
1865 | }
|
1866 | else {
|
1867 | return -Infinity;
|
1868 | }
|
1869 | }, "any"));
|
1870 | }
|
1871 | return dataItem;
|
1872 | };
|
1873 | |
1874 |
|
1875 |
|
1876 |
|
1877 |
|
1878 |
|
1879 |
|
1880 |
|
1881 |
|
1882 |
|
1883 |
|
1884 |
|
1885 | DateAxis.prototype.getPositionLabel = function (position) {
|
1886 |
|
1887 | var date = this.positionToDate(position);
|
1888 | return this._df.format(date, this.getCurrentLabelFormat());
|
1889 | };
|
1890 | |
1891 |
|
1892 |
|
1893 |
|
1894 |
|
1895 | DateAxis.prototype.getCurrentLabelFormat = function () {
|
1896 | return this.dateFormats.getKey(this._gridInterval ? this._gridInterval.timeUnit : "day");
|
1897 | };
|
1898 | |
1899 |
|
1900 |
|
1901 |
|
1902 |
|
1903 | DateAxis.prototype.initRenderer = function () {
|
1904 | _super.prototype.initRenderer.call(this);
|
1905 | var renderer = this.renderer;
|
1906 | if (renderer) {
|
1907 |
|
1908 | renderer.ticks.template.location = 0;
|
1909 | renderer.grid.template.location = 0;
|
1910 | renderer.labels.template.location = 0;
|
1911 | renderer.baseGrid.disabled = true;
|
1912 | }
|
1913 | };
|
1914 | Object.defineProperty(DateAxis.prototype, "basePoint", {
|
1915 | |
1916 |
|
1917 |
|
1918 |
|
1919 |
|
1920 |
|
1921 | get: function () {
|
1922 | return { x: 0, y: 0 };
|
1923 | },
|
1924 | enumerable: true,
|
1925 | configurable: true
|
1926 | });
|
1927 | |
1928 |
|
1929 |
|
1930 | DateAxis.prototype.animateMinMax = function (min, max) {
|
1931 | var _this = this;
|
1932 | var animation = this.animate([{ property: "_minAdjusted", from: this._minAdjusted, to: min }, { property: "_maxAdjusted", from: this._maxAdjusted, to: max }], this.rangeChangeDuration, this.rangeChangeEasing);
|
1933 | animation.events.on("animationprogress", function () {
|
1934 | _this.dispatch("extremeschanged");
|
1935 | });
|
1936 | return animation;
|
1937 | };
|
1938 | |
1939 |
|
1940 |
|
1941 | DateAxis.prototype.handleExtremesChange = function () {
|
1942 | _super.prototype.handleExtremesChange.call(this);
|
1943 | if (this.groupData) {
|
1944 | var id = this.baseInterval.timeUnit + this.baseInterval.count;
|
1945 | this.groupMin[id] = this._finalMin;
|
1946 | this.groupMax[id] = this._finalMax;
|
1947 | }
|
1948 | };
|
1949 | |
1950 |
|
1951 |
|
1952 |
|
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 | DateAxis.prototype.zoomToDates = function (startDate, endDate, skipRangeEvent, instantly, adjust) {
|
1958 | startDate = this._df.parse(startDate);
|
1959 | endDate = this._df.parse(endDate);
|
1960 | this.zoomToValues(startDate.getTime(), endDate.getTime(), skipRangeEvent, instantly, adjust);
|
1961 | };
|
1962 | |
1963 |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 |
|
1970 | DateAxis.prototype.zoomToValues = function (startValue, endValue, skipRangeEvent, instantly, adjust) {
|
1971 | var _this = this;
|
1972 | if (!this.groupData) {
|
1973 |
|
1974 |
|
1975 | var start = this.valueToPosition(startValue);
|
1976 | var end = this.valueToPosition(endValue);
|
1977 | this.zoom({ start: start, end: end }, skipRangeEvent, instantly);
|
1978 | }
|
1979 | else {
|
1980 | var difference = this.adjustDifference(startValue, endValue);
|
1981 | var isEnd = false;
|
1982 | if (endValue == this.max) {
|
1983 | isEnd = true;
|
1984 | }
|
1985 | var isStart = false;
|
1986 | if (startValue == this.min) {
|
1987 | isStart = true;
|
1988 | }
|
1989 | if ($type.hasValue(difference)) {
|
1990 | var mainBaseInterval = this.mainBaseInterval;
|
1991 | var groupInterval_1 = this.chooseInterval(0, difference, this.groupCount, this.groupIntervals);
|
1992 | if ((groupInterval_1.timeUnit == mainBaseInterval.timeUnit && groupInterval_1.count < mainBaseInterval.count) || $time.getDuration(groupInterval_1.timeUnit, 1) < $time.getDuration(mainBaseInterval.timeUnit, 1)) {
|
1993 | groupInterval_1 = __assign({}, mainBaseInterval);
|
1994 | }
|
1995 | var id = groupInterval_1.timeUnit + groupInterval_1.count;
|
1996 | var min_1 = this.groupMin[id];
|
1997 | var max_1 = this.groupMax[id];
|
1998 | if (!$type.isNumber(min_1) || !$type.isNumber(max_1)) {
|
1999 | min_1 = Number.POSITIVE_INFINITY;
|
2000 | max_1 = Number.NEGATIVE_INFINITY;
|
2001 | this.series.each(function (series) {
|
2002 | var seriesMin = series.min(_this);
|
2003 | var seriesMax = series.max(_this);
|
2004 | if (series._dataSets) {
|
2005 | var ds = series._dataSets.getKey(groupInterval_1.timeUnit + groupInterval_1.count);
|
2006 | if (ds) {
|
2007 | var mindi = ds.getIndex(0);
|
2008 | var maxdi = ds.getIndex(ds.length - 1);
|
2009 | if (mindi) {
|
2010 | if (series.xAxis == _this) {
|
2011 | seriesMin = mindi.dateX.getTime();
|
2012 | }
|
2013 | else if (series.yAxis == _this) {
|
2014 | seriesMin = mindi.dateY.getTime();
|
2015 | }
|
2016 | }
|
2017 | if (maxdi) {
|
2018 | if (series.xAxis == _this) {
|
2019 | seriesMax = maxdi.dateX.getTime();
|
2020 | }
|
2021 | else if (series.yAxis == _this) {
|
2022 | seriesMax = maxdi.dateY.getTime();
|
2023 | }
|
2024 | }
|
2025 | }
|
2026 | }
|
2027 | seriesMax = $time.round($time.add(new Date(seriesMax), groupInterval_1.timeUnit, 1, _this._df.utc), groupInterval_1.timeUnit, 1, _this._df.firstDayOfWeek, _this._df.utc, undefined, _this._df.timezoneMinutes, _this._df.timezone).getTime();
|
2028 | if (seriesMin < min_1) {
|
2029 | min_1 = seriesMin;
|
2030 | }
|
2031 | if (seriesMax > max_1) {
|
2032 | max_1 = seriesMax;
|
2033 | }
|
2034 | });
|
2035 | this.groupMin[id] = min_1;
|
2036 | this.groupMax[id] = max_1;
|
2037 | }
|
2038 | startValue = $math.fitToRange(startValue, min_1, max_1);
|
2039 | endValue = $math.fitToRange(endValue, min_1, max_1);
|
2040 | if (adjust) {
|
2041 | if (isEnd) {
|
2042 | startValue = endValue - difference;
|
2043 | startValue = $math.fitToRange(startValue, min_1, max_1);
|
2044 | }
|
2045 | if (isStart) {
|
2046 | endValue = startValue + difference;
|
2047 | endValue = $math.fitToRange(endValue, min_1, max_1);
|
2048 | }
|
2049 | }
|
2050 | var start = (startValue - min_1) / (max_1 - min_1);
|
2051 | var end = (endValue - min_1) / (max_1 - min_1);
|
2052 | this.zoom({ start: start, end: end }, skipRangeEvent, instantly);
|
2053 | }
|
2054 | }
|
2055 | };
|
2056 | |
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 | DateAxis.prototype.asIs = function (field) {
|
2063 | return field == "baseInterval" || _super.prototype.asIs.call(this, field);
|
2064 | };
|
2065 | |
2066 |
|
2067 |
|
2068 |
|
2069 |
|
2070 | DateAxis.prototype.copyFrom = function (source) {
|
2071 | var _this = this;
|
2072 | _super.prototype.copyFrom.call(this, source);
|
2073 | this.dateFormats = source.dateFormats;
|
2074 | this.periodChangeDateFormats = source.periodChangeDateFormats;
|
2075 | this.groupIntervals.clear();
|
2076 | source.groupIntervals.each(function (interval) {
|
2077 | _this.groupIntervals.push(__assign({}, interval));
|
2078 | });
|
2079 | this.gridIntervals.clear();
|
2080 | source.gridIntervals.each(function (interval) {
|
2081 | _this.gridIntervals.push(__assign({}, interval));
|
2082 | });
|
2083 | if (source._baseInterval) {
|
2084 | this.baseInterval = source._baseInterval;
|
2085 | }
|
2086 | };
|
2087 | |
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 | DateAxis.prototype.showTooltipAtPosition = function (position, local) {
|
2094 | var _this = this;
|
2095 | if (!local) {
|
2096 | position = this.toAxisPosition(position);
|
2097 | }
|
2098 | if (this.snapTooltip) {
|
2099 |
|
2100 | var actualDate = this.positionToDate(position);
|
2101 | var actualTime_1 = actualDate.getTime();
|
2102 | var closestDate_1;
|
2103 | this.series.each(function (series) {
|
2104 | if (series.baseAxis == _this) {
|
2105 | var dataItem = _this.getSeriesDataItem(series, position, true);
|
2106 | if (dataItem) {
|
2107 | var date = void 0;
|
2108 | if (series.xAxis == _this) {
|
2109 | date = dataItem.dateX;
|
2110 | }
|
2111 | if (series.yAxis == _this) {
|
2112 | date = dataItem.dateY;
|
2113 | }
|
2114 | if (!closestDate_1) {
|
2115 | closestDate_1 = date;
|
2116 | }
|
2117 | else {
|
2118 | if (Math.abs(closestDate_1.getTime() - actualTime_1) > Math.abs(date.getTime() - actualTime_1)) {
|
2119 | closestDate_1 = date;
|
2120 | }
|
2121 | }
|
2122 | }
|
2123 | }
|
2124 | });
|
2125 | if (closestDate_1) {
|
2126 | var closestTime_1 = closestDate_1.getTime();
|
2127 | closestDate_1 = $time.round(new Date(closestTime_1), this.baseInterval.timeUnit, this.baseInterval.count, this._firstWeekDay, this._df.utc, undefined, this._df.timezoneMinutes, this._df.timezone);
|
2128 | closestTime_1 = closestDate_1.getTime();
|
2129 | var tooltipLocation = this.renderer.tooltipLocation;
|
2130 | if (tooltipLocation == 0) {
|
2131 | tooltipLocation = 0.0001;
|
2132 | }
|
2133 | closestDate_1 = new Date(closestDate_1.getTime() + this.baseDuration * tooltipLocation);
|
2134 | position = this.dateToPosition(closestDate_1);
|
2135 | if (this.chart.cursor && this.chart.cursor.snapToSeries) {
|
2136 |
|
2137 | }
|
2138 | else {
|
2139 | this.series.each(function (series) {
|
2140 | var dataItem = series.dataItemsByAxis.getKey(_this.uid).getKey(closestTime_1 + series.currentDataSetId);
|
2141 | var point = series.showTooltipAtDataItem(dataItem);
|
2142 | if (point) {
|
2143 | _this.chart._seriesPoints.push({ series: series, point: point });
|
2144 | }
|
2145 | else {
|
2146 |
|
2147 | if (series.tooltipText || series.tooltipHTML) {
|
2148 | series.hideTooltip();
|
2149 | }
|
2150 | }
|
2151 | });
|
2152 | }
|
2153 |
|
2154 | }
|
2155 | }
|
2156 | _super.prototype.showTooltipAtPosition.call(this, position, true);
|
2157 | };
|
2158 | Object.defineProperty(DateAxis.prototype, "snapTooltip", {
|
2159 | |
2160 |
|
2161 |
|
2162 | get: function () {
|
2163 | return this.getPropertyValue("snapTooltip");
|
2164 | },
|
2165 | |
2166 |
|
2167 |
|
2168 |
|
2169 |
|
2170 |
|
2171 |
|
2172 | set: function (value) {
|
2173 | this.setPropertyValue("snapTooltip", value);
|
2174 | },
|
2175 | enumerable: true,
|
2176 | configurable: true
|
2177 | });
|
2178 | Object.defineProperty(DateAxis.prototype, "groupData", {
|
2179 | |
2180 |
|
2181 |
|
2182 | get: function () {
|
2183 | return this.getPropertyValue("groupData");
|
2184 | },
|
2185 | |
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 |
|
2203 |
|
2204 |
|
2205 |
|
2206 |
|
2207 |
|
2208 |
|
2209 |
|
2210 |
|
2211 |
|
2212 |
|
2213 |
|
2214 |
|
2215 |
|
2216 |
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 |
|
2242 |
|
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 |
|
2249 |
|
2250 | set: function (value) {
|
2251 | var _this = this;
|
2252 | if (this.setPropertyValue("groupData", value)) {
|
2253 | this.series.each(function (series) {
|
2254 | series.setDataSet("");
|
2255 | if (value && !series.dataGrouped && series.inited) {
|
2256 | series._baseInterval[_this.uid] = _this.mainBaseInterval;
|
2257 | _this.groupSeriesData(series);
|
2258 | }
|
2259 | });
|
2260 | this._currentDataSetId = "";
|
2261 | this._groupInterval = undefined;
|
2262 | this.invalidate();
|
2263 | this.invalidateSeries();
|
2264 | }
|
2265 | },
|
2266 | enumerable: true,
|
2267 | configurable: true
|
2268 | });
|
2269 | Object.defineProperty(DateAxis.prototype, "groupInterval", {
|
2270 | |
2271 |
|
2272 |
|
2273 | get: function () {
|
2274 | return this.getPropertyValue("groupInterval");
|
2275 | },
|
2276 | |
2277 |
|
2278 |
|
2279 |
|
2280 |
|
2281 |
|
2282 |
|
2283 | set: function (value) {
|
2284 | if (this.setPropertyValue("groupInterval", value)) {
|
2285 | this.invalidate();
|
2286 | this.invalidateSeries();
|
2287 | }
|
2288 | },
|
2289 | enumerable: true,
|
2290 | configurable: true
|
2291 | });
|
2292 | Object.defineProperty(DateAxis.prototype, "groupCount", {
|
2293 | |
2294 |
|
2295 |
|
2296 | get: function () {
|
2297 | return this.getPropertyValue("groupCount");
|
2298 | },
|
2299 | |
2300 |
|
2301 |
|
2302 |
|
2303 |
|
2304 |
|
2305 |
|
2306 |
|
2307 | set: function (value) {
|
2308 | this.setPropertyValue("groupCount", value);
|
2309 | },
|
2310 | enumerable: true,
|
2311 | configurable: true
|
2312 | });
|
2313 | Object.defineProperty(DateAxis.prototype, "timezoneOffset", {
|
2314 | |
2315 |
|
2316 |
|
2317 | get: function () {
|
2318 | return this.getPropertyValue("timezoneOffset");
|
2319 | },
|
2320 | |
2321 |
|
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 | set: function (value) {
|
2331 | this.setPropertyValue("timezoneOffset", value);
|
2332 | },
|
2333 | enumerable: true,
|
2334 | configurable: true
|
2335 | });
|
2336 | Object.defineProperty(DateAxis.prototype, "timezone", {
|
2337 | |
2338 |
|
2339 |
|
2340 | get: function () {
|
2341 | return this.getPropertyValue("timezone");
|
2342 | },
|
2343 | |
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 | set: function (value) {
|
2355 | this.setPropertyValue("timezone", value);
|
2356 | },
|
2357 | enumerable: true,
|
2358 | configurable: true
|
2359 | });
|
2360 | Object.defineProperty(DateAxis.prototype, "gridInterval", {
|
2361 | |
2362 |
|
2363 |
|
2364 |
|
2365 |
|
2366 | get: function () {
|
2367 | return this._gridInterval;
|
2368 | },
|
2369 | enumerable: true,
|
2370 | configurable: true
|
2371 | });
|
2372 | |
2373 |
|
2374 |
|
2375 | DateAxis.prototype.makeGap = function (dataItem, previous) {
|
2376 | var series = dataItem.component;
|
2377 | if (dataItem && previous) {
|
2378 | if (!series.connect && $type.isNumber(series.autoGapCount)) {
|
2379 | if (series.baseAxis == this) {
|
2380 | var date = dataItem.dates["date" + this.axisLetter];
|
2381 | var prevDate = previous.dates["date" + this.axisLetter];
|
2382 | if (date && prevDate) {
|
2383 | var time = date.getTime();
|
2384 | var prevTime = prevDate.getTime();
|
2385 | if (time - prevTime > series.autoGapCount * this.baseDuration) {
|
2386 | return true;
|
2387 | }
|
2388 | }
|
2389 | }
|
2390 | }
|
2391 | }
|
2392 | return false;
|
2393 | };
|
2394 | Object.defineProperty(DateAxis.prototype, "baseValue", {
|
2395 | |
2396 |
|
2397 |
|
2398 | get: function () {
|
2399 | return this.min;
|
2400 | },
|
2401 | enumerable: true,
|
2402 | configurable: true
|
2403 | });
|
2404 | return DateAxis;
|
2405 | }(ValueAxis));
|
2406 | export { DateAxis };
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 | registry.registeredClasses["DateAxis"] = DateAxis;
|
2414 | registry.registeredClasses["DateAxisDataItem"] = DateAxisDataItem;
|
2415 |
|
\ | No newline at end of file |