Chart::Clicker - Powerful, extensible charting.
use Chart::Clicker; use Chart::Clicker::Data::Series; use Chart::Clicker::Data::DataSet; my $cc = Chart::Clicker->new; my $series = Chart::Clicker::Data::Series->new( keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], values => [ 42, 25, 86, 23, 2, 19, 103, 12, 54, 9 ], ); my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series ]); $cc->add_to_datasets($ds); $cc->write_output('foo.png')
Chart::Clicker aims to be a powerful, extensible charting package that creates really pretty output. Charts can be saved in png, svg, pdf and postscript format.
Clicker leverages the power of Graphics::Primitive to create snazzy graphics without being tied to specific backend. You may want to begin with Chart::Clicker::Tutorial.
For examples of output, see: http://www.onemogin.com/clicker/examples
For code examples see the examples directory of this distribution.
Check the cookbook at http://www.onemogin.com/clicker/cookbook
The normal use case for a chart is a couple of datasets on the same axes. Sometimes you want to chart one or more datasets on different axes. A common need for this is when you are comparing two datasets of vastly different scale such as the number of employees in an office (1-10) to monthly revenues (10s of thousands). On a normal chart the number of employees would show up as a flat line at the bottom of the chart.
To correct this, Clicker has contexts. A context is a pair of axes, a renderer and a name. The name is the 'key' by which you will refer to the context.
my $context = Chart::Clicker::Context->new( name => 'sales' ); $clicker->add_to_contexts($context); $dataset->context('sales'); $clicker->add_to_datasets($dataset);
New contexts provide a fresh domain and range axis and default to a Line renderer.
Caveat: Clicker expects that the default context (identified by the string "default") will always be present. It is from this context that some of Clicker's internals draw their values. You should use the default context unless you need more than one, in which case you should use "default" as the base context.
Clicker supports PNG, SVG, PDF and PostScript output.
Creates a new Chart::Clicker object. If no format, width and height are specified then defaults of Png, 500 and 300 are chosen, respectively.
Add the specified context to the chart.
Add the specified dataset (or arrayref of datasets) to the chart.
Add the specified marker to the chart.
Set/Get the color_allocator for this chart.
Set/Get the context for this chart.
Returns the data for this chart as a scalar. Suitable for 'streaming' to a client.
Get/Set the datasets for this chart.
Draw this chart.
Get the format for this Chart. Required in the constructor. Must be on of Png, Pdf, Ps or Svg.
Returns an arrayref containing all datasets for the given context. Used by renderers to get a list of datasets to chart.
Flag controlling if the grid is rendered over the data. Defaults to 0. You probably want to set the grid's background color to an alpha of 0 if you enable this flag.
Get the width available in this container after taking away space for insets and borders.
Get the height available in this container after taking away space for insets and borders.
Set/Get the legend that will be used with this chart.
The position the legend will be added. Should be one of north, south, east, west or center as required by Layout::Manager::Compass.
Set/Get the marker overlay object that will be used if this chart has markers. This is lazily constructed to save time.
Sets the renderer on the specified context. If no context is provided then 'default' is assumed.
Set/Get the title component for this chart. This is a Graphics::Primitive::TextBox, not a string. To set the title of a chart you should access the TextBox's
$cc->title->text('A Title!'); $cc->title->font->size(20); # etc, etc
If the title has text then it is added to the chart in the position specified by
You should consult the documentation for Graphics::Primitive::TextBox for things like padding and text rotation. If you are adding it to the top and want some padding between it and the plot, you can:
The position the title will be added. Should be one of north, south, east, west or center as required by Layout::Manager::Compass.
Note that if no angle is set for the title then it will be changed to -1.5707 if the title position is east or west.
This method is passed through to the underlying driver. It is only necessary that you call this if you manually called
draw beforehand. You likely want to use
Write the chart output to the specified location. Output is written in the format provided to the constructor (which defaults to Png). Internally calls
draw for you. If you use this method, do not call
Cory G Watson <email@example.com>
Many thanks to the individuals who have contributed various bits:
Chart::Clicker is on github:
You can redistribute and/or modify this code under the same terms as Perl itself.