-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Support] Set Timezone to UTC on Graph #4334
Comments
@srose4 I think your best way to support this is to convert the data to UTC before passing to the chart. Otherwise, we'd need to conditional all of the |
@etimberg Whether I use moment() or moment.utc(), the date is stilled displayed with local browser time zone conversion. If you inspect the first date object, time is 3am(gmt). However it is displayed on my graph as EST and in PST in Cali. What I want is, No matter where the user is located, the graph should always display 3am for the first point on the x-axis. I'm trying to understand if this is a bug in my code, a bug in chart.js, or an item not well documented? |
Hmmm, ok I will do some investigation and see what I can find |
Yea this was sort of a problem for me as well. From poking about, it seems to be because the moment objects are converted to integer timestamps and passed to the Chart.Ticks.generators.time instead of preserving them. So inside the generator, moment( ) is called on the timestamp causing it to convert to local time. The solution for anyone that doesn't care its global can just use the moment-timezone extension that allows setting the global default for moment( ) usage. i.e.
|
Well, I do care that the proposed fix is global and I need to include another lib and would appreciate if this is fixed in chart.js. This is rather fundamental. |
+1 |
Using moment.utc gets me the correct time on the tooltip but the x-axis labels are still wrong.
This gave me the format I want. No idea why the ticks formatting is independent of the tooltip formatting but this is a work around (ie recasting the original value back into a moment.utc and manually applying a format). |
I've created issue #5186 to consolidate the various pieces of feedback we've received regarding time zone support. I'm going to close this issue in favor of that one. Please feel free to subscribe to it for update |
@marekr is there anything more to just importing
I've experimented and the chart seems to ignore it. I was expecting the time series to update with the +5 hours (from NY). ❓ |
There's quite a bit more to it. Chart.js needs substantial updates. I'm working on it, but trying to do it without including |
I found a solution to this problem, but we need to revise a line of code in Here is an example: More explicitly speaking, find the |
Where do I put it? I get |
Hi, I am trying to display the date on the x-axis to UTC, so everyone's graph has the same date. I followed the suggestions at https://stackoverflow.com/questions/40891462/chart-js-display-control-timescale-time-zone but I cannot get this to work. Here is my simple project https://jsfiddle.net/quantonos/znqfu2bp/ People should see 3am as the start time. I see 10pm EST since I'm in EST. Thanks
The text was updated successfully, but these errors were encountered: