Diff for /loncom/xml/lonplot.pm between versions 1.91 and 1.94

version 1.91, 2003/09/27 04:08:56 version 1.94, 2004/01/07 18:16:02
Line 115  my $words_test     = sub {$_[0]=~s/\s+/ Line 115  my $words_test     = sub {$_[0]=~s/\s+/
 ###################################################################  ###################################################################
 my @gnuplot_edit_order =   my @gnuplot_edit_order = 
     qw/alttag bgcolor fgcolor height width font transparent grid samples       qw/alttag bgcolor fgcolor height width font transparent grid samples 
     border align texwidth plottype/;      border align texwidth texfont plottype/;
   
 my $gnuplot_help_text = <<"ENDPLOTHELP";  my $gnuplot_help_text = <<"ENDPLOTHELP";
 <p>  <p>
Line 232  my %gnuplot_defaults = Line 232  my %gnuplot_defaults =
          edit_type   => 'entry',           edit_type   => 'entry',
          size        => '5'           size        => '5'
          },           },
        texfont     => {
            default     => '22',
            test        => $int_test,
            description => 'Font size to use in TeX output (pts):',
            edit_type   => 'choice',
            choices     => [qw/10 12 14 16 18 20 22 24 26 28 30 32 34 36/],
            },
      plottype  => {       plottype  => {
  default     => 'Cartesian',   default     => 'Cartesian',
  test        => sub {$_[0]=~/^(Polar|Cartesian)$/},   test        => sub {$_[0]=~/^(Polar|Cartesian)$/},
  description => 'Plot type:',   description => 'Plot type:',
  edit_type   => 'choice',   edit_type   => 'choice',
          choices     => ['Polar','Cartesian']           choices     => ['Cartesian','Polar']
          },           },
      );       );
   
Line 652  sub start_title { Line 659  sub start_title {
     &Apache::edit::start_spanning_row().      &Apache::edit::start_spanning_row().
     &Apache::edit::editline('',$text,'',60);      &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my $text=$$parser[-1]->get_text("/title");  
  $result.=&Apache::edit::rebuild_tag($token);   $result.=&Apache::edit::rebuild_tag($token);
  $result.=&Apache::edit::modifiedfield($token);   $result.=&Apache::edit::modifiedfield("/title",$parser);
     }      }
     return $result;      return $result;
 }  }
Line 686  sub start_xlabel { Line 692  sub start_xlabel {
     &Apache::edit::start_spanning_row().      &Apache::edit::start_spanning_row().
     &Apache::edit::editline('',$text,'',60);      &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my $text=$$parser[-1]->get_text("/xlabel");  
  $result.=&Apache::edit::rebuild_tag($token);   $result.=&Apache::edit::rebuild_tag($token);
  $result.=&Apache::edit::modifiedfield($token);   $result.=&Apache::edit::modifiedfield("/xlabel",$parser);
     }      }
     return $result;      return $result;
 }  }
Line 721  sub start_ylabel { Line 726  sub start_ylabel {
     &Apache::edit::start_spanning_row().      &Apache::edit::start_spanning_row().
     &Apache::edit::editline('',$text,'',60);      &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my $text=$$parser[-1]->get_text("/ylabel");  
  $result.=&Apache::edit::rebuild_tag($token);   $result.=&Apache::edit::rebuild_tag($token);
  $result.=&Apache::edit::modifiedfield($token);   $result.=&Apache::edit::modifiedfield("/ylabel",$parser);
     }      }
     return $result;      return $result;
 }  }
Line 763  sub start_label { Line 767  sub start_label {
  &Apache::edit::get_new_args   &Apache::edit::get_new_args
     ($token,$parstack,$safeeval,keys(%label_defaults));      ($token,$parstack,$safeeval,keys(%label_defaults));
  $result.=&Apache::edit::rebuild_tag($token);   $result.=&Apache::edit::rebuild_tag($token);
  my $text=$$parser[-1]->get_text("/label");   $result.=&Apache::edit::modifiedfield("/label",$parser);
  $result.=&Apache::edit::modifiedfield($token);  
     }      }
     return $result;      return $result;
 }  }
Line 842  sub start_function { Line 845  sub start_function {
     &Apache::edit::editline('',$text,'',60);      &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  $result.=&Apache::edit::rebuild_tag($token);   $result.=&Apache::edit::rebuild_tag($token);
  my $text=$$parser[-1]->get_text("/function");   $result.=&Apache::edit::modifiedfield("/function",$parser);
  $result.=&Apache::edit::modifiedfield($token);  
     }      }
     return $result;      return $result;
 }  }
