Gossamer Forum
Home : Products : DBMan : Installation :

Graphing

Quote Reply
Graphing
Hello,

Does anybody know of any cgi/java or some adding graphs into dbman. I am trying to do some statistics and it would be very nice if I could represent some of the data in graphs.

Cheers
-JO
Quote Reply
Re: Graphing In reply to
Try www.q32.com for a script called qgif.exe. I'm sure it will meet your needs.
Quote Reply
Re: Graphing In reply to
Hello again...

I am trying to use qgif for the graphing and it seems to be working fine except for one little detail...

When I call the gif file with
<img src="gifs/test.gif">
it uses the one that is already in the cache hence the new gif will not display (unless I do a reload of the page)

How do I force Netscape to read the actual gif file from the disk and not from the cache?

Thanks
-JO

BTW: I tried using "exec" to call the qgif program from dbman but it did not work. I had to use "system" instead. Using exec I would get nothing but an empty window.
Quote Reply
Re: Graphing In reply to
Well, I think I might be out of luck on this one Frown. I hope somebody can tell me otherwise...

After trying a few thing like
<META http-equiv="Pragma" content="no-cache">

I came across this...

Netscape made a deliberate decision to treat inline images differently from
other output formats in order to provide IMPROVED PERFORMANCE. In particular,
images are treated as if "Verify once per session" was selected in prefs,
even if "Verify every time" is the current setting.

If a user returns to a page that they previously visited in the same session,
a reload can be required to get the most recent version of any images on that
page. Navigator will not reload the image every time and this is inconsistent,
but consistency would require a separate connection to the server for every
image on a page and would handicap Navigator performance.

It seems that my only way out is to create a random file name for every gif I create.

Darn Frown

-JO
Quote Reply
Re: Graphing In reply to
I use the following line to force Netscape
to reload everytime a page is requested:

<META HTTP-EQUIV="Expires" CONTENT="Tue,21 Feb 1987 8:00:00 GMT">

Hope it helps.

Quote Reply
Re: Graphing In reply to
Thanks for your input...

I tried it but it did not make a difference. Frown
As far as I understand this cache thing, there is 2 different caches that Netscape uses, a memory one and a disk one. The gifs are being read from the memory one. Your suggestion (as well as some other ones that I came across) deal with the disk cache not the memory cache. If I use the same file name for my gifs, I would have to somehow refresh that memory cache.

Thanks again

-JO
Quote Reply
Re: Graphing In reply to
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