Format numbers on the graph selectively
authorBen Klang <ben@alkaloid.net>
Tue, 8 Jul 2008 14:26:12 +0000 (14:26 +0000)
committerBen Klang <ben@alkaloid.net>
Sun, 10 Jan 2010 04:05:28 +0000 (23:05 -0500)
graphgen.php
lib/Operator.php

index 46f44d1..0ef99c5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * $Horde: incubator/operator/graphgen.php,v 1.5 2008/07/08 14:19:11 bklang Exp $
+ * $Horde: incubator/operator/graphgen.php,v 1.6 2008/07/08 14:26:12 bklang Exp $
  *
  * Copyright 2008 The Horde Project <http://www.horde.org>
  *
@@ -17,7 +17,7 @@ require_once OPERATOR_BASE . '/lib/base.php';
 require_once 'Image/Graph.php';
 
 $graphtype = Util::getFormData('graph');
-$graphInfo = Operator::getGraphInfo($graphtype);
+$graphinfo = Operator::getGraphInfo($graphtype);
 $cachekey = Util::getFormData('key');
 
 $stats = unserialize($cache->get($cachekey, 0));
@@ -42,7 +42,7 @@ if (!empty($conf['ttf_font'])) {
 // create the plotarea layout
 $graph->add(
     Image_Graph::vertical(
-        Image_Graph::factory('title', array($graphInfo['title'], 11)),
+        Image_Graph::factory('title', array($graphinfo['title'], 11)),
         #Image_Graph::vertical(
             $plotarea = Image_Graph::factory('plotarea'),
         #    $legend = Image_Graph::factory('legend'),
@@ -86,7 +86,9 @@ $marker->setFillColor(false);
 // and use the marker on the 1st plot
 $plot1->setMarker($PointingMarker); 
 
-$marker->setDataPreProcessor(Image_Graph::factory('Image_Graph_DataPreProcessor_Formatted', '%0.1f'));
+if (!empty($graphinfo['numberformat'])) {
+    $marker->setDataPreProcessor(Image_Graph::factory('Image_Graph_DataPreProcessor_Formatted', $graphinfo['numberformat']));
+}
 $marker->setFontSize(6.5);
  
 // create an area plot using a random dataset
@@ -102,9 +104,9 @@ $marker->setFontSize(6.5);
 #$plot2->setTitle('Secondary Axis');
  
 $axisX =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
-$axisX->setTitle($graphInfo['axisX']);
+$axisX->setTitle($graphinfo['axisX']);
 $axisY =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
-$axisY->setTitle($graphInfo['axisY'], 'vertical'); 
+$axisY->setTitle($graphinfo['axisY'], 'vertical'); 
 #$axisYsecondary =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
 #$axisYsecondary->setTitle('Pears', 'vertical2'); 
  
index 7ec58d3..b9e5dc3 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Operator Base Class.
  *
- * $Horde: incubator/operator/lib/Operator.php,v 1.9 2008/07/06 18:21:50 bklang Exp $
+ * $Horde: incubator/operator/lib/Operator.php,v 1.10 2008/07/08 14:26:12 bklang Exp $
  *
  * Copyright 2008 The Horde Project <http://www.horde.org/>
  *
@@ -147,6 +147,7 @@ class Operator {
                 'title' => _("Total Minutes Used by Month"),
                 'axisX' => _("Month"),
                 'axisY' => _("Minute"),
+                'numberformat' => '%0.1f',
             );
             break;
          case 'failed':