8000 rework matching & scaleanchor so they work together by alexcjohnson · Pull Request #5287 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

rework matching & scaleanchor so they work together #5287

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

Merged
merged 11 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove autorange duplication for matching axes
  • Loading branch information
alexcjohnson committed Nov 20, 2020
commit d9f4641ae9e78b7ae48adebcbb2d392c7388b695
22 changes: 20 additions & 2 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,28 @@ exports.doAutoRangeAndConstraints = function(gd) {
var axList = Axes.list(gd, '', true);
var ax;

var autoRangeDone = {};

for(var i = 0; i < axList.length; i++) {
ax = axList[i];
cleanAxisConstraints(gd, ax);
doAutoRange(gd, ax);
if(!autoRangeDone[ax._id]) {
autoRangeDone[ax._id] = 1;
cleanAxisConstraints(gd, ax);
doAutoRange(gd, ax);

// For matching axes, just propagate this autorange to the group.
// The extra arg to doAutoRange avoids recalculating the range,
// since doAutoRange by itself accounts for all matching axes. but
// there are other side-effects of doAutoRange that we still want.
var matchGroup = ax._matchGroup;
if(matchGroup) {
for(var id2 in matchGroup) {
var ax2 = Axes.getFromId(gd, id2);
doAutoRange(gd, ax2, ax.range);
autoRangeDone[id2] = 1;
}
}
}
}

enforceAxisConstraints(gd);
Expand Down
6 changes: 2 additions & 4 deletions src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ function concatExtremes(gd, ax, noMatch) {
_concat(fullLayout.shapes || [], ax._shapeIndices || []);

// Include the extremes from other matched axes with this one
// TODO: find a way to only do this calculation once, rather than
// repeating it for every axis in the matched group
if(ax._matchGroup && !noMatch) {
for(var axId2 in ax._matchGroup) {
if(axId2 !== ax._id) {
Expand All @@ -269,11 +267,11 @@ function concatExtremes(gd, ax, noMatch) {
return {min: minArray, max: maxArray};
}

function doAutoRange(gd, ax) {
function doAutoRange(gd, ax, presetRange) {
ax.setScale();

if(ax.autorange) {
ax.range = getAutoRange(gd, ax);
ax.range = presetRange ? presetRange.slice() : getAutoRange(gd, ax);

ax._r = ax.range.slice();
ax._rl = Lib.simpleMap(ax._r, ax.r2l);
Expand Down
0