eMBR_chi has asked for the wisdom of the Perl Monks concerning the following question:

Dear Wise monks,

I would be glad if someone could walk me through the process of setting up and running Graphviz through a web server.

I use Graphviz through the perl-Graphviz rpm. I am currently able to generate images from within perl scripts, and view the images either as regular picture files or as svg(viewed using appropriate browsers).

I am writing an application that will run over the internet and would want to have the images served as I would do other cgi generated content. I do not currently completely understand how to set up and use webdot. I would be glad to have some direction from anyone who has some experience using webdot.

Thank you so much.

Replies are listed 'Best First'.
Re: Running graphviz via a web server
by lostjimmy (Chaplain) on Mar 01, 2011 at 20:29 UTC
    Please note: I know nothing about Graphviz or webdot, except what I have read in the past five minutes

    I don't think you need to use webdot. It looks to me like webdot is a set of CGI scripts that will produce images of graphs, but will also make things like image maps and allow you to specify where to go when clicking certain nodes, as well as other functionality. If you don't need these things, then don't use webdot.

    Here is how I would get this to work, and how I've done it in the past with things like gnuplot. Within your HTML page, the image tag should point to the CGI script as its src attribute, including the needed parameters to tell it what to graph. It should look something like <img src="/cgi-bin/graphviz.pl?file=example.dot"/>. Then your CGI script should do something like the following:

    print "Content-Type: image/svg\n\n"; binmode stdout; my $g = GraphViz->new(); # create graphviz stuff print $g->as_svg;