- Installation
- Frequently Asked Questions
- What is Graphviz?
- How do I use this plugin?
- How to I write DOT?
- Where can I see examples?
- Can I manipulate the rendered graph using CSS in my WordPress theme?
- Nothing is being rendered, maybe my DOT is broken?
- I'm getting strange errors that make no sense, what gives?
- How do I install the Graphviz program (not this plugin) locally?
- Example
- Changelog
- 1.14
- 1.13
- 1.12
- 1.11
- 1.10
- 1.9
- 1.8
- 1.7
- 1.6
- 1.5
- 1.4
- 1.3
- 1.2
- 1.1
- 1.0
- Upgrade Notice
- How to use TFO Graphviz
- Comments (3)
Graphviz is a powerful tool for visualising network and tree structures that connect objects.
This WordPress plugin provides a shortcode mechanism to create Graphviz graphics within blogs, including image map generation and most other Graphviz features.
Installation
Installation is simple. Either install from directly within WordPress or:
- Download and unzip the plugin to the [cci]/wp-content/plugins/tfo-graphviz[/cci] directory within your WordPress installation.
- Make the directory [cci]/wp-content/tfo-graphviz[/cci] and make it writable by the web server – this is where generated images and image maps go.
- Activate the plugin through the ‘Plugins’ menu in WordPress.
- Choose a generation method on the plugin settings page.
- Use the [cci]
Error generating Graphviz image:
Graphviz cannot generate graph Command: /usr/bin/dot '-Kdot' '-Tpng' '-o/data/blog.flirble.org/wp-content/tfo-graphviz/e234e5fe8c04cc955df7f3157eb70cda.png' Output: Error:
: syntax error in line 1 near '[' Original DOT: 1 [/cci] shortcode to generate graphs.
2
-
6
- By using a local installation of Graphviz and the [cci]dot[/cci] binary. 7
- By using a local installation and PHP bindings to the library. 8
Frequently Asked Questions
12What is Graphviz?
13 Graphviz is a way of generating visualisations of structural relationships between objects. Almost any kind of diagram where something connects to something else can be drawn and automatically laid out using the language DOT. 14 15How do I use this plugin?
16 Use the [cci][graphviz][/cci] shortcode. Various uses are explained in the "How to use" section. 17 18How to I write DOT?
19 The online documentation for Graphviz is terse and not especially helpful, in particular the DOT language page is only helpful if you happen to be able to read an approximation of BNF. 20 21 There are however several other introductions to Graphviz and DOT, including an excerpt on the O'Reilly LinuxDevCenter.com site. Another approach would be to look at the examples in the Graphviz gallery. 22 23Where can I see examples?
24-
25
- http://blog.flirble.org/2010/11/12/graphviz-demo/ 26
- http://blog.flirble.org/2015/11/15/adding-svg-support-tfo-graphviz/ 27
Can I manipulate the rendered graph using CSS in my WordPress theme?
29 The [cci]img[/cci] elements are tagged with '[cci]class="graphviz"[/cci]'. 30 31Nothing is being rendered, maybe my DOT is broken?
32 If you're using a local Graphviz renderer then errors from Graphviz should be presented where you expect the graph to appear. Note that because of how WordPress submits content to plugins the line numbering will not always match what you expect. 33 34 The error message when using the [cci]dot[/cci] binary will contain the command line used as well as a line-numbered copy of the DOT that was used. 35 36I'm getting strange errors that make no sense, what gives?
37 WordPress encodes HTML entities inside the shortcode block which this plugin attempts to demangle. 38 39 Unfortunately WordPress can also try to do smart character replacement, such as "..." into a UNICODE ellipsis character. The Graphviz plugin contains a mapping of many of these back to their ASCII equivalents, but it may not be complete. Let us know if you think this is breaking your DOT. It's also possible that non-ASCII7 characters do strange things too. 40 41 Adding [cci]define("TFO_GV_DEBUG", true)[/cci] to [cci]wp_config.php[/cci] will cause the plugin to create some diagnostic files in your system [cci]tmp[/cci] directory. The file [cci]pre-N.dot[/cci] is the contents of the DOT as given to the plugin by WordPress, [cci]post-N.dot[/cci] is the results of the plugin attempting to demangle it. The [cci]N[/cci] is a number that is incremented for each shortcode section interpreted. The plugin does not clean these files up. 42 43How do I install the Graphviz program (not this plugin) locally?
44 This depends on your host. You will find some details at http://www.graphviz.org/Download.php but many systems also have it in their own package management system, for example this is package [cci]graphviz[/cci] on Debian, Ubuntu and Fedora systems. 45 46Example
47Changelog
1.14
- Finally worked out how to disable [cci]wptexturize[/cci]! Less demangling now required.
- Add an option to control whether we ever emit JavaScript.
1.13
- Better diagnostic output when running [cci]dot[/cci] doesn't work, including the command line used and adding the DOT as submitted, with line numbers. (Joachim Durchholz)
- Add more de-mangling rules, for smart quotes and ellipsis. (Joachim Durchholz)
- Improve the newline de-mangling. (Joachim Durchholz)
- Add the SVG output format. See http://blog.flirble.org/2015/11/15/adding-svg-support-tfo-graphviz/ for example. (Joachim Durchholz)
- Add a fix for if the requires GV class isn't loadable, such as when GV gets upgraded on the system. (Sam Wilson)
- Include some JavaScript when both an image map and width/height scaling is specified. This is required to scale the image map to whatever the image has been scaled to. Image map scaling code comes from https://github.com/davidjbradshaw/image-map-resizer
1.12
- [cci]clean_url()[/cci] and [cci]attribute_escape()[/cci] have both been deprecated. Migrate to [cci]esc_url()[/cci] and [cci]esc_attr()[/cci]. (Sam Wilson)
1.11
- Remove deprecated constructor definitions. (Sam Wilson)
- Testing against 4.3.
1.10
- Require at least WP 4.2 now.
- Fix use of[cci]add_query_arg()[/cci] to escape its output; a possible XSS vector.
1.9
- Make some debugging output conditional.
- Fix where that debugging output is stored. (Sam Wilson)
1.8
- Fix a packaging error in 1.7.
- Fix use of hardcoded "/tmp" path. (Sam Wilson)
1.7
- Test upto WP 4.2.2.
- Change an [cci]exec("mv...")[/cci] to using [cci]rename()[/cci] instead. (Sam Wilson)
- Code documentation improvement.
- Some reformatting.
1.6
- Fix some cosmetic documentation issues.
1.5
- Update documentation for using the PHP gv bindings.
1.4
- WordPress 4.0 support.
- Fix for PHP Graphviz module loading; newer PHP's don't allow dl() at all in some cases, we should therefore detect this.
- Use WP_Error properly.
- Liberal use of try/catch to detect runtime issues.
1.3
- No changes; version bump for the later 3.x series.
1.2
- Removed leftover diagnostic code in PHP render class (which was appearing in posts!)
- Added remote Graphviz rendering support. Note that this is still young and will add a mark to the graph indicating it was generated by this plugin.
- Tested on WordPress 3.0.2 and 3.0.3.
1.1
- Added support for locally installed PHP bindings to the Graphviz library. This only works if PHP either allows dl() to load a module or gv.so/dll is staticly configured to load in php.ini.
- Made render module selection somewhat more robust.
- Attempt to create our wp-content/tfo-graphviz directory if it doesn't already exist.
- Better (as in, "any at all") error generation in the shortcode handler.
- Add content expiration - configurable. Will remove files from the wp-content/tfo-graphviz directory, but only if the threshold is >0 and older than the threshold.
1.0
- First release.
Upgrade Notice
Upgrading from all previous versions strongly recommended; Earlier versions will not run on WordPress 4 or on older Apache/PHP installations.
How to use TFO Graphviz
The shortcode syntax is:
[cc]
Error generating Graphviz image:
Graphviz cannot generate graph Command: /usr/bin/dot '-Kdot' '-Tpng' '-o/data/blog.flirble.org/wp-content/tfo-graphviz/6297339539d1e4c405b281f049ce634e.png' Output: Error:: syntax error in line 2 near '>' Original DOT: 1 2 3
[/cc]
Where [cci]
- [cci]href="self|
"[/cci] Encompasses the generated image with a link either to the image itself (with the [cci]self[/cci] value) or to the provided URL. If the option is empty (for example, [cci]href=""[/cci]) then no link is generated. This is the default.
- [cci]id="
"[/cci] Provides the identifier used to link the generated image to an image map. If you use the [cci]simple[/cci] option then it also provides the name of the generated DOT graph container (since Graphviz uses this to generate the image map). If not given then an identifier is generated with the form [cci]tfo_graphviz_N[/cci] whereN is an integer that starts at one when the plugin is loaded and is incremented with use.
- [cci]imap="yes|no"[/cci]
Graphviz can generate image maps using any URL's given in the DOT code so that clicking on objects in the resultant image will direct a web browser to a new page. The effect of this option is to both instruct Graphviz to generate a client-side image map and to also insert that map into the generated HTML. It will use the [cci]id[/cci] value as the name of the map (see the [cci]id[/cci] option for details). [cci]imap[/cci] defaults to [cci]no[/cci].
- [cci]lang="
"[/cci] Specifies the particular Graphviz interpreter to use. The default is [cci]dot[/cci].
- [cci]output="
"[/cci] Indicates the desired image format. Defaults to [cci]png[/cci].
- [cci]simple="yes|no"[/cci]
The [cci]simple[/cci] option provides a very basic DOT wrapper around your code such that the following is possible:
[cc]
[/cc]The generated code would look like:
[cc]
digraph tfo_graphviz_1 {
a -> b -> c;
}
[/cc]See the [cci]id[/cci] option for a description of where the name of the [cci]digraph[/cci] comes from. [cci]simple[/cci] defaults to [cci]no[/cci].
- [cci]title="
"[/cci] Indicates the title of the image. This is used in the [cci]alt[/cci] and [cci]title[/cci] attributes of the image reference. This defaults to an empty string. Note that image maps may indicate a [cci]title[/cci] string which will appear in tool-tips.
Pingback: Adding Graphviz - The Karalli Pages
Pingback: Promethean Chasms | Petty
Pingback: Personal Dataflow | Petty