NAME

Catalyst::View::SVG::TT::Graph - SVG::TT::Graph charts (in svg/png/gif/jpeg..) for your Catalyst application

SYNOPSIS

Create your view class:

./script/myapp_create.pl view Chart SVG::TT::Graph

Set your chart preferences in your config:

<View::Chart>
    format         png
    <chart_conf>
        style_sheet         /path/to/stylesheet.css
        show_graph_title    1
    </chart_conf>
</View::Chart>

Stash your chart data in your controller:

$c->stash->{chart_title} = 'Sales data'; # optional

$c->stash->{chart_type} = 'Bar'; # or Pie/Line/BarHorizontal

$c->stash->{chart_conf} = {
    height  => 400,
    width   => 600
};

$c->stash->{chart_fields} = [ qw(Jan Feb March ..) ];
$c->stash->{chart_data} = [ 120, 102, ..];

In your end method:

$c->forward($c->view('Chart'));

If you want, say a comparative line graph of mutiple sets of data:

$c->stash->{chart_type} = 'Line';

$c->stash->{chart_data} = [
    { title => 'Barcelona', data => [ ... ] },
    { title => 'Atletico', data => [ ... ] },
];

METHODS

process

Generate the SVG::TT::Graph chart

CONFIG OPTIONS

Note: These can be overridden by stashing parameters with the same name

format

Can be svg, png, gif, jpeg or any other format supported by Image::LibRSVG

chart_conf

A hashref that takes all options to SVG::TT::Graph::type . For the correct options, see the corresponding documentation:

Bar Options,

Pie Options,

Line Options,

BarLine Options,

TimeSeries Options,

BarHorizontal Options

STASHED PARAMETERS

format

An optional output format (svg/png/gif/jpeg..). Overrides config format

chart_title

An optional title for your chart

chart_type

Bar / Pie / Line / BarHorizontal / BarLine / TimeSeries

chart_conf

Any options taken by SVG::TT::Graph

chart_fields

A list (array reference) of fields to show in your graph:

$c->stash->{fields} = [ 'Jan', 'Feb', 'March' .. ];

chart_data

If all you want is a singe data set, can be a hash reference of the form:

$c->stash->{chart_data} = { title => 'sales', values => [ 1.4, 2.2, ... ] }

or a simple ArrayRef if you don't want a title

$c->stash->{chart_data} = [ 1.4, 2.2, ... ]

If you want multiple data sets, use an array reference with each set in a hashref:

$c->stash->{chart_data} = [
    { title => 'Barcelona', data => [ .. ] },
    { title => 'Atletico', data => [ .. ] }
];

SAMPLE CHARTS

See http://leo.cuckoo.org/projects/SVG-TT-Graph/

KNOWN BUGS

For jpeg pie charts, background color transparency doesn't work

REPOSITORY

See git://github.com/terencemo/Catalyst--View--SVG--TT--Graph.git

SEE ALSO

SVG::TT::Graph, Image::LibRSVG

AUTHOR

Terence Monteiro <terencemo[at]cpan.org>

LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.