Annotation of loncom/cgi/graph.png, revision 1.9

1.1       minaeibi    1: #!/usr/bin/perl
                      2: #
1.8       minaeibi    3: # $Id: graph.gif,v 1.7 2002/01/22 15:12:05 minaeibi Exp $
1.5       minaeibi    4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/cgi-bin/graph.gif
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
1.1       minaeibi   27: # The LearningOnline Network with CAPA
                     28: # Behrouz Minaei
1.5       minaeibi   29: # YEAR=2001
1.9     ! minaeibi   30: # 9/13/01, 9/25/01, 10/6/01, 10/9/01, 12/25/01
        !            31: # YEAR=2002
        !            32: # 2/1/02
1.1       minaeibi   33: # A CGI script that dynamically outputs a graphical chart for lonstatistics.
1.5       minaeibi   34: # 
                     35: #### 
1.1       minaeibi   36: 
                     37: use strict;
1.9     ! minaeibi   38: use GD::Graph::bars;
1.1       minaeibi   39: use GD::Graph::colour;
                     40: use GD::Graph::Data;
                     41: 
1.4       matthew    42: $|=1;   # Autoflush after each print/write
1.1       minaeibi   43: my ($cid, $Tag, $Max, $PNo, $data) = split(/&/,$ENV{'QUERY_STRING'});
                     44: 
                     45: my @data1=split(/\,/,$data);
                     46:    
                     47: my @xlabels;
                     48: for (my $nIdx=0; $nIdx<$PNo; $nIdx++ ) {
                     49:     $xlabels[$nIdx]=$nIdx+1;
                     50: } 
                     51: my @data =(\@xlabels,\@data1);
                     52: 
                     53: my $Range;
                     54: if ( $PNo > 10 ) {$Range = 30*$PNo;}
1.9     ! minaeibi   55: else { $Range = 400+30*$PNo; }
1.1       minaeibi   56: 
1.9     ! minaeibi   57: $Max += (10 - $Max % 10);
        !            58: $Max = int($Max);
1.1       minaeibi   59: 
1.9     ! minaeibi   60: my $MyGraph = GD::Graph::bars->new($Range, 400);
1.1       minaeibi   61: 
                     62: $MyGraph->set( 
                     63:     x_label         => 'Problems #',
                     64:     y_label         => $Tag,
                     65:     title           => 'LON-CAPA Graphical Chart, Course: '.$cid,
                     66:     y_max_value     => $Max,
                     67:     y_tick_number   => 10,
                     68:     y_label_skip    => 1,
                     69:     x_label_skip    => 2,
                     70:     
                     71:     # colors
1.3       minaeibi   72:     dclrs           => [ qw( green lblue lyellow lpurple cyan lorange)],
1.1       minaeibi   73:     
                     74:     # shadows
                     75:     bar_spacing     => 4,
                     76:     shadow_depth    => 1,
                     77:     shadowclr       => 'dred',
                     78: 
                     79:     transparent     => 0,
                     80: ) or warn $MyGraph->error; 
                     81: 
                     82: # Tell the server we are sending a gif graphic
                     83: print <<END;
                     84: Content-type: image/gif
                     85: 
                     86: END
                     87: 
                     88: my $BinaryData=$MyGraph->plot(\@data)->png;
                     89: undef $MyGraph;
                     90: binmode(STDOUT);
1.2       minaeibi   91: open IMG,"|pngtopnm|ppmtogif 2>/dev/null"; # convert into a gif image
1.1       minaeibi   92: print IMG $BinaryData; # output image
                     93: $|=1; # be sure to flush before closing
                     94: close IMG;
1.3       minaeibi   95: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.