GDGraph

 view release on metacpan or  search on metacpan

Graph/lines.pm  view on Meta::CPAN


    my $style = gdStyled;
    my @pattern = ();

    LINE: {

        ($type == 2) && do {
            # dashed

            for (1 .. $lts) { push @pattern, $clr }
            for (1 .. $lts) { push @pattern, gdTransparent }

            $self->{graph}->setStyle(@pattern);

            last LINE;
        };

        ($type == 3) && do {
            # dotted,

            for (1 .. 2) { push @pattern, $clr }
            for (1 .. 2) { push @pattern, gdTransparent }

            $self->{graph}->setStyle(@pattern);

            last LINE;
        };

        ($type == 4) && do {
            # dashed and dotted

            for (1 .. $lts) { push @pattern, $clr }
            for (1 .. 2)    { push @pattern, gdTransparent }
            for (1 .. 2)    { push @pattern, $clr }
            for (1 .. 2)    { push @pattern, gdTransparent }

            $self->{graph}->setStyle(@pattern);

            last LINE;
        };

        # default: solid
        $style = $clr;
    }

    # Tried the line_width thing with setBrush, ugly results
    # TODO: This loop probably should be around the datasets 
    # for nicer results
    my $i;
    for $i (1..$lw)
    {
        my $yslw = $ys + int($lw/2) - $i;
        my $yelw = $ye + int($lw/2) - $i;

        # Need the setstyle to reset 
        $self->{graph}->setStyle(@pattern) if (@pattern);
        $self->{graph}->line( $xs, $yslw, $xe, $yelw, $style );
    }
}

sub draw_legend_marker # (data_set_number, x, y)
{
    my $self = shift;
    my ($n, $x, $y) = @_;

    my $ci = $self->set_clr($self->pick_data_clr($n));
    return unless defined $ci;
    my $type = $self->pick_line_type($n);

    $y += int($self->{lg_el_height}/2);

    #  Joe Smith <jms@tardis.Tymnet.COM>
    local($self->{line_width}) = 2;    # Make these show up better

    $self->draw_line(
        $x, $y, 
        $x + $self->{legend_marker_width}, $y,
        $type, $ci
    );
}

"Just another true value";



( run in 1.341 second using v1.01-cache-2.11-cpan-e1769b4cff6 )