]> git.sur5r.net Git - bacula/bacula/blobdiff - gui/bacula-web/bgraph.inc.php
bacula-web: Internal code inprovment in bgraph classe
[bacula/bacula] / gui / bacula-web / bgraph.inc.php
index 9ea23f3b3dd242f42d8adf63ed32c4dc8cf72300..7d77de5e4eb0379b774d2f1804b8753aeffb06c7 100644 (file)
@@ -18,10 +18,7 @@ class BGraph{
        
        function __construct( $filename = "graph.png" )
        {
-               if( !empty($filename) )
-                       $this->output_file = "graph.png";
-               else
-                       $this->output_file = $filename;
+               $this->output_file = 'templates_c/' . $filename;
        }
        
        public function SetData( $data_in, $type, $data_type, $shading = 5 )
@@ -65,8 +62,10 @@ class BGraph{
                $this->plot = new PHPlot( $this->width, $this->height );
                
                // Render to file instead of screen
-               $this->plot->SetIsInline( true );
                $this->plot->SetOutputFile( $this->output_file );
+               $this->plot->SetFileFormat("png");
+               $this->plot->SetIsInline( true );
+               
                
                $this->plot->SetImageBorderType('plain');
 
@@ -84,28 +83,38 @@ class BGraph{
                // 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 );
+               
+               // Legend position (calculated regarding the width and height of the graph)
+               $this->plot->SetLegendPixels( ($this->width / 2) + 10, 25 );
 
-               // Labels position
+               // Labels scale position
                if( $this->type == 'pie' )
                        $this->plot->SetLabelScalePosition( 0.2 );
                
                // Graph title
                $this->plot->SetTitle( $this->title );
 
-               //$this->plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration'));
                // Setting up legends
-               $legends = array();
-               foreach( $this->data as $key => $legend ) {
-                       $this->plot->SetLegend( implode(': ',$legend) );
+               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');
+               $this->plot->SetPlotAreaWorld(NULL, 0, NULL, NULL);
+
 
                $this->plot->DrawGraph();
        } // end function Render()
-}
+} // end BGraph classe
+
 /*
 class BGraph {
 
@@ -232,7 +241,7 @@ class BCreateGraph extends BGraph {
         
                 $this->StartDate = "1900-01-01";
                 $this->EndDate = "4000-01-01";
-                $this->elapsed = "86400";                   // 24 hours in seconds.
+                $this->elapsed = LAST_DAY;                   // 24 hours in seconds.
                 
          }