From: hickert Date: Fri, 20 Aug 2010 14:32:44 +0000 (+0000) Subject: Updated graph generation X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9263477808030553bf59542b4cc06a07c1ccea8c;p=gosa.git Updated graph generation git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19420 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 693955db3..2d903c076 100644 --- a/gosa-core/plugins/generic/statistics/class_statistics.inc +++ b/gosa-core/plugins/generic/statistics/class_statistics.inc @@ -10,6 +10,8 @@ class statistics extends plugin var $rpcHandle = NULL; var $rpcConfigured = FALSE; + var $statisticData = array(); + var $graphID_1 = 0; var $graphID_2 = 0; var $graphID_3 = 0; @@ -20,6 +22,8 @@ class statistics extends plugin var $legendG = 235; var $legendB = 235; + var $font = "./themes/default/fonts/LiberationSans-Regular.ttf"; + var $graph1DatePicker1 = 0; var $graph1DatePicker2 = 0; @@ -30,7 +34,7 @@ class statistics extends plugin plugin::plugin($config, NULL); // Init start and stop times for graph 1 - $this->graph1DatePicker1 = date('d.m.Y', time() - 7 * 24 * 60 *60); + $this->graph1DatePicker1 = date('d.m.Y', time() - 14 * 24 * 60 *60); $this->graph1DatePicker2 = date('d.m.Y', time()); // First try to retrieve values via RPC @@ -65,7 +69,6 @@ class statistics extends plugin */ function getLocalStatisticsFiles() { - $res = stats::getLocalStatFiles(); $tmp = array(); if(count($res)){ @@ -157,293 +160,15 @@ class statistics extends plugin } // Transmit daily statistics to GOsa-Server - if(isset($_POST['receiveStatistics'])){ - - // First try to retrieve values via RPC - if ($this->config->get_cfg_value("core","gosaRpcServer") != ""){ - - $start = strtotime($this->graph1DatePicker1); - $stop = strtotime($this->graph1DatePicker2); - - // Request statistics now - $res = $this->rpcHandle->getInstanceStats($start,$stop); - if(!$this->rpcHandle->success()){ - msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcHandle->get_error()),ERROR_DIALOG); - } - - if($res && $this->rpcHandle->success()){ - - // Include pChart - new pChartInclude(); - - // Get most used categories, but only eight at once. - if(count($res['actionsPerCategory'])){ - $this->generateCategoryPieGraph($res['actionsPerCategory']); - } - - - // -------- - // Generate combined line and car chart of plugin usage, ldap execution time and errors - // -------- - - // Generate new and unique graph id - $this->graphID_2 = preg_replace("/[^0-9]/","",microtime(TRUE)); - - // Prepare transmitted data, sort it by date and collect - // transmitted timestamps to be able to print the x-Axis labels. - $dataArray = array(); - $dates = array(); - $dataSet = new pData; - $max = 1; - $seriesNumber = 0; - foreach($res['actionsPerInterval'] as $category => $entriesPerDate){ - - // Collect data per category and store used timestamps - foreach($entriesPerDate as $dateStr => $count){ - $date = strtotime($dateStr); - $dates[$date]=$date; - - // Do not append empty data - if(empty($category)) continue; - if($count) $count = ($count); - $dataArray[$category][$date] = $count; - } - - // Do not append empty data - if(empty($category)) continue; - - // Sort results. - ksort($dataArray[$category]); - - // Add results to our data set. - $dataSet->AddPoint($dataArray[$category], $category); - $dataSet->SetSerieName($this->getCategoryTranslation($category), $category); - $dataSet->AddSerie($category); - $seriesNumber++; - - // Detect maximum value, to adjust the Y-Axis - $tmpMax = max($dataArray[$category]); - if($tmpMax > $max) $max = $tmpMax; - } - ksort($dates); - - // Prepare date strings for X-Axis, only print a given number of - // of labels to keep the axis readable. - $Xam = 5; // Number of labels - $cnt = 0; - $dateSeries = array(); - foreach($dates as $stamp){ - if((count($dates) <= $Xam) || ($cnt % (floor(count($dates) / $Xam )) == 0)){ - $dateSeries[$stamp] = date('d.m.Y',$stamp); - }else{ - $dateSeries[$stamp] = ' '; - } - $cnt ++; - } - - $dataSet->AddPoint($dateSeries, 'date'); - $dataSet->SetAbsciseLabelSerie('date'); - - $chart = new pChart(800,230); - $chart->setFixedScale(0.0001,($max*1.1)); - $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); - $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); - $chart->drawGraphArea(255,255,255,TRUE); - $chart->drawGrid(4,TRUE,200,200,200,50); - $chart->drawTreshold(0,143,55,72,TRUE,TRUE); - $chart->drawTitle(50,22,"Plugin usage over time",50,50,50,585); - - if(count($dates)){ - $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2); - } - - // Draw the cubic curve graph - if(count($dataArray)){ - $chart->drawFilledLineGraph($dataSet->GetData(),$dataSet->GetDataDescription(),50,TRUE); - } - - // Add error series - $errors = array(); - foreach($res['errorsPerInterval'] as $dateStr => $count){ - $date = strtotime($dateStr); - if($count !=0) $count = ($count); - $errors[$date] = $count; - } - - ksort($errors); - - $dataSet->AddPoint($errors, 'Errors'); - $dataSet->SetSerieName(_('Error'), 'Errors'); - $dataSet->AddSerie('Errors'); - $seriesNumber ++; - - $chart->setColorPalette($seriesNumber-1,255,0,0); - - // Draw legend - $chart->drawLegend(650,30,$dataSet->GetDataDescription(),255,255,255); - - // Remove plugin usage from data series, just keep error series. - foreach($dataArray as $categoryName => $list){ - $dataSet->RemoveSerie($categoryName); - } - - // Draw right scale (Errors per day) - $chart->setFixedScale(0.0001,(max($errors) +1) *1.1); - $chart->drawRightScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,120,150,150,TRUE,0,2); - $chart->drawBarGraph($dataSet->GetData(),$dataSet->GetDataDescription()); - - $file = '/tmp/graph_'.$this->graphID_2; - $chart->Render($file); - session::set('statistics::graphFile'.$this->graphID_2,$file); - - - - // Prepare Data - $graphData = array(); - foreach($res['usagePerInterval'] as $dateStr => $data){ - $date = strtotime($dateStr); - foreach($data as $name => $val){ - $graphData[$name][$date] = $val; - } - } - - // Sort Data - foreach($graphData as $key => $data) - ksort($graphData[$key]); - - // Generate new and unique graph id - $this->graphID_3 = preg_replace("/[^0-9]/","",microtime(TRUE)); - - // Prepare transmitted data, sort it by date and collect - // transmitted timestamps to be able to print the x-Axis labels. - $dataSet = new pData; - - $max = max($graphData['max_mem']); - - $dataSet->AddPoint(array_values($graphData['max_mem']), 'max_mem'); - $dataSet->AddPoint(array_values($graphData['avg_mem']), 'avg_mem'); - $dataSet->AddPoint(array_values($graphData['min_mem']), 'min_mem'); - - $dataSet->SetSerieName('Min Memory', 'min_mem'); - $dataSet->SetSerieName('Max Memory', 'max_mem'); - $dataSet->SetSerieName('Average Memory', 'avg_mem'); - - $dataSet->AddAllSeries(); - $dataSet->AddPoint($dateSeries, 'date'); - $dataSet->SetAbsciseLabelSerie('date'); - - $chart = new pChart(800,230); - $chart->setFixedScale(0.0001,($max*1.1)); - $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); - $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); - $chart->drawGraphArea(255,255,255,TRUE); - $chart->drawGrid(4,TRUE,200,200,200,50); - $chart->drawTreshold(0,143,55,72,TRUE,TRUE); - $chart->drawTitle(50,22,"Memory usage",50,50,50,585); - - $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE); - $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50); - - $file = '/tmp/graph_'.$this->graphID_3; - $chart->Render($file); - session::set('statistics::graphFile'.$this->graphID_3,$file); - - - - - - - - // Generate new and unique graph id - $this->graphID_4 = preg_replace("/[^0-9]/","",microtime(TRUE)); - - // Prepare transmitted data, sort it by date and collect - // transmitted timestamps to be able to print the x-Axis labels. - $dataSet = new pData; - - $max = max($graphData['max_dur']); - - $dataSet->AddPoint(array_values($graphData['max_dur']), 'max_dur'); - $dataSet->AddPoint(array_values($graphData['avg_dur']), 'avg_dur'); - $dataSet->AddPoint(array_values($graphData['min_dur']), 'min_dur'); - - $dataSet->SetSerieName('Min dur', 'min_dur'); - $dataSet->SetSerieName('Max dur', 'max_dur'); - $dataSet->SetSerieName('Average dur', 'avg_dur'); - - $dataSet->AddAllSeries(); - $dataSet->AddPoint($dateSeries, 'date'); - $dataSet->SetAbsciseLabelSerie('date'); - - $chart = new pChart(800,230); - $chart->setFixedScale(0.0001,($max*1.1)); - $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); - $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); - $chart->drawGraphArea(255,255,255,TRUE); - $chart->drawGrid(4,TRUE,200,200,200,50); - $chart->drawTreshold(0,143,55,72,TRUE,TRUE); - $chart->drawTitle(50,22,"Render time",50,50,50,585); - - $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE); - $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50); - - $file= '/tmp/graph_'.$this->graphID_4; - $chart->Render($file); - session::set('statistics::graphFile'.$this->graphID_4,$file); - - - - - - - - - // Generate new and unique graph id - $this->graphID_5 = preg_replace("/[^0-9]/","",microtime(TRUE)); - - // Prepare transmitted data, sort it by date and collect - // transmitted timestamps to be able to print the x-Axis labels. - $dataSet = new pData; - - $max = max($graphData['max_load']); - - $dataSet->AddPoint(array_values($graphData['max_load']), 'max_load'); - $dataSet->AddPoint(array_values($graphData['avg_load']), 'avg_load'); - $dataSet->AddPoint(array_values($graphData['min_load']), 'min_load'); - - $dataSet->SetSerieName('Min Load', 'min_load'); - $dataSet->SetSerieName('Max Load', 'max_load'); - $dataSet->SetSerieName('Average Load', 'avg_load'); - - $dataSet->AddAllSeries(); - $dataSet->AddPoint($dateSeries, 'date'); - $dataSet->SetAbsciseLabelSerie('date'); - - $chart = new pChart(800,230); - $chart->setFixedScale(0.0001,($max*1.1)); - $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); - $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); - $chart->drawGraphArea(255,255,255,TRUE); - $chart->drawGrid(4,TRUE,200,200,200,50); - $chart->drawTreshold(0,143,55,72,TRUE,TRUE); - $chart->drawTitle(50,22,"CPU load",50,50,50,585); - - $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE); - $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50); - - $file = '/tmp/graph_'.$this->graphID_5; - $chart->Render($file); - session::set('statistics::graphFile'.$this->graphID_5,$file); - - } + if(isset($_POST['receiveStatistics']) && $this->rpcConfigured){ + $start = strtotime($this->graph1DatePicker1); + $stop = strtotime($this->graph1DatePicker2); + $res = $this->rpcHandle->getInstanceStats($start,$stop); + if(!$this->rpcHandle->success()){ + msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcHandle->get_error()),ERROR_DIALOG); + }elseif($res){ + $this->statisticData = $this->prepareGraphData($res); + $this->reloadGraphs(); } } @@ -461,6 +186,70 @@ class statistics extends plugin } + function prepareGraphData($res) + { + $gData = array(); + + /* Build up array which represents the amount of errors per + * interval. + */ + foreach($res['errorsPerInterval'] as $dateStr => $data){ + $date = strtotime($dateStr); + $gData['errorsPerInterval'][$date] = $data; + } + ksort($gData['errorsPerInterval']); + + + /* Build up timeline + */ + $Xam = 5; + $cnt = 0; + $numCnt = $res['errorsPerInterval']; + foreach($gData['errorsPerInterval'] as $date => $data){ + if((count($numCnt) <= $Xam) || + ($cnt % (floor(count($numCnt) / $Xam )) == 0)){ + $gData['dates'][$date] = date('d.m.Y', $date); + }else{ + $gData['dates'][$date] = ' '; + } + $cnt ++; + } + ksort($gData['dates']); + + + /* Build up 'actions per category' array, this will later + * be represented using a pie chart. + */ + $gData['actionsPerCategory'] = $res['actionsPerCategory']; + arsort($gData['actionsPerCategory']); + + + /* Build up system-info array per interval. + */ + foreach($res['usagePerInterval'] as $dateStr => $data){ + $date = strtotime($dateStr); + foreach($data as $type => $count){ + $gData['usagePerInterval'][$type][$date] = $count; + } + } + foreach($gData['usagePerInterval'] as $key => $data) + ksort($gData['usagePerInterval'][$key]); + + + /* Prepare actions-per-interval array. + */ + foreach($res['actionsPerInterval'] as $category => $data){ + if(empty($category)) continue; + foreach($data as $dateStr => $count){ + $date = strtotime($dateStr); + $gData['actionsPerInterval'][$category][$date]=$count; + } + ksort($gData['actionsPerInterval'][$category]); + } + return($gData); + } + + function check() { $messages = plugin::check(); @@ -505,6 +294,221 @@ class statistics extends plugin } + function reloadGraphs() + { + new pChartInclude(); + $gData = $this->statisticData; + if(count($gData['actionsPerCategory'])){ + $this->generateCategoryPieGraph($gData['actionsPerCategory']); + } + $this->generateActionsGraph($gData); + } + + + function generateActionsGraph($gData) + { + $lineMax = 100; + $errorMax = (max($gData['errorsPerInterval']) < 100)? 100:max($gData['errorsPerInterval']); + $dataSet = new pData; + foreach($gData['actionsPerInterval'] as $category => $entriesPerDate){ + if(empty($category)) continue; + + // 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; + } + + // 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); + $chart->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); + $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); + $chart->drawGraphArea(255,255,255,TRUE); + $chart->drawGrid(4,TRUE,200,200,200,50); + $chart->drawTreshold(0,143,55,72,TRUE,TRUE); + $chart->drawTitle(50,22,"Plugin usage over time",50,50,50,585); + $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, TRUE); + $chart->drawFilledLineGraph($dataSet->GetData(),$dataSet->GetDataDescription(),50,TRUE); + $chart->setColorPalette(count($gData['actionsPerInterval']),255,0,0); + + // Draw legend + $dataSet->AddPoint($gData['errorsPerInterval'], 'Errors'); + $dataSet->SetSerieName(_('Error'), 'Errors'); + $dataSet->AddSerie('Errors'); + $chart->drawLegend(650,30,$dataSet->GetDataDescription(),255,255,255); + + // Remove all graph series and add the error-series, then draw the new graph. + foreach($gData['actionsPerInterval'] as $category => $data){ + $dataSet->RemoveSerie($category); + } + $chart->setFixedScale(0,$errorMax); + $chart->drawRightScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,120,150,150,TRUE,0,2, TRUE); + $chart->drawBarGraph($dataSet->GetData(),$dataSet->GetDataDescription()); + + // Generate new and unique graph id + $this->graphID_2 = preg_replace("/[^0-9]/","",microtime(TRUE)); + $file = '/tmp/graph_'.$this->graphID_2; + $chart->Render($file); + session::set('statistics::graphFile'.$this->graphID_2,$file); + + return; + } + +# // Prepare Data +# $graphData = array(); +# foreach($gData['usagePerInterval'] as $dateStr => $data){ +# $date = strtotime($dateStr); +# foreach($data as $name => $val){ +# $graphData[$name][$date] = $val; +# } +# } +# +# // Sort Data +# foreach($graphData as $key => $data) +# ksort($graphData[$key]); +# +# // Generate new and unique graph id +# $this->graphID_3 = preg_replace("/[^0-9]/","",microtime(TRUE)); +# +# // Prepare transmitted data, sort it by date and collect +# // transmitted timestamps to be able to print the x-Axis labels. +# $dataSet = new pData; +# +# $max = max($graphData['max_mem']); +# +# $dataSet->AddPoint(array_values($graphData['max_mem']), 'max_mem'); +# $dataSet->AddPoint(array_values($graphData['avg_mem']), 'avg_mem'); +# $dataSet->AddPoint(array_values($graphData['min_mem']), 'min_mem'); +# +# $dataSet->SetSerieName('Min Memory', 'min_mem'); +# $dataSet->SetSerieName('Max Memory', 'max_mem'); +# $dataSet->SetSerieName('Average Memory', 'avg_mem'); +# +# $dataSet->AddAllSeries(); +# $dataSet->AddPoint($dateSeries, 'date'); +# $dataSet->SetAbsciseLabelSerie('date'); +# +# $chart = new pChart(800,230); +# $chart->setFixedScale(0.0001,($max*1.1)); +# $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); +# $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); +# $chart->drawGraphArea(255,255,255,TRUE); +# $chart->drawGrid(4,TRUE,200,200,200,50); +# $chart->drawTreshold(0,143,55,72,TRUE,TRUE); +# $chart->drawTitle(50,22,"Memory usage",50,50,50,585); +# +# $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE); +# $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50); +# +# $file = '/tmp/graph_'.$this->graphID_3; +# $chart->Render($file); +# session::set('statistics::graphFile'.$this->graphID_3,$file); +# +# +# +# +# +# +# +# // Generate new and unique graph id +# $this->graphID_4 = preg_replace("/[^0-9]/","",microtime(TRUE)); +# +# // Prepare transmitted data, sort it by date and collect +# // transmitted timestamps to be able to print the x-Axis labels. +# $dataSet = new pData; +# +# $max = max($graphData['max_dur']); +# +# $dataSet->AddPoint(array_values($graphData['max_dur']), 'max_dur'); +# $dataSet->AddPoint(array_values($graphData['avg_dur']), 'avg_dur'); +# $dataSet->AddPoint(array_values($graphData['min_dur']), 'min_dur'); +# +# $dataSet->SetSerieName('Min dur', 'min_dur'); +# $dataSet->SetSerieName('Max dur', 'max_dur'); +# $dataSet->SetSerieName('Average dur', 'avg_dur'); +# +# $dataSet->AddAllSeries(); +# $dataSet->AddPoint($dateSeries, 'date'); +# $dataSet->SetAbsciseLabelSerie('date'); +# +# $chart = new pChart(800,230); +# $chart->setFixedScale(0.0001,($max*1.1)); +# $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); +# $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); +# $chart->drawGraphArea(255,255,255,TRUE); +# $chart->drawGrid(4,TRUE,200,200,200,50); +# $chart->drawTreshold(0,143,55,72,TRUE,TRUE); +# $chart->drawTitle(50,22,"Render time",50,50,50,585); +# +# $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE); +# $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50); +# +# $file= '/tmp/graph_'.$this->graphID_4; +# $chart->Render($file); +# session::set('statistics::graphFile'.$this->graphID_4,$file); +# +# +# +# +# +# +# +# +# // Generate new and unique graph id +# $this->graphID_5 = preg_replace("/[^0-9]/","",microtime(TRUE)); +# +# // Prepare transmitted data, sort it by date and collect +# // transmitted timestamps to be able to print the x-Axis labels. +# $dataSet = new pData; +# +# $max = max($graphData['max_load']); +# +# $dataSet->AddPoint(array_values($graphData['max_load']), 'max_load'); +# $dataSet->AddPoint(array_values($graphData['avg_load']), 'avg_load'); +# $dataSet->AddPoint(array_values($graphData['min_load']), 'min_load'); +# +# $dataSet->SetSerieName('Min Load', 'min_load'); +# $dataSet->SetSerieName('Max Load', 'max_load'); +# $dataSet->SetSerieName('Average Load', 'avg_load'); +# +# $dataSet->AddAllSeries(); +# $dataSet->AddPoint($dateSeries, 'date'); +# $dataSet->SetAbsciseLabelSerie('date'); +# +# $chart = new pChart(800,230); +# $chart->setFixedScale(0.0001,($max*1.1)); +# $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); +# $chart->drawRoundedRectangle(5,5,695,225,5,230,230,230); +# $chart->drawGraphArea(255,255,255,TRUE); +# $chart->drawGrid(4,TRUE,200,200,200,50); +# $chart->drawTreshold(0,143,55,72,TRUE,TRUE); +# $chart->drawTitle(50,22,"CPU load",50,50,50,585); +# +# $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, FALSE); +# $chart->drawFilledCubicCurve($dataSet->GetData(),$dataSet->GetDataDescription(),.1,50); +# +# $file = '/tmp/graph_'.$this->graphID_5; +# $chart->Render($file); +# session::set('statistics::graphFile'.$this->graphID_5,$file); +# + + function generateCategoryPieGraph($data) { // Sort data by usage count and slice array to get @@ -530,11 +534,15 @@ class statistics extends plugin $dataSet->AddPoint($keys,"Serie2"); $dataSet->SetAbsciseLabelSerie("Serie2"); + // Set graph area + $x = 400; + $y = 200; + // Initialise the graph - $chart = new pChart(600,250); - $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10); - $chart->drawPieGraph($dataSet->GetData(),$dataSet->GetDataDescription(),200,120,150,PIE_PERCENTAGE,TRUE,50,20,3); - $chart->drawPieLegend(420,15,$dataSet->GetData(),$dataSet->GetDataDescription(), + $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->drawPieLegend(($x/3*2),15,$dataSet->GetData(),$dataSet->GetDataDescription(), $this->legendR,$this->legendG,$this->legendB); // Store graph data