summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9fa641a)
raw | patch | inline | side by side (parent: 9fa641a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Aug 2010 14:38:50 +0000 (14:38 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Aug 2010 14:38:50 +0000 (14:38 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19440 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/plugins/generic/statistics/chartClasses/class_categoryActionOverTime.inc | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/generic/statistics/chartClasses/class_statChart.inc | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/generic/statistics/graphClasses/class_categoryActionOverTime.inc | [deleted file] | patch | blob | history |
gosa-core/plugins/generic/statistics/graphClasses/class_statChart.inc | [deleted file] | patch | blob | history |
diff --git a/gosa-core/plugins/generic/statistics/chartClasses/class_categoryActionOverTime.inc b/gosa-core/plugins/generic/statistics/chartClasses/class_categoryActionOverTime.inc
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+
+class categoryActionsOverTime extends statChart
+{
+ var $title = 'Plugin usage over time';
+ var $enableCaching = TRUE;
+
+ function __construct(&$config)
+ {
+ parent::__construct($config);
+ $this->graphName = get_class();
+ }
+
+
+ /*! \brief Generates the line-graph which displays the plugin usage over time.
+ */
+ function render()
+ {
+ $lineMax = 100;
+ $gData = $this->graphData;
+ $errorMax = (max($gData['errorsPerInterval']) < 100)? 100:max($gData['errorsPerInterval']);
+ $dataSet = new pData;
+ $seriesCnt = 0;
+ foreach($gData['actionsPerInterval'] 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);
+
+ // 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($gData['actionsPerInterval'] as $key => $data){
+ $this->seriesList[$key] = $this->getCategoryTranslation($key);
+ }
+ $this->seriesList['errorsPerInterval'] = _("Error");
+
+ // Create a dataSet containing all series
+ $allSeriesDataSet = clone $dataSet;
+ if(!in_array('errorsPerInterval', $this->skipSeries)){
+ $allSeriesDataSet->AddPoint($gData['errorsPerInterval'], 'Errors');
+ $allSeriesDataSet->SetSerieName(_('Error'), 'Errors');
+ $allSeriesDataSet->AddSerie('Errors');
+ }
+
+ // Add timeline
+ $dataSet->AddPoint($gData['dates'], 'date');
+ $dataSet->SetAbsciseLabelSerie('date');
+
+ // Read graph from cache?
+ $pCache = new pCache('/var/spool/gosa/');
+ if($this->enableCaching && $pCache->IsInCache(get_class(),$allSeriesDataSet->GetData())){
+ $filename = $pCache->GetHash(get_class(),$allSeriesDataSet->GetData());
+ $filename = '/var/spool/gosa/'.$filename;
+ if(file_exists($filename) && is_readable($filename)){
+ $this->graphID = preg_replace("/[^0-9]/","",microtime(TRUE)).rand(0,99999);
+ session::set('statistics::graphFile'.$this->graphID,$filename);
+ return;
+ }
+ }
+
+ $chart = new pChart(900,230);
+ $chart->setFixedScale(0.000,$lineMax);
+ $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10);
+ $chart->setGraphArea(50,8,830,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,_($this->title),50,50,50,585);
+ $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, TRUE);
+
+ // Only draw this graph if we've at least one series to draw!
+ if($seriesCnt){
+ $chart->drawFilledLineGraph($dataSet->GetData(),$dataSet->GetDataDescription(),50,TRUE);
+ }
+
+ // Do we've to add the errors series?
+ // If we have to, then add the error-data-series.
+ // and set the color for the new error-series to red.
+ if(!in_array('errorsPerInterval', $this->skipSeries)){
+
+ // Set the color for the error Series to 'red'.
+ // This has to be done before drawing the legend.
+ $chart->setColorPalette($seriesCnt,255,0,0);
+
+ $dataSet->AddPoint($gData['errorsPerInterval'], 'Errors');
+ $dataSet->SetSerieName(_('Error'), 'Errors');
+ $dataSet->AddSerie('Errors');
+ }
+
+ $chart->drawLegend(750,30,$dataSet->GetDataDescription(),255,255,255);
+
+ // Draw the error graph on top of the other graphs now.
+ // But remove the category-graph before.
+ if(!in_array('errorsPerInterval', $this->skipSeries)){
+
+ // Remove all graph series and add the error-series, then draw the new graph.
+ // (It is not relevant if it was really added before, so we simply remove all series!)
+ 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 = preg_replace("/[^0-9]/","",microtime(TRUE));
+ $file = '/tmp/graph_'.$this->graphID;
+ $chart->Render($file);
+ session::set('statistics::graphFile'.$this->graphID,$file);
+ $pCache->WriteToCache(get_class(),$allSeriesDataSet->GetData(),$chart);
+
+ return;
+ }
+
+}
+?>
diff --git a/gosa-core/plugins/generic/statistics/chartClasses/class_statChart.inc b/gosa-core/plugins/generic/statistics/chartClasses/class_statChart.inc
--- /dev/null
@@ -0,0 +1,107 @@
+<?php
+
+class statChart{
+
+ // Graph data
+ var $statisticData = array(); // Via rpc received stats
+
+ // Font used in graphs
+ var $font = "./themes/default/fonts/LiberationSans-Regular.ttf";
+ var $graphData = array();
+ var $graphID = 0;
+ var $enableCaching = TRUE;
+
+ var $skipSeries = array();
+
+ var $graphName = 0;
+
+ var $seriesList = array();
+
+ function __construct(&$config,$gData = array())
+ {
+ $this->config = $config;
+
+ // Collect category translations
+ $this->catTranslations = array();
+ foreach($this->config->configRegistry->getListOfPlugins() as $plugin => $data){
+ if(isset($data['plCategory'])){
+ foreach($data['plCategory'] as $id => $name){
+ if(!is_numeric($id)){
+ $this->catTranslations[$id] = $name['description'];
+ }
+ }
+ }
+ }
+ }
+
+
+ function setGraphData($data)
+ {
+ $this->graphData = $data;
+ }
+
+
+ /*! \brief This method tries to translate category names.
+ * @param The category name to translate
+ * @return String The translated category names.
+ */
+ function getCategoryTranslation($name)
+ {
+ $ret ="";
+
+ // We do not have a category for systems directly, so we've to map all system types to 'System'.
+ // If we do not map to _(Systems) the graph legend will be half screen width.
+ if($name == "systems"){
+ return(_("Systems"));
+ }
+
+ // Walk through category names and try to find a translation.
+ $cat = trim($name);
+ if(isset($this->catTranslations[$cat])){
+ $cat = _($this->catTranslations[$cat]);
+ }elseif(!empty($cat)){
+ $cat = _($cat);
+ }
+ return($cat);
+ }
+
+
+ function getGraphID()
+ {
+ return($this->graphID);
+ }
+
+ function getSeriesList()
+ {
+ return($this->seriesList);
+ }
+
+ function getSeriesSelector()
+ {
+ $str = "<input type='hidden' name='{$this->graphName}_posted' value='1'>";
+ $list = $this->getSeriesList();
+ foreach($list as $key => $item){
+ $checked = (in_array($key, $this->skipSeries))? '': 'checked';
+ $str .= "<span style='padding-right:20px'>".
+ " <input type='checkbox' name='addSeries_{$this->graphName}_{$key}' value='1'".
+ " onClick=\"document.mainform.submit();\" ".
+ " {$checked}>{$item}".
+ " </span>";
+ }
+ return($str);
+ }
+
+ function save_object()
+ {
+ if(!isset($_POST["{$this->graphName}_posted"])) return;
+
+ // Get series to enable or disable
+ $this->skipSeries = array();
+ foreach($this->seriesList as $seriesName => $seriesDesc){
+ if(!isset($_POST["addSeries_{$this->graphName}_{$seriesName}"])){
+ $this->skipSeries[] = $seriesName;
+ }
+ }
+ }
+}
+?>
diff --git a/gosa-core/plugins/generic/statistics/graphClasses/class_categoryActionOverTime.inc b/gosa-core/plugins/generic/statistics/graphClasses/class_categoryActionOverTime.inc
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-
-class categoryActionsOverTime extends statChart
-{
- var $title = 'Plugin usage over time';
- var $enableCaching = TRUE;
-
- function __construct(&$config)
- {
- parent::__construct($config);
- $this->graphName = get_class();
- }
-
-
- /*! \brief Generates the line-graph which displays the plugin usage over time.
- */
- function render()
- {
- $lineMax = 100;
- $gData = $this->graphData;
- $errorMax = (max($gData['errorsPerInterval']) < 100)? 100:max($gData['errorsPerInterval']);
- $dataSet = new pData;
- $seriesCnt = 0;
- foreach($gData['actionsPerInterval'] 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);
-
- // 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($gData['actionsPerInterval'] as $key => $data){
- $this->seriesList[$key] = $this->getCategoryTranslation($key);
- }
- $this->seriesList['errorsPerInterval'] = _("Error");
-
- // Create a dataSet containing all series
- $allSeriesDataSet = clone $dataSet;
- if(!in_array('errorsPerInterval', $this->skipSeries)){
- $allSeriesDataSet->AddPoint($gData['errorsPerInterval'], 'Errors');
- $allSeriesDataSet->SetSerieName(_('Error'), 'Errors');
- $allSeriesDataSet->AddSerie('Errors');
- }
-
- // Add timeline
- $dataSet->AddPoint($gData['dates'], 'date');
- $dataSet->SetAbsciseLabelSerie('date');
-
- // Read graph from cache?
- $pCache = new pCache('/var/spool/gosa/');
- if($this->enableCaching && $pCache->IsInCache(get_class(),$allSeriesDataSet->GetData())){
- $filename = $pCache->GetHash(get_class(),$allSeriesDataSet->GetData());
- $filename = '/var/spool/gosa/'.$filename;
- if(file_exists($filename) && is_readable($filename)){
- $this->graphID = preg_replace("/[^0-9]/","",microtime(TRUE)).rand(0,99999);
- session::set('statistics::graphFile'.$this->graphID,$filename);
- return;
- }
- }
-
- $chart = new pChart(900,230);
- $chart->setFixedScale(0.000,$lineMax);
- $chart->setFontProperties("./themes/default/fonts/LiberationSans-Regular.ttf",10);
- $chart->setGraphArea(50,8,830,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,_($this->title),50,50,50,585);
- $chart->drawScale($dataSet->GetData(),$dataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2, TRUE);
-
- // Only draw this graph if we've at least one series to draw!
- if($seriesCnt){
- $chart->drawFilledLineGraph($dataSet->GetData(),$dataSet->GetDataDescription(),50,TRUE);
- }
-
- // Do we've to add the errors series?
- // If we have to, then add the error-data-series.
- // and set the color for the new error-series to red.
- if(!in_array('errorsPerInterval', $this->skipSeries)){
-
- // Set the color for the error Series to 'red'.
- // This has to be done before drawing the legend.
- $chart->setColorPalette($seriesCnt,255,0,0);
-
- $dataSet->AddPoint($gData['errorsPerInterval'], 'Errors');
- $dataSet->SetSerieName(_('Error'), 'Errors');
- $dataSet->AddSerie('Errors');
- }
-
- $chart->drawLegend(750,30,$dataSet->GetDataDescription(),255,255,255);
-
- // Draw the error graph on top of the other graphs now.
- // But remove the category-graph before.
- if(!in_array('errorsPerInterval', $this->skipSeries)){
-
- // Remove all graph series and add the error-series, then draw the new graph.
- // (It is not relevant if it was really added before, so we simply remove all series!)
- 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 = preg_replace("/[^0-9]/","",microtime(TRUE));
- $file = '/tmp/graph_'.$this->graphID;
- $chart->Render($file);
- session::set('statistics::graphFile'.$this->graphID,$file);
- $pCache->WriteToCache(get_class(),$allSeriesDataSet->GetData(),$chart);
-
- return;
- }
-
-}
-?>
diff --git a/gosa-core/plugins/generic/statistics/graphClasses/class_statChart.inc b/gosa-core/plugins/generic/statistics/graphClasses/class_statChart.inc
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-
-class statChart{
-
- // Graph data
- var $statisticData = array(); // Via rpc received stats
-
- // Font used in graphs
- var $font = "./themes/default/fonts/LiberationSans-Regular.ttf";
- var $graphData = array();
- var $graphID = 0;
- var $enableCaching = TRUE;
-
- var $skipSeries = array();
-
- var $graphName = 0;
-
- var $seriesList = array();
-
- function __construct(&$config,$gData = array())
- {
- $this->config = $config;
-
- // Collect category translations
- $this->catTranslations = array();
- foreach($this->config->configRegistry->getListOfPlugins() as $plugin => $data){
- if(isset($data['plCategory'])){
- foreach($data['plCategory'] as $id => $name){
- if(!is_numeric($id)){
- $this->catTranslations[$id] = $name['description'];
- }
- }
- }
- }
- }
-
-
- function setGraphData($data)
- {
- $this->graphData = $data;
- }
-
-
- /*! \brief This method tries to translate category names.
- * @param The category name to translate
- * @return String The translated category names.
- */
- function getCategoryTranslation($name)
- {
- $ret ="";
-
- // We do not have a category for systems directly, so we've to map all system types to 'System'.
- // If we do not map to _(Systems) the graph legend will be half screen width.
- if($name == "systems"){
- return(_("Systems"));
- }
-
- // Walk through category names and try to find a translation.
- $cat = trim($name);
- if(isset($this->catTranslations[$cat])){
- $cat = _($this->catTranslations[$cat]);
- }elseif(!empty($cat)){
- $cat = _($cat);
- }
- return($cat);
- }
-
-
- function getGraphID()
- {
- return($this->graphID);
- }
-
- function getSeriesList()
- {
- return($this->seriesList);
- }
-
- function getSeriesSelector()
- {
- $str = "<input type='hidden' name='{$this->graphName}_posted' value='1'>";
- $list = $this->getSeriesList();
- foreach($list as $key => $item){
- $checked = (in_array($key, $this->skipSeries))? '': 'checked';
- $str .= "<span style='padding-right:20px'>".
- " <input type='checkbox' name='addSeries_{$this->graphName}_{$key}' value='1'".
- " onClick=\"document.mainform.submit();\" ".
- " {$checked}>{$item}".
- " </span>";
- }
- return($str);
- }
-
- function save_object()
- {
- if(!isset($_POST["{$this->graphName}_posted"])) return;
-
- // Get series to enable or disable
- $this->skipSeries = array();
- foreach($this->seriesList as $seriesName => $seriesDesc){
- if(!isset($_POST["addSeries_{$this->graphName}_{$seriesName}"])){
- $this->skipSeries[] = $seriesName;
- }
- }
- }
-}
-?>