Skip to content

Commit

Permalink
add "matches" + "scaleanchor" mock
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Feb 1, 2019
1 parent 9f2fad1 commit 8c09944
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,8 @@ exports.doAutoRangeAndConstraints = function(gd) {
doAutoRange(gd, ax);
}

enforceAxisConstraints(gd);

// TODO bypass this when matching axes aren't autoranged?
for(var j = 0; j < matchGroups.length; j++) {
var group = matchGroups[j];
Expand Down Expand Up @@ -737,9 +739,6 @@ exports.doAutoRangeAndConstraints = function(gd) {
ax.setScale(0);
}
}

// TODO before or after matching axes?
enforceAxisConstraints(gd);
};

// An initial paint must be completed before these components can be
Expand Down
2 changes: 0 additions & 2 deletions src/plots/cartesian/constraints.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, a
found = true;
}

// TODO what happens when both scaleanchor and matches are present???

if(matches) {
updateConstraintGroups(matchGroups, opts.thisGroup, thisID, matches, 1);
found = true;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions test/image/mocks/axes_scaleanchor-with-matches.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"data":[
{"x": [0,1,1,0,0,1,1,2,2,3,3,2,2,3], "y": [0,0,1,1,3,3,2,2,3,3,1,1,0,0]},
{"x": [0,1,2,3], "y": [1,2,4,8], "yaxis":"y2"}
],
"layout":{
"width": 500,
"height": 500,
"xaxis": {
"constrain": "domain"
},
"yaxis": {
"scaleanchor": "x",
"constrain": "domain",
"domain": [0, 0.45],
"title": {"text": "1:1<br>matching y range above"}
},
"yaxis2": {
"matches": "y",
"constrain": "domain",
"scaleanchor": "x",
"scaleratio": 0.2,
"domain": [0.55, 1],
"title": {"text": "1:5<br>matching y range below"}
},
"showlegend": false
}
}

0 comments on commit 8c09944

Please sign in to comment.