I tried your code below but had problems:
First, apache didn't like creating the image in the cgi-bin dir, so I
changed the reference to apache/icons instead of current directory. Perhaps
this is unimportant for your setup.
Second - where is @data defined and populated? I assume your code snippet
just doesn't show it (if you don't have it defined, then you would not get
red OR green bars, much less both!). If you used the example in the docs (my
assumption), perhaps you did something like this:
my @data = (
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
[ sort { $a <=> $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ]
);
If so, you have two datasets for your graph. To reduce this to one dataset
remove the third array.
my @data = (
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
);
(Of course, these datapoints are too small for the scale of your graph, so
adjust accordingly).
Here's the sample code I used to make a single dataset graph (I adjusted
your scale down):
#!\perl\bin\perl.exe -w
print <<HTML_SCRIPT1;
Content-type: text/html
<html><head><title>Test Graphic</title></head>
<body><h2>Test Graphic</h2><hr>
<img src="/icons/iraBar.png">
</body></html>
HTML_SCRIPT1
use strict;
use GD;
use GD::Graph;
use GD::Graph::bars;
# Get a new bar graph object
my $graph = GD::Graph::bars->new(800,600);
# Set the graph options
$graph->set(x_label=>'Date',
x_label_position=> 1/2,
y_label=>'Amount',
y_label_position=> 1/2,
title=>'IRA Performance',
y_max_value=>10,
y_tick_number=>1,
y_label_skip=>0);
$graph->set_text_clr('blue');
# Plot the data
my @data = (
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
);
my $gd = $graph->plot(\@data);
# Write the image to a file
open(IMG, '>../icons/iraBar.png') or die "Unable to write grph to file:
$!\n";
binmode IMG;
print IMG $gd->png;
# Be nice and close the file
close IMG;
hth
--
Robert Taylor mailto:[EMAIL PROTECTED]
Thermeon Corporation http://www.thermeon.com/
Santa Ana, CA Office Phone: (714) 731-9191 Fax: (714) 731-5938
WebRes Demo site http://webres.thermeon.com/webres/res.html
WebRent Demo site
https://secure.thermeon.com/webrent/index.html
(please request username and
password for access)
> -----Original Message-----
> From: Michael D. Risser [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, June 22, 2001 3:04 PM
> To: [EMAIL PROTECTED]
> Subject: GD::Graph
>
> Does any one knw why I get a red and a green bar side-by-side for the same
>
> value when using GD::Graph::bars? Is there any way to stop thjis behavior?
>
> I've checked the perldocs on GD::Graph, but can't find anything about it.
...