-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Automargin pipeline #2704
Comments
- N.B. consider this a 'temporary' fix until we improve the automargin pipeline, see #2704 for more detail.
This wasn't possible the first time round because as the margins change, some components change how they draw themselves... for example as the left margin increases, the x-axis tick labels compress and then draw themselves on an angle. |
After an investigation, I'm realising that our "pipeline problems" are a little deeper than first expected, specifically for cartesian axes. In brief, cartesian auto-margin push values depend on the axis range (as the axis range determines which tick labels appear on the graph and thus their size) AND cartesian axis auto-range depends on the margins (via To illustrate, consider: Plotly.newPlot('graph', [{
mode: 'markers',
marker: {size: 100},
x: [1, 200, 6000]
}], {
width: 400, height: 400,
yaxis: {
visible: false,
range: [-1, 3]
},
xaxis: {
tickfont: {size: 32},
tickangle: 'auto',
automargin: true,
autorange: true
},
margin: {l: 0, t: 0, r: 0, b: 0}
}) where the auto-range padding and auto-margin push values are exaggerated via With the current pipeline,
So, there are a few ways to "quickly" fix the problem. Off the top of my head:
All in all, I can wait to get rid of the replot calls inside |
The approach I used in my original |
Writing down a few notes I took on the topic: Components that push margins
Coming soon:
Components that depend on the axis auto-range results
Current sketch of plot pipeline
Other "plot pipeline" problems (in near future)
|
Pre
|
var seq = [ | |
Plots.previousPromises, | |
addFrames, | |
drawFramework, | |
positionAndAutorange, | |
pushMargin, | |
pushMarginAgain, | |
pushMarginAgain, | |
positionAndAutorange, | |
saveInitial, | |
subroutines.layoutStyles, | |
subroutines.drawData, | |
subroutines.drawMarginPushers, | |
drawAxes, | |
subroutines.finalDraw, | |
initInteractions, | |
Plots.addLinks, | |
Plots.rehover, | |
Plots.redrag, | |
Plots.previousPromises | |
]; |
Some general TODOs:
- fixup the image tests
- margin pushes for colorbar with titles are off
- constrained axes sometimes don't get the right range
- investigate sub-pixels diff
- add new subroutine to make
relayout
work again for margin-pushing components- this is necessary now that
Plots.autoMargin
can no longer trigger a redraw
- this is necessary now that
- perf testing!!
- investigate transfering in text elements from
Drawing.tester
into graph div, instead of drawing them twice
Dropping from the Unfortunately, I'm not sure if we'll have the time to resume work on this ticket until the start of 2020. |
Quick note saying that I won't remove branch https://github.com/plotly/plotly.js/tree/auto-margin-pipeline-DEV which was referenced above in #2704 (comment) This branch is already too far behind |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
Our automatic margin expansion system is a mess: components generally determine their sizes - and thus the amount they need to increase the margin - only while being drawn. So in order for the new margin to take effect, the component gets drawn, which updates the margin calculation, then all of these components need to be drawn again if the new margin is different from the old one. The situation is even worse for axis automargins, since axes are drawn later in the process, changes they make to the margins result in an entire redraw of the plot, ie nearly doubling the initial plot time.
Much better would be to separate out margin calculations from component drawing; that way we can determine all sizes before we draw anything, then each component need only be drawn once. The challenge with this is that these sizes depend on text bounding boxes, so in order for this not to add its own overhead we may need to create the text elements as part of the margin calculation step, stash them somewhere hidden, and then pull them back out during the drawing step and attach them to the component. Or perhaps the two steps are 1) component creation and sizing, 2) component positioning and updating?
Some related discussion happened during #2681. See also #1988 and #2434.
The text was updated successfully, but these errors were encountered: