HTML::InfoVis::Graph - Generate a JSON structure suitable for loadJSON classes
use HTML::InfoVis; my $graph = HTML::InfoVis::Graph->new; $graph->add_edge( 'foo' => 'bar' ); print "var json = " . $graph->as_json . "\n";
HTML::InfoVis::Graph is used to generate a JSON structure suitable for loading by any InfoVis Javascript object that has the loadJSON method.
loadJSON
This is a basic first implementation, designed to prove the concept of converting Perl graphs into InfoVis graphs.
It provides a few Graph-like methods to populate the graph, and a single method for generating an anonymous JSON structure representing the graph.
my $graph = HTML::InfoVis::Graph->new( Graph->new, );
The default constructor takes a single optional param of a Graph object that represents the graph structure.
Returns a new HTML::InfoVis::Graph object.
$graph->add_node( 'foo' );
The add_node method is a pass-through method to the underlying Graph add_vertex method.
add_node
add_vertex
$graph->add_edge( 'foo' => 'bar' );
The add_edge method is a pass-through method to the underlying Graph add_edge method.
add_edge
my $json = $graph->as_json;
The as_json method generates a serialized anonymous JSON structure that represents the graph in a form suitable for loading by any InfoVis loadJSON method.
as_json
Because it is generated anonymously, if you wish to assign it to a variable you will need to do that yourself in your JavaScript template.
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-InfoVis
For other issues, or commercial enhancement or support, contact the author.
Adam Kennedy <adamk@cpan.org>
Copyright 2009 - 2012 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install HTML::InfoVis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::InfoVis
CPAN shell
perl -MCPAN -e shell install HTML::InfoVis
For more information on module installation, please visit the detailed CPAN module installation guide.