24 Mar 2011 08:09:54 UTC
- Distribution: Chart-Math-Axis
- Module version: 1.06
- Source (raw)
- Browse (raw)
- How to Contribute
- Clone repository
- Issues (3)
- Testers (1297 / 0 / 0)
- KwaliteeBus factor: 1
- 88.76% Coverage
- License: perl_5
- Perl: v5.5.0
- Activity24 month
- Download (33.42KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionADAMK Adam Kennedy
- SEE ALSO
Chart::Math::Axis - Implements an algorithm to find good values for chart axis
# Create a new Axis my $axis = Chart::Math::Axis->new; # Provide is some data to calculate on $axis->add_data( @dataset ); # Get the values for the axis print "Top of axis: " . $axis->top . "\n"; print "Bottom of axis: " . $axis->bottom . "\n"; print "Tick interval: " . $axis->interval_size . "\n"; print "Number of ticks: " . $axis->ticks . "\n"; # Apply the axis directly to a GD::Graph. $axis->apply_to( $graph );
Chart::Math::Axis implements in a generic way an algorithm for finding a set of ideal values for an axis. That is, for any given set of data, what should the top and bottom of the axis scale be, and what should the interval between the ticks be.
bottomare used throughout this module, as it's primary use is for determining the Y axis. For calculating the X axis, you should think of 'top' as 'right', and 'bottom' as 'left'.
my $null = Chart::Math::Axis->new; my $full = Chart::Math::Axis->new( @dataset );
newmethod creates a new
Chart::Math::Axisobject. Any arguments passed to the constructor are used as dataset values. Whenever the object has some values on which to work, it will calculate the axis. If the object is created with no values, most methods will return undef.
Returns the maximum value in the dataset.
Returns the minimum value in the dataset.
topmethod returns the value that should be the top of the axis.
bottommethod returns the value that should be the bottom of the axis.
Although Chart::Math::Axis can work out scale and intervals, it doesn't know how many pixels you might need, how big labels etc are, so it can determine the tick density you are going to need. The
maximum_intervalsmethod returns the current value for the maximum number of ticks the object is allowed to have.
To change this value, see the
set_maximum_intervalsmethod. The default for the maximum number of intervals is 10.
interval_sizemethod returns the interval size in dataset terms.
ticksmethod returns the number of intervals that the top/bottom/size values will result in.
$self->add_data( @dataset );
add_datamethod allows you to provide data that the object should be aware of when calculating the axis. In fact, you can add additional data at any time, and the axis will be updated as needed.
$self->set_maximum_intervals( $intervals );
set_maximum_intervalsmethod takes an argument and uses it as the maximum number of ticks the axis is allowed to have.
If you have a dataset something like ( 10, 11, 12 ) the bottom of the axis will probably be somewhere around 9 or 8. That is, it won't show the zero axis. If you want to force the axis to include zero, use this method to do so.
$self->apply_to( $gd_graph_object )
apply_tomethod is intended to provide a series of shortcuts for automatically applying an axis to a graph of a know type. At the present, this will change only the Y axis of a GD::Graph object. This method is considered experimental. If in doubt, extract and set the graph values yourself.
Bugs should be reported via the CPAN bug tracker
For other issues, or commercial enhancement or support, contact the author.
Adam Kennedy <firstname.lastname@example.org>
Copyright 2002 - 2011 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Module Install Instructions
To install Chart::Math::Axis, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Chart::Math::Axis
For more information on module installation, please visit the detailed CPAN module installation guide.