Skip to content

Commit f442f59

Browse files
committed
fixup autotype for splom trace w/ visible false dims
1 parent a077c3f commit f442f59

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/plots/cartesian/type_defaults.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ function setAutoType(ax, data) {
6565

6666
var calAttr = axLetter + 'calendar';
6767
var calendar = d0[calAttr];
68+
var i;
6869

6970
// check all boxes on this x axis to see
7071
// if they're dates, numbers, or categories
7172
if(isBoxWithoutPositionCoords(d0, axLetter)) {
7273
var posLetter = getBoxPosLetter(d0);
7374
var boxPositions = [];
7475

75-
for(var i = 0; i < data.length; i++) {
76+
for(i = 0; i < data.length; i++) {
7677
var trace = data[i];
7778
if(!Registry.traceIs(trace, 'box-violin') ||
7879
(trace[axLetter + 'axis'] || axLetter) !== id) continue;
@@ -87,7 +88,14 @@ function setAutoType(ax, data) {
8788
ax.type = autoType(boxPositions, calendar);
8889
}
8990
else if(d0.type === 'splom') {
90-
ax.type = autoType(d0.dimensions[0].values, calendar);
91+
var dimensions = d0.dimensions;
92+
for(i = 0; i < dimensions.length; i++) {
93+
var dim = dimensions[i];
94+
if(dim.visible) {
95+
ax.type = autoType(dim.values, calendar);
96+
break;
97+
}
98+
}
9199
}
92100
else {
93101
ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar);

test/jasmine/tests/splom_test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,17 @@ describe('Test splom trace defaults:', function() {
139139
expect(fullLayout.xaxis.type).toBe('category');
140140
expect(fullLayout.yaxis.type).toBe('category');
141141
});
142+
143+
it('should lead to correct axis auto type value (case 2)', function() {
144+
_supply({
145+
dimensions: [
146+
{visible: false, values: ['2018-01-01', '2018-02-01', '2018-03-03']},
147+
{values: ['2018-01-01', '2018-02-01', '2018-03-03']}
148+
]
149+
});
150+
151+
var fullLayout = gd._fullLayout;
152+
expect(fullLayout.xaxis.type).toBe('date');
153+
expect(fullLayout.yaxis.type).toBe('date');
154+
});
142155
});

0 commit comments

Comments
 (0)