Knowing what graph has been clicked

AFAIK there is currently no good way to do this within the Dash design, see the discussion in dash/#59 and dash/#140 for a future solution.

However, I found the workaround suggested in this thread Sharing a dataframe between plots to be very effective. In your case, you would create a hidden Div for each click (one for graph-stats-metric and one for graph-metric-frames) that records the timestamp of the click. Then your display-images update callback would depend on these hidden Div children, which contain the timestamp, as well as optionally the state of the two graphs. The callback can then see which click was the latest.

This can be extended in some nice ways, for instance only updating the timestamp on certain conditions on the state of the object being clicked on (or other actions), so that you can basically record a specific type of interaction. You do have to be careful of the potential complications mentioned in that thread.

1 Like