Skip to content

Commit

Permalink
Merge pull request #3565 from plotly/matching-axes-category-and-linear
Browse files Browse the repository at this point in the history
Fix category init for non-matching axes on graphs with matching axes
  • Loading branch information
etpinard authored Feb 21, 2019
2 parents 3fc50cc + 598a67b commit 9ef8617
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/plots/cartesian/set_convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,21 @@ module.exports = function setConvert(ax, fullLayout) {

// should skip if not category nor multicategory
ax.clearCalc = function() {
var emptyCategories = function() {
ax._categories = [];
ax._categoriesMap = {};
};

var matchGroups = fullLayout._axisMatchGroups;

if(matchGroups && matchGroups.length) {
var found = false;

for(var i = 0; i < matchGroups.length; i++) {
var group = matchGroups[i];

if(group[axId]) {
found = true;
var categories = null;
var categoriesMap = null;

Expand All @@ -598,14 +606,14 @@ module.exports = function setConvert(ax, fullLayout) {
ax._categories = categories;
ax._categoriesMap = categoriesMap;
} else {
ax._categories = [];
ax._categoriesMap = {};
emptyCategories();
}
break;
}
}
if(!found) emptyCategories();
} else {
ax._categories = [];
ax._categoriesMap = {};
emptyCategories();
}

if(ax._initialCategories) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions test/image/mocks/axes_matches-linear-categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"data": [
{
"y": [ "a", "b" ],
"x": [ 1, 2 ],
"xaxis": "x",
"yaxis": "y"
},
{
"y": [ "a", "b" ],
"x": [ 1, 2 ],
"xaxis": "x2",
"yaxis": "y"
},
{
"x": [ "a", "b" ],
"y": [ 1, 2 ],
"xaxis": "x3",
"yaxis": "y2"
},
{
"x": [ "a", "b" ],
"y": [ 1, 2 ],
"xaxis": "x3",
"yaxis": "y3"
}
],
"layout": {
"showlegend": false,
"xaxis": {
"title": {
"text": "matches ->"
},
"domain": [ 0, 0.5 ]
},
"xaxis2": {
"title": {
"text": "matches <-"
},
"domain": [ 0.5, 1 ],
"matches": "x"
},
"xaxis3": {
"anchor": "y2"
},
"yaxis": {
"domain": [ 0, 0.4 ]
},
"yaxis2": {
"title": {
"text": "matches<br>->"
},
"anchor": "x3",
"domain": [ 0.5, 0.75 ]
},
"yaxis3": {
"anchor": "x3",
"title": {
"text": "matches<br><-"
},
"domain": [ 0.75, 1 ],
"matches": "y2"
}
}
}

0 comments on commit 9ef8617

Please sign in to comment.