version 1.68, 2002/04/25 17:23:10
|
version 1.71, 2002/04/25 17:40:50
|
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[width=9.0 cm]{'.&Apache::lonnet::unescape($filename).'.eps}} \\\\'; |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
Line 1068 sub write_gnuplot_file {
|
Line 1068 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 1099 sub write_gnuplot_file {
|
Line 1099 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. |