version 1.17, 2001/12/21 22:45:47
|
version 1.19, 2001/12/27 19:47:02
|
Line 34 use Apache::File;
|
Line 34 use Apache::File;
|
use Apache::response; |
use Apache::response; |
use Apache::lonxml; |
use Apache::lonxml; |
|
|
use Digest::MD5 qw(md5_base64); |
|
|
|
sub BEGIN { |
sub BEGIN { |
&Apache::lonxml::register('Apache::lonplot',('plot')); |
&Apache::lonxml::register('Apache::lonplot',('plot')); |
} |
} |
Line 53 sub BEGIN {
|
Line 51 sub BEGIN {
|
## grid |
## grid |
## border |
## border |
## font |
## font |
|
## align |
## |
## |
## @labels: $labels[$i] = \%label |
## @labels: $labels[$i] = \%label |
## %label: text, xpos, ypos, justify |
## %label: text, xpos, ypos, justify |
Line 68 sub BEGIN {
|
Line 67 sub BEGIN {
|
## Tests used in checking the validitity of input |
## Tests used in checking the validitity of input |
## |
## |
my $int_test = sub {$_[0]=~s/\s+//g;$_[0]=~/^\d+$/}; |
my $int_test = sub {$_[0]=~s/\s+//g;$_[0]=~/^\d+$/}; |
my $real_test = sub {$_[0]=~s/\s+//g;$_[0]=~/^[+-]?\d*\.?\d*$/}; |
my $real_test = |
|
sub {$_[0]=~s/\s+//g;$_[0]=~/^[+-]?\d*\.?\d*([eE][+-]\d+)?$/}; |
my $color_test = sub {$_[0]=~s/\s+//g;$_[0]=~/^x[\da-f]{6}$/}; |
my $color_test = sub {$_[0]=~s/\s+//g;$_[0]=~/^x[\da-f]{6}$/}; |
my $onoff_test = sub {$_[0]=~/^(on|off)$/}; |
my $onoff_test = sub {$_[0]=~/^(on|off)$/}; |
my $key_pos_test = sub {$_[0]=~/^(top|bottom|right|left|outside|below| )+$/}; |
my $key_pos_test = sub {$_[0]=~/^(top|bottom|right|left|outside|below| )+$/}; |
Line 88 my %plot_defaults =
|
Line 88 my %plot_defaults =
|
grid => {default => 'off', test => $onoff_test }, |
grid => {default => 'off', test => $onoff_test }, |
border => {default => 'on', test => $onoff_test }, |
border => {default => 'on', test => $onoff_test }, |
font => {default => 'medium', test => $sml_test }, |
font => {default => 'medium', test => $sml_test }, |
align => {default => 'left', test => $words_test } |
align => {default => 'left', test => |
|
sub {$_[0]=~/^(left|right|center)$/} } |
); |
); |
|
|
my %key_defaults = |
my %key_defaults = |
Line 365 sub start_data {
|
Line 366 sub start_data {
|
delete($curves[-1]->{'function'}); |
delete($curves[-1]->{'function'}); |
} |
} |
my $datatext = &Apache::lonxml::get_all_text("/data",$$parser[-1]); |
my $datatext = &Apache::lonxml::get_all_text("/data",$$parser[-1]); |
&Apache::lonxml::warning( |
|
' Length of data string: '.length($datatext)); |
|
$datatext =~ s/\s+/ /g; |
$datatext =~ s/\s+/ /g; |
if ($datatext !~ /^(([+-]?\d*\.?\d*)[, ]?)+$/) { |
|
&Apache::lonxml::warning('Malformed data: '.$datatext); |
|
$datatext = ''; |
|
} |
|
# Need to do some error checking on the @data array - |
# Need to do some error checking on the @data array - |
# make sure it's all numbers and make sure each array |
# make sure it's all numbers and make sure each array |
# is of the same length. |
# is of the same length. |
Line 381 sub start_data {
|
Line 376 sub start_data {
|
} else { # Assume it's space seperated. |
} else { # Assume it's space seperated. |
@data = split / /,$datatext; |
@data = split / /,$datatext; |
} |
} |
&Apache::lonxml::warning(' Data Points: '.$#data); |
|
for (my $i=0;$i<=$#data;$i++) { |
for (my $i=0;$i<=$#data;$i++) { |
# Check that it's non-empty |
# Check that it's non-empty |
|
if (! defined($data[$i])) { |
|
&Apache::lonxml::warning( |
|
'undefined <data> value. Replacing with '. |
|
' pi/e = 1.15572734979092'); |
|
$data[$i] = 1.15572734979092; |
|
} |
# Check that it's a number |
# Check that it's a number |
# Maybe I need a 'debug=on' switch to list the data set |
if (! &$real_test($data[$i]) & ! &$int_test($data[$i])) { |
# out in a warning? |
&Apache::lonxml::warning( |
|
'Bad <data> value of '.$data[$i].' Replacing with '. |
|
' pi/e = 1.15572734979092'); |
|
$data[$i] = 1.15572734979092; |
|
} |
} |
} |
push @{$curves[-1]->{'data'}},\@data; |
push @{$curves[-1]->{'data'}},\@data; |
# This routine should never return anything. |
# This routine should never return anything. |
Line 441 sub get_attributes{
|
Line 445 sub get_attributes{
|
my $parstack = shift; |
my $parstack = shift; |
my $safeeval = shift; |
my $safeeval = shift; |
my $tag = shift; |
my $tag = shift; |
my $attr; |
foreach my $attr (keys %{$defaults}) { |
foreach $attr (keys %{$defaults}) { |
|
$values->{$attr} = |
$values->{$attr} = |
&Apache::lonxml::get_param($attr,$parstack,$safeeval); |
&Apache::lonxml::get_param($attr,$parstack,$safeeval); |
if ($values->{$attr} eq '' | !defined($values->{$attr})) { |
if ($values->{$attr} eq '' | !defined($values->{$attr})) { |