From 8f78ebc9b9abeb560849596ede7e69b2556e5e37 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 26 Aug 2010 11:17:09 +0000 Subject: [PATCH] Updated graph handling in case of no data git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19462 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../chartClasses/class_memoryUsageChart.inc | 14 +++++++++++--- .../statistics/chartClasses/class_pieChart1.inc | 9 +++++++-- .../plugins/generic/statistics/statistics.tpl | 8 ++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gosa-core/plugins/generic/statistics/chartClasses/class_memoryUsageChart.inc b/gosa-core/plugins/generic/statistics/chartClasses/class_memoryUsageChart.inc index da16ec54e..ac6b8d3c3 100644 --- a/gosa-core/plugins/generic/statistics/chartClasses/class_memoryUsageChart.inc +++ b/gosa-core/plugins/generic/statistics/chartClasses/class_memoryUsageChart.inc @@ -23,11 +23,19 @@ class memoryUsageChart extends statChart */ function render() { + // Add series data to dataSet $dataSet = new pData; - $max = 0; + $max = 1; foreach($this->series as $seriesName => $seriesDesc){ - if(isset($this->graphData[$this->dataName][$seriesName])){ + + // Check if we've useable series data + $renderable = + (isset($this->graphData[$this->dataName][$seriesName])) && + (count($this->graphData[$this->dataName][$seriesName])); + + // Add series if it has at least one result + if($renderable){ $dataSet->AddPoint($this->graphData[$this->dataName][$seriesName],$seriesName); $dataSet->SetSerieName($seriesDesc,$seriesName); if($max < max($this->graphData[$this->dataName][$seriesName])) $max = max($this->graphData[$this->dataName][$seriesName]); @@ -50,7 +58,7 @@ class memoryUsageChart extends statChart } $chart = new pChart(800,230); - $chart->setFixedScale(0.0001,($max*1.1)); + $chart->setFixedScale(0,$max); $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10); $chart->setGraphArea(50,30,585,200); $chart->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); diff --git a/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc b/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc index e63ecb6e4..5bbce475b 100644 --- a/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc +++ b/gosa-core/plugins/generic/statistics/chartClasses/class_pieChart1.inc @@ -28,12 +28,15 @@ class pieChart1 extends statChart // Detect max value and throw out entries less than 1% // the will else be unreadable - $max = max($data); + + $max = (count($data)) ? max($data) : 1; $pos = 0; foreach($data as $key => $count){ if($pos >=7 || ($count / $max)*100 < 1) break; $pos ++; } + + $this->graphID = 0; $dataRes = array_slice($data,0,$pos); @@ -48,6 +51,8 @@ class pieChart1 extends statChart $keys[$id] = $this->getCategoryTranslation($cat); } + if(!count($data)) return; + // Dataset definition $dataSet = new pData; $dataSet->AddPoint($values,"Serie1"); @@ -76,8 +81,8 @@ class pieChart1 extends statChart $chart->setFontProperties($this->font,10); if(count($data)) { $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(),255,255,255); } - $chart->drawPieLegend(($x/3*2),15,$dataSet->GetData(),$dataSet->GetDataDescription(),255,255,255); // Store graph data $this->graphID = preg_replace("/[^0-9]/","",microtime(TRUE)); diff --git a/gosa-core/plugins/generic/statistics/statistics.tpl b/gosa-core/plugins/generic/statistics/statistics.tpl index 0ad79788e..670bc8f5a 100644 --- a/gosa-core/plugins/generic/statistics/statistics.tpl +++ b/gosa-core/plugins/generic/statistics/statistics.tpl @@ -58,11 +58,19 @@ {if isset($staticChart1_ID) && $staticChart1_ID} + {else} +
+ {t}No statistic data for given period{/t} +
{/if} {if isset($staticChart2_ID) && $staticChart2_ID} + {else} +
+ {t}No statistic data for given period{/t} +
{/if} -- 2.30.2