#!/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 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;