]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Improved code in CGraph class
authorDavide Franco <bacula-dev@dflc.ch>
Sun, 24 Jul 2011 10:25:05 +0000 (12:25 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:27 +0000 (14:49 +0200)
 - Changed angle for X axis with bars graph

gui/bacula-web/includes/graph/cgraph.class.php

index 255931aa0ef9678b74bd4f12ee394f24ad12e538..e710306494cab171cadb7659f8537e7ec12185be 100644 (file)
@@ -106,29 +106,28 @@ class CGraph{
                // Image border
                $this->plot->SetImageBorderType( 'none' );
 
-               // Plot area (calculated regarding the width and height of the graph)
-               if( $this->type == 'pie' )
-                       $this->plot->SetPlotAreaPixels( 10, 10, ($this->width / 2), $this->height-10 );
+               switch( $this->type )
+               {
+                       case 'pie':
+                               $this->plot->SetPlotAreaPixels( 10, 10, ($this->width / 2), $this->height-10 );
+                               $this->plot->SetLabelScalePosition( 0.2 );
+                               
+                               $legends = array();
+                               foreach( $this->data as $key => $legend )
+                                       $this->plot->SetLegend( implode(': ',$legend) );
+                       break;
+                       case 'bars':
+                               $this->plot->SetXLabelAngle(90);
+                       break;
+               }
                
                // Legend position (calculated regarding the width and height of the graph)
                $this->plot->SetLegendPixels( ($this->width / 2) + 10, 25 );
-
-               // Labels scale position
-               if( $this->type == 'pie' )
-                       $this->plot->SetLabelScalePosition( 0.2 );
                
                // Graph title
                $this->plot->SetTitle( $this->title );
                $this->plot->SetYTitle( $this->ytitle );
 
-               // Setting up legends
-               if( $this->type != 'bars' ) {
-                       $legends = array();
-                       foreach( $this->data as $key => $legend ) {
-                               $this->plot->SetLegend( implode(': ',$legend) );
-                       }
-               }
-
                # Turn off X tick labels and ticks because they don't apply here:
                $this->plot->SetXTickLabelPos('none');
                $this->plot->SetXTickPos('none');
@@ -138,5 +137,4 @@ class CGraph{
                $this->plot->DrawGraph();
        } // end function Render()
 } // end BGraph classe
-
 ?>