GD-Graph-Cartesian
view release on metacpan or search on metacpan
lib/GD/Graph/Cartesian.pm view on Meta::CPAN
=cut
sub _scaley {
my $self = shift;
my $y = shift; #units
my $max = $self->maxy;
my $min = $self->miny;
my $s = 1;
if (defined($max) and defined($min) and $max-$min) {
$s=($max - $min) / ($self->height - 2 * $self->bordery); #units/pixel
}
return $y / $s; #pixels
}
=head2 _imgxy_xy
Method to convert xy to imgxy coordinates
=cut
sub _imgxy_xy {
my $self = shift;
my $x = shift;
my $y = shift;
return ($self->_imgx_x($x), $self->_imgy_y($y));
}
sub _imgx_x {
my $self = shift;
my $x = shift;
return $self->borderx + $self->_scalex($x - $self->minx);
}
sub _imgy_y {
my $self = shift;
my $y = shift;
return $self->height - ($self->bordery + $self->_scaley($y - $self->miny));
}
=head1 TODO
I'd like to add this capability into L<Chart> as a use base qw{Chart::Base}
=head1 BUGS
Log on RT and email the author
=head1 LIMITS
There are many packages on CPAN that create graphs and plots from data. But, each one has it's own limitations. This is the research that I did so that hopefully you won't have to...
=head2 Similar CPAN Packages
=head3 L<Chart::Plot>
This is the second best package that I could find on CPAN that supports scatter plots of X/Y data. However, it does not supports a zero based Y-axis for positive data. Otherwise this is a great package.
=head3 L<Chart>
This is a great package for its support of legends, layouts and labels but it only support equally spaced x axis data.
=head3 L<GD::Graph>
This is a great package for pie charts but for X/Y scatter plots it only supports equally spaced x axis data.
=head1 AUTHOR
Michael R. Davis qw/perl michaelrdavis com/
=head1 LICENSE
Copyright (c) 2009 Michael R. Davis (mrdvt92)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=head1 SEE ALSO
L<GD::Graph::Cartesian>, L<GD>, L<Chart::Plot>, L<Chart>, L<GD::Graph>
=cut
1;
( run in 1.537 second using v1.01-cache-2.11-cpan-39bf76dae61 )