Chart-Clicker

 view release on metacpan or  search on metacpan

README.mkdn  view on Meta::CPAN

    $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.

# 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
[Catalyst::View::Graphics::Primitive](https://metacpan.org/pod/Catalyst::View::Graphics::Primitive).

# ATTRIBUTES

## background\_color

Set/Get the background [color](https://metacpan.org/pod/Graphics::Color::RGB). Defaults to white.

## border

Set/Get the [border](https://metacpan.org/pod/Graphics::Primitive::Border).

## color\_allocator

Set/Get the [color\_allocator](https://metacpan.org/pod/Chart::Clicker::Drawing::ColorAllocator) for this chart.

## contexts

Set/Get the [contexts](https://metacpan.org/pod/Chart::Clicker::Context) for this chart.

## datasets

Get/Set the datasets for this chart.

## driver

Set/Get the [driver](https://metacpan.org/pod/Graphics::Primitive::Driver) used to render this Chart. Defaults to
[Graphics::Primitive::Driver::Cairo](https://metacpan.org/pod/Graphics::Primitive::Driver::Cairo).

## format

Get the format for this Chart.  Required in the constructor.  Must be on of
Png, Pdf, Ps or Svg.

## 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'

## grid\_over

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.

## height

Set/Get the height.  Defaults to 300.

## layout\_manager

Set/Get the layout manager.  Defaults to [Layout::Manager::Compass](https://metacpan.org/pod/Layout::Manager::Compass).

## legend

Set/Get the [legend](https://metacpan.org/pod/Chart::Clicker::Decoration::Legend) that will be used with this chart.

## legend\_position

The position the legend will be added.  Should be one of north, south, east,
west or center as required by [Layout::Manager::Compass](https://metacpan.org/pod/Layout::Manager::Compass).

## marker\_overlay

Set/Get the [marker overlay](https://metacpan.org/pod/Chart::Clicker::Decoration::MarkerOverlay) object that will be used if this chart
has markers.  This is lazily constructed to save time.

## over\_decorations

Set/Get an arrayref of "over decorations", or things that are drawn OVER the
chart.  This is an advanced feature.  See `overaxis-bar.pl` in the examples.

## padding

Set/Get the [padding](https://metacpan.org/pod/Graphics::Primitive::Insets). Defaults
to 3px on all sides.

## plot

Set/Get the [plot](https://metacpan.org/pod/Chart::Clicker::Decoration::Plot) on which things are drawn.

## subgraphs

You can add "child" graphs to this one via `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.

## title

Set/Get the title component for this chart.  This is a
[Graphics::Primitive::TextBox](https://metacpan.org/pod/Graphics::Primitive::TextBox), not a string.  To set the title of a chart
you should access the TextBox's `text` method.

README.mkdn  view on Meta::CPAN

## draw

Draw this chart.

## 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.

## add\_data ($name, $data)

Convenience method for adding data to the chart.  Can be called one of three
ways.

- **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.

- **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);

- **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).

## set\_renderer ($renderer\_object, \[ $context \]);

Sets the renderer on the specified context.  If no context is provided then
'default' is assumed.

## write

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_output`.

## 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 `draw` for you.  If you use this method, do not call `draw` first!

    $c->write_output('/path/to/the.png');

## inside\_width

Get the width available in this container after taking away space for
insets and borders.

## inside\_height

Get the height available in this container after taking away space for
insets and borders.

# 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.

# CONTRIBUTORS

Many thanks to the individuals who have contributed various bits:

Ash Berlin

Brian Cassidy

Guillermo Roditi

Torsten Schoenfeld

Yuval Kogman

# SOURCE

Chart::Clicker is on github:

    http://github.com/gphat/chart-clicker/tree/master

# AUTHOR

Cory G Watson <gphat@cpan.org>

# 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.



( run in 0.778 second using v1.01-cache-2.11-cpan-39bf76dae61 )