Svjard / jinrikisha

JavaScript toolkit for creating interactive real-time graphs
http://code.shutterstock.com/rickshaw/
MIT License
2 stars 0 forks source link

Timezone is not adjustable for Time based axis #14

Open Svjard opened 11 years ago

Svjard commented 11 years ago

While very elegant, the existing system doesn't seem to allow displaying the x axis unix timestamps using whatever time zone is appropriate (browser time zone for example).

It ends up using (for hour formatting) something like this: new Date(1350425400*1000).toUTCString().match(/(\d+:\d+):/)[1]

See also https://github.com/shutterstock/rickshaw/blob/master/src/js/Rickshaw.Fixtures.Time.js#L5 -- this tzOffset variable isn't being used anywhere.

We actually ran into this problem recently, and we forked the repo to include time zone offset. You can check out the code here: https://github.com/alphaboost/rickshaw/blob/master/src/js/Rickshaw.Graph.Axis.Time.js

Basically, we added an argument to the Rickshaw.Graph.Axis.Time.js, which should be the time zone offset from UTC (i.e. -7 for PDT) * the number of seconds in an hour (3600, since Rickshaw uses seconds instead of milliseconds).

The code isn't quite ready for a pull request on Rickshaw, but it did the trick for us. When we have time to polish it up we'll drop it on a pull.

anders-atex commented 10 years ago

Is there some way to "upvote" this?

I have the same issue and it would be great to be able to optionally pass an argument to set time zone for display. Best? The best would be to just say where you are, something like "CET" or "EST+1" and that would magically set the right offset through the use of some lookup table for constants.

ivks commented 10 years ago

Please use Rickshaw.Fixtures.Time / Rickshaw.Fixtures.Time.Local wherever you need to fix timezone related issues. For eg: var x_axis = new Rickshaw.Graph.Axis.Time({ graph: graph, timeFixture: new Rickshaw.Fixtures.Time.Local() });