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

Option for <canvas> padding #71

Closed
silverwind opened this issue Dec 11, 2019 · 5 comments
Closed

Option for <canvas> padding #71

silverwind opened this issue Dec 11, 2019 · 5 comments

Comments

@silverwind
Copy link
Contributor

silverwind commented Dec 11, 2019

Very minor issue here with a chart with a line width of 4 where the line and highlight dot is partially cut off on 0 values:

Maybe have a option to define a padding on the <canvas> area? I'd define a 2px padding in this case to accommodate the line width.

@leeoniya
Copy link
Owner

sounds doable.

@leeoniya
Copy link
Owner

leeoniya commented Dec 14, 2019

this is now possible to do externally:

https://leeoniya.github.io/uPlot/demos/pad-scale.html

i probably won't add a built-in padding feature because the heuristics can get pretty opinionated and complex, depending on the data & requirements.

another neat thing is the elegant (imo) external impl of mousewheel zooming:

https://leeoniya.github.io/uPlot/demos/wheel-zoom.html

@silverwind
Copy link
Contributor Author

Very nice, thanks. I will play with this soon.

It might be just me but the dot on the first example seems a bit off-centered:

I think the dot position might not yet take the line width into account. I guess I'd also increase the dot radius a bit with, is there a option for it yet?

@leeoniya
Copy link
Owner

leeoniya commented Dec 15, 2019

It might be just me but the dot on the first example seems a bit off-centered: I think the dot position might not yet take the line width into account.

there were a couple rounding issues that should be fixed now. it's never gonna be perfect since all interactive elements are in the DOM while the grid + trendlines are on canvas (which follows devicePixelRatio). feel free to PR any improvements, though.

I guess I'd also increase the dot radius a bit with, is there a option for it yet?

i've moved the dot sizing logic to JS and it's now relative to series line width: Math.max(5, width * 2 - 1). additionally, series.class now exists and will get tacked onto the cursor points & legend, so you can tweak those further in css as required. at some point it might be good to add full customization like providing ready-to-go dom elements for the cursor points, but that'll likely be considered when i give more thought to #10, post 1.0.

@leeoniya
Copy link
Owner

leeoniya commented Mar 4, 2020

@silverwind as of 0bbe163, the custom padding should no longer be necessary. now that the canvas goes extends outside the plotting area, it was a matter of adjusting the clipping regions for the paths and [new!] points.

if you look at https://leeoniya.github.io/uPlot/demos/pad-scale.html, there's no longer anything custom there. i'll remove this demo before 1.0, since it no longer demonstrates anything. i might re-internalize uPlot.rangeNum(), since it was first exposed specifically for this purpose.

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

No branches or pull requests

2 participants