PmGraphViz

Summary: Produced graphs using graphviz inside of PmWiki.
Version: 0.03
Prerequisites: pmwiki-2.1
Status: Stable
Maintainer: ccox
Categories: Images MindMapping

Description

This recipe uses GraphViz to produce inline graphs and even org charts.

This recipe is a rewrite of a recipe idea from Pmwiki-V1 at GraphViz.

Download: pmgraphviz.phpΔ (for PHP 5.5, 7.2 or newer please get pmgraphviz-php72.phpΔ instead, requires PmWiki 2.2.58 or newer).

You can see an example here: http://theendlessnow.com/ten/Test/PmGraphViz

Notes

Place pmgraphviz.php (this file) into your cookbook directory (e.g. /srv/www/htdocs/pmwiki/cookbook)

Include the cookbook in your local/config.php
include_once("$FarmD/cookbook/pmgraphviz.php");

Create a cache directory at pub/cache under your your PmWiki base directory. Needs to be writable by the web http server username.

On a page include the markup (the -- is important).

(:pmgraphviz -- [=
   digraph {
      "hello" -> "world";
   }
=] :)

PmGraphViz

You set these variables to override defaults (usually set inside your config.php before including the recipe):

$PmGraphVizCacheDir = Path to cache dir ($FarmD/pub/pmgraphviz)
$PmGraphVizDotPgm = Path to graphviz dot (/usr/bin/dot)
$PmGraphVizCacheDirUrl = Url to cache dir ($FarmPubUrl/pmgraphviz)
$PmGraphVizConvertPgm = Path to ImageMagick convert (<empty>)
0.01: Initial release.
0.02: Bug fixes, use Keep, added client side image map handling.
0.03: Fixed typo bug. Attempt to standardize cache vars, prefixes added to file names.PmGraphVizDotPgm can now be a URL to a remote webdot server (e.g. http://www.research.att.com/~north/cgi-bin/webdot/webdot.cgi). PmGraphVizConvertPgm if set to the ImageMagick convert program, it will try to render postscript into convert to produce a nice anti-aliased version of the image. If it fails it tries to rerender without using convert.
Variables:
     
     forceregen   If set to true, cache is ignored and files are forced to regenerate.
                   Defaults to false.
     mapname      Set this to the dot graph name if you include URL's for image mapping.
                   Must set this to generate client side maps.
     typeext      Used to determine the type of output from dot and the extension (e.g. 
                   gif, png, jpg). (recipe assumes it is a displayable inline image type)
     

Comments

Breyten September 17, 2006, at 05:16 AM
I've modified the script a little to allow the use of a public webdot server. It checks if $PmGraphVizDotPgm begines with 'http', and then uses the specified public webdot server to generate the image. Unfortunately no map support.

There is a public webdot server at http://www.research.att.com/~north/cgi-bin/webdot/webdot.cgi

ccox This feature has been added as of 0.03. Thanks for the tip Breyton!!

Adrianna March 14, 2008, at 10:05 AM
I have modified the script to be WikiPublisher-friendly: if the global variable $format is set to pdf, it outputs pmwiki markup for the generated image, rather than HTML, so that WikiPublisher can pick it up.

Here's my modified copy: pmgraphviz-2008-03-14.phpΔ

Please can you be a little more specific?! Do you mean create a folder called (e.g.) "GraphVizCache" in pub/cache?! Don't we need to download GraphViz and Imagemagick themselves and put them somewhere to make this work?! Sorry if these are stupid questions, I'm only trying to expand the instructions and make this work!Promsan

ccox By default the cache will be pub/cache... but it is configurable by PmGraphVizCacheDir variable. And no... you don't need graphviz or imagemagick. You can point the PmGraphVizDotPgm to a remote public dot serving URL. But it's probably wiser to use something local. And with ImageMagick you'll get the nice anti-aliasing (but you will want to test without that... and add that later).

So if I'm hosting somewhere online, what do I do with the graphviz and imagemagick stuff? Do we download the zipfiles for them somewhere, and extract them and upload them into a particular folder via our ftp/ssh software? Sure I want to go step by step... put GraphViz on a single wiki; then add Imagemagick; then try it out on a wikifarm. Promsan July 16, 2009, at 06:03 AMPromsan

See Also

Contributors

Ccox

Sandbox

PmGraphViz

(:pmgraphviz mapname=mine -- [=
digraph mine {
//
[node tooltip="This is the node named \N"];
Hello [URL="http://www.ntlug.org" target="_ntlug"];
World [URL="http://theendlessnow.com" target="_ten"];
Countries;
People;
States;
Hello -> World;
World -> Countries -> States;
World -> People [dir=both];
}
=] :)

PmGraphViz

(:pmgraphviz mapname=mine2 -- [=
graph mine2 {
   //
   // Managers
   node [shape=box style=filled fillcolor=white];
   rmac [label="Ronald McDonald\nDirector IT" style=filled fillcolor=yellow];
   ccox [label="Chris Cox\nMgr. Open Systems" style=filled fillcolor=orange URL="http://www.google.com" target="_google"];
   //
   // Workers
   bbuilder [label="Bob Builder\nUnix Sys Admin"]; 
   ggad [label="Greg Gad\nSr. Network Admin"];
   bdino [label="Bruce Dino\nSr. Systems Programmer"];
   jjmadman [label="J.J. Madman\nTemp. Worker"];
   bgates [label="Bill Gates\nWindows Admin"];
   //
   // Define hierarchy
   rmac -- ccox;
   rmac -- ggad;
   rmac -- bdino;
   ccox -- bbuilder
   ccox -- jjmadman;
   bbuilder -- bgates;
   rmac -- bgates [style=dotted constraint=false];
}
=]:)

PmGraphViz

(:pmgraphviz -- [=
graph  {
   compound=true;
   //
   // Managers
   node [shape=box style=filled fillcolor=white];
   rmac [label="Ron McDonald\nDirector IT" style=filled fillcolor=yellow];
   ccox [label="Chris Cox\nMgr. Open Systems" style=filled fillcolor=orange];
   //
   subgraph cluster_ccox {
       style=filled;
       color=lightgrey;
       bbuilder [label="Bob Builder\nUnix Sys Admin"]; 
       jjmadman [label="J.J. Madman\nTemp. Worker"];
       bgates [label="Bill Gates\nWindows Admin"];
       bbuilder -- jjmadman -- bgates [style=invis];
   }
   ggad [label="Greg Gad\nSr. Network Admin"];
   bdino [label="Bruce Dino\nSr. Systems Programmer"];
   //
   // Define hierarchy
   rmac -- ccox;
   rmac -- ggad;
   rmac -- bdino;
   ccox -- bbuilder [ lhead=cluster_ccox ];
   rmac -- bgates [style=dashed constraint=false];
}
=]:)

PmGraphViz

(:pmgraphviz -- [=
digraph G {
        fontname = "Bitstream Vera Sans"
        fontsize = 8
//
        node [
                fontname = "Bitstream Vera Sans"
                fontsize = 8
                shape = "record"
        ]
//
        edge [
                fontname = "Bitstream Vera Sans"
                fontsize = 8
        ]
//
        Animal [
                label = "{Animal|+ name : string\l+ age : int\l|+ die() : void\l}"
        ]
//
        subgraph clusterAnimalImpl {
                label = "Package animal.impl"
//
                Dog [
                        label = "{Dog||+ bark() : void\l}"
                ]
//
                Cat [
                        label = "{Cat||+ meow() : void\l}"
                ]
        }
//
        edge [
                arrowhead = "empty"
        ]
//
        Dog -> Animal
        Cat -> Animal
//
        edge [
                arrowhead = "none"
//
                headlabel = "0..*"
                taillabel = "0..*"
        ]
//
        Dog -> Cat
} =] :)

PmGraphViz

(:pmgraphviz -- [=
digraph map {
//
  node [shape=box     fontsize=10 fontname=verdana]; configure_in Makefile_am acconfig_h    man_created;   
  node [shape=box     fontsize=10 fontname=verdana]; aclocal_m4 configure config_h_in Makefile_in Makefile
                                                     config_guess config_log configure_scan  created; 
  node [shape=ellipse fontsize=10 fontname=verdana]; aclocal autoheader autoconf automake autoscan  gnu_tools;      
//
  configure_in   [label="configure.ac\npreviously: configure.in"];
  Makefile_am    [label="Makefile.am"                           ];
  configure      [label="./configure"                           ];
  aclocal        [label="aclocal"                               ];
  autoheader     [label="autoheader"                            ];
  autoconf       [label="autoconf"                              ];
  autoscan       [label="autoscan"                              ];
  config_h_in    [label="config.h.in"                           ];
  aclocal_m4     [label="aclocal.m4"                            ];
  config_h       [label="config.h"                              ];
  Makefile_in    [label="Makefile.in"                           ];
  gnu_tools      [label="GNU Tools"                             ];
  created        [label="created"                               ];
  man_created    [label="manually created"                      ];
  acconfig_h     [label="acconfig.h"                            ];
  config_guess   [label="config.guess"                          ];
  config_log     [label="config.log"                            ];
  configure_scan [label="configure.scan"                        ];
//
  configure_in   -> autoconf;
  autoconf       -> configure;
//
  autoscan       -> configure_scan;
  configure_scan -> configure_in    [label="Manually editing" fontname=verdana fontsize=10];
//
  configure_in   -> aclocal      [label=reads  fontname=verdana fontsize=10];
  aclocal        -> aclocal_m4;
//
  acconfig_h     -> autoheader;
  configure_in   -> autoheader   [label=reads  fontname=verdana fontsize=10];
  autoheader     -> config_h_in;
//
  Makefile_am    -> automake;
  automake       -> Makefile_in;
//
  configure_in   -> automake     [label=reads  fontname=verdana fontsize=10];
  config_h_in    -> configure    [label=reads  fontname=verdana fontsize=10];
  Makefile_in    -> configure    [label=reads  fontname=verdana fontsize=10];
  configure      -> config_h     [label=writes fontname=verdana fontsize=10];
  configure      -> Makefile     [label=writes fontname=verdana fontsize=10];
  configure      -> config_guess [label=writes fontname=verdana fontsize=10 style=dotted];
  configure      -> config_log   [label=writes fontname=verdana fontsize=10];
//
  Makefile       -> make         [label=reads  fontsize=verdana fontsize=10];
} =] :)

PmGraphViz

(:pmgraphviz -- [=
digraph G {
//size="7,7";
 graph [rankdir="TB" label="1st Time Use/Phone Registration" fontsize=12 bgcolor="#eeeeff"];
	node [shape=box fontsize=8 style=filled fillcolor=yellow];
	edge [color=blue fontsize=8 font="Arial"];
//
	cell_number_entry [label="Cell Number Entry"];
	welcome [label="Welcome Page"];
	member_name_creation [label="Member Name Creation"];
	password_creation [label="Password Creation"];
	member_name_unavailable [label="Member Name Unavailable"];
	email_entry [label="Email Entry"];
	zip_code_entry [label="Zip Code Entry"];
	tos [label="TOS"];
	decline_confirmation [label="Decline Confirmation"];
	registration_confirmation [label="Registration Confirmation"];
	member_name_entry [label="Member Name Entry"];
	password_entry [label="Password Entry"];
	confirm_phone_number [label="Confirm Phone Number"];
	unsuccessfull_sign_in [label="Unsuccessfull Sign In"];
	email_confirmation [label="Email Confirmation"];
	main_menu [label="Main Menu"];
	initial_screen [label="Initial Screen"];
	exit_application [label="Exit the Application"];
//
	welcome -> initial_screen [label="First Time"]
	initial_screen -> member_name_creation [label="Register"];
	initial_screen -> member_name_entry [label="Sign In"];
	member_name_creation -> password_creation [label="Valid Member Name" dir="both"];
	member_name_creation -> member_name_unavailable [label="Invalid Member Name" dir="both"];
	welcome -> password_creation;
	password_creation -> cell_number_entry [dir="both"];
	member_name_entry -> password_entry [dir="both"];
	cell_number_entry -> email_entry [dir="both"];
	password_entry -> confirm_phone_number [label="Auth. Successful" dir="both"];
	password_entry -> unsuccessfull_sign_in [label="Auth. Unsuccessful"];
	email_entry -> zip_code_entry [dir="both"];
	zip_code_entry -> tos [dir="both"];
	confirm_phone_number -> main_menu;
	unsuccessfull_sign_in -> member_name_entry [label="Try Again" constraint="false"];
	unsuccessfull_sign_in -> email_confirmation;
	tos -> decline_confirmation [label="Decline" dir="both"];
	tos -> registration_confirmation [label="Accept"];
	decline_confirmation -> exit_application [label="Yes"];
	registration_confirmation -> main_menu [label="10 Sec/NEXT"]; 
} =] :)

PmGraphViz

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.