I have a graph where I want to add the tooltips in a separate div. For that, I’m listening to the ‘plotly_hover’ event and using the trace.hovertemplate
to add the information on it. I don’t want to show the tooltips also on the graph. However, if I set 'hovermode'=false
, the event is not triggered, and if I set trace.hoverinfo="none"
, it is still shown. The later function works if I don’t set a trace.hovertemplate
myself.
Is there any way to deactivate the tooltip of the graphs even when I set the hovertemplate, or do I have to use another name to store the template?
Although the hovertemplate description says that it overwrites the hoverinfo, this is the configuration that I have so that the tooltips do not appear and I have the plotly_hoverinfo event
In the layout I have
hovermode: "x",
hoverdistance: 1
and in the plot
hoverinfo: "none"
As an extra piece of information, you can create parameters whose name does not match the parameters already used by the plotly traces to save info. You can access them through layer.data but they will not appear in layer._fullData. I use it to give IDs and names to the traces and be able to identify them.
Using
layout.hovermode = "x"
layout.hoverdistance = 1
and trace.hoverinfo: "none"
did not work for me. I am using a custom parameter in the trace to get the template from ed.points[0].data.hovertemplatecustom
. That seems to work.
That’s weird, in this example that I created to position the legends I have that configuration and it works, check it out, maybe there’s something else that I didn’t consider.
Ah, I see now what may be the issue: the tooltips in your example still show up, but the mouse has to be really on top of the point. In my case, I have a barplot, and when I hover inside the bar, the tooltip shows up too.
You’re right, I hadn’t considered the hovertemplate in my example, as the documentation mentions it to be ignored the hoverinfo, in that case I recommend not using the hovertemplate to save information and use the method I mentioned.