Chart

 view release on metacpan or  search on metacpan

lib/Chart/Direction.pm  view on Meta::CPAN

                    # store the imagemap data if they asked for it
                    if ( $self->true( $self->{'imagemap'} ) )
                    {
                        $self->{'imagemap_data'}->[$j][$i] = [ $x, $y ];
                    }
                }    # end if ( defined ...
                else
                {
                    if ( $self->true( $self->{'imagemap'} ) )
                    {
                        $self->{'imagemap_data'}->[$j][$i] = [ undef(), undef() ];
                    }
                }
            }    #end for $i

            # draw the last line to the first point
            if ( $self->true( $self->{'line'} ) )
            {
                $self->{'gd_obj'}->line( $x, $y, $first_x, $first_y, gdBrushed );
            }
            $n += 2;
        }    # end for $j
    }    # end if pairs

    # now outline it
    $self->{'gd_obj'}
      ->rectangle( $self->{'curr_x_min'}, $self->{'curr_y_min'}, $self->{'curr_x_max'}, $self->{'curr_y_max'}, $misccolor );

    return;
}

## @fn private int _prepare_brush($color,$type)
#  set the gdBrush object to trick GD into drawing fat lines
#
#
# @param[in] color Color to be used
# @param[in] type  Type of line
# @return status
sub _prepare_brush
{
    my $self  = shift;
    my $color = shift;
    my $type  = shift;
    my ( $radius, @rgb, $brush, $white, $newcolor );

    @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
#
# Overwrite corresponding function of Base
#
sub _draw_legend
{
    my $self = shift;
    my $length;

    # check to see if legend type is none..
    if ( $self->{'legend'} =~ /^none$/ )
    {
        return 1;
    }

    # check to see if they have as many labels as datasets,
    # warn them if not
    if (   ( $#{ $self->{'legend_labels'} } >= 0 )
        && ( ( scalar( @{ $self->{'legend_labels'} } ) ) != $self->{'num_datasets'} ) )
    {
        carp "The number of legend labels and datasets doesn\'t match";
    }

    # 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

    if ( $self->false( $self->{'pairs'} ) )
    {
        for ( 1 .. $self->{'num_datasets'} )
        {
            unless ( $self->{'legend_labels'}[ $_ - 1 ] )
            {
                $self->{'legend_labels'}[ $_ - 1 ] = "Dataset $_";
            }
            $length = length( $self->{'legend_labels'}[ $_ - 1 ] );
            if ( $length > $self->{'max_legend_label'} )
            {
                $self->{'max_legend_label'} = $length;
            }
        }    #end for
    }



( run in 0.583 second using v1.01-cache-2.11-cpan-39bf76dae61 )