![]() Release status: unmaintained |
|
---|---|
![]() |
|
Implementation | Tag |
Description | Provides an online graph renderer |
Author(s) |
|
Latest version | 3.1.0 (2018-03-13) |
MediaWiki | 1.29.x - 1.32.x only |
PHP | 5.4+ |
Composer | mediawiki/graph-viz |
License | GNU General Public License 2.0 or later |
Download | Download extension Git [?]: README RELEASE-NOTES |
Example | |
Parameters
|
|
Hooks used
|
|
Quarterly downloads | 29 (Ranked 141st) |
Translate the GraphViz extension if it is available at translatewiki.net | |
Issues | Open tasks · Report a bug |
The GraphViz extension lets you create and display graphs as in-line images on wiki pages using tools from the open-source Graphviz and Mscgen projects:
- Graphviz (short for Graph Visualization Software) is a package of open-source tools initiated by AT&T Labs Research for drawing graphs specified in DOT files.
- Mscgen (short for MSC generator) is a software tool for drawing message sequence charts from a text source file.
Compatibility
MediaWiki | GraphViz | Semantic Result Formats |
---|---|---|
1.27.x - 1.28.x | 2.x.x | 2.5.x |
1.27.x - 1.28.x | 2.x.x | 3.0.x |
1.29.x - 1.32.x | 3.x.x | 3.0.x |
1.33+ | Not compatible, use the Diagrams or External Data extension |
see http://wiki.bitplan.com/index.php/GraphViz_MediaWiki_extension and http://wiki.bitplan.com/index.php/Diagrams for current discussion about replacing this extension with a somewhat compatible solution.
Installation
From the MediaWiki Extension Distributor
Download from Special:ExtensionDistributor/GraphViz
With Composer
GraphViz should be installed using built-in Composer support. The package name is mediawiki/graph-viz
. For instructions on how to install Composer see MediaWiki's user manual for Composer.
Once you have Composer properly installed, go to your MediaWiki installation directory and add the extension to your to your composer.local.json
:
{
"require": {
"mediawiki/graph-viz": "^3.1"
}
}
And then run:
composer update
Without Composer
- Download the GraphViz extension archive from GIT and extract it into your MediaWiki "/extensions/GraphViz" directory.
Common
- Update LocalSettings.php to include the following:
wfLoadExtension( 'GraphViz' );
- Visit your wiki's Special:Version page and verify that the correct version of the GraphViz extension is installed.
- Install one of the external tools "Graphviz" or "Mscgen".
- Windows: Get your copy here: http://www.graphviz.org/Download.php or here http://www.mcternan.me.uk/mscgen/
- Unix: Same links as for windows but normally it should be pre-installed (at least graphviz - search for dot) or can be found in the package manager.
- Ubuntu/Debian: and
sudo apt-get install graphviz
sudo apt-get install mscgen
- Make sure that write permissions for the "$IP/images" directory are granted.
- Make sure that internet users get read/execute access on your executables if you use server installations (especially under Windows).
Configuration
Set configuration parameters in LocalSettings.php only if the defaults do not suit your environment.
Variable name | Platform | Default Value | Description | Version |
---|---|---|---|---|
$wgGraphVizExecPath | Windows | C:/Program Files/Graphviz/bin/ | Path of the directory containing the Graphviz executables (dot.exe, circo.exe, fpdp.exe, neato.exe, twopi.exe) | all |
Unix/linux | /usr/bin/ | Path of the directory containing the Graphviz executables (dot, circo, fdp, neato, twopi) | all | |
$wgGraphVizMscgenPath | all | <none> | Path to the mscgen executable | all |
$wgGraphVizDefaultImageType | all | png | Default output image type if none is specified on the "format" attribute of an individual graph | >= 1.0 |
Note: Under Linux, shell commands such as the Graphviz and mscgen executables are invoked with the limits given by $wgMaxShellTime, $wgMaxShellMemory and $wgMaxShellFileSize. If graphs or message sequence charts do not render then you may need to tune these settings for your installation.
Drawing Graphs
You may define a graph in the dot language and enclose it in graphviz tags as follows:
<graphviz> dot-language </graphviz>
You may define a message sequence chart in the mscgen language and enclose it in mscgen tags as follows:
<mscgen> mscgen-language </mscgen>
When the wiki page is saved (or when you click "Show preview" after editing) an image is produced that corresponds to the DOT or mscgen text and it is shown in-line on the page. The image is also uploaded so it may be included in other pages directly.
See the #Examples for some basic graphs.
Graph Tag Attributes
Graph tag attributes may be supplied with either graphviz or mscgen as follows:
<graphviz attr1="value1" attr2="value2" ... attrN="valueN"> dot-language <graphviz/>
<mscgen attr1="value1" attr2="value2" ... attrN="valueN"> mscgen-language <mscgen/>
The following extended image syntax attributes are supported as graph tag attributes: type, border, location, alignment, size, link, alt, caption.
Attribute | Tag | Description | Value | Version |
---|---|---|---|---|
format | graphviz | specifies the graph image output format | gif, jpg, jpeg, png, svg* | all |
format | mscgen | specifies the message sequence chart image output format | png, svg* | all |
uniquifier | graphviz | needed to display graphs of the same name on the same page (rare) | text (appended to the graph name) | >=1.0 |
uniquifier | mscgen | needed to display multiple message sequence charts on the same page (common) | text (used as message sequence chart name) | >=1.0 |
renderer | graphviz | see "layout commands" in the Graphviz documentation | dot, neato, fdp, sfdp, circo, twopi | all |
preparse | graphviz | replace magic words before invoking the graphviz renderer | dynamic | >=1.5.0 |
preparse | mscgen | replace magic words before invoking the mscgen command | dynamic | >=1.5.0 |
The option preparse="dynamic"
makes it also possible to use GraphViz and templates and import these into a MediaWiki site. Changes to the original template will then be passed on. No preparse
option will lead to two images, in case of a change to the original, of which the older version will always be imported should the template be called.
- svg requires additional configuration.
Multiple Graphs Per Page
For graphviz, use unique names for each graph to display multiple graphs on the same page.
First Graph | Second Graph |
---|---|
<graphviz> graph NAME {... } </graphviz> |
<graphviz> graph ANOTHERNAME {... } </graphviz> |
For mscgen, use the "uniquifier" tag attribute to display multiple message sequence charts on the same page.
First Message Sequence Chart | Second Message Sequence Chart |
---|---|
<mscgen uniquifier="NAME"> msc {... } </mscgen> |
<mscgen uniquifier="ANOTHERNAME"> msc {... } </mscgen> |
Links
Graphs in the DOT and mscgen languages may include URLs. These follow the pattern URL="link" where "link" is governed by the ImageMap syntax:
"All links are given in either the form [[Page title]] or [[Page title|description]]. In the latter case, the part after the pipe becomes the title attribute of the link—in most browsers, it will pop up as a tooltip when the user hovers over it; the part after the pipe also becomes the alt text for the link. If no explicit link description is given, the page title is used."
Additionally, external links are supported with or without square brackets. Specify external links without square brackets in order to honor DOT tooltip attributes (e.g. URL="http://mediawiki.org", tooltip="MediaWiki"). The MediaWiki "external link with different label" form is also supported (e.g. [http://mediawiki.org MediaWiki]).
Remark:
The link format is different from the format used in earlier versions. ( < 1.0).
See #Example 3 for an example with links.
Finding graphs and message sequence charts
Pages with graphs or message sequence charts will have the "graphviz" page property set. Using Special:PagesWithProp, you can find pages that have graphs or message sequence charts. (Example query for the English Wikipedia.)
Restrictions
This extension imposes the following restrictions on the DOT language input:
- Any image attribute values are required to be the names of uploaded files.
- Any IMG SRC attribute values in HTML-like labels are required to be the names of uploaded files.
- The imagepath attribute is not allowed.
- The shapefile attribute is not allowed.
- The fontpath attribute is not allowed.
Examples
In addition to the examples below, here is a nice flickr gallery of graphviz-rendered graphs.
Example 1

<graphviz border='frame' format='png' caption='Graph for example no. 1'> digraph example1 {Hello->World} </graphviz>
Example 2

<graphviz renderer="neato" caption="Graph for example no. 2"> graph example2 { run -- intr; intr -- runbl; runbl -- run; run -- kernel; kernel -- zombie; kernel -- sleep; kernel -- runmem; sleep -- swap; swap -- runswap; runswap -- new; runswap -- runmem; new -- runmem; sleep -- runmem; } </graphviz>
Example 3

<graphviz caption="Graph for example no. 3 (contains Wiki-Links)" alt="phylogenetic tree" format="png"> digraph example3 { node [shape=plaintext]; Mollusca [URL="[[w:Mollusca]]"]; Neomeniomorpha [URL="[[w:Neomeniomorpha]]"]; X1 [shape=point,label=""]; Caudofoveata [URL="[[w:Caudofoveata]]"]; Testaria [URL="[[w:Testaria]]"]; Polyplacophora [URL="[[w:Polyplacophora]]"]; Conchifera [URL="[[w:Conchifera]]"]; Tryblidiida [URL="[[w:Tryblidiida]]"]; Ganglioneura [URL="[[w:Ganglioneura]]"]; Bivalvia [URL="[[w:Bivalvia]]"]; X2 [shape=point,label=""]; X3 [shape=point,label=""]; Scaphopoda [URL="[[w:Scaphopoda]]"]; Cephalopoda [URL="[[w:Cephalopoda]]"]; Gastropoda [URL="[[w:Gastropoda]]"]; Mollusca->X1->Testaria->Conchifera->Ganglioneura->X2->Gastropoda Mollusca->Neomeniomorpha X1->Caudofoveata Testaria->Polyplacophora Conchifera->Tryblidiida Ganglioneura ->Bivalvia X2->X3->Cephalopoda X3->Scaphopoda } </graphviz>
Example 4

<mscgen caption="Message sequence chart for example no. 4">
msc {
a,b,c;
a->b [label="ab()"];
b->c [label="bc(TRUE)"];
c=>c [label="process(1)"];
c=>c [label="process(2)"];
...;
c=>c [label="process(n)"];
c=>c [label="process(END)"];
a<<=c [label="callback()"];
--- [label="If more to run", ID="*"];
a->a [label="next()"];
a->c [label="ac()"];
b<-c [label="cb(TRUE)"];
b->b [label="stalled(...)"];
a<-b [label="ab() = FALSE"];
}
</mscgen>
Contributions and history
See RELEASE-NOTES.md.
Dependencies
The GraphViz extension depends on Extension:ImageMap as of version 1.0.
The following extensions depend on the GraphViz extension:
- Extension:SemanticResultFormats, used in conjunction with Extension:Semantic MediaWiki , bundles a number of result formats for SMW's inline queries.
- graph format (displays connections between pages as graphs)
- process format (displays process graphs)
- Extension:Collaboration_Diagram (renders and visualizes a bipartite graph of any article and its editors)
- Extension:Genealogy, for displaying family tree diagrams.
See also
![]() | This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |