--- loncom/xml/lonplot.pm 2002/03/22 14:48:00 1.59 +++ loncom/xml/lonplot.pm 2002/03/22 16:04:09 1.61 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Dynamic plot # -# $Id: lonplot.pm,v 1.59 2002/03/22 14:48:00 matthew Exp $ +# $Id: lonplot.pm,v 1.61 2002/03/22 16:04:09 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -91,10 +91,6 @@ my %linestyles = yerrorbars => [3,4], xyerrorbars => [4,6], boxes => 3, -# boxerrorbars => [3,4,5], -# boxxyerrorbars => [4,6,7], -# financebars => 5, -# candlesticks => 5, vector => 4 ); @@ -371,6 +367,8 @@ is an error in your function tag. ENDCURVEHELP +my @curve_edit_order = ('color','name','linestyle','pointsize'); + my %curve_defaults = ( color => { @@ -393,7 +391,22 @@ my %curve_defaults = description => 'Line style', edit_type => 'choice', choices => [keys(%linestyles)] - } + }, +# gnuplots term=gif driver does not handle linewidth :( +# linewidth => { +# default => 1, +# test => $int_test, +# description => 'Line width (may not apply to all line styles)', +# edit_type => 'choice', +# choices => [1,2,3,4,5,6,7,8,9,10] +# }, + pointsize => { + default => 1, + test => $int_test, + description => 'point size (may not apply to all line styles)', + edit_type => 'choice', + choices => [0,1,2,3,4,5,6,7,8,9,10] + } ); ################################################################### @@ -731,7 +744,8 @@ sub start_curve { } elsif ($target eq 'edit') { $result .= &Apache::edit::tag_start($target,$token,'Curve'); $result .= &help_win($curve_help_text); - $result .= &edit_attributes($target,$token,\%curve_defaults); + $result .= &edit_attributes($target,$token,\%curve_defaults, + \@curve_edit_order); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args ($token,$parstack,$safeeval,keys(%curve_defaults)); @@ -1018,6 +1032,18 @@ sub write_gnuplot_file { $curve->{'function'}.' title "'. $curve->{'name'}.'" with '. $curve->{'linestyle'}; +# +# gnuplot's term=gif driver does not handle linewidths :( +# . ' linewidth '. $curve->{'linewidth'}; +# + if (($curve->{'linestyle'} eq 'points') || + ($curve->{'linestyle'} eq 'linespoints') || + ($curve->{'linestyle'} eq 'errorbars') || + ($curve->{'linestyle'} eq 'xerrorbars') || + ($curve->{'linestyle'} eq 'yerrorbars') || + ($curve->{'linestyle'} eq 'xyerrorbars')) { + $gnuplot_input.=' pointsize '.$curve->{'pointsize'}; + } } elsif (exists($curve->{'data'})) { # Store data values in $datatext my $datatext = ''; @@ -1114,11 +1140,11 @@ sub edit_attributes { sub insert_gnuplot { my $result = ''; # plot attributes - $result .= "{'default'}\"\n"; + $result .= "\n $attr=\"$gnuplot_defaults{$attr}->{'default'}\""; } - $result .= ">\n"; + $result .= ">"; # Add the components (most are commented out for simplicity) # $result .= &insert_key(); # $result .= &insert_axis(); @@ -1127,7 +1153,7 @@ sub insert_gnuplot { # $result .= &insert_ylabel(); $result .= &insert_curve(); # close up the - $result .= "\n"; + $result .= "\n"; return $result; } @@ -1141,9 +1167,9 @@ sub insert_xtics { my $result; $result .= "\n {'default'}\" "; + $result .= "\n $attr=\"$tic_defaults{$attr}->{'default'}\" "; } - $result .= "/>\n"; + $result .= "/>"; return $result; } @@ -1151,19 +1177,19 @@ sub insert_ytics { my $result; $result .= "\n {'default'}\" "; + $result .= "\n $attr=\"$tic_defaults{$attr}->{'default'}\" "; } - $result .= "/>\n"; + $result .= "/>"; return $result; } sub insert_key { my $result; - $result .= "\n {'default'}\"\n"; + $result .= "\n $attr=\"$key_defaults{$attr}->{'default'}\""; } - $result .= " />\n"; + $result .= " />"; return $result; } @@ -1171,24 +1197,24 @@ sub insert_axis{ my $result; $result .= "\n {'default'}\"\n"; + $result .= "\n $attr=\"$axis_defaults{$attr}->{'default'}\""; } - $result .= " />\n"; + $result .= " />"; return $result; } -sub insert_title { return "\n \n"; } -sub insert_xlabel { return "\n \n"; } -sub insert_ylabel { return "\n \n"; } +sub insert_title { return "\n "; } +sub insert_xlabel { return "\n "; } +sub insert_ylabel { return "\n "; } sub insert_label { my $result; $result .= "\n \n"; + $result .= ">"; return $result; } @@ -1196,22 +1222,22 @@ sub insert_curve { my $result; $result .= "\n {'default'}."\""; } - $result .= " >\n"; - $result .= &insert_data().&insert_data()."\n"; + $result .= " >"; + $result .= &insert_data().&insert_data()."\n "; } sub insert_function { my $result; - $result .= "\n"; + $result .= "\n "; return $result; } sub insert_data { my $result; - $result .= " \n"; + $result .= "\n "; return $result; }