Skip to content

Commit 28347ff

Browse files
committed
add fallback to annotations/images convertCoords
- so that they don't throw exceptions with the excepted axis container is undefined.
1 parent 35c5917 commit 28347ff

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/components/annotations/convert_coords.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var toLogRange = require('../../lib/to_log_range');
2626
* same relayout call should override this conversion.
2727
*/
2828
module.exports = function convertCoords(gd, ax, newType, doExtra) {
29+
ax = ax || {};
30+
2931
var toLog = (newType === 'log') && (ax.type === 'linear'),
3032
fromLog = (newType === 'linear') && (ax.type === 'log');
3133

src/components/images/convert_coords.js

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var toLogRange = require('../../lib/to_log_range');
3131
* same relayout call should override this conversion.
3232
*/
3333
module.exports = function convertCoords(gd, ax, newType, doExtra) {
34+
ax = ax || {};
35+
3436
var toLog = (newType === 'log') && (ax.type === 'linear'),
3537
fromLog = (newType === 'linear') && (ax.type === 'log');
3638

test/jasmine/tests/gl_plot_interact_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,23 @@ describe('Test gl3d relayout calls', function() {
679679
.then(done);
680680
});
681681

682+
it('should skip root-level axis objects', function(done) {
683+
Plotly.newPlot(gd, [{
684+
type: 'scatter3d',
685+
x: [1, 2, 3],
686+
y: [1, 2, 3],
687+
z: [1, 2, 1]
688+
}])
689+
.then(function() {
690+
return Plotly.relayout(gd, {
691+
xaxis: {},
692+
yaxis: {},
693+
zaxis: {}
694+
});
695+
})
696+
.catch(fail)
697+
.then(done);
698+
});
682699
});
683700

684701
describe('Test gl2d plots', function() {

test/jasmine/tests/plot_api_test.js

+15
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,21 @@ describe('Test plot api', function() {
237237
})
238238
.then(done);
239239
});
240+
241+
it('should skip empty axis objects', function(done) {
242+
Plotly.plot(gd, [{
243+
x: [1, 2, 3],
244+
y: [1, 2, 1]
245+
}], {
246+
xaxis: { title: 'x title' },
247+
yaxis: { title: 'y title' }
248+
})
249+
.then(function() {
250+
return Plotly.relayout(gd, { zaxis: {} });
251+
})
252+
.catch(fail)
253+
.then(done);
254+
});
240255
});
241256

242257
describe('Plotly.restyle', function() {

0 commit comments

Comments
 (0)