Since James e-mailed me asking if I got it working, I figured that somebody else might also be interested.
Below is the mail I sent him...
I am running it on NT. I donīt know which program you should use to build graphs on a UNIX machine.
I will hopefully move to Linux in the future but...
Anyway, this is what I have done to get it working.
First, this is my Perl Version
Perl Version : 5.00502
I am running on Netscape FastTrack server
I have a sub called html_stats_display and this are pieces of it.
You can probably use the same code and put it anywhere you want to.
I have a loop that puts the data to be graphed in an array first
my @Chart_Data = "Item,Number:"; # sets up the heading of the data file, Using : as a delimiter for next row
@Chart_Data="@Chart_Data$button,$db_total_hits:"; # This is inside the loop. @Chart_Data contains the previous data and
# $button,$db_total_hits: has the new data.
After the data is in @Chart_Data I call another sub (in my db.pl) that creates the data file and calls the qgif program
Code:
if ($in{"Use_Charts"} ne "No") { # This is a checkbutton that is selected on a previous form and past though POST
print "<BR>";
($random) = &print_graphs (@Chart_Data); # This calls the sub in db.pl. $random will have the name of the file
print "<img src=\"gifs/temp/$random.gif\">"; # Does the actual printing of the file in dbman
}
In db.pl (You can put it anywhere...)
Code:
sub print_graphs {
# Prints the graph requested ...
# Stores the data in $gdata and creates the input file for qgif
my ($gdata)=@_;
my $data_file_name= "d:\\web\\fasttrack\\scripts\\dbman\\gifs\\temp\\test.csv"; # I have these two in my .cfg file as global variables.
my $command_path="d:\\web\\fasttrack\\scripts\\dbman";
my $random = (int(rand(100000)) + 1); # creates a random file to avoid reading from memory cache
my $command = "$command_path\\qgif /pie /size=500,260 /border=black,1 /background=#FFFFCC /in=$data_file_name /out=$command_path\\gifs\\temp\\$random.gif" ;
# Creating the data file
open (DATAFILE, ">$data_file_name") or &cgierr("error in add_record. unable to open database: $data_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DATAFILE, 2) or &cgierr("unable to get exclusive lock on $data_file_name.\nReason: $!");
}
my @cdata = split (/:/, $gdata); # Looking for the : delimiter
foreach $data (@cdata) {
print DATAFILE "$data\n";
}
close DATAFILE;
system($command); # executing command. I tried exec but did not work.
# my $exit_value = $? >> 8; # Traces the return values of the system call
# my $signal_num = $? & 127;
# my $dumped_core = $? & 128;
return ($random); # Passing back the name of the file
}
Hope that helps
Cheers
-JO