Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e714651

Browse files
Improvement - Allow more formats for time values when using datetimeFormatter
1 parent 44b12da commit e714651

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎src/useTimeLabels.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ export function useTimeLabels({
1919
}) {
2020
const out = [];
2121
if (!xl.enable || values.length === 0) {
22-
for (let i = sliceStart; i < sliceEnd; i++) {
22+
for (let i = sliceStart; i < sliceEnd; i+=1) {
2323
out.push({ text: String(values[i] ?? i), absoluteIndex: i });
2424
}
2525
return out;
2626
}
2727

28-
const window = values.slice(sliceStart, sliceEnd);
28+
const formattedValues = values.map(v => {
29+
const f = new Date(v).getTime();
30+
return isNaN(f) ? v : f
31+
});
32+
33+
const window = formattedValues.slice(sliceStart, sliceEnd);
2934
if (window.length === 0) return [];
3035
const minX = window[0], maxX = window[window.length - 1];
3136
const dt = useDateTime({

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /