# Chart Timezone Issue : X axis wrong

**URL:** <https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801>\
**Category:** Dashboard\
**Created:** [14 January 2019 16:46 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801 "2019-01-14T16:46:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathi78](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mathi78](https://discourse.nodered.org/u/Mathi78)\
**Post date:** [14 January 2019 16:46 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/1 "2019-01-14T16:46:48Z")

</div>

Hello guys, I found a behavior I can't explain, maybe you can help 🙂 !  
here is my test code :

msg.payload = [{  
"series": ["A", "B", "C"],  
"data": [  
[{ "x": new Date(1504029632890).toUTCString(), "y": 5 },  
{ "x": new Date(1504029636001).toUTCString(), "y": 4 },  
{ "x": new Date(1504029638656).toUTCString(), "y": 2 }  
],  
[{ "x": new Date(1504029633514).toUTCString(), "y": 6 },  
{ "x": new Date(1504029636622).toUTCString(), "y": 7 },  
{ "x": new Date(1504029639539).toUTCString(), "y": 6 }  
],  
[{ "x": new Date(1504029634400).toUTCString(), "y": 7 },  
{ "x": new Date(1504029637959).toUTCString(), "y": 7 },  
{ "x": new Date(1504029640317).toUTCString(), "y": 7 }  
]  
],  
"labels": ["A","b","C"]  
}]

here is the result :

 ![timezone%20chart%20issue](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/07b0f2018f438a140416beee41aa527a9528444f.png)

**When I add the .toUTCString() the time is correct for my zone but the X axis is still wrong (GMT +2).**  
**My NodeRed is in the correct GMT.**

I searched a little on internet and saw some people with the same problem but no good solution ...

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [14 January 2019 18:07 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/2 "2019-01-14T18:07:17Z")

</div>

Try `Date.toLocaleString()`;

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [14 January 2019 18:43 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/3 "2019-01-14T18:43:18Z")

</div>

Why turn those nice timestamps into strings, and send them to the chart as X values? It should do the right thing is you just pass those timestamps in directly:

```auto
"data": [
[{ "x": 1504029632890, "y": 5 },
...

```

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [14 January 2019 18:44 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/4 "2019-01-14T18:44:40Z")

</div>

> [@shrickus](#):
>
> Why turn those nice timestamps into strings

Because of tooltip maybe  
And then the problem starts. X-axsis and tooltip values show different times.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [14 January 2019 18:55 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/5 "2019-01-14T18:55:45Z")

</div>

Then that should be raised as a bug on the dashboard...

The tooltip is meant to be human-readable -- but the charts use UTC timestamps to correctly render the lines, especially when showing in multiple timezones and around Daylight Savings time changes. Since the dashboard line charts are expecting the x-axis to be dates, it detects a timestamp and correctly creates the right date for each point.

DaveCJ will have to elaborate on how the axis tics and tooltips are determining which Locale to use when showing them (typically it uses the browser's timezone and language settings).

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 January 2019 21:32 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/6 "2019-01-14T21:32:39Z")

</div>

Will have a look...  
Pushed a fix to master to make the hover match the xAxis formatting

---

<div class="post-metadata">

**Author:** ![Mathi78](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@Mathi78](https://discourse.nodered.org/u/Mathi78)\
**Post date:** [15 January 2019 08:22 UTC](https://discourse.nodered.org/t/chart-timezone-issue-x-axis-wrong/6801/7 "2019-01-15T08:22:50Z")

</div>

Thanks ! 🙂
