--- loncom/interface/loncommon.pm 2003/10/23 21:01:54 1.133 +++ loncom/interface/loncommon.pm 2003/10/27 21:21:08 1.136 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.133 2003/10/23 21:01:54 albertel Exp $ +# $Id: loncommon.pm,v 1.136 2003/10/27 21:21:08 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -274,7 +274,7 @@ of the element the selection from the se sub browser_and_searcher_javascript { return < $Title, - 'cgi.'.$identifier.'.xlabel' => $xlabel, - 'cgi.'.$identifier.'.ylabel' => $ylabel, - 'cgi.'.$identifier.'.Max' => $Max, - 'cgi.'.$identifier.'.NumBars' => $NumBars, - 'cgi.'.$identifier.'.NumSets' => $NumSets, - 'cgi.'.$identifier.'.Colors' => join(',',@{$colors}), - %ValuesHash); + &Apache::lonnet::appenv(%ValuesHash); + return ''; +} + +############################################################ +############################################################ + +=pod + +=item DrawXYGraph + +=cut + +############################################################ +############################################################ +sub DrawXYGraph { + my ($Title,$xlabel,$ylabel,$Max,$Xlabels,$Ydata,%Values)=@_; + # + # Create the identifier for the graph + my $identifier = &get_cgi_id(); + my $id = 'cgi.'.$identifier; + # + $Title = '' if (! defined($Title)); + $xlabel = '' if (! defined($xlabel)); + $ylabel = '' if (! defined($ylabel)); + my %ValuesHash = + ( + $id.'.title' => &Apache::lonnet::escape($Title), + $id.'.xlabel' => &Apache::lonnet::escape($xlabel), + $id.'.ylabel' => &Apache::lonnet::escape($ylabel), + $id.'.Max' => $Max, + $id.'.labels' => join(',',@$Xlabels), + $id.'.PlotType' => 'XY', + $id.'.NumSets' => 2, + ); + # + if (! ref($Ydata) || ref($Ydata) ne 'ARRAY') { + return ''; + } + my $NumSets=1; + foreach my $array ($Ydata){ + next if (! ref($array)); + $ValuesHash{$id.'.data.'.$NumSets++} = join(',',@$array); + } + # + &Apache::lonnet::appenv(%ValuesHash); return ''; }