I'm using D3 to graph some data, and if I change my time zone away from my current one, the time scale changes based on my client's time zone. I would rather be able to force the graph to display in one time zone because that's what the data makes sense when being looked at.
I am using
x.domain([lowerTime, upperTime])
to create the x axis, but I'm not sure how I'd take advantage of
x.timeFormat()
to force this domain to be in a certain time zone, can anyone help here?
By using Time Scales you can get the following:
# d3.time.scale.utc()
Constructs a new time scale with the default domain and range; the ticks and tick format are configured for UTC time.
So, in the end you can do:
scale = d3.time.scale.utc()
scale.domain([lowerTime, upperTime])
Now you have the same time on any client. You still have to figure out what is your current time in UTC, but it is way easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With