Subject: | Need help with infinite loop in GD::Graph |
Date: Wed, 14 Jan 2004 21:58:40 +0000
From: john mcilwain <johnmcilwain@hotmail.com>
Subject: Re: Need help with infinite loop in GD::Graph
To: martien.verbruggen@tradingpost.com.au
Message-id: <Law9-F122PTWgpGnUT6000293be@hotmail.com>
Sure!
use GD;
use GD::Graph;
use GD::Graph::lines;
@data = (
["1st"],
[ -1],
);
$graph = GD::Graph::lines->new(400, 300);
$graph->set(
x_label => 'X Label',
y_label => 'Y label',
title => 'Some simple graph',
y_max_value => 8,
y_tick_number => 8,
y_label_skip => 2
);
$gd = $graph->plot(\@data);
Show quoted text
>From: Martien Verbruggen <mgjv@tradingpost.com.au>
>Reply-To: Martien Verbruggen <mgjv@tradingpost.com.au>
>To: john mcilwain <johnmcilwain@hotmail.com>
>Subject: Re: Need help with infinite loop in GD::Graph
>Date: Thu, 15 Jan 2004 08:39:58 +1100
>
>On Wed 14 Jan 21:22 PM, john mcilwain wrote:
>
to
Show quoted text> > Hi Martien,
> >
> > I posted this on news the other day and thought I'd send it directly
>you,
failed
Show quoted text> > in case you have time to look at it ;-)
> >
> > I am nervous about making changes that could affect other parts...
> >
> > ---
> >
> > I am plotting a line graph with 1 data point "9:00" and "-1"
> >
> > Inside axestype.pm, ~line 1627, there is a comment about
> > this possibly happening...
> >
> > This module sets min="-0.5" and max="-1.5"
> > (guess min and max can't be the same value ie: -1)
> >
> > This snippet is where the problem lays:
> > # create array of interval sizes
> > my $s = 1;
> > while ($s < $range) { $s *= 10 }
> > ->while ($s > $range) { $s /= 10 }
> > my @step = map {$_ * $s} (0.2, 0.5, 1, 2, 5);
> >
> > Range keeps getting smaller and never exits the while loop,
> > here are the values going into the snippet above:
> > $s = "1"
> > $range = "-1"
> >
> > What if $s and $range are equal?
> > It seems like it doesn't check for negative values...but then I
>math
> > ;-)
>
>You're right. There's a problem there. I should probably use the
>absolute value. Do you maybe have a small snippet of code that I could
>use as a test case? It'll make my life a little easier when fixing the
>problem:)
>
>Thanks,