3

I am playing with generating dot files and then turned them into SVG graphs with a lot of nodes.

My question is that are there event listeners to detect mouse clicks on dot/SVG graph nodes?

For example, right click on a node in the SVG graph, I do something(maybe get the related information from the node and then do something),

Then how to generate dot file or SVG file to achieve this?

3 Answers3

2

There are several ways to create an interactive SVG graph:

In any case, you'll have to display the svg graphs in a client which supports any of those technologies (browser), and you will have to code it in addition to the svg output graphviz creates.

marapet
  • 54,856
  • 12
  • 170
  • 184
2

Just another thought on this (realizing the question is old, but maybe it helps someone coming across).

Depending on what you want to do, it may be easiest to decouple the event handling from the drawing. I mean, you can find out where graphviz positions the nodes (as well as edges, labels etc.), see, for example, this post on how to do it in python. Then you can paint the graph in the background of whatever GUI you're using, and use its native event handling to react on on_click by placing invisible clickable objects over the nodes.

Duke
  • 410
  • 7
  • 15
  • I realize this is not a precise answer to the exact original question, but I assume after 7 years it's not an issue for the OP anymore, anyway... – Duke Sep 28 '19 at 06:20
-1

If you want interactive graphs then graphviz might not be the best choice.

I'd recommend having a look at D3.js. Perhaps you could construct the graph data in json and load them with D3?

Erik Dahlström
  • 59,452
  • 12
  • 120
  • 139
  • D3 is typically used together with svg (generating an svg representation of some dataset). One of the main benefits compared to using graphviz is that all graph layout is done dynamically in the browser. – Erik Dahlström Sep 04 '12 at 21:55