Skip to content
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

Fix category init for non-matching axes on graphs with matching axes #3565

Merged
merged 2 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
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"
}
}
}