NAME Chart::OFC2 - Generate html and data files for use with Open Flash Chart version 2 SYNOPSIS OFC2 html: use Chart::OFC2; my $chart = Chart::OFC2->new( 'title' => 'Bar chart test', ); print $chart->render_swf(600, 400, 'chart-data.json', 'test-chart'); OFC2 bar chart data: use Chart::OFC2; use Chart::OFC2::Axis; use Chart::OFC2::Bar; my $chart = Chart::OFC2->new( 'title' => 'Bar chart test', 'x_axis' => { 'labels' => [ 'Jan', 'Feb', 'Mar', 'Apr', 'May' ], }, ); my $bar = Chart::OFC2::Bar->new(); $bar->values([ 1..5 ]); $chart->add_element($bar); print $chart->render_chart_data(); WARNING Current version implements just subset of functionality that Open Flash Chart 2 is offering. But it should help you to starting creating OFC2 graphs quite fast. The JSON format is quite intuitive and can be created from any hash. This module is more like guideline. This is early version PROTOTYPE so the API WILL change, be careful when upgrading versions. DESCRIPTION OFC2 is a flash script for creating graphs. To have a graph we need an open-flash-chart.swf and a JSON data file describing graph data. Complete examples you can find after successful run of this module tests in t/output/ folder - t/output/bar.html, t/output/pie.html, t/output/hbar.html are html graphs and t/output/bad-data.json, t/output/pie-data.json, t/output/hbar-data.json are the data files. PROPERTIES has 'data_load_type' => (is => 'rw', isa => 'Str', default => 'inline_js'); has 'bootstrap' => (is => 'rw', isa => 'Bool', default => '1'); has 'title' => (is => 'rw', isa => 'Chart::OFC2::Title', default => sub { Chart::OFC2::Title->new() }, lazy => 1, coerce => 1); has 'x_axis' => (is => 'rw', isa => 'Chart::OFC2::XAxis', default => sub { Chart::OFC2::XAxis->new() }, lazy => 1,); has 'y_axis' => (is => 'rw', isa => 'Chart::OFC2::YAxis', default => sub { Chart::OFC2::YAxis->new() }, lazy => 1, ); has 'elements' => (is => 'rw', isa => 'ArrayRef', default => sub{[]}, lazy => 1); has 'extremes' => (is => 'rw', isa => 'Chart::OFC2::Extremes', default => sub { Chart::OFC2::Extremes->new() }, lazy => 1); has 'tooltip' => (is => 'rw', isa => 'Chart::OFC2::ToolTip',); METHODS new() Object constructor. get_element($type) Returns new chart object of selected type. Currently only "bar" and "pie" is available. add_element($element) Adds passed element to the graph. render_chart_data Returns stringified JSON encoded graph data. auto_extremes Recalculate graph auto extremes. render_swf($width, $height, $data_url, $div_id) Returns html snippet that will represent one graph in a html document. WARN: the arguments format will change to "key =" value> in the next releases. FUNCTIONS smoother_number round the number up a bit to a nice round number also changes number to an int smooth($axis_name, $axis_type) Smooth axis min/max. NOTE Refresh button will not cause the data file of the graph to be reloaded so either use proper expiration settings for it or change the name of the file in html every time you generate new data. Like ""data.json?".time()". SEE ALSO Chart::OFC, , SUPPORT * Mailinglist * GitHub: issues * RT: CPAN's request tracker * AnnoCPAN: Annotated CPAN documentation * CPAN Ratings * Search CPAN ACKNOWLEDGEMENTS Thanks to John Goulah "" for his patches and suggestions (#49416, #48821, #48376, #48380). COPYRIGHT AND LICENSE GNU GPL AUTHOR Jozef Kutej "" I've used some of the code from the perl-ofc-library/open_flash_chart.pm that is shipped together with all the rest OFC2 files.