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 ?).
Ok maybe I found a thread here:
opened 12:36PM - 12 Jun 20 UTC
closed 02:56PM - 24 Jul 24 UTC
**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).
I didnt get it to work. Help please
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.
Hmm ok… I really wish Dash had the support for noticing when the user clicks the background of a html component such as graph.