Hi Nelson,

if you only want to have the graphs created dynamically and not stored on 
your hard disk, the simplest way is to break the program up into two parts. 
Assuming there is a way of working out what data set you want to plot,  (eg 
an SQL query) have your link point to your main script...

<IMG SRC=\"$ENV{SCRIPT_NAME}?Query=$Query\">

Then in your script  check if Query was passed with a parameter, if it was, 
call a subroutine that does something like this...

     my $dbh = DBI->connect($DB_dsh, $DB_Username, $DB_Password, 
{RaiseError => 0}) || die "could not c
onnect to database\n";
     my $sth = $dbh->prepare($Query) || die "\$sth not created!\n";
     $sth->execute();
     while (@arrtmp = $sth->fetchrow_array()){
         push (@data0, $arrtmp[0]);
         push (@data1, $arrtmp[1]);
     }
     $dbh->disconnect;
     if (@data0 + 0 == 0) {
#       print "<BR>No data exists!<BR>\n";
         return(-1);
     }

     $ymin = $data1[0];
     $ymax = $data1[0];

for ($a=0;$a<=$#data0;$a++) {
             $data->add_point($data0[$a],$data1[$a]);
             $ymax = $data1[$a] if ($ymax < $data1[$a]);
             $ymin = $data1[$a] if ($ymin > $data1[$a]);

         }

         $my_graph = GD::Graph::bars->new($xsize,$ysize);
         if ($ymax < 20) { $yskip = $ymax; }
         else { $yskip = 20; }
         $my_graph->set(
         x_label             => $xTitle,
         y_label             => $yTitle,
         title               => $Title,
         y_max_value         => $ymax,
         y_tick_number       => $ymax,
         y_tick_number       => $yskip,
         x_labels_vertical   => 1,
         bar_spacing         => 8,
         shadow_depth        => 2,
         shadowclr           => 'dred',
         transparent         => 0
         ) or warn $my_graph->error;


         $my_graph->plot($data) or warn $my_graph->error;
         binmode STDOUT;
         print $my_graph->gd->jpeg(100);



That's a bit rough and ready, but I think it gives the general idea.


R


At 22:00 22/09/2002 -0600, Nelson Goforth wrote:
>I'm gathering numeric survey data from users with a perl script and then 
>showing their scores on a results page.
>
>On this page I want to include a graph of the results.  I've written a 
>script that uses gd.PM, but I'm at a loss on how to pass the result set 
>array over to the separate graphing script.
>
>I've tried calling the graphing script as:
>
>print "<IMG SRC="graph.pl?results=@results">";
>
>but can't seem to pull the data out.   I've tried a couple other options 
>but nothing seems to work properly.
>
>I've done a workaround in the past by calling a similar graphing script 
>that actually creates a .gif file which is then displayed in an HTML page, 
>but I don't NEED to create a file, and figure there must be a better way 
>to do this.
>
>Any ideas?
>
>Nelson
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to