-
Notifications
You must be signed in to change notification settings - Fork 301
New chart layout algorithm #258
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
Comments
Hi, thanks for working on this. In general this sounds great to me, and it would be awesome if Plotters can do some automatic adjustment by default. There are few things coming out from my mind at this time:
Also, I am curious is the new layout algorithm able to automatically layout multi-panel charts? BTW, as the scratch crate doesn't introduces tons of dependencies, I would like to make it default in next major release if everything goes well. Really appreciate for the contribution! |
Great :-). The new algorithm will exist in parallel to the old one, since it cannot be a drop-in replacement (it cannot eagerly return a sub drawing area). Can you explain more what's needed for "real time" mode? |
In real time mode, the trick is we only update the actual chart area, but keep those axes and labels untouched when possible. So we need to make sure that new layout algorithm will not move/resize while the dynamic chart is updating. Oh, an irrelevant question if you don't mind. As long as the new algorithm is based on layout boxes, so I am also curious the possibility of interactivity based on this new algorithm? For example, dispatching the UI event to particular label and axis based on the box model ? See discussion under #13. Forgive me if you feel this is out of your scope. |
This should work fine with the new algorithm. The
Yes. With a box model, it should be fairly easy to translate pixel locations into lists of elements below that pixel. |
I am working on a new chart layout algorithm that may be slightly controversial, so I wanted to get some feedback before I make a PR.
My goal is to make charts appear nicer by default. For example, to have margins/padding automatically computed based on font size and to prevent axis labels from printing off the edge as in
The idea I had was to use the stretch library, which performs flex-box calculations in Rust (and is WASM compatible and supposedly very efficient). Then, a chart could be laid out as a series of nested flex boxes, and a layout could be computed when needed, instead of immediately as in the current
ChartBuilder
api.If a layout is set up and then computed, this means it can have default font sizes, etc, which can be overwritten, instead of everything having to be set upfront. Size calculations can then be done dynamically.
So far I have decomposed a chart into regions as follows:
Any region can have a size set to zero and it will disappear from the layout. I believe the above decomposition will be able to handle all current use cases. Please correct me if I'm wrong!
Is this something that would make it into standard
plotters
? Behind a config flag maybe?The text was updated successfully, but these errors were encountered: