tvcharts 0.9.36 → 0.9.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -536,7 +536,7 @@ function setEventData(el, graphicModel, elOption) {
|
|
|
536
536
|
}
|
|
537
537
|
// `elOption.info` enables user to mount some info on
|
|
538
538
|
// elements and use them in event handlers.
|
|
539
|
-
if (eventData) {
|
|
539
|
+
if (eventData && elOption.hasOwnProperty('info')) {
|
|
540
540
|
eventData.info = elOption.info;
|
|
541
541
|
}
|
|
542
542
|
}
|
|
@@ -45,52 +45,45 @@ export function weightToTickMarkType(weight, timeVisible, secondsVisible) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
var dateTimeFormatCache = {};
|
|
49
|
+
function getDateTimeFormat(locale, timeZone, tickMarkType) {
|
|
50
|
+
var key = locale + '\0' + timeZone + '\0' + tickMarkType;
|
|
51
|
+
var fmt = dateTimeFormatCache[key];
|
|
52
|
+
if (!fmt) {
|
|
53
|
+
var options = {
|
|
54
|
+
timeZone: timeZone
|
|
55
|
+
};
|
|
56
|
+
switch (tickMarkType) {
|
|
57
|
+
case 0 /* Year */:
|
|
58
|
+
options.year = 'numeric';
|
|
59
|
+
break;
|
|
60
|
+
case 1 /* Month */:
|
|
61
|
+
options.month = 'short';
|
|
62
|
+
break;
|
|
63
|
+
case 2 /* DayOfMonth */:
|
|
64
|
+
options.day = 'numeric';
|
|
65
|
+
break;
|
|
66
|
+
case 3 /* Time */:
|
|
67
|
+
options.hour12 = false;
|
|
68
|
+
options.hour = '2-digit';
|
|
69
|
+
options.minute = '2-digit';
|
|
70
|
+
break;
|
|
71
|
+
case 4 /* TimeWithSeconds */:
|
|
72
|
+
options.hour12 = false;
|
|
73
|
+
options.hour = '2-digit';
|
|
74
|
+
options.minute = '2-digit';
|
|
75
|
+
options.second = '2-digit';
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
fmt = new Intl.DateTimeFormat(locale, options);
|
|
79
|
+
dateTimeFormatCache[key] = fmt;
|
|
80
|
+
}
|
|
81
|
+
return fmt;
|
|
82
|
+
}
|
|
48
83
|
export function defaultTickMarkFormatter(timePoint, tickMarkType, locale, timeZone) {
|
|
49
84
|
if (timeZone === void 0) {
|
|
50
85
|
timeZone = 'Asia/Shanghai';
|
|
51
86
|
}
|
|
52
|
-
var formatOptions = {
|
|
53
|
-
timeZone: timeZone
|
|
54
|
-
};
|
|
55
|
-
switch (tickMarkType) {
|
|
56
|
-
case 0 /* Year */:
|
|
57
|
-
formatOptions.year = 'numeric';
|
|
58
|
-
break;
|
|
59
|
-
case 1 /* Month */:
|
|
60
|
-
formatOptions.month = 'short';
|
|
61
|
-
break;
|
|
62
|
-
case 2 /* DayOfMonth */:
|
|
63
|
-
formatOptions.day = 'numeric';
|
|
64
|
-
break;
|
|
65
|
-
case 3 /* Time */:
|
|
66
|
-
formatOptions.hour12 = false;
|
|
67
|
-
formatOptions.hour = '2-digit';
|
|
68
|
-
formatOptions.minute = '2-digit';
|
|
69
|
-
break;
|
|
70
|
-
case 4 /* TimeWithSeconds */:
|
|
71
|
-
formatOptions.hour12 = false;
|
|
72
|
-
formatOptions.hour = '2-digit';
|
|
73
|
-
formatOptions.minute = '2-digit';
|
|
74
|
-
formatOptions.second = '2-digit';
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
return '';
|
|
78
|
-
}
|
|
79
87
|
var date = new Date(timePoint.timestamp * 1000);
|
|
80
|
-
return
|
|
81
|
-
// const date = timePoint.businessDay === undefined
|
|
82
|
-
// ? new Date(timePoint.timestamp * 1000)
|
|
83
|
-
// : new Date(Date.UTC(timePoint.businessDay.year, timePoint.businessDay.month - 1, timePoint.businessDay.day));
|
|
84
|
-
// // from given date we should use only as UTC date or timestamp
|
|
85
|
-
// // but to format as locale date we can convert UTC date to local date
|
|
86
|
-
// const localDateFromUtc = new Date(
|
|
87
|
-
// date.getUTCFullYear(),
|
|
88
|
-
// date.getUTCMonth(),
|
|
89
|
-
// date.getUTCDate(),
|
|
90
|
-
// date.getUTCHours(),
|
|
91
|
-
// date.getUTCMinutes(),
|
|
92
|
-
// date.getUTCSeconds(),
|
|
93
|
-
// date.getUTCMilliseconds()
|
|
94
|
-
// );
|
|
95
|
-
// return localDateFromUtc.toLocaleString(locale, formatOptions);
|
|
88
|
+
return getDateTimeFormat(locale, timeZone, tickMarkType).format(date);
|
|
96
89
|
}
|