Skip to content

Commit 49b4053

Browse files
committedMar 12, 2020
set scattergl and splom traces to visible:false on axis with breaks
- this will be dealt with in #4630
1 parent 1b55b42 commit 49b4053

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
 

Diff for: ‎src/plots/cartesian/axis_defaults.js

+12
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,18 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
128128
handleItemDefaults: breaksDefaults
129129
});
130130
setConvert(containerOut, layoutOut);
131+
132+
if(layoutOut._has('scattergl') || layoutOut._has('splom')) {
133+
for(var i = 0; i < options.data.length; i++) {
134+
var trace = options.data[i];
135+
if(trace.type === 'scattergl' || trace.type === 'splom') {
136+
trace.visible = false;
137+
Lib.warn(trace.type +
138+
' traces do not work on axes with breaks.' +
139+
' Setting trace ' + trace.index + ' to `visible: false`.');
140+
}
141+
}
142+
}
131143
}
132144
}
133145

Diff for: ‎test/jasmine/tests/axes_test.js

+32
Original file line numberDiff line numberDiff line change
@@ -4901,6 +4901,38 @@ describe('Test axes', function() {
49014901
.then(done);
49024902
});
49034903
});
4904+
4905+
it('should set visible:false in scattergl traces on axis with breaks', function(done) {
4906+
var gd = createGraphDiv();
4907+
4908+
spyOn(Lib, 'warn');
4909+
4910+
Plotly.plot(gd, [{
4911+
type: 'scattergl',
4912+
x: [
4913+
'2020-01-02 08:00', '2020-01-02 17:00',
4914+
'2020-01-03 08:00', '2020-01-03 17:00',
4915+
'2020-01-04 08:00', '2020-01-04 17:00',
4916+
'2020-01-05 08:00', '2020-01-05 17:00',
4917+
'2020-01-06 08:00', '2020-01-06 17:00',
4918+
'2020-01-07 08:00', '2020-01-07 17:00'
4919+
]
4920+
}], {
4921+
xaxis: {
4922+
breaks: [{pattern: '%H', bounds: [17, 8]}]
4923+
}
4924+
})
4925+
.then(function() {
4926+
expect(gd._fullData[0].visible).toBe(false, 'sets visible:false');
4927+
expect(Lib.warn).toHaveBeenCalledTimes(1);
4928+
expect(Lib.warn).toHaveBeenCalledWith('scattergl traces do not work on axes with breaks. Setting trace 0 to `visible: false`.');
4929+
})
4930+
.catch(failTest)
4931+
.then(function() {
4932+
destroyGraphDiv();
4933+
done();
4934+
});
4935+
});
49044936
});
49054937
});
49064938

0 commit comments

Comments
 (0)
Please sign in to comment.