This page describes just another creole macro which renders graphviz instructions from a creole page into an image.
The macro is included by the instruction.
<<dot>>
digraph G {Hello->World}
<</dot>>
As with mathplot there are optional parameters.
title that defines the title and alt attributes of the <img> tag
show_source is False by default. If True the content of the graph source is displayed
Here is the simple test example.
Rendering a dot macro is a two tier process.
When the creole markup language is translated the macro gives the HTML code of an <img> tag and the graph source is stored temporarily into the database. The key to that database is the src attribute of the <img> tag.
When rendering the image the graph source is taken from the database and stored temporarily into a file, rendered to a png image file. Both temporary files are removed after the procedure returned the image to the server.
The Creole Macro
The graph source is taken from the macro's body and stored with a unique key into the database.
[Error: Wrong macro arguments: "py" for macro 'code' (maybe wrong macro tag syntax?)]
The Graphviz View
The vie translates the graphviz source into a png image and returns the image as a HttpResponse object. As the the translation is accomplished by a system call to the dot routine, the files have to be stored temporarily. That process require 3 external prerequisites.
The installation of graphviz
The command to launch the dot routine settings.GRAPHVIZ_DOT_CMD. (On a linux platform you can use the "whereis dot" command to locate it.)
A temporary directory should exist somewhere settings.GRAPHVIZ_TMP_DIR. Write permissions have to be granted to the server.
For convenience i stored the latter two parameters in my setting.
[Error: Wrong macro arguments: "py" for macro 'code' (maybe wrong macro tag syntax?)]
And this is the view code.
[Error: Wrong macro arguments: "py" for macro 'code' (maybe wrong macro tag syntax?)]