chefjerome/graphalchemy — pull request #17 by chefkevin (2013-09-24 15:45:53+00:00)
Title: Model visualization generator

Overview

The model visualization generator feature allows to check the completeness of a data model and to produce a diagram of it:
- Metadata object parsing:
- nodes are defined by Node objects;
- relationships are defined by Relationship objects and couples of Adjacency objects.
- Output formatting: Dot code format implementation done and tested.

How to use

python:
> visualizer = GraphvizVisualizationGenerator(myMetadata)
> visualizer.set_output_path('/tmp/viz.dot') \
.set_graph_title('Data model diagram') \
.run() \
.write_output()

Then:

shell:
$ dot -Tjpg /tmp/viz.dot -o /tmp/viz.jpeg
$ eog /tmp/viz.jpg

or

python:
>from subprocess import call
> call(["dot", "-Tjpg", "/tmp/viz.dot",
"-o", "/tmp/viz.jpg"])
> call(["eog", "/tmp/viz.jpg"])

Content

- VisualizationGenerator: abstract class implementing non-output-language-dependent methods only.
- GraphvizVisualizationGenerator: Implements output formatting methods for dot code generation.
- configuration:
- color_settings: a list of Graphviz colors (see: Configuration)
- dot_template: a Graphviz template optimized for dot generation (see: How to use)
- TestGraphvizVisualizationGenerator: Testcase on title, node and relationships specifications.

Graphviz visualization Configuration

A configuration folder is located in graphviz/blueprints/model_visualization.
It contains 2 configuration files:

Template

Graphviz digraph template:
- Sets Graph style
- Is appended with:
- title;
- node specifications;
- relationship specifications.

Colors

To color the nodes, one can either create a customed configuration or use the default color list.

A customed configuration could be:
- A list: The final visualization will color nodes using those colors only. Order is not respected.
- A dictionary, with node names as keys and colors as values: this allows to keep a colour code.