version 1.51, 2002/02/27 22:10:23
|
version 1.57, 2002/03/14 21:44:37
|
Line 29
|
Line 29
|
# 12/17 12/18 12/19 12/20 12/21 12/27 12/28 12/30 12/31 Matthew |
# 12/17 12/18 12/19 12/20 12/21 12/27 12/28 12/30 12/31 Matthew |
# 01/01/02 Matthew |
# 01/01/02 Matthew |
# 01/02 01/03 01/04 01/07 01/08 01/09 Matthew |
# 01/02 01/03 01/04 01/07 01/08 01/09 Matthew |
# 01/21 02/05 02/06 Matthew |
# 01/21 02/05 02/06 2/28Matthew |
|
|
package Apache::lonplot; |
package Apache::lonplot; |
|
|
Line 144 A <b>gnuplot</b> tag can contain the fol
|
Line 144 A <b>gnuplot</b> tag can contain the fol
|
<dd> Allows specification of the x and y coordinate 'tics' on the axes. |
<dd> Allows specification of the x and y coordinate 'tics' on the axes. |
This is mostly used to adjust the grid lines when a grid is displayed. |
This is mostly used to adjust the grid lines when a grid is displayed. |
</dl> |
</dl> |
|
If you are having trouble with your plot, please read the help |
|
available on Plot Curve. |
ENDPLOTHELP |
ENDPLOTHELP |
|
|
my %gnuplot_defaults = |
my %gnuplot_defaults = |
Line 360 first tag will be the X data and the sec
|
Line 362 first tag will be the X data and the sec
|
</p> |
</p> |
<dt> Curve Function |
<dt> Curve Function |
<dd> The <b>function</b> tag allows you to specify the curve to be |
<dd> The <b>function</b> tag allows you to specify the curve to be |
plotted as a formula that gnuplot can understand. Be careful using this |
plotted as a formula that gnuplot can understand. <b>Be careful using this |
tag - it is surprisingly easy to give gnuplot a function it cannot deal |
tag.</b> It is surprisingly easy to give gnuplot a function it cannot deal |
with properly. Be explicit: 2*sin(2*3.141592*x/4) will work but |
with properly. Be explicit: 2*sin(2*3.141592*x/4) will work but |
2sin(2*3.141592x/4) will not. If you do not receive any errors in the |
2sin(2*3.141592x/4) will not. If you do not receive any errors in the |
gnuplot data but still do not have an image produced, it is likely there |
gnuplot data but still do not have an image produced, it is likely there |
Line 441 sub end_gnuplot {
|
Line 443 sub end_gnuplot {
|
&Apache::lonxml::deregister('Apache::lonplot', |
&Apache::lonxml::deregister('Apache::lonplot', |
('title','xlabel','ylabel','key','axis','label','curve')); |
('title','xlabel','ylabel','key','axis','label','curve')); |
my $result = ''; |
my $result = ''; |
|
my $randnumber; |
|
# need to call rand everytime start_script would evaluate, as the |
|
# safe space rand number generator and the global rand generator |
|
# are not seperate |
|
if ($target eq 'web' || $target eq 'tex' || $target eq 'grade' || |
|
$target eq 'answer') { |
|
$randnumber=int(rand(1000)); |
|
} |
if ($target eq 'web' || $target eq 'tex') { |
if ($target eq 'web' || $target eq 'tex') { |
&check_inputs(); # Make sure we have all the data we need |
&check_inputs(); # Make sure we have all the data we need |
## |
## |
## 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.'_'.$$.int(rand(1000)).'_plot.data'; |
'_'.time.'_'.$$.$randnumber.'_plot.data'; |
## 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); |
## 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?$filename" |
<img src = "/cgi-bin/plot.gif?file=$filename&output=gif" |
width = "$plot{'width'}" |
width = "$plot{'width'}" |
height = "$plot{'height'}" |
height = "$plot{'height'}" |
align = "$plot{'align'}" |
align = "$plot{'align'}" |
alt = "image should be /cgi-bin/plot.gif?$filename" /> |
alt = "image should be /cgi-bin/plot.gif?$filename" /> |
ENDIMAGE |
ENDIMAGE |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
|
&Apache::lonnet::ssi('cgi-bin/plot.gif?file=$filename'. |
|
'&output=eps'); |
$result = "$filename.eps"; |
$result = "$filename.eps"; |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |