Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GD::Graph::mixed Unwanted line when using area

Status
Not open for further replies.

tlohan

Programmer
Sep 14, 2001
19
BE
Hi,

I'm using GD::Graph::mixed to create a graph of performance over time.

My time array has data 00:00, 00:30, 01:00, 01:30 etc.
The Summ array has data 0, 0, 0, 10.5, etc.

I am producing an area graph for the Summ array but I am getting a diagonal line for the period 1:00 to 1:30.

| /
| /
| /
|___/_________
1 1:30

I only have data at 1:30 onwards an want to try and get the area part of the graph to start with a vertical line, like below:

| |
| |
| |
|_____|_
1 1:30

Any ideas??

Thanks,

Tom

The code is below:

open (OUTFILE,'>'.$outfile) or die "Could not open file";

@data=(\@Time,\@Summ,\@Good,\@Ldrs);

use GD::Graph::mixed;

$mygraph = GD::Graph::mixed->new(600, 400);

$mygraph->set(
x_label => 'Time',
y_label => 'No. of Lifs',
title => 'Loader Performance',
# Draw datasets in 'solid', 'dashed' and 'dotted-dashed' lines
line_types => [1],
# Set the thickness of line
line_width => 2,
# Set colors for datasets
#long_ticks => 1,
types => ['area', 'lines', 'lines'],
dclrs => ['cyan', 'red', 'green'],
transparent => 0,
x_min_value => 0,
x_tick_length => -4,
) or warn $mygraph->error;

$mygraph->set_x_axis_font(GD::gdMediumBoldFont);
$mygraph->set_y_axis_font(GD::gdMediumBoldFont);
$mygraph->set_x_label_font(GD::gdMediumBoldFont);
$mygraph->set_y_label_font(GD::gdMediumBoldFont);

$mygraph->set_legend_font(GD::gdMediumBoldFont);
$mygraph->set_legend('Summaries Running', 'Good', 'No of Loaders');
$myimage = $mygraph->plot(\@data) or die $mygraph->error;

binmode OUTFILE;

print OUTFILE $myimage->png;

close(OUTFILE);
 
Instead of zero's in the array for before your real data starts - have you tried 'undef' ? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Mike,

That worked for the start of the area graph, however it seems to have caused another problem.

The dotted lines that appear in the area graph for each data point are now going all the way up the height of the graph for some of the points at the end of the area graph.

| . .
| . .
| /---\______/------\_______
| | . . . . .
| | . . . . .
|___|___.____._____.___.____.__________
1.30 2 2.30 3 3.30 4

Any ideas ??

Thanks for the help,

Tom
 
Tom,

Sorry no, I was just guessing to be honest. Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
I think if you're using a line graph you're going to get the sloping lines no matter what (if 0 is a real data point. [tt]undef[/tt] means that there is no data point whatsoever at that position.) It seems like what you really want is a bar graph, but multiple bars in GD::Graph::mixed is not supposed to work very well (I've never tried.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top