From: hickert Date: Mon, 23 Aug 2010 15:24:04 +0000 (+0000) Subject: Added a new pie chart which show the used actions X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9b23eb73ae8285d7cfaf9c3199c02c911ab81bef;p=gosa.git Added a new pie chart which show the used actions git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19429 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/generic/statistics/class_statistics.inc b/gosa-core/plugins/generic/statistics/class_statistics.inc index cc43dc124..677b0b24f 100644 --- a/gosa-core/plugins/generic/statistics/class_statistics.inc +++ b/gosa-core/plugins/generic/statistics/class_statistics.inc @@ -274,6 +274,8 @@ class statistics extends plugin } } + // Get action usage, to be able to render a pie chart about most done actions. + $gData['actionsPerPluginAction'] = $res['actionsPerPluginAction']; return($gData); } @@ -341,9 +343,8 @@ class statistics extends plugin if(!count($gData)){ return; } - if(count($gData['actionsPerCategory'])){ - $this->generateCategoryPieGraph($gData['actionsPerCategory']); - } + $this->generateCategoryPieGraph($gData['actionsPerCategory'], 1, _("Plugin usage")); + $this->generateCategoryPieGraph($gData['actionsPerPluginAction'], 7,_("Actions")); $this->generateActionsGraph($gData); // Generate graph which displays the memory usage over time @@ -514,21 +515,33 @@ class statistics extends plugin /*! \brief Generate the pie-chart which displays the overall-plugin-usage */ - function generateCategoryPieGraph($data) + function generateCategoryPieGraph($data, $gID, $title) { + $this->graphIDs[$gID] = 0; + if(!count($data)) return; + // Sort data by usage count and slice array to get // the eight most used categories - $gID = 1; arsort($data); - $mostUsedCategories = array_slice($data,0,7); + + // Detect max value and throw out entries less than 1% + // the will else be unreadable + $max = max($data); + $pos = 0; + foreach($data as $key => $count){ + if($pos >=7 || ($count / $max)*100 < 1) break; + $pos ++; + } + + $dataRes = array_slice($data,0,$pos); // Get the rest of categories and combine them 'others' - $theRest = array_slice($data,7); - $mostUsedCategories['remaining'] = array_sum($theRest); + $theRest = array_slice($data,$pos); + $dataRes['remaining'] = array_sum($theRest); // Try to find a translation for the given category names - $values = array_values($mostUsedCategories); - $keys = array_keys($mostUsedCategories); + $values = array_values($dataRes); + $keys = array_keys($dataRes); foreach($keys as $id => $cat){ $keys[$id] = $this->getCategoryTranslation($cat); } @@ -547,7 +560,7 @@ class statistics extends plugin // Initialise the graph $chart = new pChart($x,$y); $chart->setFontProperties($this->font,10); - $chart->drawPieGraph($dataSet->GetData(),$dataSet->GetDataDescription(),($x/3),($y/2)-10,($y/2),PIE_PERCENTAGE,TRUE,50,20,3); + $chart->drawPieGraph($dataSet->GetData(),$dataSet->GetDataDescription(),($x/3),($y/2)-10,($y/2),PIE_PERCENTAGE,TRUE,50,20,6); $chart->drawPieLegend(($x/3*2),15,$dataSet->GetData(),$dataSet->GetDataDescription(), $this->legendR,$this->legendG,$this->legendB); diff --git a/gosa-core/plugins/generic/statistics/statistics.tpl b/gosa-core/plugins/generic/statistics/statistics.tpl index b848c3fe6..4892b4fd1 100644 --- a/gosa-core/plugins/generic/statistics/statistics.tpl +++ b/gosa-core/plugins/generic/statistics/statistics.tpl @@ -53,9 +53,21 @@
- {if isset($graphIDs.1) && $graphIDs.1} - - {/if} + + + + + + +
+ {if isset($graphIDs.1) && $graphIDs.1} + + {/if} + + {if isset($graphIDs.7) && $graphIDs.7} + + {/if} +