DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:graphviz

Graphviz-plugin

Compatible with DokuWiki

  • 2013-12-08 "Binky" unknown
  • 2013-05-10 "Weatherwax" yes
  • 2012-10-13 "Adora Belle" yes
  • 2012-01-25 "Angua" unknown

plugin Graph Visualization (from text with links between objects to image)

Last updated on
2010-11-24
Provides
Syntax
Repository
Source

This plugin can create directed and non-directed graph images from a textual description language called “dot” using the Graphviz program. It can use a locally installed graphviz or use Google's chart API for rendering.

The plugin supports exporting to OpenOffice through the ODT Plugin (only with a local graphviz install).

For more information on Graphviz and the dot language refer to the Graphviz documentation

This plugin was originally written by Carl-Christian Salvesen. The current plugin is a nearly complete rewrite and differs on how it works internally and where graphs are stored.

Download and Installation

Download and install the plugin using the Plugin Manager using the URL given above. Refer to Plugins on how to install plugins manually.

Changes

Configuration

The full path to your graphviz' dot binary can be configured in the config manager. When it isn't configured, remote rendering at Google is used.

Syntax and Usage

Any Graphviz compatible graph definition can be given with graphviz tags.

The rendering engine can optionally be given as argument in the opening tag. Supported are dot, neato, twopi, circo and fdp with dot being the default:

  • dot – “hierarchical” or layered drawings of directed graphs. This is the best tool to use if edges have directionality.
  • neato – “spring model” layouts. This is the best tool to use if the graph is not too large (about 100 nodes) and you don't know anything else about it. Neato attempts to minimize a global energy function, which is equivalent to statistical multi-dimensional scaling.
  • fdp – “spring model” layouts similar to those of neato, but does this by reducing forces rather than working with energy.
  • twopi – radial layouts, after Graham Wills 97. Nodes are placed on concentric circles depending their distance from a given root node.
  • circo – circular layout, after Six and Tollis 99, Kauffman and Wiese 02. This is suitable for certain diagrams of multiple cyclic structures, such as certain telecommunications networks.

You can also specify left, center or right to align the resulting image.

A parameter in the form of <number>x<number> is interpreted as wanted output size. To only specify width width=<number> or <number>x0 can be used, for height height=<number> or 0x<number>.

Example

<graphviz dot right 500x200>
digraph finite_state_machine {
	rankdir=LR;
	size="9,5"
	node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8;
	node [shape = circle];
	LR_0 -> LR_9 [ label = "Sa(B)" ];
	LR_0 -> LR_1 [ label = "SS(S)" ];
	LR_1 -> LR_3 [ label = "S($end)" ];
	LR_2 -> LR_6 [ label = "SS(b)" ];
	LR_2 -> LR_5 [ label = "SS(a)" ];
	LR_2 -> LR_4 [ label = "S(A)" ];
	LR_5 -> LR_7 [ label = "S(b)" ];
	LR_5 -> LR_5 [ label = "S(a)" ];
	LR_6 -> LR_6 [ label = "S(b)" ];
	LR_6 -> LR_5 [ label = "S(a)" ];
	LR_7 -> LR_8 [ label = "S(b)" ];
	LR_7 -> LR_5 [ label = "S(a)" ];
	LR_8 -> LR_6 [ label = "S(b)" ];
	LR_8 -> LR_5 [ label = "S(a)" ];
}
</graphviz>

Compatibility

It seems to be compatible with “Rincewind”, but I don't dare to list it as compatible based on only my test.

I use it in Rincewind, it seems to work fine for me! Thanks for this great plugin! jdt

I use it in Rincewind but it did not work as all my graphics disapeared (see issue 4. But I seem to have found a workaround since my problem seemed to be a cache problem:

syntax.php
 
    /**
     * Return path to the rendered image on our local system
     */
    function _imgfile($data){
        if($conf['debug']){
            dbglog($cache, 'image file cache');
        }
        $cache  = $this->_cachename($data,'png');
                // create the file if needed
+++        /*******************************************************
+++        ****  CSJ added line ****/
+++        clearstatcache();
+++        /*******************************************************/
 
 
        if(!file_exists($cache)){
            $in = $this->_cachename($data,'txt');
            if($this->getConf('path')){
                $ok = $this->_run($data,$in,$cache);
            }else{
                $ok = $this->_remote($data,$in,$cache);
            }
            if(!$ok) return false;
            clearstatcache();
        }
 
        // resized version
        if($data['width']){
            $cache = media_resize_image($cache,'png',$data['width'],$data['height']);
        }
 
        // something went wrong, we're missing the file
        if(!file_exists($cache)) return false;
        //print $cache;
        return $cache;
    }



So there you go!

Enjoy.
Claude

—-

Dokuwiki Farmer issue

It did not work for our wiki which makes use of dokuwiki-farmer. Adding unset($data['animal']); in syntax.php in the function _cachename solved the problem.:

function _cachename($data,$ext){
        unset($data['width']);
        unset($data['height']);
        unset($data['align']);
+++	unset($data['animal']);
        return getcachename(join('x',array_values($data)),'.graphviz.'.$ext);
    }

When trying to debug I also realized that $conf['debug'] is never set but i guess it is $conf['allowdebug'].

FAQ

How do I get anti-aliased images ?

Make sure you have a Graphviz version compiled against Cairo, this will cause it to use it by default, and results in anti-aliased images.

Does the server need an access to Internet ?

Yes, it uses Google API to generate graphs.

plugin/graphviz.txt · Last modified: 2014/04/02 08:26 by 129.13.72.198