Comments (6)
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.
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.
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.
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.
closing this as done, but feel free to discuss further or open new issues for bugs. thabks!
from uplot.
Nice! That's awesome :-) Thanks so much for the fast turnaround!
from uplot.
Related Issues (20)
- How to programatically know if the chart is locked or not? (it was clicked having cursor.lock = true)? HOT 3
- add something like series.order
- ordinal y scales
- hooks.setSeries HOT 3
- About axes.y.splits HOT 3
- Shifted y series not support bar chart type HOT 2
- Change bar color through setCursor hook with bars plugin HOT 5
- UI is overlapping and not sized correctly HOT 4
- really like uPlot but how to get it to work properly HOT 3
- strange behaviour when scaling multiple y axes via setScale HOT 12
- multi-bars valToPos HOT 3
- Labels above all bar and lines HOT 2
- Points and paths are separated when changing scale width HOT 2
- When the data is too large, such as exceeding 1.00e+16, the y-axis cannot render properly? HOT 3
- Title and Legend onto Canvas ? HOT 4
- How to freely segment the timeline in a grouped graph? HOT 12
- How to have scrollable and smaller font in legends? HOT 1
- all-null series incorrectly accumulate log scales to min: 1, max: 10 HOT 2
- Change grid.stroke color HOT 1
- Point hover bounding box option for individual series HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uplot.