Hover to control a subplot

I have added a subplot which is controlled by Hover in my main plot. It works great except for the fact that Hover is constantly on. So for example, I Hover over the first plot and stop somewhere to see what the subplot now looks like. I then want to zoom into the subplot, which requires moving my mouse down to it. However, the process of moving the mouse changes the location on the first plot where Hover is activated, changing the subplot! I would like to only activate Hover with a right click of the mouse. Is this possible?

Right click being held down, or right click to toggle?

You could use a click instead of the hover for the subplot. Or even a selectedData for it. These might be easier to implement and giving you a lot more control. And maybe a little more intuitive for the user?

User sees chart, hovers over the data, “that’s interesting. I want to look further…” click … “oh that’s cool!”

With selecedData, you can allow for multiple selections, but its not available on every chart.

Thanks so much! I used clickData and it gave me what I needed. Can I add a submit button to my Dashboard when I need to be over the first plot to hit click for the second plot? I need a situation where the submit button controls all of the Dashboard selections, but does not control the mouse click on the main plot.


Yes, you can add a button that toggles on and off. Then inside the callback for the clickData, just pull the state of the button as to whether or not you do anything with the data.

Thanks so much! I made it work. I have everything entered as State except for clickData which is entered as Input, so clickData works the minute I click the mouse, but everything else waits until I hit the Submit button. Perfect!!

1 Like

Now I have a second question. How do I set things up so that the second graph, the subplot, is cleared every time the Submit button is used? After the Submit button is used, the primary graph will change. I want the subplot to clear at this point until I click in the primary graph again.

Can you hide the subplot when it is not used?

When I first open the Dashboard, the subplot is there but empty. I want to empty it again every time I hit the Submit button. Because otherwise the subplot shown does not work with the new main plot, until the main plot is clicked in again.

Add a secondary input of the button click with the clickedData. If the button click is what triggered the callback, then return an empty figure.

Just what I needed, thanks!

1 Like