Skip to content
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

Add scattermapbox select/lasso drag modes #1836

Merged
merged 10 commits into from
Jul 10, 2017
Merged

Conversation

etpinard
Copy link
Contributor

resolves #1402

peek 2017-06-30 16-52

In brief, this PR:

  • adds arrayOk support for marker.opacity in scattermapbox traces [ 7d3dd35 ]
    • this makes dimming the markers points much easier (and faster 🐎 ) than having to use a multi-trace solution like we did for scattergl's gl-scatter2d mode.
  • adds support for select and lasso dragmode for circle markers in scattermapbox traces [294e5f6]
    • ♻️ reuses dragElement on the mapbox <div>
    • 🚀 events plotly_selecting, plotly_selected and plotly_deselect work as on the other supported subplot types
    • 📚 event data also includes the boxes' range (in select mode) and lasso points (in lasso mode) in lon/lat coordinates.
    • ⚠️ I chose to not allow non-circle markers and text fields to dim during selections in this PR. Main reason: mapbox-gl@0.22.1 doesn't allow arrayOk settings for those, but the latest version does. So this could be easily added when we bumped the mapbox-gl version after the image server rewrite. Note that, non-circle markers and text fields are still included in the plotly_selected event data even though they're not dimmed.
  • adds three new modebar buttons to control layout.dragmode (pan, select, lasso, note that dragmode zoom hasn't been implemented yet for mapbox subplots)
  • cleans up a few other things selection related [commits e8b8624, 744f3c8 and a376817]

cc @alexcjohnson @dfcreative

etpinard added 9 commits June 30, 2017 13:36
- `npm run test-image -- mapbox_*` sometimes blows up
- to easily combine logic for scatter* trace types
  that use scatter/subtypes.js
- e.g. to allow mapbox subplot convert px coords to lon/lat
  w/o hackely mocking too many things
- create dragElement on mapbox subplot <div>
  when dragmode is set to select or lasso,
- undo dragElement onmousedown handle for other dragmode values
- keep ref to scattermapbox/plot instance in calcdata to call
  its update method directly in select
- must keep track of trace with dimmed pts to go through arrayOk logic
  in scatter/convert
- ... as it should have been all along, non-attribute keys
  in fullTrace (and fullLayout for that matter) should be
  named with a leading underscore.
- scattergl glTrace ref is now consistent with
  the scattermapbox version
- and set dragmode to 'pan' in fullLayout when its value is coerced
  to 'zoom' so the corresponding modebar button is correctly
  highlighted.
- do this until dragmode 'zoom' (i.e. a zoombox like behavior)
  is implemented.
@etpinard etpinard added this to the 1.29.0 milestone Jun 30, 2017
@etpinard
Copy link
Contributor Author

might as well ping @jackparmer @chriddyp @cpsievert who probably can't wait to use this feature.

@jackparmer
Copy link
Contributor

jonas

@d-wasserman
Copy link

d-wasserman commented Jul 4, 2017

When will this make it into pip? Is it already? Really excited for this feature!

dataPts[ax._id] = pts.filtered.map(axValue(ax));
}
}
fillRangeItems(eventData, poly, pts);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, probably we have to merge this before I continue multiselect, because I depend on this part of code a lot.

@dy
Copy link
Contributor

dy commented Jul 4, 2017

@etpinard should we consider enabling multiple selection for this too? Related PR

@etpinard
Copy link
Contributor Author

etpinard commented Jul 4, 2017

@etpinard should we consider enabling multiple selection for this too?

Not in this PR. This PR here has to go in the next release. Multiple selections is a lower priority item at the moment. Apologies in advance for the merge conflicts.

@etpinard
Copy link
Contributor Author

@alexcjohnson would you mind taking a 👓 at this?

@@ -20,7 +22,8 @@ var convertTextOpts = require('../../plots/mapbox/convert_text_opts');

var COLOR_PROP = 'circle-color';
var SIZE_PROP = 'circle-radius';

var OPACITY_PROP = 'circle-opacity';
var DESELECTDIM = 0.2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you pull this out of here, scatter, and scattergl into a shared constant?

Copy link
Contributor Author

@etpinard etpinard Jul 10, 2017

Choose a reason for hiding this comment

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

Ha. You caught me being lazy. #1847 will make this thing configurable, but yeah might as well move it to a constant file for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 882e8e3

@alexcjohnson
Copy link
Collaborator

Very nice - you can address DESELECTDIM now or just wait for #1847, up to you. 💃

@etpinard etpinard merged commit edf52ca into master Jul 10, 2017
@etpinard etpinard deleted the scattermapbox-lasso branch July 10, 2017 22:27
@plotly plotly deleted a comment from jackparmer Aug 3, 2017
@chriddyp
Copy link
Member

chriddyp commented Aug 3, 2017

@Holisticnature - This is getting into plotly.py pip tonight or tomorrow: plotly/plotly.py#796 and into Dash tonight or tomorrow as well (plotly/dash-core-components#46)

@d-wasserman
Copy link

That is great! Thanks for the update!

@d-wasserman
Copy link

@chriddyp - I have it working on my install, but I was hoping there might be some codes samples on added to the Scattermapbox docs on how to update a chart based on the selection. Are there any examples on how to apply the selected items to update a chart? I found a few similar examples with hovering/selecting on histograms on the scatter plot page/dash docs/uber example, but it is not exactly the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lasso & box selection in scattermapbox
6 participants