Description
Hi, I hope all of you are doing well! I'm glad to see @archmoj's leading the v2 push 🚀
I'm currently rewriting an internal app using Dash.jl and I came across a situation where (I think) common dash callback logic could be greatly simplified with a small plotly.js tweak.
From https://jsbin.com/piveyuniso/edit?html,js,output, we can see that in the plotly_selected
event data after a multi-selection interaction, the range.x
/ range.y
coordinates (only!) correspond to the most recent selection.
In situations where we need to consider all the selected regions (i.e. not just the most recent one), we need to accumulate the coordinates from the individual plotly_selected
events. This is of course very much doable in dash, but also a little annoying.
Probably the easiest and least-invasive solution would be to add a new plotly_selected
event data field named e.g. rangeMulti
(and lassoPointsMulti
for dragmode: 'lasso'
) so that:
gd.on('plotly_selected, d =>
d.rangeMulti.x // [[x00, x01], [x10, x11], ...]
d.rangeMulti.y // [[y00, y01], [y10, y11], ...]
// and for 'lasso'
d.lassoPointsMulti.x // [[Xs of first lasso selection], [Xs of 2nd ...], ...]
d.lassoPointsMulti.y // [[Ys of first lasso selection], [Ys of 2nd ...], ...]
)
Let me know if this solution makes sense! I can happily open a PR that implements it.
Cheers!