Extension:GraphViz
GraphViz Release status: stable | |||
---|---|---|---|
![]() | |||
Implementation | Tag | ||
Description | Provides an online graph renderer | ||
Author(s) | |||
Latest version | 3.1.0 (2018-03-13) | ||
MediaWiki | 1.29+ | ||
PHP | 5.4+ | ||
Database changes | No | ||
Composer | mediawiki/graph-viz | ||
License | GNU General Public License 2.0 or later | ||
Download | README RELEASE-NOTES | ||
Example | |||
| |||
| |||
Translate the GraphViz extension if it is available at translatewiki.net | |||
Check usage and version matrix. | |||
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.
Contents
Compatibility[edit]
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+ | 3.x.x | 3.0.x |
Installation[edit]
From the MediaWiki Extension Distributor[edit]
Download from Special:ExtensionDistributor/GraphViz
With Composer[edit]
From MediaWiki version 1.22 onwards, 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. MediaWiki versions prior to 1.22 can use Composer via Extension:ExtensionInstaller.
Once you have Composer properly installed, go to your MediaWiki installation directory and run:
php composer.phar require mediawiki/graph-viz '*'
for the latest stable version or
php composer.phar require mediawiki/graph-viz 'dev-master'
for the latest development version.
If Composer is globally available on the server:
composer require mediawiki/graph-viz '*'
For future updates call
php composer.phar update
or
php composer.phar update mediawiki/graph-viz
Without Composer[edit]
- Download the GraphViz extension archive from GIT and extract it into your MediaWiki "/extensions/GraphViz" directory.
Common[edit]
- 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[edit]
Set configuration parameters in LocalSettings.php only if the defaults do not suit your environment. For each parameter, add the line
$wgGraphVizSettings->Parameter = "value";
in your LocalSettings.php after the line
wfLoadExtension( 'GraphViz' );
e.g.
$wgGraphVizSettings->createCategoryPages = "yes";
- Available parameters
Parameter | Platform | Default Value | Description | Version |
---|---|---|---|---|
execPath | Windows | C:/Program Files/Graphviz/bin/ | path to the Graphviz executables (dot.exe, circo.exe, fpdp.exe, neato.exe, twopi.exe) | all |
execPath | Unix/linux | /usr/bin/ | path to the Graphviz executables (dot, circo, fdp, neato, twopi) | all |
mscgenPath | all | <none> | path to the mscgen executable | all |
defaultImageType | 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[edit]
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[edit]
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[edit]
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[edit]
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[edit]
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[edit]
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[edit]
In addition to the examples below, here is a nice flickr gallery of graphviz-rendered graphs.
Example 1[edit]
<graphviz border='frame' format='png' caption='Graph for example no. 1'> digraph example1 {Hello->World} </graphviz>
Example 2[edit]
<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[edit]
<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[edit]
<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[edit]
See RELEASE-NOTES.md.
Dependencies[edit]
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:SemanticMediaWiki, 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[edit]
- Mermaid extension.
Language: | English • русский |
---|
- GPL licensed extensions
- Stable extensions
- Tag extensions
- Extensions without a compatibility policy
- Extensions supporting Composer
- Extensions in Wikimedia version control
- ParserFirstCallInit extensions
- PageContentSave extensions
- UnitTestsList extensions
- OutputPageParserOutput extensions
- ArticleDeleteComplete extensions
- RejectParserCacheValue extensions
- All extensions
- Graph extensions
- Image map extensions