NAME

SVG::TT::Graph::HeatMap - Create presentation quality SVG HeatMap graph of XYZ data points easily

SYNOPSIS

use SVG::TT::Graph::HeatMap;

my @data_cpu = (
                 {  x        => x_point1,
                    y_point1 => 10,
                    y_point2 => 200,
                    y_point3 => 1000,
                 },
                 {  x        => x_point2,
                    y_point1 => 100,
                    y_point2 => 400,
                    y_point3 => 500,
                 },
                 {  x        => x_point3,
                    y_point1 => 1000,
                    y_point2 => 600,
                    y_point3 => 0,
                 },
               );

my $graph = SVG::TT::Graph::HeatMap->new(
                                          { block_height => 24,
                                            block_width  => 24,
                                            gutter_width => 1,
                                          } );

$graph->add_data(
                  { 'data'  => \@data_cpu,
                    'title' => 'CPU',
                  } );

print "Content-type: image/svg+xml\n\n";
print $graph->burn();

DESCRIPTION

This object aims to allow you to easily create high quality SVG HeatMap graphs of XYZ data. You can either use the default style sheet or supply your own.

Please note, the height and width of the final image is computed from the size of the labels, block_height/block_with and gutter_size.

METHODS

new()

use SVG::TT::Graph::HeatMap;

my $graph = SVG::TT::Graph::HeatMap->new({

  # Optional - defaults shown
  block_height => 24,
  block_width  => 24,
  gutter_width => 1,

  'y_axis_order' => [],
});

The constructor takes a hash reference with values defaulted to those shown above - with the exception of style_sheet which defaults to using the internal style sheet.

add_data()

my @data_cpu = (
                 {  x        => x_point1,
                    y_point1 => 10,
                    y_point2 => 200,
                    y_point3 => 1000,
                 },
                 {  x        => x_point2,
                    y_point1 => 100,
                    y_point2 => 400,
                    y_point3 => 500,
                 },
                 {  x        => x_point3,
                    y_point1 => 1000,
                    y_point2 => 600,
                    y_point3 => 0,
                 },
               );
or

 my @data_cpu = ( ['x',        'y_point1', 'y_point2', 'y_point3'],
               ['x_point1', 10,         200,        5],
               ['x_point2', 100,        400,        1000],
               ['x_point3', 1000,       600,        0],
             );

$graph->add_data({
  'data' => \@data_cpu,
  'title' => 'CPU',
});

This method allows you to add data to the graph object. The data are expected to be either a array of hashes or as a 2D matrix (array of arrays), with the Y-axis as the first arrayref, and the X-axis values in the first element of subsequent arrayrefs.

clear_data()

my $graph->clear_data();

This method removes all data from the object so that you can reuse it to create a new graph but with the same config options.

burn()

print $graph->burn();

This method processes the template with the data and config which has been set and returns the resulting SVG.

This method will croak unless at least one data set has been added to the graph object.

config methods

my $value = $graph->method();
my $confirmed_new_value = $graph->method($value);

The following is a list of the methods which are available to change the config of the graph object after it has been created.

compress()

Whether or not to compress the content of the SVG file (Compress::Zlib required).

tidy()

Whether or not to tidy the content of the SVG file (XML::Tidy required).

block_width()

The width of the blocks in px.

block_height()

The height of the blocks in px.

gutter()

The space between the blocks in px.

y_axis_order()
This is order the columns are presented on the y-axis, if the data is in a Array of hashes,
this has to be set, however is the data is in an 2D matrix (array of arrays), it will use
the order presented in the header array. 

If the data is given in a 2D matrix, and the y_axis_order is set, the y_axis_order will take 
prescience.

EXAMPLES

For examples look at the project home page http://leo.cuckoo.org/projects/SVG-TT-Graph/

EXPORT

None by default.

SEE ALSO

SVG::TT::Graph, SVG::TT::Graph::Line, SVG::TT::Graph::Bar, SVG::TT::Graph::BarHorizontal, SVG::TT::Graph::BarLine, SVG::TT::Graph::Pie, SVG::TT::Graph::Bubble, Compress::Zlib, XML::Tidy