Repository navigation
Lasso and select-box support for traces other than scatter marker and scatter text #170
Description
Activity
Top ones for crossfilter project:
- Line charts
- Bar charts done in Bar | histogram lasso / select box dragmode #2045
- Histograms done in Bar | histogram lasso / select box dragmode #2045
- Choropleths done in Geo refactor and lasso/select-box selections #2030
- scattergeo done in Geo refactor and lasso/select-box selections #2030
- box with
boxpoints: 'all'done in Box points hover & select #2094 - heatmap (at least for
zsmotth: falsebricks)
Reacted by etpinard, Dmitry Iv., Andre Bieler and Ricardo DecalFor bar chart and histogram selection, I think just touching a bar should include it in a selection. Thoughts @cpsievert based on plotly.js selections in Shiny apps?
16 remaining items
@tenshis Here's a mock for how we were considering
plotly_selectedin a heatmap:Essentially if you lasso the centroid of the cell, the entire cell highlights as "selected."
@etpinard @jackparmer Since this feature isn't yet available. Is there a way to stylize heatmap cells individually? Like ability to specify the color of a certain cell, or add a marker line for a cell?
@etpinard is this supported for pie charts? Dont see it in the code myself but cant say I fully understand the plotly code base either. Could you please help point me in the right direction on how to get select events working on a pie chart.
Thanks
@tenshis not currently - it would be great if you could work on this!
I am interested to work on this. How to participate to work on this issue?
@tenshis not currently - it would be great if you could work on this!
I am interested to work on this. How to participate to work on this issue?
@alexcjohnson this seems to be related to adding selection to
heatmapwhich could be little tricky.
If so, how about starting a new issue as a place holder just for that?Let's keep the discussion here for now. Looking at @jackparmer's comment #170 (comment) the only remaining items are heatmap and line - is that right or is there anything else people would like add selections to? I'm not sure what this would look like for lines so for now I'm just going to talk about heatmaps.
I think what will be needed is:
- attributes for selection styling - as far as I can see the only thing that really makes sense would be
unselected.opacity. Or perhaps it wouldn't really be an opacity, if we implement this by overlaying a shape that partially masks the heatmap? Then it could be something likeunselected.fadeandunselected.bgcolor? - figure out what the
selectedpointsattribute should look like forheatmaptraces - I guess when the heatmap came from all 1D arrays it can just be an array of indices, but whenzis a 2D array, the equivalent of an array of point indices would be an array of length-2 arrays,[row, column]? This line from hover (that controls hover and click event data) looks like the behavior to match:
plotly.js/src/traces/heatmap/hover.js
Line 115 in 5b8b1db
index: trace._after2before ? trace._after2before[ny][nx] : [ny, nx], - Implement the selection by making a
heatmap/selectedPointsroutine - the PRs linked in Lasso and select-box support for traces other than scatter marker and scatter text #170 (comment) should give a good idea how to implement this and expose it in the trace module. - Implement drawing the selection within
heatmap/plotorheatmap/style. The two general ways I can imagine doing this are: (1) alter the colors of the image we draw for the heatmap itself, or (2) mask the image element. (1) would be pretty easy to implement, but I don't think it'll do what we need: it would mean redrawing the whole heatmap every time a new element is added to or removed from the selection (heatmap/plot), and it would make blurred edges withzsmooth: fast. (2) will be trickier to implement but can go inheatmap/styleand would have crisp edges regardless ofzsmooth.
- attributes for selection styling - as far as I can see the only thing that really makes sense would be
Selecting multiple cells in the heatmap is done by plotting a scatter of the heatmap values along with the heatmap. Thus the lasso tool selects points from the scatter. The points from the scatter are in the center of the heatmap cells, thus the cells of the heatmap will appear to be chosen if the center of the cell is within the lasso
from hereDon't know if this sufficient for what is needed, but this was my workaround for using lasso tool on heatmaps. Would be really nice to have this work without having to plot twice.
This issue has been tagged with
NEEDS SPON$ORA community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.
Sponsorship range: $10k-$15k
What Sponsorship includes:
- Completion of this feature to the Sponsor's satisfaction, in a manner coherent with the rest of the Plotly.js library and API
- Tests for this feature
- Long-term support (continued support of this feature in the latest version of Plotly.js)
- Documentation at plotly.com/javascript
- Possibility of integrating this feature with Plotly Graphing Libraries (Python, R, F#, Julia, MATLAB, etc)
- Possibility of integrating this feature with Dash
- Feature announcement on community.plotly.com with shout out to Sponsor (or can remain anonymous)
- Gratification of advancing the world's most downloaded, interactive scientific graphing libraries (>50M downloads across supported languages)
Please include the link to this issue when contacting us to discuss.
- added a commit that references this issue
on Mar 8, 2021 Funny thing is that you can force the selection box modebar button on even in pure scatter traces (without markers and text), and it works pretty much perfectly fine. However, it's still spamming errors in the console and the selection is not retained on Plotly.react calls. Other than that I couldn't see any real differences to normal use.
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson
Reacted by Matthias, tribohr, Abram Fleishman, Jonas Van Der Donckt and Petar Pejovic



Lasso and select-box were added in #154
Adding support for other trace types should be as easy as adding a
selectPointsto the other trace modules.