--- loncom/xml/lonplot.pm 2002/01/03 22:09:49 1.31 +++ loncom/xml/lonplot.pm 2002/01/04 14:30:08 1.32 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.31 2002/01/03 22:09:49 matthew Exp $ +# $Id: lonplot.pm,v 1.32 2002/01/04 14:30:08 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,6 +72,9 @@ sub BEGIN { ## ## ################################################################### +my $max_str_len = 50; # if a label, title, xlabel, or ylabel text + # is longer than this, it will be truncated. + my %linestyles = ( lines => 2, # Maybe this will be used in the future @@ -382,6 +385,9 @@ sub start_title { my $result=''; if ($target eq 'web') { $title = &Apache::lonxml::get_all_text("/title",$$parser[-1]); + if (length($title) > $max_str_len) { + $title = substr($title,0,$max_str_len); + } } elsif ($target eq 'edit') { $result.=&Apache::edit::tag_start($target,$token,'Plot Title'); my $text=&Apache::lonxml::get_all_text("/title",$$parser[-1]); @@ -409,6 +415,9 @@ sub start_xlabel { my $result=''; if ($target eq 'web') { $xlabel = &Apache::lonxml::get_all_text("/xlabel",$$parser[-1]); + if (length($xlabel) > $max_str_len) { + $xlabel = substr($xlabel,0,$max_str_len); + } } elsif ($target eq 'edit') { $result.=&Apache::edit::tag_start($target,$token,'Plot Xlabel'); my $text=&Apache::lonxml::get_all_text("/xlabel",$$parser[-1]); @@ -437,6 +446,9 @@ sub start_ylabel { my $result=''; if ($target eq 'web') { $ylabel = &Apache::lonxml::get_all_text("/ylabel",$$parser[-1]); + if (length($ylabel) > $max_str_len) { + $ylabel = substr($ylabel,0,$max_str_len); + } } elsif ($target eq 'edit') { $result .= &Apache::edit::tag_start($target,$token,'Plot Ylabel'); my $text = &Apache::lonxml::get_all_text("/ylabel",$$parser[-1]); @@ -467,12 +479,9 @@ sub start_label { my %label; &get_attributes(\%label,\%label_defaults,$parstack,$safeeval, $tagstack->[-1]); - $label{'text'} = &Apache::lonxml::get_all_text("/label",$$parser[-1]); - $label{'text'} =~ s/[\-\:\`\'\"\,\.]//g; - if (! &$words_test($label{'text'})) { - # I should probably warn about it, too. - $label{'text'} = 'Illegal text'; - } + my $text = &Apache::lonxml::get_all_text("/label",$$parser[-1]); + $text = substr($text,0,$max_str_len) if (length($text) > $max_str_len); + $label{'text'} = $text; push(@labels,\%label); } elsif ($target eq 'edit') { $result .= &Apache::edit::tag_start($target,$token,'Plot Label');