[LON-CAPA-cvs] cvs: loncom /cgi graph.png

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 29 Oct 2003 15:18:10 -0000


matthew		Wed Oct 29 10:18:10 2003 EDT

  Modified files:              
    /loncom/cgi	graph.png 
  Log:
  Added some POD, comments, and changed the  manner in which the maximum
  y value is passed in to be truer to the GD::Graph name of the parameter.
  
  
Index: loncom/cgi/graph.png
diff -u loncom/cgi/graph.png:1.30 loncom/cgi/graph.png:1.31
--- loncom/cgi/graph.png:1.30	Wed Oct 29 09:47:43 2003
+++ loncom/cgi/graph.png	Wed Oct 29 10:18:09 2003
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 #
-# $Id: graph.png,v 1.30 2003/10/29 14:47:43 matthew Exp $
+# $Id: graph.png,v 1.31 2003/10/29 15:18:09 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,19 +38,18 @@
 
 =head1 SYNOPSIS
 
-produces plots based on input
+produces plots from data stored in users environment.
 
 =head1 DESCRIPTION
 
-graph.png is a cgi-bin script which produces plots based on input data.
-
-The query string is expected to be as follows (without whitespace):
-
-escape(Plot title) & escape(X label)& escape(Y label) & Maximum Y value &
-Number of bars & $data1 & $data2
-
-$data1 and $data2 are expected to be comma seperated lists of numbers.
-escape( value ) means the values must be run through lonnet::escape.
+graph.png is a cgi-bin script which produces plots based on data stored
+in the users environment.  The users cookie is checked prior to producing
+a plot.  The query string is expected to be an identifier, $id.  
+The parameters defining the plot must be stored in the environment as 
+$ENV{'cgi.'.$id.'.'.$dataname}.  Two types of plots can be produced, 'bar'
+and 'xy'.  The 'xy' graph can will 1 or 2 y-axes if the parameter
+'two_axes' is set to false or true respectively.  See perldoc GD::Graph and
+loncommon::DrawBarGraph, loncommon::DrawXYGraph, and loncommon::DrawXYYGraph.
 
 =cut
 
@@ -90,7 +89,7 @@
 my $id = $ENV{'QUERY_STRING'};
 
 #
-# &get_env($name,$default)
+# usage: &get_env($name,$default)
 sub get_env {
     my $key = 'cgi.'.$id.'.'.(shift());
     return shift if (! exists($ENV{$key}));
@@ -113,6 +112,9 @@
 
 $|=1;   # Autoflush after each print/write
 
+##
+## Set up the plot
+##
 my $colordefaults = join(',',
                          ('#33ff00', 
                           '#0033cc','#990000','#aaaa66','#663399','#ff9933',
@@ -143,7 +145,7 @@
 
 $GraphSettings{'x_label_skip'}  = &get_env('xskip',1);
 $GraphSettings{'x_tick_offset'} = &get_env('x_tick_offset',0);
-$GraphSettings{'y_max_value'}   = &get_env('Max',1);
+$GraphSettings{'y_max_value'}   = &get_env('y_max_value',1);
 
 my $MyGraph;
 if ($PlotType eq 'bar') {