Diff for /loncom/xml/lonplot.pm between versions 1.46 and 1.47

version 1.46, 2002/01/30 13:27:51 version 1.47, 2002/02/05 15:05:44
Line 40  use Apache::lonxml; Line 40  use Apache::lonxml;
 use Apache::edit;  use Apache::edit;
   
 BEGIN {  BEGIN {
   &Apache::lonxml::register('Apache::lonplot',('plot'));    &Apache::lonxml::register('Apache::lonplot',('gnuplot'));
 }  }
   
 ##   ## 
Line 113  my $words_test     = sub {$_[0]=~s/\s+/ Line 113  my $words_test     = sub {$_[0]=~s/\s+/
 ##                      Attribute metadata                       ##  ##                      Attribute metadata                       ##
 ##                                                               ##  ##                                                               ##
 ###################################################################  ###################################################################
 my @plot_edit_order =   my @gnuplot_edit_order = 
     qw/bgcolor fgcolor height width font transparent grid border align/;      qw/bgcolor fgcolor height width font transparent grid border align/;
 my %plot_defaults =   my %gnuplot_defaults = 
     (      (
      height       => {       height       => {
  default     => 200,   default     => 200,
Line 339  my %curve_defaults = Line 339  my %curve_defaults =
 ###################################################################  ###################################################################
 my (%plot,%key,%axis,$title,$xlabel,$ylabel,@labels,@curves,%xtics,%ytics);  my (%plot,%key,%axis,$title,$xlabel,$ylabel,@labels,@curves,%xtics,%ytics);
   
 sub start_plot {  sub start_gnuplot {
     %plot    = ();      %key     = ();      %axis   = ();       %plot    = ();      %key     = ();      %axis   = (); 
     $title   = undef;   $xlabel  = undef;   $ylabel = undef;      $title   = undef;   $xlabel  = undef;   $ylabel = undef;
     $#labels = -1;      $#curves = -1;      $#labels = -1;      $#curves = -1;
Line 352  sub start_plot { Line 352  sub start_plot {
       'xtics','ytics'));        'xtics','ytics'));
     push (@Apache::lonxml::namespace,'lonplot');      push (@Apache::lonxml::namespace,'lonplot');
     if ($target eq 'web') {      if ($target eq 'web') {
  my $inside = &Apache::lonxml::get_all_text("/plot",$$parser[-1]);   my $inside = &Apache::lonxml::get_all_text("/gnuplot",$$parser[-1]);
  $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);   $inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
  &Apache::lonxml::newparser($parser,\$inside);   &Apache::lonxml::newparser($parser,\$inside);
  &get_attributes(\%plot,\%plot_defaults,$parstack,$safeeval,   &get_attributes(\%plot,\%gnuplot_defaults,$parstack,$safeeval,
  $tagstack->[-1]);   $tagstack->[-1]);
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result .= &Apache::edit::tag_start($target,$token,'Plot');   $result .= &Apache::edit::tag_start($target,$token,'GnuPlot');
  $result .= &edit_attributes($target,$token,\%plot_defaults,   $result .= &edit_attributes($target,$token,\%gnuplot_defaults,
     \@plot_edit_order);      \@gnuplot_edit_order);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my $constructtag=&Apache::edit::get_new_args   my $constructtag=&Apache::edit::get_new_args
     ($token,$parstack,$safeeval,keys(%plot_defaults));      ($token,$parstack,$safeeval,keys(%gnuplot_defaults));
  if ($constructtag) {   if ($constructtag) {
     $result = &Apache::edit::rebuild_tag($token);      $result = &Apache::edit::rebuild_tag($token);
  }   }
Line 371  sub start_plot { Line 371  sub start_plot {
     return $result;      return $result;
 }  }
   
 sub end_plot {  sub end_gnuplot {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   
     pop @Apache::lonxml::namespace;      pop @Apache::lonxml::namespace;
     &Apache::lonxml::deregister('Apache::lonplot',      &Apache::lonxml::deregister('Apache::lonplot',
  ('title','xlabel','ylabel','key','axis','label','curve'));   ('title','xlabel','ylabel','key','axis','label','curve'));
Line 393  sub end_plot { Line 392  sub end_plot {
      width  = "$plot{'width'}"        width  = "$plot{'width'}" 
      height = "$plot{'height'}"       height = "$plot{'height'}"
      align  = "$plot{'align'}"       align  = "$plot{'align'}"
      alt    = "/cgi-bin/plot.gif?$filename" />       alt    = "image should be /cgi-bin/plot.gif?$filename" />
 ENDIMAGE  ENDIMAGE
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.=&Apache::edit::tag_end($target,$token);   $result.=&Apache::edit::tag_end($target,$token);
Line 962  sub write_gnuplot_file { Line 961  sub write_gnuplot_file {
 sub check_inputs {  sub check_inputs {
     ## Note: no inputs, no outputs - this acts only on global variables.      ## Note: no inputs, no outputs - this acts only on global variables.
     ## Make sure we have all the input we need:      ## Make sure we have all the input we need:
     if (! %plot) { &set_defaults(\%plot,\%plot_defaults); }      if (! %plot) { &set_defaults(\%plot,\%gnuplot_defaults); }
     if (! %key ) {} # No key for this plot, thats okay      if (! %key ) {} # No key for this plot, thats okay
 #    if (! %axis) { &set_defaults(\%axis,\%axis_defaults); }  #    if (! %axis) { &set_defaults(\%axis,\%axis_defaults); }
     if (! defined($title )) {} # No title for this plot, thats okay      if (! defined($title )) {} # No title for this plot, thats okay
Line 1018  sub edit_attributes { Line 1017  sub edit_attributes {
 ##                                                               ##  ##                                                               ##
 ###################################################################  ###################################################################
   
 #------------------------------------------------ insert_xxxxxxx  sub insert_gnuplot {
 sub insert_plot {  
     my $result = '';      my $result = '';
     #  plot attributes      #  plot attributes
     $result .= "<plot \n";      $result .= "<plot \n";
     foreach my $attr (keys(%plot_defaults)) {      foreach my $attr (keys(%gnuplot_defaults)) {
  $result .= "     $attr=\"$plot_defaults{$attr}->{'default'}\"\n";   $result .= "     $attr=\"$gnuplot_defaults{$attr}->{'default'}\"\n";
     }      }
     $result .= ">\n";      $result .= ">\n";
     # Add the components      # Add the components (most are commented out for simplicity)
     # $result .= &insert_key();      # $result .= &insert_key();
     # $result .= &insert_axis();      # $result .= &insert_axis();
     # $result .= &insert_title();          # $result .= &insert_title();    

Removed from v.1.46  
changed lines
  Added in v.1.47


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