# Clear clickData in dcc.graph

**URL:** <https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [March 6, 2025, 3:16pm UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889 "2025-03-06T15:16:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JD222SD](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@JD222SD](https://community.plotly.com/u/JD222SD)\
**Post date:** [March 6, 2025, 3:16pm UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889/1 "2025-03-06T15:16:53Z")

</div>

I’ve scouted through this forum for an answer to clearing clickData by simple clicking/double-clicking the background of the dcc.graph but Iam unable to find threads with solutions.

Have I not looked enough or is it simply not possible?

What I want to use this for is to clear my selection. I have a bar plot, i click one of the bars, it is snapped up in my callback that then filters an ag.AgGrid table… But i can’t clear the filter since I cant get my code to notice when I click the background of the graph (clickData should be None ?).

---

<div class="post-metadata">

**Author:** ![JD222SD](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@JD222SD](https://community.plotly.com/u/JD222SD)\
**Post date:** [March 6, 2025, 3:19pm UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889/2 "2025-03-06T15:19:00Z")

</div>

Ok maybe I found a thread here:

> <https://github.com/plotly/dash/issues/1300#issuecomment-788145161>
>
> \*\*Describe your context\*\*
> Please provide us your environment so we can easily r…eproduce the issue.
> 
> \`\`\`
> dash 1.12.0
> dash-core-components 1.10.0
> dash-html-components 1.0.3
> dash-renderer 1.4.1
> \`\`\`
> \- if frontend related, tell us your Browser, Version and OS
> 
> - OS: Windows 10
> - Browser: chrome
> - Version: 83.0.4103.97 (Official Build) (64-bit)
> 
> \*\*Describe the bug\*\*
> 
> When using pie chart clickData as an input for a callback, it does not trigger when clicking the same segment twice (or multiple times) in a row.
> 
> \*\*Expected behavior\*\*
> 
> I would expect the callback to trigger again with the same clickData.
> 
> \*\*Simple app\*\*
> 
> A simple app to help reproduce the bug.
> 
> \`\`\`
> import dash
> import dash\_core\_components as dcc
> import dash\_html\_components as html
> from dash.dependencies import Input, Output
> import json
> 
> labels = \['Oxygen','Hydrogen','Carbon\_Dioxide','Nitrogen'\]
> values = \[4500, 2500, 1053, 500\]
> 
> app = dash.Dash(\_\_name\_\_)
> 
> app.layout = html.Div(\[
> dcc.Graph(
> id='pie',
> figure={
> 'data': \[{
> 'values': values,
> 'labels': labels,
> 'type': 'pie'
> }\]
> }
> ),
> html.Pre(id='clickDataDisplay')
> \])
> 
> @app.callback(
> Output('clickDataDisplay', 'children'),
> \[Input('pie', 'clickData')\]
> )
> def display\_click\_data(clickData):
> print("Processing click data.")
> return json.dumps(clickData, indent=2)
> 
> if \_\_name\_\_ == '\_\_main\_\_':
> app.run\_server(debug=True)
> \`\`\`

But if anyone have another solution please share (i will try this meanwhile).

---

<div class="post-metadata">

**Author:** ![JD222SD](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@JD222SD](https://community.plotly.com/u/JD222SD)\
**Post date:** [March 6, 2025, 3:51pm UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889/3 "2025-03-06T15:51:32Z")

</div>

I didnt get it to work. Help please

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [March 6, 2025, 5:21pm UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889/4 "2025-03-06T17:21:49Z")

</div>

Hey there!

> [@Callback for repeated data click](https://community.plotly.com/t/callback-for-repeated-data-click/82876/6):
>
> Hey @bhowey You are right, the clickData does not get reset automatically. So if you click twice on the same point, the callback gets triggered only once. You have to manually reset the clickData: @app.callback( Output('map', 'figure'), Output('map', 'clickData'), [Input('map', 'clickData'), Input('dummy-button', 'n\_clicks')], [State('df-store', 'data')] ) def update\_marker\_color(clickData, dummy\_button\_n\_clicks, df\_json): df\_new = pd.read\_json(df\_json) if clickDat…

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [March 7, 2025, 1:49pm UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889/5 "2025-03-07T13:49:23Z")

</div>

Hello @JD222SD,

Welcome to the community!

`clickData` will only be triggered upon clicking a mapped point, so its difficult to clear the `clickData` for that purpose.

However, you could add an event listener to the div of the graph and implement your own logic for determining if the `clickData` should be cleared.

---

<div class="post-metadata">

**Author:** ![JD222SD](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@JD222SD](https://community.plotly.com/u/JD222SD)\
**Post date:** [March 10, 2025, 11:08am UTC](https://community.plotly.com/t/clear-clickdata-in-dcc-graph/90889/6 "2025-03-10T11:08:43Z")

</div>

Hmm ok… I really wish Dash had the support for noticing when the user clicks the background of a html component such as graph.
