[LON-CAPA-cvs] cvs: loncom /xml lonplot.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 05 Dec 2007 23:22:22 -0000


albertel		Wed Dec  5 18:22:22 2007 EDT

  Modified files:              
    /loncom/xml	lonplot.pm 
  Log:
  - Phil Fazio fix to BUG#2137, add ability to control formatting of axes numbers
  
  
  
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.131 loncom/xml/lonplot.pm:1.132
--- loncom/xml/lonplot.pm:1.131	Tue Oct  9 18:11:51 2007
+++ loncom/xml/lonplot.pm	Wed Dec  5 18:22:18 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.131 2007/10/09 22:11:51 albertel Exp $
+# $Id: lonplot.pm,v 1.132 2007/12/05 23:22:18 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -435,7 +435,7 @@
 	 },         
      );
 
-my @axis_edit_order = ('color','xmin','xmax','ymin','ymax');
+my @axis_edit_order = ('color','xmin','xmax','ymin','ymax','xformat', 'yformat');
 my %axis_defaults = 
     (
      color   => {
@@ -472,7 +472,22 @@
 	 description => 'Maximum y-value shown in plot',	 
 	 edit_type   => 'entry',
 	 size        => '10'
-	 }
+        },
+     xformat      => {
+         default     => 'on',
+         test        => sub {$_[0]=~/^(on|off|\d+(f|F|e|E))$/},
+         description => 'X-axis number formatting',
+         edit_type   => 'choice',
+         choices     => ['on', 'off', '2e', '2f'],
+         },
+     yformat      => {
+         default     => 'on',
+         test        => sub {$_[0]=~/^(on|off|\d+(f|F|e|E))$/},
+         description => 'X-axis number formatting',
+         edit_type   => 'choice',
+         choices     => ['on', 'off', '2e', '2f'],
+         },
+
      );
 
 my @curve_edit_order = ('color','name','linestyle','linewidth','pointtype','pointsize','limit');
@@ -1321,6 +1336,22 @@
     }
     # axis
     if (%axis) {
+        if ($axis{'xformat'} ne 'on') {
+            $gnuplot_input .= "set format x ";
+            if ($axis{'xformat'} eq 'off') {
+                $gnuplot_input .= "\"\"\n";
+            } else {
+                $gnuplot_input .= "\"\%.".$axis{'xformat'}."\"\n";
+            }
+        }
+        if ($axis{'yformat'} ne 'on') {
+            $gnuplot_input .= "set format y ";
+            if ($axis{'yformat'} eq 'off') {
+                $gnuplot_input .= "\"\"\n";
+            } else {
+                $gnuplot_input .= "\"\%.".$axis{'yformat'}."\"\n";
+            }
+        }
 	$gnuplot_input .= "set xrange \[$axis{'xmin'}:$axis{'xmax'}\]\n";
 	$gnuplot_input .= "set yrange \[$axis{'ymin'}:$axis{'ymax'}\]\n";
     }