Description
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?