Chart
view release on metacpan or search on metacpan
lib/Chart/ErrorBars.pm view on Meta::CPAN
#reset the brush for lines
$brush = $self->_prepare_brush( $color, 'line' );
$self->{'gd_obj'}->setBrush($brush);
#draw the error bars
if ( $self->true($flag) )
{
# the upper lines
$self->{'gd_obj'}->line( $x2, $y2, $x3, $y_error_up, gdBrushed );
$self->{'gd_obj'}->line( $x2 - 3, $y_error_up, $x3 + 3, $y_error_up, gdBrushed );
# the down lines
$self->{'gd_obj'}->line( $x2, $y2, $x3, $y_error_down, gdBrushed );
$self->{'gd_obj'}->line( $x2 - 3, $y_error_down, $x3 + 3, $y_error_down, gdBrushed );
$flag = 'false';
}
# store the imagemap data if they asked for it
if ( $self->true( $self->{'imagemap'} ) )
{
$self->{'imagemap_data'}->[$i][$j] = [ $x2, $y2 ];
}
}
} #end for
}
}
}
return 1;
}
## @fn private _prepare_brush
# set the gdBrush object to trick GD into drawing fat lines
#
# Overwrite Base function
#
sub _prepare_brush
{
my $self = shift;
my $color = shift;
my $type = shift;
my ( $radius, @rgb, $brush, $white, $newcolor );
# get the rgb values for the desired color
@rgb = $self->{'gd_obj'}->rgb($color);
# get the appropriate brush size
if ( $type eq 'line' )
{
$radius = $self->{'brush_size'} / 2;
}
elsif ( $type eq 'point' )
{
$radius = $self->{'pt_size'} / 2;
}
# create the new image
$brush = GD::Image->new( $radius * 2, $radius * 2 );
# get the colors, make the background transparent
$white = $brush->colorAllocate( 255, 255, 255 );
$newcolor = $brush->colorAllocate(@rgb);
$brush->transparent($white);
# draw the circle
$brush->arc( $radius - 1, $radius - 1, $radius, $radius, 0, 360, $newcolor );
# fill it if we're using lines
$brush->fill( $radius - 1, $radius - 1, $newcolor );
# set the new image as the main object's brush
return $brush;
}
## @fn private int _draw_legend()
# let them know what all the pretty colors mean
# @return status
## let them know what all the pretty colors mean
sub _draw_legend
{
my $self = shift;
my ( $length, $step, $temp, $post_length );
my $j = 0;
# check to see if legend type is none..
if ( $self->{'legend'} =~ /^none$/ )
{
return 1;
}
#just for later checking and warning
if ( $#{ $self->{'legend_labels'} } >= 0 )
{
$post_length = scalar( @{ $self->{'legend_labels'} } );
}
#look if every second or eyery third dataset is a set for data
if ( $self->false( $self->{'same_error'} ) )
{
$step = 3;
}
else
{
$step = 2;
}
# init a field to store the length of the longest legend label
unless ( $self->{'max_legend_label'} )
{
$self->{'max_legend_label'} = 0;
}
# fill in the legend labels, find the longest one
for ( my $i = 1 ; $i < $self->{'num_datasets'} ; $i += $step )
{
my $label = $j + 1;
unless ( $self->{'legend_labels'}[$j] )
{
$self->{'legend_labels'}[$j] = "Dataset $label";
}
$length = length( $self->{'legend_labels'}[$j] );
if ( $length > $self->{'max_legend_label'} )
{
( run in 1.129 second using v1.01-cache-2.11-cpan-39bf76dae61 )