# Callback origin and reset clickdata on Python Dash

**URL:** <https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805>\
**Category:** Dash Python\
**Created:** [October 9, 2019, 5:21pm UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805 "2019-10-09T17:21:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuricda96](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/yuricda96/32/8028_2.png) [@yuricda96](https://community.plotly.com/u/yuricda96)\
**Post date:** [October 9, 2019, 5:21pm UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/1 "2019-10-09T17:21:37Z")

</div>

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?

Thanks

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [October 9, 2019, 7:03pm UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/2 "2019-10-09T19:03:02Z")

</div>

Checkout `dash.callback_context.triggered`  
[https://dash.plot.ly/faqs](https://dash.plot.ly/faqs) \>\> **Q:** _How do I determine which `Input` has changed?_

---

<div class="post-metadata">

**Author:** ![sjtrny](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sjtrny/32/12714_2.png) [@sjtrny](https://community.plotly.com/u/sjtrny)\
**Post date:** [October 10, 2019, 12:00am UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/3 "2019-10-10T00:00:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [October 10, 2019, 12:39am UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/4 "2019-10-10T00:39:17Z")

</div>

You’re absolutely right -\> [https://github.com/plotly/dash-docs/issues/668](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 🙂

---

<div class="post-metadata">

**Author:** ![yuricda96](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/yuricda96/32/8028_2.png) [@yuricda96](https://community.plotly.com/u/yuricda96)\
**Post date:** [October 10, 2019, 2:04am UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/5 "2019-10-10T02:04:38Z")

</div>

Thank you, it works!

---

<div class="post-metadata">

**Author:** ![HarishOsthe](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/harishosthe/32/9949_2.png) [@HarishOsthe](https://community.plotly.com/u/HarishOsthe)\
**Post date:** [March 26, 2020, 9:37am UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/6 "2020-03-26T09:37:49Z")

</div>

Now **dash.callback\_context** has been documented with an nice example at [https://dash.plotly.com/advanced-callbacks](https://dash.plotly.com/advanced-callbacks)

---

<div class="post-metadata">

**Author:** ![ddr](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/ddr/32/10717_2.png) [@ddr](https://community.plotly.com/u/ddr)\
**Post date:** [May 14, 2020, 2:21pm UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/7 "2020-05-14T14:21:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![toucanna](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@toucanna](https://community.plotly.com/u/toucanna)\
**Post date:** [May 28, 2020, 10:24pm UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/8 "2020-05-28T22:24:43Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![ddr](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/ddr/32/10717_2.png) [@ddr](https://community.plotly.com/u/ddr)\
**Post date:** [June 11, 2020, 5:19pm UTC](https://community.plotly.com/t/callback-origin-and-reset-clickdata-on-python-dash/29805/9 "2020-06-11T17:19:16Z")

</div>

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.

Good luck!
