.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Chart::Clicker::Tutorial 3pm" .TH Chart::Clicker::Tutorial 3pm "2016-12-28" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Chart::Clicker::Tutorial \- A Tutorial for using Chart::Clicker .SH "VERSION" .IX Header "VERSION" version 2.90 .SH "DESCRIPTION" .IX Header "DESCRIPTION" This document aims to provide a tutorial for using Chart::Clicker. .SH "EXAMPLES" .IX Header "EXAMPLES" .SS "Simple chart from a single data source" .IX Subsection "Simple chart from a single data source" .Vb 4 \& # grab the needed modules \& use Chart::Clicker; \& use Chart::Clicker::Data::Series; \& use Chart::Clicker::Data::DataSet; \& \& # build the chart \& my $chart = Chart::Clicker\->new; \& \& # build the series (static here, will usually be supplied arrayrefs from elsewhere) \& my $series = Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 52,74,52,82,14 ], \& ); \& \& # build the dataset \& my $dataset = Chart::Clicker::Data::DataSet\->new( \& series => [ $series ], \& ); \& \& # add the dataset to the chart \& $chart\->add_to_datasets($dataset); \& \& # write the chart to a file \& $chart\->write_output(\*(Aqchart.png\*(Aq); .Ve .SS "Simple chart from multiple data sources" .IX Subsection "Simple chart from multiple data sources" .Vb 3 \& use Chart::Clicker; \& use Chart::Clicker::Data::Series; \& use Chart::Clicker::Data::DataSet; \& \& my $chart = Chart::Clicker\->new; \& \& # start an array that will hold the series data \& my $series1 = Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 52,74,52,82,14 ] \& ); \& my $series2 = Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 34,67,89,45,67 ] \& ); \& \& # add the array of series data to the dataset \& my $dataset = Chart::Clicker::Data::DataSet\->new( \& series => [ $series1, $series2 ] \& ); \& \& $chart\->add_to_datasets($dataset); \& \& $chart\->write_output(\*(Aqchart.png\*(Aq); .Ve .SS "Simple chart with multiple data sources and custom colors" .IX Subsection "Simple chart with multiple data sources and custom colors" .Vb 6 \& use Chart::Clicker; \& use Chart::Clicker::Data::Series; \& use Chart::Clicker::Data::DataSet; \& # some new modules, these are only needed if you want to monkey with color changing \& use Graphics::Color::RGB; \& use Chart::Clicker::Drawing::ColorAllocator; \& \& # build the color allocator \& my $ca = Chart::Clicker::Drawing::ColorAllocator\->new; \& # this hash is simply here to make things readable and cleaner, you can always call G::C::R inline \& my $red = Graphics::Color::RGB\->new({ \& red => .75, green => 0, blue => 0, alpha => .8 \& }); \& my $green = Graphics::Color::RGB\->new({ \& red => 0,green => .75, blue=> 0, alpha=> .8 \& }); \& my $blue = Graphics::Color::RGB\->new({ \& red => 0, green => 0, blue => .75, alpha => .8 \& }), \& \& my $chart = Chart::Clicker\->new; \& \& # Create an empty dataset that we can add to \& my $dataset = Chart::Clicker::Data::DataSet\->new; \& \& $dataset\->add_to_series(Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 52,74,52,82,14 ] \& )); \& # add a color \- note that the order of colors and the order of the \& # series must match, the first series will use the first color and so on \& # see contexts and axes for alternate ways of doing this \& $ca\->add_to_colors($blue); \& \& $dataset\->add_to_series(Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 34,67,89,45,67 ] \& )); \& # add a second color \& $ca\->add_to_colors($red); \& \& $dataset\->add_to_series(Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 11,22,33,44,55 ] \& )); \& # add a third color \& $ca\->add_to_colors($green); \& \& $chart\->add_to_datasets($dataset); \& \& # assign the color allocator to the chart \& $chart\->color_allocator($ca); \& \& $chart\->write_output(\*(Aqchart.png\*(Aq); .Ve .SS "Example 4 : Simple chart with a different render type" .IX Subsection "Example 4 : Simple chart with a different render type" .Vb 5 \& use Chart::Clicker; \& use Chart::Clicker::Data::Series; \& use Chart::Clicker::Data::DataSet; \& # add in the module of the renerer(s) you want to use \& use Chart::Clicker::Renderer::Area; \& \& my $chart = Chart::Clicker\->new; \& \& my $series = Chart::Clicker::Data::Series\->new( \& keys => [ 1,2,3,4,5 ], \& values => [ 52,74,52,82,14 ] \& ); \& \& my $dataset = Chart::Clicker::Data::DataSet\->new( \& series => [ $series ] \& ); \& \& $chart\->add_to_datasets($dataset); \& \& # build the renderer to use \& my $renderer = Chart::Clicker::Renderer::Area\->new( \& opacity => .75, \& ); \& \& # assign the renderer to the default context \& $chart\->set_renderer($renderer); \& \& $chart\->write_output(\*(Aqchart.png\*(Aq); .Ve .SS "Example 5 : Width and Height" .IX Subsection "Example 5 : Width and Height" .Vb 1 \& my $chart = Chart::Clicker\->new(width => 1024, height => 768); .Ve .SS "Example 6 : \s-1PDF \s0(or \s-1SVG\s0 or \s-1PS\s0)" .IX Subsection "Example 6 : PDF (or SVG or PS)" .Vb 1 \& my $chart = Chart::Clicker\->new(format => \*(Aqpdf\*(Aq); \& \& # Create the rest of your chart normally \& \& $chart\->write_output(\*(Aqchart.pdf\*(Aq); .Ve .SS "Example 7 : Hide the Legend and X\-Axis" .IX Subsection "Example 7 : Hide the Legend and X-Axis" .Vb 1 \& my $chart = Chart::Clicker\->new; \& \& # hide the legend \& $chart\->legend\->visible(0); \& \& # hide the X\-Axis \& $chart\->get_context(\*(Aqdefault\*(Aq)\->domain_axis\->hidden(1); .Ve .SS "Example 8 : Change the display format of the Y\-Axis" .IX Subsection "Example 8 : Change the display format of the Y-Axis" .Vb 1 \& my $chart = Chart::Clicker\->new; \& \& # a sprintf format to have 3 decimal places showing on the Y\-Axis \& $chart\->get_context(\*(Aqdefault\*(Aq)\->range_axis\->format(\*(Aq%.3f\*(Aq); .Ve .SH "DISCLAIMER" .IX Header "DISCLAIMER" This is a work in progress. If you find errors or would like to make contributions, drop me a line! .SH "AUTHOR" .IX Header "AUTHOR" Cory G Watson .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2016 by Cory G Watson. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.