JavaScript config, change between 'Show closest data on hover' and 'Compare data on hover'

I need to switch between these 2 modes from JavaScript code:

I’ve consulted this: plot . ly/javascript/configuration-options/

And then the config object source code here:

Where it appears there’s no option to set so.

Is there anyway I can access this portion of the code:

Using Plotly.React when refreshing the chart?

Use case is: user clicks a button and either only 2 lines are drawn or many more. First case needs “compare data” and second one needs “show closest”. By default it is always set to “compare” which is tedious if the user pulls the data many times, as he has to switch mode after every refresh.


Have you tried setting layout.hovermode to 'closest'?

1 Like