Lire::ChartType(3) Base interface for all ChartType.

SYNOPSIS


use base qw/ Lire::ChartType /;

DESCRIPTION

This package defines the interface which is implemented by all the different charts that Lire is able to produce using the ploticus pl(1) command.

A chart type will generate a chart using data from a subreport.

META INFORMATION METHODS

The Lire::ChartType interface extends the Lire::Plugin interface, so they must implement all standard meta-information methods (name(), title(), description()).

GENERATING A CHART

write_chart( $chart_config, $subreport, [ %params ] )

This will write a chart from the data contained in the Lire::Report::Subreport $subreport using the configuration $chart_config. Additional parameters are passed in 'key' => $value form. The $chart_config parameters should be a Lire::Config::Dictionary object instantiated from a Lire::Config::ChartSpec.
outputdir
Directory where the file will be created. Use the working directory by default.
format
One of eps, png, jpeg or gif. Default to the configuration variable lr_image_format.

The function returns the path to the created file. The filename is generated base on the 'name' configuration value or the subreport's id if the other isn't defined. The extension is added based on the output format.

It returns the file where the chart was written.

prefab()

This method must be implemented by the subclass and should return a string representing the first parameters to pass to ploticus (that is either -prefab name or the path to a script file).

write_parameters( $chart_config, $fh )

This method is used to write parameters to the ploticus file handle. This is the place to use the #set command to set all of the prefabs parameters. Subclass must chain to this implementation for the standard chart parameters. It also write '#set name' directives for each numerical variables defined by get_vars().

write_data( $chart_config, $subreport, $fh )

This method is used by the write_chart() implementation to write the chart data from $subreport to the Ploticus commond opened on $fh. It uses the get_vars() method to obtain the numerical variables that should be written to the stream and the encode_value() method to marshall values before writing them. Before any data is written to $fh the maximum value on the Y axis is determined and output as a ploticus setting. (ploticus fails if this is not set, a single bar is drawn and the value is greater than 1.1e9.)

get_vars( $chart_config )

This method should be overriden by subclasses to return an array reference containing the Lire::Report::ColumnInfo specifying the numerical column's of data that should be written. This is usually specified using a ReferenceSpec with the 'numerical_variables' index.

These variables will start at the ploticus index 2 (@2).

encode_value( $value )

By default, this method just returns the 'content' component of the item when the $value is a name and the 'value' component otherwise. It can used for data type that needs special encoding (like datetime).

AUTHOR

Francis J. Lacoste <[email protected]>

VERSION

$Id: ChartType.pm,v 1.17 2006/07/29 18:01:14 vanbaal Exp $

COPYRIGHT

Copyright (C) 2004 Stichting LogReport Foundation [email protected]

This file is part of Lire.

Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html.