Code

Prepared statistics to show error count in graph
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Aug 2010 09:30:24 +0000 (09:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Aug 2010 09:30:24 +0000 (09:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19406 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/statistics/class_statistics.inc

index 3f69ca1dfa9bc242d54a9d8ccd4bb318270105a1..ecd85d9a9a0487c8b8d460652130ffe9637d8246 100644 (file)
@@ -91,7 +91,6 @@ class statistics extends plugin
 
                 if($res){
 
-
                     // Include pChart 
                     new pChartInclude();
 
@@ -149,7 +148,7 @@ class statistics extends plugin
 
                             // Do not append empty data                            
                             if(empty($category)) continue;
-                            if($count) $count = log($count);
+                            if($count) $count = ($count);
                             $dataArray[$category][$date] = $count;
                         }
                       
@@ -170,8 +169,6 @@ class statistics extends plugin
                     }
                     ksort($dates);
 
-
-
                     $DataSet2->AddAllSeries();  
 
                     // Prepare date strings for X-Axis, only print a given number of 
@@ -192,14 +189,14 @@ class statistics extends plugin
                     $DataSet2->SetAbsciseLabelSerie('date');  
                     $DataSet2->RemoveSerie('date');  
 
-                    $Test2 = new pChart(700,230);  
-                    $Test2->setFixedScale(0.0001,$max);  
+                    $Test2 = new pChart(800,230);  
+                    $Test2->setFixedScale(0.0001,($max*1.1));  
                     $Test2->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10);  
                     $Test2->setGraphArea(50,30,585,200);  
                     $Test2->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);  
                     $Test2->drawRoundedRectangle(5,5,695,225,5,230,230,230);  
                     $Test2->drawGraphArea(255,255,255,TRUE);  
-                    $Test2->drawGrid(4,TRUE,230,230,230,50);  
+                    $Test2->drawGrid(4,TRUE,200,200,200,50);  
                     $Test2->drawTreshold(0,143,55,72,TRUE,TRUE);  
                     $Test2->drawTitle(50,22,"Plugin usage over time",50,50,50,585);  
 
@@ -208,12 +205,38 @@ class statistics extends plugin
                         $DataSet2->RemoveSerie('date');
                     }
 
+
                     // Draw the cubic curve graph  
                     if(count($dataArray)){
                         $Test2->drawFilledLineGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),50,TRUE);
-                        $Test2->drawLegend(600,30,$DataSet2->GetDataDescription(),255,255,255);  
                     }
 
+                    // Add error series
+                    $errors = array();
+                    foreach($res['errorsPerInterval'] as $dateStr => $count){
+                        $date = strtotime($dateStr);
+                        if($count !=0) $count = ($count);
+                        $errors[$date] = $count;
+                    }
+
+                    $DataSet2->AddPoint($errors, 'Errors');
+                    $DataSet2->SetSerieName('Errors', 'Errors');
+                    $DataSet2->AddAllSeries();  
+                    $DataSet2->RemoveSerie('date');
+
+                    // Draw legend
+                    $Test2->drawLegend(650,30,$DataSet2->GetDataDescription(),255,255,255);  
+
+                    // Remove plugin usage from data series, just keep error series.
+                    foreach($dataArray as $categoryName => $list){
+                        $DataSet2->RemoveSerie($categoryName);
+                    }
+    
+                    // Draw right scale (Errors per day)
+                    $Test2->setFixedScale(0.0001,(max($errors) +1) *1.1);
+                    $Test2->drawRightScale($DataSet2->GetData(),$DataSet2->GetDataDescription(),SCALE_NORMAL,120,150,150,TRUE,0,2);
+                    $Test2->drawBarGraph($DataSet2->GetData(),$DataSet2->GetDataDescription(),TRUE);
+
                     $file = '/tmp/graph_'.$this->graphID_2;
                     $Test2->Render($file);
                     session::set('statistics::graphFile'.$this->graphID_2,$file);