From: hickert Date: Tue, 24 Aug 2010 09:46:07 +0000 (+0000) Subject: Updated statistiks X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1a82a7ae2d780d5cb5cf60287b4433d94e0d79bc;p=gosa.git Updated statistiks git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19432 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 4f7d62fa6..677b0b24f 100644 --- a/gosa-core/plugins/generic/statistics/class_statistics.inc +++ b/gosa-core/plugins/generic/statistics/class_statistics.inc @@ -15,28 +15,12 @@ class statistics extends plugin var $graphIDs = array(); // IDs for created grpah var $skipSeries = array(); // Graph series which should be skipped var $seriesListPerGraph = array(); // Series names per graph - var $graphLegends = array(); // A self-made legend // Legend colors var $legendR = 235; var $legendG = 235; var $legendB = 235; - // Pre define the used chart colors - var $legendColors = - array( - array(127,127,116), - array(114,176,180), - array(0,124,143), - array(20,67,93), - array(39,10,43), - array(82,124,148), - array(97,152,183), - array(115,173,207), - array(144,196,226), - array(174,216,240)); - - // Font used in graphs var $font = "./themes/default/fonts/LiberationSans-Regular.ttf"; @@ -197,8 +181,6 @@ class statistics extends plugin } - $smarty->assign('legendColors', $this->legendColors); - $smarty->assign('graphLegends', $this->graphLegends); $smarty->assign('seriesListPerGraph', $this->seriesListPerGraph); $smarty->assign('skipSeries', $this->skipSeries); $smarty->assign('graphIDs', $this->graphIDs); @@ -214,17 +196,10 @@ class statistics extends plugin /*! \brief Prepares the graph data we've received from the rpc-service. * This method will construct a usable data-array with converted - * date strings, cleaned up categories. + * date strings. */ function prepareGraphData($res) { - // Dummy, please check later if it is still required. - $this->skipSeries[1] = array(); - $this->skipSeries[2] = array(); - $this->skipSeries[3] = array(); - $this->skipSeries[4] = array(); - $this->skipSeries[5] = array(); - /* Build up array which represents the amount of errors per * interval. */ @@ -281,6 +256,12 @@ class statistics extends plugin } ksort($gData['actionsPerInterval'][$category]); } + $this->skipSeries[1] = array(); + $this->skipSeries[2] = array(); + $this->skipSeries[3] = array(); + $this->skipSeries[4] = array(); + $this->skipSeries[5] = array(); + // Clean data from unusable categories like ('terminals workstations, ...') foreach($gData as $serieName => $seriesData){ @@ -400,49 +381,30 @@ class statistics extends plugin */ function generateActionsGraph($gData) { - - // Prepare self-made legend data - $legendData = array(); - - $lineMax = 10; - $errorMax = max($gData['errorsPerInterval']); + $lineMax = 100; + $errorMax = (max($gData['errorsPerInterval']) < 100)? 100:max($gData['errorsPerInterval']); $dataSet = new pData; $seriesCnt = 0; $gID = 2; - $chart = new pChart(800,230); - $seriesShown = 0; foreach($gData['actionsPerInterval'] as $category => $entriesPerDate){ - if(empty($category)) continue; - - // Add entry to legendData array. - $desc = $this->getCategoryTranslation($category); - - // Set series color - $color = $this->legendColors[$seriesCnt]; - $legendData[$seriesCnt] = array('name' => $category,'desc'=>$desc,'color' => $color); - - // Do not add graph data for skipped series - if(!in_array($category, $this->skipSeries[$gID])){ - $dataSet->AddPoint($entriesPerDate, $category); - $dataSet->SetSerieName($desc, $category); - $dataSet->AddSerie($category); - - list($r,$g,$b) = $color; - $chart->setColorPalette($seriesShown,$r,$g,$b); - - // Detect maximum value, to adjust the Y-Axis - $tmpMax = max($entriesPerDate); - if($tmpMax > $lineMax) $lineMax = $tmpMax; + if(empty($category) || in_array($category, $this->skipSeries[$gID])) continue; - $seriesShown ++; - } + // Add results to our data set. + $dataSet->AddPoint($entriesPerDate, $category); + $dataSet->SetSerieName($this->getCategoryTranslation($category), $category); + $dataSet->AddSerie($category); + // Detect maximum value, to adjust the Y-Axis + $tmpMax = max($entriesPerDate); + if($tmpMax > $lineMax) $lineMax = $tmpMax; $seriesCnt ++; } // Add timeline $dataSet->AddPoint($gData['dates'], 'date'); $dataSet->SetAbsciseLabelSerie('date'); + + $chart = new pChart(800,230); $chart->setFixedScale(0.000,$lineMax); $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10); $chart->setGraphArea(50,30,585,200); @@ -466,15 +428,18 @@ class statistics extends plugin // Set the color for the error Series to 'red'. // This has to be done before drawing the legend. - $chart->setColorPalette($seriesShown,255,0,0); + $chart->setColorPalette($seriesCnt,255,0,0); + $dataSet->AddPoint($gData['errorsPerInterval'], 'Errors'); $dataSet->SetSerieName(_('Error'), 'Errors'); $dataSet->AddSerie('Errors'); - } - // Add entry to legendData array. - $legendData[$seriesCnt] = array('name' => 'errorsPerInterval','desc'=>_('Error'),'color' => array(255,0,0)); + + // Draw legend, but only if there is something to draw! + if($seriesCnt || !in_array('errorsPerInterval', $this->skipSeries[$gID])){ + $chart->drawLegend(650,30,$dataSet->GetDataDescription(),255,255,255); + } // Draw the error graph on top of the other graphs now. // But remove the category-graph before. @@ -503,44 +468,11 @@ class statistics extends plugin $this->seriesListPerGraph[$gID][$key] = $this->getCategoryTranslation($key); } $this->seriesListPerGraph[$gID]['errorsPerInterval'] = _("Error"); - - // Create self-made legend with checkboxes to be able to select the desired graph series. - $this->graphLegends[$gID] = $this->generateLegend($legendData,$gID, TRUE); + return; } - function generateLegend($legendData,$gID, $useCheckboxes = FALSE) - { - $str = ""; - $str .= ""; - foreach($legendData as $id => $data){ - - $label = $data['desc']; - $name = $data['name']; - if(count($data['color'])){ - list($r,$g,$b) = $data['color']; - $color = "rgba({$r},{$g},{$b},1)"; - }else{ - $color = "rgba(255,255,255,1);"; - } - $colorDiv = "
"; - - if($useCheckboxes){ - $checked = (in_array($name, $this->skipSeries[$gID]))? '':'checked'; - $checkbox = ""; - } - - $str .= "
"; - $str .= "\n"; - $str .= ""; - } - $str.="
{$checkbox}{$colorDiv}{$label}
"; - return($str); - } - - /*! \brief Generates a graph about system informations. */ function generateSystemStatsGraph($gData, $key = "", $series= array(), $title = "", $gID=0 ) @@ -560,7 +492,6 @@ class statistics extends plugin $dataSet->SetAbsciseLabelSerie('date'); $chart = new pChart(800,230); - $this->loadColors($chart); $chart->setFixedScale(0.0001,($max*1.1)); $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10); $chart->setGraphArea(50,30,585,200); @@ -628,7 +559,6 @@ class statistics extends plugin // Initialise the graph $chart = new pChart($x,$y); - $this->loadColors($chart); $chart->setFontProperties($this->font,10); $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(), @@ -640,26 +570,5 @@ class statistics extends plugin $chart->Render($file); session::set('statistics::graphFile'.$this->graphIDs[$gID],$file); } - - function loadColors(&$graph) - { - $colors = - array( - array(227,227,216), - array(114,176,180), - array(0,124,143), - array(20,67,93), - array(39,10,43), - array(82,124,148), - array(97,152,183), - array(115,173,207), - array(144,196,226), - array(174,216,240)); - - foreach($this->legendColors as $key => $values){ - list($R,$G,$B) = $values; - $graph->setColorPalette($key,$R,$G,$B); - } - } } ?> diff --git a/gosa-core/plugins/generic/statistics/statistics.tpl b/gosa-core/plugins/generic/statistics/statistics.tpl index b9cd6bfb8..af919b7d5 100644 --- a/gosa-core/plugins/generic/statistics/statistics.tpl +++ b/gosa-core/plugins/generic/statistics/statistics.tpl @@ -77,9 +77,17 @@ {/if} + + - {if isset($graphLegends.2) && $graphIDs.2} - {$graphLegends.2} + {if isset($graphIDs.2) && $graphIDs.2} + {foreach from=$seriesListPerGraph.2 key=key item=item} + + {$item} + + {/foreach} {/if}