[LON-CAPA-cvs] cvs: loncom /cgi graph.png
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 15 Oct 2003 21:08:39 -0000
matthew Wed Oct 15 17:08:39 2003 EDT
Modified files:
/loncom/cgi graph.png
Log:
Added support for variable number of data sets and user specified colors.
Index: loncom/cgi/graph.png
diff -u loncom/cgi/graph.png:1.24 loncom/cgi/graph.png:1.25
--- loncom/cgi/graph.png:1.24 Thu Oct 9 18:04:37 2003
+++ loncom/cgi/graph.png Wed Oct 15 17:08:39 2003
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# $Id: graph.png,v 1.24 2003/10/09 22:04:37 matthew Exp $
+# $Id: graph.png,v 1.25 2003/10/15 21:08:39 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -88,13 +88,8 @@
my $ylabel = &unescape($ENV{$identifier.'.ylabel'});
my $Max = $ENV{$identifier.'.Max'};
my $NumBars = $ENV{$identifier.'.NumBars'};
-my $data1 = $ENV{$identifier.'.data1'};
-my $data2 = $ENV{$identifier.'.data2'};
-
-my @data11=split(/\,/,$data1);
-my @data12=split(/\,/,$data2);
-my $skip_x = 1;
-my $bar_width=10;
+my $NumSets = $ENV{$identifier.'.NumSets'};
+my @Colors = split(',',$ENV{$identifier.'.Colors'});
#
# Labels are always digits
@@ -102,8 +97,14 @@
for (my $nIdx=0; $nIdx<$NumBars; $nIdx++ ) {
$xlabels[$nIdx]=$nIdx+1;
}
+my @data; # stores the data for the graph
+push(@data,\@xlabels);
+for (my $i=1;$i<=$NumSets;$i++) {
+ push(@data,[split(',',$ENV{$identifier.'.data.'.$i})]);
+}
-my @data =(\@xlabels,\@data11,\@data12);
+my $skip_x = 1;
+my $bar_width=10;
#
# Customize graph based on the
@@ -146,8 +147,7 @@
x_label_skip => $skip_x,
x_tick_offset => $x_tick_offset,
#
- dclrs => [ qw(lgreen dgreen lyellow
- lpurple cyan lorange)],
+ dclrs => \@Colors,
bar_width => $bar_width,
cumulate => 2,
zero_axis => 1,