Line 920  sub start_data { Line 922  sub start_data {
     &Apache::edit::editline('',$text,'',60);      &Apache::edit::editline('',$text,'',60);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  $result.=&Apache::edit::rebuild_tag($token);   $result.=&Apache::edit::rebuild_tag($token);
  my $text=$$parser[-1]->get_text("/data");   $result.=&Apache::edit::modifiedfield("/data",$parser);
  $result.=&Apache::edit::modifiedfield($token);  
     }      }
     return $result;      return $result;
 }  }
Line 987  sub set_defaults { Line 988  sub set_defaults {
 sub get_attributes{  sub get_attributes{
     my ($values,$defaults,$parstack,$safeeval,$tag) = @_;      my ($values,$defaults,$parstack,$safeeval,$tag) = @_;
     foreach my $attr (keys(%{$defaults})) {      foreach my $attr (keys(%{$defaults})) {
  if ($attr eq 'texwidth') {   if ($attr eq 'texwidth' || $attr eq 'texfont') {
     $values->{$attr} =       $values->{$attr} = 
  &Apache::lonxml::get_param($attr,$parstack,$safeeval,undef,1);   &Apache::lonxml::get_param($attr,$parstack,$safeeval,undef,1);
  } else {   } else {
Line 1014  sub write_gnuplot_file { Line 1015  sub write_gnuplot_file {
     my ($tmpdir,$filename,$target)= @_;      my ($tmpdir,$filename,$target)= @_;
     my $gnuplot_input = '';      my $gnuplot_input = '';
     my $curve;      my $curve;
       my $pt = $plot{'texfont'};
     # Collect all the colors      # Collect all the colors
     my @Colors;      my @Colors;
     push @Colors, $plot{'bgcolor'};      push @Colors, $plot{'bgcolor'};
Line 1034  sub write_gnuplot_file { Line 1036  sub write_gnuplot_file {
  # set output   # set output
  $gnuplot_input .= "set output\n";   $gnuplot_input .= "set output\n";
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $gnuplot_input .= "set term postscript eps monochrome solid \"Helvetica\" 25 \n";   $gnuplot_input .= "set term postscript eps monochrome solid \"Helvetica\" $pt \n";
  $gnuplot_input .= "set output \"/home/httpd/perl/tmp/".   $gnuplot_input .= "set output \"/home/httpd/perl/tmp/".
     &Apache::lonnet::unescape($filename).".eps\"\n";      &Apache::lonnet::unescape($filename).".eps\"\n";
     }      }
Line 1055  sub write_gnuplot_file { Line 1057  sub write_gnuplot_file {
     # title, xlabel, ylabel      # title, xlabel, ylabel
     # titles      # titles
     if ($target eq 'tex') {      if ($target eq 'tex') {
         $gnuplot_input .= "set title  \"$title\" font \"Helvetica,25pt\"\n"  if (defined($title)) ;          $gnuplot_input .= "set title  \"$title\" font \"Helvetica,".$pt."pt\"\n"  if (defined($title)) ;
         $gnuplot_input .= "set xlabel \"$xlabel\" font \"Helvetica,25pt\" \n" if (defined($xlabel));          $gnuplot_input .= "set xlabel \"$xlabel\" font \"Helvetica,".$pt."pt\" \n" if (defined($xlabel));
         $gnuplot_input .= "set ylabel \"$ylabel\" font \"Helvetica,25pt\"\n" if (defined($ylabel));          $gnuplot_input .= "set ylabel \"$ylabel\" font \"Helvetica,".$pt."pt\"\n" if (defined($ylabel));
     } else {      } else {
         $gnuplot_input .= "set title  \"$title\"  \n"  if (defined($title)) ;          $gnuplot_input .= "set title  \"$title\"  \n"  if (defined($title)) ;
         $gnuplot_input .= "set xlabel \"$xlabel\" \n" if (defined($xlabel));          $gnuplot_input .= "set xlabel \"$xlabel\" \n" if (defined($xlabel));
Line 1103  sub write_gnuplot_file { Line 1105  sub write_gnuplot_file {
     my $label;      my $label;
     foreach $label (@labels) {      foreach $label (@labels) {
  $gnuplot_input .= 'set label "'.$label->{'text'}.'" at '.   $gnuplot_input .= 'set label "'.$label->{'text'}.'" at '.
     $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'}.' font "Helvetica,25pt"'.$/ ;      $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'}.' font "Helvetica,'.$pt.'pt"'.$/ ;
     }      }
     if ($target eq 'tex') {      if ($target eq 'tex') {
         $gnuplot_input .="set size 1,".$plot{'height'}/$plot{'width'}*1.38;          $gnuplot_input .="set size 1,".$plot{'height'}/$plot{'width'}*1.38;

Removed from v.1.91  
changed lines
  Added in v.1.94


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