Svg without tooltips?

I’m making svg files with dot, and it automatically adds unhelpful tooltips. I’m thinking about putting tooltips on all of the links to make it more obvious where you can click and what it leads to. But then I’d want everything else to not have tooltips. Is there a way to tell dot to not put in any tooltips besides the ones I specify?

Good question. I don’t think there is a way. This comes close, but just outputs a space tooltip.

digraph {
node [tooltip=" "];
Hello -> World
}

This just outputs the label as tooltip, as described at http://graphviz.org/doc/info/attrs.html#d:tooltip.

digraph {
node [tooltip=""];
Hello -> World
}

I think it’s a reasonable thing to want to suppress in SVG output. Perhaps diving into the svg outputting code may yield more clues to whether there’s some way to suppress these.

https://gitlab.com/graphviz/graphviz/-/blob/master/plugin/core/gvrender_core_svg.c#L368

Seems to imply that if tooltip is empty, it won’t be output. But deciding what the tooltip should be happens further up the code stack.

if (tooltip && tooltip[0]) {
gvputs(job, " xlink:title=\"");
gvputs(job, xml_string0(tooltip, 1));
gvputs(job, "\"");
}

Which is called from https://gitlab.com/graphviz/graphviz/-/blob/master/lib/gvc/gvrender.c#L405

which is called from (among other places), https://gitlab.com/graphviz/graphviz/-/blob/master/lib/common/emit.c#L2628

Which is where you see the fallback to label if the tooltip isn’t set.

Perhaps we could:

  • have a special value [tooltip=false/none/no] to designate no tooltip. This could of course collide with other preexisting tooltip usages, but there’s prior art for mixed boolean/string attributes.
  • have another attribute for showing the tooltip at all? this wouldn’t collide.

Even though the SVG contains a space as tooltip it doesn’t seem to be displayed by the browser. At least not with Firefox or Chrome on Ubuntu 20.04:

[dot verbose=true]

digraph {
    node [tooltip=" "];
    Hello -> World
}

[/dot]

The default is tooltips on the nodes with the node name, tooltips on the edges that look like “node1->node2” (at least, on the arrow and label of the edge), and no tooltip for the graph itself. I’m not really sure what the reasoning behind this is. You could have the default be no tooltips that aren’t specified in the file and have something like [tooltip=auto] to let dot generate them. Just a thought; the current implementation really isn’t a problem.