I had set a callback that receives the value of a dropdown and a clickdata on a graph. If dropdown value changes, the graph was recolored and table values were updated. If I click on the graph, the same thing happens with the colors and the table Data. But there’s this situation: When I already clicked on the graph the clickdata haven’t been cleaned. So, how can I know the origin of the callback or how can i clean the clickdata on the end of the current callback?
https://dash.plot.ly/faqs >> Q: How do I determine which
Input has changed?
I think this needs to be moved to a more prominent position in the docs. I’ve been using Dash for over a year and didn’t know about this!
You’re absolutely right -> https://github.com/plotly/dash-docs/issues/668
We’ll get to it eventually, but if anyone is motivated to contribute, this would be a great one to take on
Now dash.callback_context has been documented with an nice example at https://dash.plotly.com/advanced-callbacks
I found this thread for a related issue:
I’m using the dcc.Graph figure (plotly figure type=choroplethmapbox) ‘clickData’ input to highlight the area of the map clicked on. The first click works fine. But clicking again on the same area is supposed to “deselect” that area. But I don’t get another clickData event because of course that property hasn’t changed for the figure.
What should be the pattern to detect a second click on the same map area?
@ddr I have the same issue, let me know if you find a good workaround for this.
I’m using clickData to popup a modal and clicking on the same place in the graph consecutively doesn’t re-trigger the callback.
What I did to resolve this was to create a layer above the base map for “selections”. The selection layer paints the same data/color for the polygons but outlines them in a highlight color. Since that layer establishes a new identity for the area under that region, so clicking again is delivered as a new event to a new figure layer.
I have yet to investigate whether there is built-in “selection” capability I can exploit on choropleth-mapbox.