Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Fix relayout constrained axes + various multi-subplot perf improvements#2628
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a12a22b23964caabd4bcf09d5dd05557d7b73b354be69b7ddc947b2c6fa8ffd455ff4d72b6558File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -50,7 +50,7 @@ exports.lsInner = function(gd) { | ||
| var fullLayout = gd._fullLayout; | ||
| var gs = fullLayout._size; | ||
| var pad = gs.p; | ||
| var axList = Axes.list(gd); | ||
| var axList = Axes.list(gd, '', true); | ||
| // _has('cartesian') means SVG specifically, not GL2D - but GL2D | ||
| // can still get here because it makes some of the SVG structure | ||
| @@ -95,6 +95,11 @@ exports.lsInner = function(gd) { | ||
| ax._mainMirrorPosition = (ax.mirror && counterAx) ? | ||
| getLinePosition(ax, counterAx, | ||
| alignmentConstants.OPPOSITE_SIDE[ax.side]) : null; | ||
| // Figure out which subplot to draw ticks, labels, & axis lines on | ||
| // do this as a separate loop so we already have all the | ||
| // _mainAxis and _anchorAxis links set | ||
| ax._mainSubplot = findMainSubplot(ax, fullLayout); | ||
| } | ||
| fullLayout._paperdiv | ||
| @@ -324,6 +329,48 @@ exports.lsInner = function(gd) { | ||
| return gd._promises.length && Promise.all(gd._promises); | ||
| }; | ||
| function findMainSubplot(ax, fullLayout) { | ||
| ||
| var subplotList = fullLayout._subplots; | ||
| var ids = subplotList.cartesian.concat(subplotList.gl2d || []); | ||
| var mockGd = {_fullLayout: fullLayout}; | ||
| var isX = ax._id.charAt(0) === 'x'; | ||
| var anchorAx = ax._mainAxis._anchorAxis; | ||
| var mainSubplotID = ''; | ||
| var nextBestMainSubplotID = ''; | ||
| var anchorID = ''; | ||
| // First try the main ID with the anchor | ||
| if(anchorAx) { | ||
| anchorID = anchorAx._mainAxis._id; | ||
| mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id); | ||
| } | ||
| // Then look for a subplot with the counteraxis overlaying the anchor | ||
| // If that fails just use the first subplot including this axis | ||
| if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) { | ||
| mainSubplotID = ''; | ||
| for(var j = 0; j < ids.length; j++) { | ||
| var id = ids[j]; | ||
| var yIndex = id.indexOf('y'); | ||
| var idPart = isX ? id.substr(0, yIndex) : id.substr(yIndex); | ||
| var counterPart = isX ? id.substr(yIndex) : id.substr(0, yIndex); | ||
| if(idPart === ax._id) { | ||
| if(!nextBestMainSubplotID) nextBestMainSubplotID = id; | ||
| var counterAx = Axes.getFromId(mockGd, counterPart); | ||
| if(anchorID && counterAx.overlaying === anchorID) { | ||
| mainSubplotID = id; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return mainSubplotID || nextBestMainSubplotID; | ||
| } | ||
| function shouldShowLinesOrTicks(ax, subplot) { | ||
| return (ax.ticks || ax.showline) && | ||
| (subplot === ax._mainSubplot || ax.mirror === 'all' || ax.mirror === 'allticks'); | ||
| @@ -448,8 +495,12 @@ exports.doLegend = function(gd) { | ||
| return Plots.previousPromises(gd); | ||
| }; | ||
| exports.doTicksRelayout = function(gd) { | ||
| Axes.doTicks(gd, 'redraw'); | ||
| exports.doTicksRelayout = function(gd, rangesAltered) { | ||
| if(rangesAltered) { | ||
| Axes.doTicks(gd, Object.keys(rangesAltered), true); | ||
| } else { | ||
| Axes.doTicks(gd, 'redraw'); | ||
| } | ||
| if(gd._fullLayout._hasOnlyLargeSploms) { | ||
| clearGlCanvases(gd); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, nice catch!