Git Product home page Git Product logo

Comments (6)

leeoniya avatar leeoniya commented on May 22, 2024

i guess my answer for this is more-or-less the same as #43. but maybe native timezone support is more trivial than i18n, so i'll leave this open for now.

from uplot.

benmccann avatar benmccann commented on May 22, 2024

Supporting time zones can be a little more challenging than just formatting because it also changes where the date boundaries are. So if you want to support something like what I was calling "major" ticks or labels then the code that determines whether a date is a new hour, month, year, etc. also needs to take into account what timezone the chart is being displayed in.

from uplot.

leeoniya avatar leeoniya commented on May 22, 2024

i think most of the date snapping is already handled in uPlot and simply providing & passing through a tz offset opt should be sufficient.

do you have any small representative datasets and what you expect to see?

from uplot.

leeoniya avatar leeoniya commented on May 22, 2024

ok, this was a "fun" challenge.

what i ended up with is a solution based on this neat "hack" [1]. i tested it for a few timezones and it seemed to work well. in essence it allows you to grab the timezone offset for any timestamp in a named timezone.

the compat is pretty good for it [2]: "toLocaleDateString: IANA time zone names in timeZone option".

the high/low bands demo actually needed this since it showed the gold prices at some mid-day 5pm times (on my machine) when the timestamps were all for 12am UTC. here's what the API is for now:

https://github.com/leeoniya/uPlot/blob/master/demos/high-low-bands.html#L44

let me know if it gives you the expected results.

[1] https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Browser_compatibility

from uplot.

leeoniya avatar leeoniya commented on May 22, 2024

closing this as done, but feel free to discuss further or open new issues for bugs. thabks!

from uplot.

benmccann avatar benmccann commented on May 22, 2024

Nice! That's awesome :-) Thanks so much for the fast turnaround!

from uplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.