NAME

HTML::InfoVis::Graph - Generate a JSON structure suitable for loadJSON classes

SYNOPSIS

use HTML::InfoVis;

my $graph = HTML::InfoVis::Graph->new;
$graph->add_edge( 'foo' => 'bar' );

print "var json = " . $graph->as_json . "\n";

DESCRIPTION

HTML::InfoVis::Graph is used to generate a JSON structure suitable for loading by any InfoVis Javascript object that has the loadJSON method.

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.

METHODS

new

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.

add_node

$graph->add_node( 'foo' );

The add_node method is a pass-through method to the underlying Graph add_vertex method.

add_edge

$graph->add_edge( 'foo' => 'bar' );

The add_edge method is a pass-through method to the underlying Graph add_edge method.

as_json

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.

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.

SUPPORT

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.

AUTHORS

Adam Kennedy <adamk@cpan.org>

COPYRIGHT

Copyright 2009 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.