Skip to content

Commit 11d8ee0

Browse files
committed
Instead of adjusting the histogram X Axis lables for local time, keep the labels 00-23 and access the bins according to local time
1 parent cafcaf3 commit 11d8ee0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Histogram.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class Histogram extends Component{
1919
formatHistogram(histogram) {
2020
return Object.keys(histogram).sort().map(x => {
2121
return {
22-
// Adjust the 24 hour 'name' for local timezone
23-
'name': ((parseInt(x) - new Date().getTimezoneOffset() / 60 + 24) % 24).toString().padStart(2,"0"),
24-
'count': histogram[x]
22+
// Display the histogram starting at midnight --local-- time.
23+
// To do this, access the histogram bins with the index adjusted by the timezone offset in hours.
24+
'name': x,
25+
'count': histogram[((parseInt(x) + new Date().getTimezoneOffset() / 60 + 24) % 24).toString().padStart(2,"0")]
2526
}
2627
})
2728
}

0 commit comments

Comments
 (0)