The Triples Visualizer Plugin can generate graphviz files and images. It needs two configuration parameters and an ARC triples array as input:
/* ARC2 static class inclusion */
include_once('path/to/arc/ARC2.php');
/* configuration */
$config = array(
/* path to dot */
'graphviz_path' => '/usr/local/bin/dot',
/* tmp dir (default: '/tmp/') */
'graphviz_temp' => '/usr/local/tmp/',
/* pre-defined namespace prefixes (optional) */
'ns' => array('foaf' => 'http://xmlns.com/foaf/0.1/')
);
/* instantiation */
$viz = ARC2::getComponent('TriplesVisualizerPlugin', $config);
$triples = ...; /* e.g. from parse() or a "SELECT ?s ?p ?o" query */
/* display an svg image */
$svg = $viz->draw($triples, 'svg', 'base64');
echo '<embed type="image/svg+xml" src="data:image/svg+xml;base64,' . $svg . '"/>';
/* display a png image */
$png = $viz->draw($triples, 'png', 'base64');
echo '<img src="data:image/png;base64,' . $png . '"/>';
/* generate a dot file */
$dot_src = $viz->dot($triples);
Download
- The latest version of this plugin is available in the plugin download section.
Requirements
- graphviz/dot
- write access for the temp directory
