Skip to content

Subplot mode bars #258

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 21 commits into from
Feb 17, 2016
Merged

Subplot mode bars #258

merged 21 commits into from
Feb 17, 2016

Conversation

etpinard
Copy link
Contributor

@mdtusz

A follow-up of #246

This PR ended up being pretty big as I kept discovering bugs in some very uncharted waters of the plotly.js subplot sea 🌊

Main additions

  • Mode bar of multi-subplot-type graphs don't look hideous any more. This PR adds multi-plot-type mode bar buttons that can reset the view and toggle hover label visibility of all subplots at once.
  • layout.hovermode and layout.dragmode are now also attributes of each gl3d scene. This was needed so that cartesian and gl3d hovermodes and dragmodes don't conflict with one another. In gl3d-only graphs scene.hovermode and scene.dragmode inherit from layout.hovermode and layout.dragmode respectively, keeping backward compatibility.
  • Mode bar button click handlers are now tested.

Previously undiscovered bug fixes

  • Gl3d scenes used to not hide hover labels when hovermode was set to false (I can't believe we never caught that)
  • Gl3d scenes used to set their camera position using the camera attribute of the first scene always..
  • The GL3d toggle hover mode button used to reset the scene domains after two clicks.
  • Resetting the camera position to last save when the supplied camera attribute wasn't filled with all eye, center and up objects did not work (resulted in a js error)

 - using nested property to dive into fullLayout
- Use layout.dragmode and layout.hovermode as default
  for layout.scene?.dragmode and layout.scene?.hovermode
  if plot has only GL3D (backward compat) and if valid
 - which is more robust then via layout (in case where
   users partly supply the camera object.
  - the previous version overrode the current scene layout
 - this fixes an to this point undiscovered bug, where the
   camera position of non-first scenes in multi-scene
   wasn't set properly.
- to be consistent with scene2d
- note that updateFx is called w/o passing through scene.proto.plot
  for Plotly.relayout when 'layout.dragmode' and/or
  'layout.hovermode' are updated
 - these will only run locally at the moment as
   and until #241
   is resolved.
- propatet hovermode update into geo using updateFx
- port relayout shortcut from modebar to Plotly.relayout
- make toogle hover mode bar using stock Plotly.relayout
- graphs with more than one plot types get 'union buttons'
  which reset the view or toggle hover labels across all subplots.
 so that cartesian plots keep retrieve their 'x' and 'y' hovermode
 when toggling.
@etpinard etpinard added this to the subplotly.js milestone Feb 16, 2016

function handleHover3d(gd, ev) {
var button = ev.currentTarget,
val = JSON.parse(button.getAttribute('data-val')) || false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Will button.getAttribute('data-val') always be defined? If not, I think this will throw an error.

Also, are we really storing JSON as a string in the dom with a data-attribute?

@mdtusz
Copy link
Contributor

mdtusz commented Feb 17, 2016

Looks good otherwise. Nice tests!

etpinard added a commit that referenced this pull request Feb 17, 2016
@etpinard etpinard merged commit 34438d7 into master Feb 17, 2016
@etpinard etpinard deleted the subplot-modebar branch February 17, 2016 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants