Imager-Plot

 view release on metacpan or  search on metacpan

lib/Imager/Plot/Axis.pm  view on Meta::CPAN

package Imager::Plot::Axis;

use strict;
use vars qw();

use Imager;

use Imager::Plot::Util;
use Imager::Plot::DataSet;


############################################
#                                          #
#_                                         #
#                                          #
#_                                         #
#                                          #
#_                                         #
#                                          #
#_                                         #
#                                          #
#_                                         #
#                                          #
#_                                         #
#                                          #
# |    |   |   |   |   |   |   |   |   |   #
############################################

my $black = Imager::Color->new(0,0,0,255);
my $blue  = Imager::Color->new(0,0,70,255);
my $white = Imager::Color->new(255,255,255,255);

sub gfont {
  my $fname = shift;
  if (ref($fname)) {
    return $fname;
  } else {
    my $font = Imager::Font->new(file => $fname, size=>10,color=>$black);
    die "Unable to load font $fname for Axis labels\n" unless $font;
    return $font;
  }
}


sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my %temp = @_;
  my $fname = $temp{'GlobalFont'};

  my %opts=(
	    Width          => undef,   # width includes axis drawing
	    Height         => undef,   # height and the endpoints
	    XRANGE         => undef,
	    YRANGE         => undef,
	    XDRANGE        => undef,
	    YDRANGE        => undef,
	    DATASETS       => [],
	    XGRIDLIST      => [],
	    YGRIDLIST      => [],
	    grid           => 1,
	    make_decor     => \&make_decor,
	    make_ranges    => \&make_ranges,
	    make_xrange    => \&make_xrange,
	    make_yrange    => \&make_yrange,
	    make_xticklist => \&nothing,
	    make_yticklist => \&nothing,
	    make_xgridlist => \&MakeXGridList,
	    make_ygridlist => \&MakeYGridList,
	    XtickFont      => gfont($fname),
	    YtickFont      => gfont($fname),
	    BackGround     => $white,
	    FrameColor     => $black,
	    XgridShow	   => 1,
	    YgridShow	   => 1,
	    YgridNum	   => 5,
	    XgridNum	   => 5,
	    XtickMargin	   => 3,
	    YtickMargin	   => 3,
	    Border         => "lrtb", #rt",	# left, right, top, bottom
	    Xformat        => \&myround,
	    Yformat        => \&myround,
	    @_);
  my $self  = \%opts;

  bless ($self, $class);
  return $self;
}

sub AddDataSet {
  my $self = shift;
  my $hint = @{$self->{DATASETS}};
  my $dataset = Imager::Plot::DataSet->new(@_, hint=>$hint);
  push(@{$self->{DATASETS}}, $dataset);
  return $dataset;
}


sub setparm {
  my $self = shift;
  my %np=@_;
  for (keys %np) {
    $self->{$_}=$np{$_};
  }
}

sub CheckValues {
  my $self = shift;
}

# gets the cumulative bounding box

sub data_bbox {



( run in 0.762 second using v1.01-cache-2.11-cpan-524268b4103 )