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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.