diff --git a/src/plots/cartesian/set_convert.js b/src/plots/cartesian/set_convert.js index e22f2609728..941d01de3e7 100644 --- a/src/plots/cartesian/set_convert.js +++ b/src/plots/cartesian/set_convert.js @@ -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; @@ -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) { diff --git a/test/image/baselines/axes_matches-linear-categories.png b/test/image/baselines/axes_matches-linear-categories.png new file mode 100644 index 00000000000..00f6e5cc12e Binary files /dev/null and b/test/image/baselines/axes_matches-linear-categories.png differ diff --git a/test/image/mocks/axes_matches-linear-categories.json b/test/image/mocks/axes_matches-linear-categories.json new file mode 100644 index 00000000000..806df011a02 --- /dev/null +++ b/test/image/mocks/axes_matches-linear-categories.json @@ -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
->" + }, + "anchor": "x3", + "domain": [ 0.5, 0.75 ] + }, + "yaxis3": { + "anchor": "x3", + "title": { + "text": "matches
<-" + }, + "domain": [ 0.75, 1 ], + "matches": "y2" + } + } +}