version 1.128, 2003/10/13 22:35:05
|
version 1.131, 2003/10/16 20:03:31
|
Line 2686 Returns a link to cgi-bin/graph
|
Line 2686 Returns a link to cgi-bin/graph
|
############################################################ |
############################################################ |
############################################################ |
############################################################ |
sub DrawGraph { |
sub DrawGraph { |
my ($Title,$xlabel,$ylabel,$Max,$values1,$values2)=@_; |
my ($Title,$xlabel,$ylabel,$Max,$colors,@Values)=@_; |
# |
# |
my $identifier = time.'_'.int(rand(1000)); |
my $identifier = time.'_'.int(rand(1000)); |
if (! defined($values1) || ref($values1) ne 'ARRAY') { |
if (! @Values || ref($Values[0]) ne 'ARRAY') { |
return ''; |
return ''; |
} |
} |
|
my $NumBars = scalar(@{$Values[0]}); |
|
my %ValuesHash; |
|
my $NumSets=1; |
|
foreach my $array (@Values) { |
|
next if (! ref($array)); |
|
$ValuesHash{$identifier.'.data.'.$NumSets++} = join(',',@$array); |
|
} |
# |
# |
$Title = '' if (! defined($Title)); |
$Title = '' if (! defined($Title)); |
$xlabel = '' if (! defined($xlabel)); |
$xlabel = '' if (! defined($xlabel)); |
Line 2700 sub DrawGraph {
|
Line 2707 sub DrawGraph {
|
$xlabel = &Apache::lonnet::escape($xlabel); |
$xlabel = &Apache::lonnet::escape($xlabel); |
$ylabel = &Apache::lonnet::escape($ylabel); |
$ylabel = &Apache::lonnet::escape($ylabel); |
# |
# |
my $data1 = join(',', @$values1); |
|
my $data2; |
|
if (defined($values2)) { |
|
$data2 = join(',', @$values2); |
|
} |
|
# |
|
my $NumBars = scalar(@$values1); |
|
$Max = 1 if ($Max < 1); |
$Max = 1 if ($Max < 1); |
if ( int($Max) < $Max ) { |
if ( int($Max) < $Max ) { |
$Max++; |
$Max++; |
$Max = int($Max); |
$Max = int($Max); |
} |
} |
# |
# |
&Apache::lonnet::appenv($identifier.'.title' => $Title, |
&Apache::lonnet::appenv('cgi.'.$identifier.'.title' => $Title, |
$identifier.'.xlabel' => $xlabel, |
'cgi.'.$identifier.'.xlabel' => $xlabel, |
$identifier.'.ylabel' => $ylabel, |
'cgi.'.$identifier.'.ylabel' => $ylabel, |
$identifier.'.Max' => $Max, |
'cgi.'.$identifier.'.Max' => $Max, |
$identifier.'.NumBars' => $NumBars, |
'cgi.'.$identifier.'.NumBars' => $NumBars, |
$identifier.'.data1' => $data1, |
'cgi.'.$identifier.'.NumSets' => $NumSets, |
$identifier.'.data2' => $data2); |
'cgi.'.$identifier.'.Colors' => join(',',@{$colors}), |
return '<IMG src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
%ValuesHash); |
|
return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />'; |
} |
} |
|
|
############################################################ |
############################################################ |