clickData doesn't work unless i click on another bar

Hey guys!
So, I have a bar chart and a callback that fires if one of the bars has been clicked.
now, I am filtering other graphs with the data I get from the clickData, and I am saving the labels of the data in a random div which are used to filter the other graph.
now I want to be able to click on the same bar twice to apply the filter and remove it.
but for some reason, clickData doesn’t fire the callback unless I click another bar in the barchart.
Any idea why is that and how to get around it?

Hi,

Starting with the why: since clickData has the same value when you click the same bar twice, the callback doesn’t get triggered.

The workaround is to “reset” it manually at each callback. It is documented in this thread: https://github.com/plotly/dash/issues/1300#issuecomment-788145161
You can store the previous value in a dcc.Store component and use it in thw callback logic.

Sorry, I didn’t mention this but I did manually reset the click data I return None each time the callback finished into the click data and it still doesn’t work.

Can you share a minimal reproducible example of your code, so I can see what you tried and give a better suggestion?

Hi! I am really sorry for the delay!, my code is actually on another network so I didn’t have access to it yesterday, and when I tried doing some more research I found a bug in my code that caused the problem So thanks for the help! I really appreciate it!

Glad you figured it out!

1 Like