Dash: selectedData does not update on deselection

Created on 24 Jul 2017  路  10Comments  路  Source: plotly/dash

selectedData does not update when data that is selected through the lasso or rectangular selection tool is deselected. You can view this behavior from the crossfiltering example in the docs: https://plot.ly/dash/getting-started-part-2#basic-interactions

This has an impact on building dashboards that use crossfiltering to summarize information for a set of points. For example, I have a chart that by default aggregates information for all points in a scatterplot if selectedData is empty. Once selectedData is not empty, the aggregating charts then summarize info for the selected data. If I deselect points, I want the charts to return to aggregating for all data points. Currently, in order to get this behavior, I would have to reselect all points in the plot with the select tools.

Replication:

  1. Select a set of points using lasso or rectangular selection
  2. Deselect points by double-clicking elsewhere in the plot

data-deselect


I have also asked on the community forums if this is the expected behavior.

dash-type-bug

All 10 comments

Seems like this is a bug 馃憤 . Thanks for reporting! Will work on a fix this week.

@pmbaumgartner - Returning

{
    "points": []
}

or

None

I think that points: [] makes more sense here. However, it will be impossible to distinguish between the "unselect" case and the "selected no points" case.

It looks like plotly.js doesn't distinguish between "single-click" and "double-click to remove selection box" in the selected event. We'll need plotly.js to update this event data before we patch this.

I think that points: [] makes more sense here.

Actually, I don't think this makes sense. The Dash developer needs to know if there is a persistent selection box or not. If there is a persistent selection box but no data, then the data structure will be {points: []}. However, if there is _no_ selection box then the developer needs to know that so they can e.g. redraw all of the original points.

Maybe reset to None makes the most sense here then. That's the initial value when there is no selection box.

This is actually sort of related to https://github.com/plotly/plotly.js/issues/1848

re: return value - I think it depends on what you want the pattern to be for when data is selected to crossfilter.

A change that would be consistent with the pattern of if selectedData: or if selectedData is None: would be returning None. (ex),

The other pattern is if (selectedData or len(selectedData['points']) == 0): which would be consistent with returning points: [] (ex)

Fixed! see plotly/dash-core-components#40. Upgrade with pip install dash-core-components==0.7.1

@chriddyp not sure if this is related to the change, but I'm getting Error loading dependencies or Error loading layout on my app after the upgrade. It's also happening with the docs @ https://plot.ly/dash/

screen shot 2017-07-24 at 6 12 07 pm

Guessing the CDN needs to be updated?

screen shot 2017-07-24 at 6 24 36 pm

Yeah, forgot to update the CDN :man_facepalming: Updated now, should be good to go. Thanks for reporting!

Was this page helpful?
0 / 5 - 0 ratings