Skip to content

Relayout edge case fixes #1494

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

Merged
merged 2 commits into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/components/annotations/convert_coords.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var toLogRange = require('../../lib/to_log_range');
* same relayout call should override this conversion.
*/
module.exports = function convertCoords(gd, ax, newType, doExtra) {
ax = ax || {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. so that e.g. in relayout blank axis objects that pass the forgiving AX_NAME_PATTERN (which also matches zaxis? by the way) don't leave to exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @alexcjohnson ⤴️

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, if only I could turn back time and not use linearized coordinates on log axes...


var toLog = (newType === 'log') && (ax.type === 'linear'),
fromLog = (newType === 'linear') && (ax.type === 'log');

Expand Down
2 changes: 2 additions & 0 deletions src/components/images/convert_coords.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var toLogRange = require('../../lib/to_log_range');
* same relayout call should override this conversion.
*/
module.exports = function convertCoords(gd, ax, newType, doExtra) {
ax = ax || {};

var toLog = (newType === 'log') && (ax.type === 'linear'),
fromLog = (newType === 'linear') && (ax.type === 'log');

Expand Down
17 changes: 17 additions & 0 deletions test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,23 @@ describe('Test gl3d relayout calls', function() {
.then(done);
});

it('should skip root-level axis objects', function(done) {
Plotly.newPlot(gd, [{
type: 'scatter3d',
x: [1, 2, 3],
y: [1, 2, 3],
z: [1, 2, 1]
}])
.then(function() {
return Plotly.relayout(gd, {
xaxis: {},
yaxis: {},
zaxis: {}
});
})
.catch(fail)
.then(done);
});
});

describe('Test gl2d plots', function() {
Expand Down
15 changes: 15 additions & 0 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,21 @@ describe('Test plot api', function() {
})
.then(done);
});

it('should skip empty axis objects', function(done) {
Plotly.plot(gd, [{
x: [1, 2, 3],
y: [1, 2, 1]
}], {
xaxis: { title: 'x title' },
yaxis: { title: 'y title' }
})
.then(function() {
return Plotly.relayout(gd, { zaxis: {} });
})
.catch(fail)
.then(done);
});
});

describe('Plotly.restyle', function() {
Expand Down