Code

Fixed errors in graph generation
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 26 Aug 2010 11:22:37 +0000 (11:22 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 26 Aug 2010 11:22:37 +0000 (11:22 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19463 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/statistics/chartClasses/class_actionSelectChart.inc

index c70ad38305b1894ada4d076de8a75313401ff4ce..a983ab28a1f1b958f636ae95bb030a1887764d5d 100644 (file)
@@ -20,32 +20,39 @@ class actionSelectChart extends statChart
         $gData = $this->graphData;
         $dataSet = new pData;  
         $seriesCnt = 0;
+        $pCache = new pCache('/var/spool/gosa/');
 
-        if(!isset($gData['actionTypeGraph'][$this->current_action])){
-            $this->current_action = key($gData['actionTypeGraph']);
-        }
+        // Check if we've received data for the graph we've to render now.
+        $seriesValid = count($gData['actionTypeGraph']);
+        if($seriesValid){
 
-        $dataBase = $gData['actionTypeGraph'][$this->current_action];
-    
-        foreach($dataBase as $category => $entriesPerDate){
-            if(empty($category) || in_array($category, $this->skipSeries)) continue;
+            // Ensure that we've a valid action type selected.
+            if(!isset($gData['actionTypeGraph'][$this->current_action])){
+                $this->current_action = key($gData['actionTypeGraph']);
+            }
 
-            // Add results to our data set.
-            $dataSet->AddPoint($entriesPerDate, $category);
-            $dataSet->SetSerieName($this->getCategoryTranslation($category), $category);
-            $dataSet->AddSerie($category);
+            $dataBase = $gData['actionTypeGraph'][$this->current_action];
 
-            // Detect maximum value, to adjust the Y-Axis
-            $tmpMax = max($entriesPerDate);
-            if($tmpMax > $lineMax) $lineMax = $tmpMax;
-            $seriesCnt ++;
-        }
+            foreach($dataBase as $category => $entriesPerDate){
+                if(empty($category) || in_array($category, $this->skipSeries)) continue;
+
+                // Add results to our data set.
+                $dataSet->AddPoint($entriesPerDate, $category);
+                $dataSet->SetSerieName($this->getCategoryTranslation($category), $category);
+                $dataSet->AddSerie($category);
 
-        // Keep a list of all selecteable data-series, to allow the user to disable
-        //  or enable series on demand.
-        $this->seriesList = array();
-        foreach($dataBase as $key => $data){
-            $this->seriesList[$key] = $this->getCategoryTranslation($key); 
+                // Detect maximum value, to adjust the Y-Axis
+                $tmpMax = max($entriesPerDate);
+                if($tmpMax > $lineMax) $lineMax = $tmpMax;
+                $seriesCnt ++;
+            }
+
+            // Keep a list of all selecteable data-series, to allow the user to disable
+            //  or enable series on demand.
+            $this->seriesList = array();
+            foreach($dataBase as $key => $data){
+                $this->seriesList[$key] = $this->getCategoryTranslation($key); 
+            }
         }
 
         // Add timeline
@@ -53,7 +60,6 @@ class actionSelectChart extends statChart
         $dataSet->SetAbsciseLabelSerie('date');  
 
         // Read graph from cache?
-        $pCache = new pCache('/var/spool/gosa/');
         if($this->enableCaching && $pCache->IsInCache(get_class(),$dataSet->GetData())){
             $filename =  $pCache->GetHash(get_class(),$dataSet->GetData());
             $filename = '/var/spool/gosa/'.$filename;