version 1.68, 2002/04/25 17:23:10
|
version 1.73, 2002/04/25 21:33:52
|
Line 484 sub end_gnuplot {
|
Line 484 sub end_gnuplot {
|
## Determine filename |
## Determine filename |
my $tmpdir = '/home/httpd/perl/tmp/'; |
my $tmpdir = '/home/httpd/perl/tmp/'; |
my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. |
my $filename = $ENV{'user.name'}.'_'.$ENV{'user.domain'}. |
'_'.time.'_'.$$.$randnumber.'_plot.data'; |
'_'.time.'_'.$$.$randnumber.'_plot'; |
## Write the plot description to the file |
## Write the plot description to the file |
&write_gnuplot_file($tmpdir,$filename,$target); |
&write_gnuplot_file($tmpdir,$filename,$target); |
$filename = &Apache::lonnet::escape($filename); |
$filename = &Apache::lonnet::escape($filename); |
## return image tag for the plot |
## return image tag for the plot |
if ($target eq 'web') { |
if ($target eq 'web') { |
$result .= <<"ENDIMAGE"; |
$result .= <<"ENDIMAGE"; |
<img src = "/cgi-bin/plot.gif?file=$filename&output=gif" |
<img src = "/cgi-bin/plot.gif?file=$filename.data&output=gif" |
width = "$plot{'width'}" |
width = "$plot{'width'}" |
height = "$plot{'height'}" |
height = "$plot{'height'}" |
align = "$plot{'align'}" |
align = "$plot{'align'}" |
alt = "$plot{'alttag'}" /> |
alt = "$plot{'alttag'}" /> |
ENDIMAGE |
ENDIMAGE |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
&Apache::lonnet::ssi("/cgi-bin/plot.gif?file=$filename&output=eps"); |
&Apache::lonnet::ssi("/cgi-bin/plot.gif?file=$filename.data&output=eps"); |
$result = '\\\\ \graphicspath{/home/httpd/perl/tmp/}\fbox{\includegraphics[width=9.0 cm]{'.&Apache::lonnet::unescape($filename).'.eps}} \\\\'; |
$result = '\graphicspath{{/home/httpd/perl/tmp/}}\fbox{\includegraphics{'.&Apache::lonnet::unescape($filename).'.eps}}'; |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_end($target,$token); |
$result.=&Apache::edit::tag_end($target,$token); |
Line 1050 sub write_gnuplot_file {
|
Line 1050 sub write_gnuplot_file {
|
$gnuplot_input.= |
$gnuplot_input.= |
$curve->{'function'}.' title "'. |
$curve->{'function'}.' title "'. |
$curve->{'name'}.'" with '. |
$curve->{'name'}.'" with '. |
$curve->{'linestyle'}; |
$curve->{'linestyle'}; |
# |
$gnuplot_input.= ' linewidth 4 ' if ($target eq 'tex'); |
# gnuplot's term=gif driver does not handle linewidths :( |
|
# . ' linewidth '. $curve->{'linewidth'}; |
|
# |
|
if (($curve->{'linestyle'} eq 'points') || |
if (($curve->{'linestyle'} eq 'points') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'errorbars') || |
($curve->{'linestyle'} eq 'errorbars') || |
Line 1068 sub write_gnuplot_file {
|
Line 1065 sub write_gnuplot_file {
|
# Store data values in $datatext |
# Store data values in $datatext |
my $datatext = ''; |
my $datatext = ''; |
# get new filename |
# get new filename |
my $datafilename = "$tmpdir/$filename.$i"; |
my $datafilename = "$tmpdir/$filename.data.$i"; |
my $fh=Apache::File->new(">$datafilename"); |
my $fh=Apache::File->new(">$datafilename"); |
# Compile data |
# Compile data |
my @Data = @{$curve->{'data'}}; |
my @Data = @{$curve->{'data'}}; |
Line 1087 sub write_gnuplot_file {
|
Line 1084 sub write_gnuplot_file {
|
$gnuplot_input.= '"'.$datafilename.'" title "'. |
$gnuplot_input.= '"'.$datafilename.'" title "'. |
$curve->{'name'}.'" with '. |
$curve->{'name'}.'" with '. |
$curve->{'linestyle'}; |
$curve->{'linestyle'}; |
|
$gnuplot_input.= ' linewidth 4 ' if ($target eq 'tex'); |
if (($curve->{'linestyle'} eq 'points') || |
if (($curve->{'linestyle'} eq 'points') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'linespoints') || |
($curve->{'linestyle'} eq 'errorbars') || |
($curve->{'linestyle'} eq 'errorbars') || |
Line 1099 sub write_gnuplot_file {
|
Line 1097 sub write_gnuplot_file {
|
} |
} |
} |
} |
# Write the output to a file. |
# Write the output to a file. |
my $fh=Apache::File->new(">$tmpdir$filename"); |
my $fh=Apache::File->new(">$tmpdir$filename.data"); |
print $fh $gnuplot_input; |
print $fh $gnuplot_input; |
close($fh); |
close($fh); |
# That's all folks. |
# That's all folks. |