Chart-Clicker
view release on metacpan or search on metacpan
lib/Chart/Clicker.pm view on Meta::CPAN
$clicker->add_to_datasets($dataset);
New contexts provide a fresh domain and range axis and default to a Line
renderer.
B<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.
=head1 FORMATS & OUTPUT
Clicker supports PNG, SVG, PDF and PostScript output. To change your output
type, specificy it when you create your Clicker object:
my $cc = Chart::Clicker->new(format => 'pdf', ...);
# ...
$cc->write_output('chart.pdf');
If you are looking to get a scalar of the output for use with HTTP or
similar things, you can use:
# ... make your chart
$cc->draw;
my $image_data = $cc->rendered_data;
If you happen to be using Catalyst then take a look at
L<Catalyst::View::Graphics::Primitive>.
=head1 ATTRIBUTES
=head2 background_color
Set/Get the background L<color|Graphics::Color::RGB>. Defaults to white.
=head2 border
Set/Get the L<border|Graphics::Primitive::Border>.
=head2 color_allocator
Set/Get the L<color_allocator|Chart::Clicker::Drawing::ColorAllocator> for this chart.
=head2 contexts
Set/Get the L<contexts|Chart::Clicker::Context> for this chart.
=head2 datasets
Get/Set the datasets for this chart.
=head2 driver
Set/Get the L<driver|Graphics::Primitive::Driver> used to render this Chart. Defaults to
L<Graphics::Primitive::Driver::Cairo>.
=head2 format
Get the format for this Chart. Required in the constructor. Must be on of
Png, Pdf, Ps or Svg.
=head2 plot_mode
Fast or slow plot mode. When in fast mode, data elements that are deemed to be
superfluous or invisible will not be drawn. Default is 'slow'
=head2 grid_over
Flag controlling if the grid is rendered B<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.
=head2 height
Set/Get the height. Defaults to 300.
=head2 layout_manager
Set/Get the layout manager. Defaults to L<Layout::Manager::Compass>.
=head2 legend
Set/Get the L<legend|Chart::Clicker::Decoration::Legend> that will be used with this chart.
=head2 legend_position
The position the legend will be added. Should be one of north, south, east,
west or center as required by L<Layout::Manager::Compass>.
=head2 marker_overlay
Set/Get the L<marker overlay|Chart::Clicker::Decoration::MarkerOverlay> object that will be used if this chart
has markers. This is lazily constructed to save time.
=head2 over_decorations
Set/Get an arrayref of "over decorations", or things that are drawn OVER the
chart. This is an advanced feature. See C<overaxis-bar.pl> in the examples.
=head2 padding
Set/Get the L<padding|Graphics::Primitive::Insets>. Defaults
to 3px on all sides.
=head2 plot
Set/Get the L<plot|Chart::Clicker::Decoration::Plot> on which things are drawn.
=head2 subgraphs
You can add "child" graphs to this one via C<add_subgraph>. These must be
Chart::Clicker objects and they will be added to the bottom of the existing
chart. This is a rather esoteric feature.
=head2 title
Set/Get the title component for this chart. This is a
L<Graphics::Primitive::TextBox>, not a string. To set the title of a chart
you should access the TextBox's C<text> method.
lib/Chart/Clicker.pm view on Meta::CPAN
=head2 get_datasets_for_context
Returns an arrayref containing all datasets for the given context. Used by
renderers to get a list of datasets to chart.
=head2 add_data ($name, $data)
Convenience method for adding data to the chart. Can be called one of three
ways.
=over 4
=item B<scalar>
Passing a name and a scalar will append the scalar data to that series' data.
$cc->add_data('Sales', 1234);
$cc->add_data('Sales', 1235);
This will result in a Series named 'Sales' with two values.
=item B<arrayref>
Passing a name and an arrayref works much the same as the scalar method
discussed above, but appends the supplied arrayref to the existing one. It
may be mixed with the scalar method.
$cc->add_data('Sales', \@some_sales);
$cc->add_data('Sales', \@some_more_sales);
# This works still!
$cc->add_data('Sales', 1234);
=item B<hashref>
This allows you to pass both keys and values in all at once.
$cc->add_data('Sales', { 2009 => 1234, 2010 => 1235 });
# appends to last call
$cc->add_data('Sales', { 2011 => 1234, 2012 => 1235 });
You may call the hashref version after the scalar or arrayref versions, but you
may not add a scalar or arrayref after adding a hashref (as it's not clear what
indices should be used for the new data).
=back
=head2 set_renderer ($renderer_object, [ $context ]);
Sets the renderer on the specified context. If no context is provided then
'default' is assumed.
=head2 write
This method is passed through to the underlying driver. It is only necessary
that you call this if you manually called C<draw> beforehand. You likely
want to use C<write_output>.
=head2 write_output ($path)
Write the chart output to the specified location. Output is written in the
format provided to the constructor (which defaults to Png). Internally
calls C<draw> for you. If you use this method, do not call C<draw> first!
$c->write_output('/path/to/the.png');
=head2 inside_width
Get the width available in this container after taking away space for
insets and borders.
=head2 inside_height
Get the height available in this container after taking away space for
insets and borders.
=head1 ISSUES WITH CENTOS
I've had numerous reports of problems with Chart::Clicker when using CentOS.
This problem has usually be solved by updating the version of cairo. I've
had reports that upgrading to at least cairo-1.8.8-3 makes thinks work properly.
I hesitate to provide any other data with this because it may get out of date
fast. If you have trouble feel free to drop me an email and I'll tell you
what I know.
=head1 CONTRIBUTORS
Many thanks to the individuals who have contributed various bits:
Ash Berlin
Brian Cassidy
Guillermo Roditi
Torsten Schoenfeld
Yuval Kogman
=head1 SOURCE
Chart::Clicker is on github:
http://github.com/gphat/chart-clicker/tree/master
=head1 AUTHOR
Cory G Watson <gphat@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Cory G Watson.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.111 second using v1.01-cache-2.11-cpan-39bf76dae61 )