The Wayback Machine - https://web.archive.org/web/20201203021205/https://github.com/leeoniya/uPlot/issues/119
Skip to content
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

Highlight intervals (weekends, etc..) #119

Open
CrashLaker opened this issue Feb 5, 2020 · 2 comments
Open

Highlight intervals (weekends, etc..) #119

CrashLaker opened this issue Feb 5, 2020 · 2 comments
Labels

Comments

@CrashLaker
Copy link

@CrashLaker CrashLaker commented Feb 5, 2020

Hi all,

Is there a way to highlight intervals along the X axis? e.g. weekends, holidays, etc.
Like in:
http://dygraphs.com/gallery/#g/highlighted-weekends

@leeoniya
Copy link
Owner

@leeoniya leeoniya commented Feb 5, 2020

nothing out of the box, but it should be easy enough to author a plugin that does this. you have full access to all timestamps obviously, and you can use uPlot.tzDate() to get a timezone-adjusted date objects which you can use to isolate weekend ranges, then simply paint on u.ctx in the drawAxes hook if want it atop the grid (but below the series), or drawClear hook if you need it under the grid.

take a look at how https://github.com/leeoniya/uPlot/blob/master/demos/draw-hooks.html does everything.

would be a good plugin to author for the demos here ;)

@leeoniya
Copy link
Owner

@leeoniya leeoniya commented Mar 21, 2020

copying from #126 (comment):

yes, you have to use uPlot.tzDate. the real trick is not to iterate every datapoint in the scale range in search of weekends, because that would mean creating 60,000 Date instances when you have 30,000 datapoints. you have to find these weekends efficiently, like the axis ticks find breaks in months, days, hours without walking the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.