Contents

1 Description 2 2 Chart::Base 4 3 Chart::Bars 12 4 Chart::Composite 14 5 Chart::Direction 17 6 Chart::ErrorBars 20 7 Chart::HorizontalBars 22 8 Chart::Lines 24 9 Chart::LinesPoints 26 10 Chart::Mountain 28 11 Chart::Pareto 30 12 Chart::Pie 32 13 Chart::Points 34 14 Chart::Split 36 15 Chart::StackedBars 39

1 Description

SYNOPSIS

use Chart::type;     (type is one of: Bars, Composite,
Direction, ErrorBars, HorizontalBars, Lines, LinesPoints,
Mountain,Pareto, Pie, Points, Split or StackedBars)
$obj = Chart::type->new;
$obj = Chart::type->new (width, height);
$obj->set( $key_1, $val_1, ... , $key_n, $val_n);
$obj->set( $key_1 => $val_1, ... , $key_n => $val_n);
$obj->set( %hash );
#GifGraph.pm-style API to produce png formatted charts
@data = ( \@x_tick_labels, \@dataset_1, ... \@datase_n);
$obj->png ( "filename", \@data );
$obj->png ( $filehandle, \@data );
$obj->png ( FILEHANDLE, \@data );
$obj->cgi_png ();
#Graph.pm-style API
$obj->add_pt ($label, $val_1, ... $val_n);
$obj->add_dataset ($val_1, ..., $val_n);
$obj->png ("filename");
$obj->png ($filehandle);
$obj->png (FILEHANDLE);
$obj->cgi_png();
The similar functions are available for jpeg
#Retrieve imagemap information
$obj->set('imagemap' => 'true' );
$imagemap_ref = $obj->imagemap_dump();

The Perl module Chart creates png or jpeg Files with charts. Chart can also create dynamic charts for web sites.

It is possible to create a lot of different chart types with Chart: Bars, Composite, Direction, ErrorBars, HorizontalBars, Lines, LinesPoints, Mountain, Pareto, Pie, Points, Split and StackedBars.

Take a look at their descriptions to see how they work. All of the special types are classes by themselves. All these classes have the same abstract superclass: Base.pm. The hierarchy of Chart is shown in Figure 1.

heightwidthdepthAufbau.png

Figure 1: The hierarchy of chart

Therefore, you have to create an instance of one of the subclasses , to get a chart object.

All of the methods and most of the options chart provides are implemented in Base. But the drawing of the graph itself happens in the respective subclass. Figure 2 shows the elements of an chart object.

heightwidthdepthElemente.png

Figure 2: Elements of a chart

The graph area in the middle is drawn by the subclass, all other elements are drawn by Base. But some classes don’t need all of these elements or need special elements. Those elements have to be over written in the respective class. For example, the class Pie doesn’t need axes, so the methods for drawing the axes in Base.pm are over written by methods in Pie.pm; the draw nothing in this case. Furthermore the legend in a pie chart are a little bit different. Therefore Pie.pm has its own methods for drawing the legends. These rules are managed by Chart. You don’t have to attend to it.

Chart uses Lincoln Stein’s GD module for all its graphics primitives calls. So you need a installed version of GD.pm to use Chart. This module is like Chart available in the CPAN online archive at http://www.cpan.org/ .

List of Figures

1 The hierarchy of chart . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Elements of a chart . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 Bars chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4 Composite chart . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5 Direction chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 6 Error bars chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 7 Chart with horizontal bars . . . . . . . . . . . . . . . . . . . . . . 22 8 Lines chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 9 Linespoints chart . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 10 Mountain chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 11 Pare-to chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 12 Pie chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 13 Points chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 14 Split chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 15 Chart with stacked bars . . . . . . . . . . . . . . . . . . . . . . . 39

Index

Lincoln Stein’s GD module, 3