crake
|
Posted: 12/22/2004, 3:06 AM |
|
I'm using GD Graph module (GD::Graph::lines) with perl
(http://crs.ciril.fr/public/docs/perl/GD/Graph.html).
I think that I have maybe found bug or there is something weird?
If x axis data values are negative numbers and all the values are same numbers then script runs very long time with maximum cpu usage and doesn't draw image.
Why it not work?
I run script from http server.
--- cut and paste -----
#!/usr/bin/perl -w
# Change above line to point to your perl binary
use CGI ':standard';
use GD::Graph::lines;
use strict;
#############################################
# Here bug?
my @data = (['Fall 01', 'Spr 01', 'Fall 02', 'Spr 02' ], # Ok, works
[-1, -1, -1, -1]); # Why data values are not work?
# I tried with other values and works without problems:
# [-1, -2, -2, -1]); # Ok works
# [0, 0, 0, 0]); # Ok, works
# [1, 1, 1, 1]); # Ok, works
#
# If I use negative numbers and all the values are same numbers
# script runs long time with maximum cpu usage and doesn't draw image.
# Is this bug?
#
# What I can do so that my script can draw all same negative numbers to my graph?
#
#
#
##########################################################3
my $mygraph = GD::Graph::lines->new(600, 300);
$mygraph->set(
x_label => 'Semester',
y_label => 'Marks',
title => 'Grade report for a student',
y_max_value => 10,
y_min_value => -10,
# Draw datasets in 'solid', 'dashed' and 'dotted-dashed' lines
line_types => [1, 2, 4],
# Set the thickness of line
line_width => 2,
# Set colors for datasets
dclrs => ['blue'],
) or warn $mygraph->error;
$mygraph->set_legend_font(GD::gdMediumBoldFont);
$mygraph->set_legend('Exam 1');
my $myimage = $mygraph->plot(\@data) or die $mygraph->error;
print "Content-type: image/png\n\n";
print $myimage->png;
|
|
 |
Last Hero
|
Posted: 12/22/2004, 6:06 AM |
|
Bug in GD::Graph::axestype
sub _best_ends
Try to make some changes:
C:\lang\Perl\site\lib\GD\Graph>diff axestype.orig axestype.pm
1631,1632c1631,1646
< ($min, $max) = ($min) ? ($min * 0.5, $min * 1.5) : (-1,1)
< if ($max == $min);
---
> if ($max == $min)
> {
> if ($min > 0)
> {
> ($min, $max) = ($min * 0.5, $min * 1.5);
> }
> elsif($max < 0)
> {
> ($min, $max) = ($min * 1.5, $min * 0.5);
> }
> else
> {
> ($min, $max) = (-1,1);
> }
> }
>
|
|
 |
crake
|
Posted: 12/22/2004, 11:06 AM |
|
Ok, I have done changes to module and it works now.
I'm very happy that it runs without problems now 
Thank you very much and merry christmas!
|
|
 |
|