-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Include gl3d scene.aspectmode changes in relayout updates #4579
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
Conversation
@@ -219,6 +219,12 @@ proto.initializeGLPlot = function() { | |||
if(scene.isAspectChanged(layout)) { | |||
// scene updates | |||
update[scene.id + '.aspectratio'] = scene.glplot.getAspectratio(); | |||
|
|||
if(layout[scene.id].aspectmode !== 'manual') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we get back to the original aspectmode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When resetting the view (e.g via the modebar buttons), yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I think we have some tests related to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plotly.js/test/jasmine/tests/plot_api_test.js
Lines 394 to 411 in 4d24c36
it('sets aspectmode to manual when you provide any aspectratio', function(done) { | |
Plotly.plot(gd, [{x: [1, 2], y: [1, 2], z: [1, 2], type: 'scatter3d'}]) | |
.then(function() { | |
expect(gd.layout.scene.aspectmode).toBe('auto'); | |
return Plotly.relayout(gd, {'scene.aspectratio.x': 2}); | |
}) | |
.then(function() { | |
expect(gd.layout.scene.aspectmode).toBe('manual'); | |
return Queue.undo(gd); | |
}) | |
.then(function() { | |
expect(gd.layout.scene.aspectmode).toBe('auto'); | |
}) | |
.catch(failTest) | |
.then(done); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, to be clear, once a user scrolls into a orthographic scene, the aspectmode
is turned to 'manual'
and the only way to get back to original aspectmode
is by resetting the view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we should keep that in viewInitial
props?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it handled currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -790,6 +790,9 @@ proto.plot = function(sceneData, fullLayout, layout) { | |||
y: fullSceneLayout.aspectratio.y, | |||
z: fullSceneLayout.aspectratio.z | |||
}; | |||
|
|||
// also keep track of aspectmode here | |||
scene.viewInitial.aspectmode = fullSceneLayout.aspectmode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
if(!scene.viewInitial.aspectmode) {
scene.viewInitial.aspectmode = fullSceneLayout.aspectmode
}
that way we don't override viewInitia.aspectmodel
on updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call.
We could. Done in c730f12.
Thanks - 💃 ! |
Follow up of #4578 this PR adds gl3d
scene.aspectmode
changes in relayout updates.Demo
@plotly/plotly_js