cosmicsoup has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I'm trying to create a bar graph by reading in data from a flat file using GD::Graph::Data. I keep getting an error message and I don't see the error of my ways.
File Contents of all_space.dat: adsrv2h,5 cibs1host,34 cibs2host,53 dw04host,44 dw06host,43 dwrdb1,77 dwr1dv,3 etl1host,78 etl2host,17 m03host,64 --------------------- #!/usr/local/bin/perl use CGI ':standard'; use GD::Graph::Data; use GD::Graph::bars; use strict; my $data = GD::Graph::Data->new(); my @data; $data->read(file =>'/data/space/all_space.dat', delimiter => ','); my $mygraph = GD::Graph::bars->new(500, 300); $mygraph->set( x_label => 'Machines', y_label => 'Percent of used space', title => 'Machines - Disk Availablility', ) or warn $mygraph->error; my $myimage = $mygraph->plot(\@data) or die $mygraph->error; print "Content-type: image/png\n\n"; print $myimage->png;
The exact error I'm getting is "no data sets or points at /data/cgi/machines.cgi line 28". Line 28 is the plotting line. Any suggestions?

Thanks,
Louis

Replies are listed 'Best First'.
Re: Issues with GD::Graph::Data
by Happy-the-monk (Canon) on Jun 28, 2004 at 16:29 UTC

    Any suggestions?

    It's true, the array   "@data"   is actually empty at line 28.
    You define it as empty with the statement   my @data;   and do nothing with it until line 28.
    What you do is make use of an object called   "$data".  But that isn't the same or a part of your array "@data".

    Cheers, Sören