Diff for /loncom/interface/loncommon.pm between versions 1.136 and 1.137

version 1.136, 2003/10/27 21:21:08 version 1.137, 2003/10/29 15:21:10
Line 2741  sub DrawBarGraph { Line 2741  sub DrawBarGraph {
         push (@Labels,$i+1);          push (@Labels,$i+1);
     }      }
     #      #
       $Max = 1 if ($Max < 1);
       if ( int($Max) < $Max ) {
           $Max++;
           $Max = int($Max);
       }
     $Title  = '' if (! defined($Title));      $Title  = '' if (! defined($Title));
     $xlabel = '' if (! defined($xlabel));      $xlabel = '' if (! defined($xlabel));
     $ylabel = '' if (! defined($ylabel));      $ylabel = '' if (! defined($ylabel));
     $ValuesHash{$id.'.title'}    = &Apache::lonnet::escape($Title);      $ValuesHash{$id.'.title'}    = &Apache::lonnet::escape($Title);
     $ValuesHash{$id.'.xlabel'}   = &Apache::lonnet::escape($xlabel);      $ValuesHash{$id.'.xlabel'}   = &Apache::lonnet::escape($xlabel);
     $ValuesHash{$id.'.ylabel'}   = &Apache::lonnet::escape($ylabel);      $ValuesHash{$id.'.ylabel'}   = &Apache::lonnet::escape($ylabel);
     $ValuesHash{$id.'.Max'}      = $Max;      $ValuesHash{$id.'.y_max_value'} = $Max;
     $ValuesHash{$id.'.NumBars'}  = $NumBars;      $ValuesHash{$id.'.NumBars'}  = $NumBars;
     $ValuesHash{$id.'.NumSets'}  = $NumSets;      $ValuesHash{$id.'.NumSets'}  = $NumSets;
     $ValuesHash{$id.'.PlotType'} = 'bar';      $ValuesHash{$id.'.PlotType'} = 'bar';
Line 2758  sub DrawBarGraph { Line 2763  sub DrawBarGraph {
     $ValuesHash{$id.'.bar_width'} = $bar_width;      $ValuesHash{$id.'.bar_width'} = $bar_width;
     $ValuesHash{$id.'.labels'} = join(',',@Labels);      $ValuesHash{$id.'.labels'} = join(',',@Labels);
     #      #
     $Max = 1 if ($Max < 1);      &Apache::lonnet::appenv(%ValuesHash);
     if ( int($Max) < $Max ) {      return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
         $Max++;  }
         $Max = int($Max);  
   ############################################################
   ############################################################
   
   =pod
   
   =item DrawXYGraph
   
   =cut
   
   ############################################################
   ############################################################
   sub DrawXYGraph {
       my ($Title,$xlabel,$ylabel,$Max,$colors,$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.'.y_max_value'=> $Max,
            $id.'.labels'     => join(',',@$Xlabels),
            $id.'.PlotType'   => 'XY',
            $id.'.NumSets'    => 1,
            );
       #
       if (defined($colors) && ref($colors) eq 'ARRAY') {
           $ValuesHash{$id.'.Colors'}   = join(',',@{$colors});
       }
       #
       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);
       }
       #
       # Deal with other parameters
       while (my ($key,$value) = each(%Values)) {
           $ValuesHash{$id.'.'.$key} = $value;
     }      }
     #      #
     &Apache::lonnet::appenv(%ValuesHash);      &Apache::lonnet::appenv(%ValuesHash);
     return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';      return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
 }  }
   
   
 ############################################################  ############################################################
 ############################################################  ############################################################
   
Line 2779  sub DrawBarGraph { Line 2833  sub DrawBarGraph {
   
 ############################################################  ############################################################
 ############################################################  ############################################################
 sub DrawXYGraph {  sub DrawXYYGraph {
     my ($Title,$xlabel,$ylabel,$Max,$Xlabels,$Ydata,%Values)=@_;      my ($Title,$xlabel,$ylabel,$colors,$Xlabels,$Ydata1,$Min1,$Max1,
                                           $Ydata2,$Min2,$Max2,%Values)=@_;
     #      #
     # Create the identifier for the graph      # Create the identifier for the graph
     my $identifier = &get_cgi_id();      my $identifier = &get_cgi_id();
Line 2794  sub DrawXYGraph { Line 2849  sub DrawXYGraph {
          $id.'.title'  => &Apache::lonnet::escape($Title),           $id.'.title'  => &Apache::lonnet::escape($Title),
          $id.'.xlabel' => &Apache::lonnet::escape($xlabel),           $id.'.xlabel' => &Apache::lonnet::escape($xlabel),
          $id.'.ylabel' => &Apache::lonnet::escape($ylabel),           $id.'.ylabel' => &Apache::lonnet::escape($ylabel),
          $id.'.Max'    => $Max,  
          $id.'.labels' => join(',',@$Xlabels),           $id.'.labels' => join(',',@$Xlabels),
          $id.'.PlotType' => 'XY',           $id.'.PlotType' => 'XY',
          $id.'.NumSets' => 2,           $id.'.NumSets' => 2,
            $id.'.two_axes' => 1,
            $id.'.y1_max_value' => $Max1,
            $id.'.y1_min_value' => $Min1,
            $id.'.y2_max_value' => $Max2,
            $id.'.y2_min_value' => $Min2,
          );           );
     #      #
     if (! ref($Ydata) || ref($Ydata) ne 'ARRAY') {      if (defined($colors) && ref($colors) eq 'ARRAY') {
           $ValuesHash{$id.'.Colors'}   = join(',',@{$colors});
       }
       #
       if (! ref($Ydata1) || ref($Ydata1) ne 'ARRAY' ||
           ! ref($Ydata2) || ref($Ydata2) ne 'ARRAY'){
         return '';          return '';
     }      }
     my $NumSets=1;      my $NumSets=1;
     foreach my $array ($Ydata){      foreach my $array ($Ydata1,$Ydata2){
         next if (! ref($array));          next if (! ref($array));
         $ValuesHash{$id.'.data.'.$NumSets++} = join(',',@$array);          $ValuesHash{$id.'.data.'.$NumSets++} = join(',',@$array);
     }      }
     #      #
       # Deal with other parameters
       while (my ($key,$value) = each(%Values)) {
           $ValuesHash{$id.'.'.$key} = $value;
       }
       #
     &Apache::lonnet::appenv(%ValuesHash);      &Apache::lonnet::appenv(%ValuesHash);
     return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';      return '<img src="/cgi-bin/graph.png?'.$identifier.'" border="1" />';
 }  }

Removed from v.1.136  
changed lines
  Added in v.1.137


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>