summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/controllers/StatisticController.php6
-rwxr-xr-xapplication/models/EventMapper.php57
-rwxr-xr-xapplication/models/EventcategoryMapper.php9
-rw-r--r--application/views/scripts/statistic/category.phtml56
-rw-r--r--application/views/scripts/statistic/running.phtml25
-rwxr-xr-xpublic/media/css/style.css13
6 files changed, 140 insertions, 26 deletions
diff --git a/application/controllers/StatisticController.php b/application/controllers/StatisticController.php
index 330e104..7b15531 100644
--- a/application/controllers/StatisticController.php
+++ b/application/controllers/StatisticController.php
@@ -60,8 +60,10 @@ class StatisticController extends Zend_Controller_Action
$eventList = $this->eventMapper->findBy(array("pbs_membershipID", $this->userIDsNamespace['membershipID']));
}*/
- $ret = $this->eventMapper->getCategoryCount($poolID);
-
+ $ret['dataBar'] = $this->eventMapper->getCategoryBarCount($poolID);
+ $ret['dataPie'] = $this->eventMapper->getCategoryPieCount($poolID);
+ $ret['color'] = $this->eventcategoryMapper->getCategoryColor($poolID);
+
echo json_encode($ret);
}
diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php
index af0b7b2..8d05754 100755
--- a/application/models/EventMapper.php
+++ b/application/models/EventMapper.php
@@ -184,7 +184,7 @@ class Application_Model_EventMapper
return array_diff($vv1,$vv2);
}
- public function getCategoryCount($poolID) {
+ public function getCategoryBarCount($poolID) {
$db = Zend_Db_Table::getDefaultAdapter();
$select = $this->getDbTable()->select()
@@ -192,9 +192,60 @@ class Application_Model_EventMapper
->from(array('pce' => 'poolctrl_event'),
array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
->join(array('pcec' => 'poolctrl_eventcategory'),
- 'pce.category = pcec.eventcategoryID')
+ 'pce.category = pcec.eventcategoryID',
+ array())
->where('pce.pbs_poolID = ?', $poolID)
- ->group('pce.category');
+ ->group('pce.category')
+ ->order('pce.category ASC');
+
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll(PDO::FETCH_NUM);
+ $ret = null;
+
+ foreach ($result as $r) {
+ $ret[] = array((int)$r[0], $r[1]);
+ }
+
+ return array($ret);
+ }
+
+ public function getCategoryPieCount($poolID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->setIntegrityCheck(false)
+ ->from(array('pce' => 'poolctrl_event'),
+ array('category' => 'pcec.title', 'count' => 'COUNT(*)'))
+ ->join(array('pcec' => 'poolctrl_eventcategory'),
+ 'pce.category = pcec.eventcategoryID',
+ array())
+ ->where('pce.pbs_poolID = ?', $poolID)
+ ->group('pce.category')
+ ->order('pce.category ASC');
+
+ $stmt = $db->query($select);
+ $result = $stmt->fetchAll(PDO::FETCH_NUM);
+ $ret = null;
+
+ foreach ($result as $r) {
+ $ret[] = array($r[0], (int)$r[1]);
+ }
+
+ return array($ret);
+ }
+
+ public function getRunningCount($poolID) {
+
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->setIntegrityCheck(false)
+ ->from(array('pce' => 'poolctrl_event'),
+ array('count' => 'COUNT(*)', 'category' => 'pcec.title'))
+ ->join(array('pcec' => 'poolctrl_eventcategory'),
+ 'pce.category = pcec.eventcategoryID')
+ ->where('pce.pbs_poolID = ?', $poolID)
+ ->group('pce.category')
+ ->order('pce.category ASC');
$stmt = $db->query($select);
$result = $stmt->fetchAll(PDO::FETCH_NUM);
diff --git a/application/models/EventcategoryMapper.php b/application/models/EventcategoryMapper.php
index 5298af1..f481140 100755
--- a/application/models/EventcategoryMapper.php
+++ b/application/models/EventcategoryMapper.php
@@ -161,12 +161,15 @@ class Application_Model_EventcategoryMapper
->from(array('pcec' => 'poolctrl_eventcategory'),
array('color' => 'pcec.color'))
->join(array('pce' => 'poolctrl_event'),
- 'pce.category = pcec.eventcategoryID')
+ 'pce.category = pcec.eventcategoryID',
+ array())
->where('pce.pbs_poolID = ?', $poolID)
- ->group('pce.category');
+ ->group('pce.category')
+ ->order('eventcategoryID ASC')
+ ;
$stmt = $db->query($select);
- $result = $stmt->fetchAll(PDO::FETCH_NUM);
+ $result = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
return $result;
}
diff --git a/application/views/scripts/statistic/category.phtml b/application/views/scripts/statistic/category.phtml
index 44fb749..55143d0 100644
--- a/application/views/scripts/statistic/category.phtml
+++ b/application/views/scripts/statistic/category.phtml
@@ -1,8 +1,12 @@
<h1>Statistic - Category</h1>
-
+
<link
rel="stylesheet" type="text/css"
href="/media/css/jquery.jqplot.min.css" />
+<link
+ rel="stylesheet" type="text/css"
+ href="/media/css/style.css" />
+
<select id="poolselectbox" name="PoolSelectbox"
onclick="setPoolIDtmp();" onChange="fetchPoolEvents();">
@@ -24,22 +28,22 @@ function setPoolIDtmp() {
function plot() {
poolID = $("#poolselectbox option:selected").val();
$.get("/statistic/categorylist/poolID/" + poolID, function(data) {
- $.get("/statistic/colorlist/poolID/" + poolID, function(color) {
- if(data == '') {
+ if(data.dataBar == '') {
$( "#noEventsDialog" ).dialog('open');
$('#plot').empty();
- } else refreshPlot(data);
+ } else refreshPlot(data.dataBar, data.dataPie, data.color);
}, "json");
- }, "json");
}
-function refreshPlot(data, color) {
- $('#plot').empty();
- $.jqplot('plot', data, {
+//[[[4,"Lecture"],[36,"Maintenance"],[9,"Boot"],[21,"Shutdown"]]]
+
+function refreshPlot(dataBar, dataPie, color) {
+ $('#plotBar').empty();
+ $.jqplot('plotBar', dataBar, {
seriesDefaults: {
//renderer: $.jqplot.PieRenderer,
- renderer: $.jqplot.BarRenderer,
- pointLabels: { show: true, edgeTolerance: -15 },
+ renderer:$.jqplot.BarRenderer,
+ pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
shadowAngle: 135,
rendererOptions: {
//showDataLabels: true,
@@ -50,14 +54,29 @@ function refreshPlot(data, color) {
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
- },
- xaxis: {
- renderer: $.jqplot.CategoryAxisRenderer
}
},
- seriesColors: [ "green", "blue", "red", "yellow" ], //color,
+ seriesColors: color,
highlighter: { show: false }
});
+ $('#plotPie').empty();
+ //var data = [['Commuting', 7], ['Orientation', 9]];
+ $.jqplot('plotPie', dataPie,
+ {
+ seriesDefaults: {
+ // Make this a pie chart.
+ renderer: jQuery.jqplot.PieRenderer,
+ rendererOptions: {
+ // Put data labels on the pie slices.
+ // By default, labels show the percentage of the slice.
+ showDataLabels: true,
+ lineLabels: true,
+ varyBarColor : true
+ }
+ },
+ seriesColors: color
+ //legend: { show:true, location: 'e' }
+ });
}
$(document).ready(function(){
@@ -90,10 +109,13 @@ $(function() {
</script>
-<div id="plot"
- style="height: 400px; width: 700px;"></div>
+<div class="clear"></div>
+<div id="plotBar" class="left"
+ style="height: 250px; width: 350px;"></div>
+<div id="plotPie" class="right"
+ style="height: 250px; width: 350px;"></div>
<!-- no events -->
<div id="noEventsDialog" style="display: none">
<p>There are no events in this pool to plot a statistic</p>
-</div> \ No newline at end of file
+</div>
diff --git a/application/views/scripts/statistic/running.phtml b/application/views/scripts/statistic/running.phtml
index ada2431..019b7fc 100644
--- a/application/views/scripts/statistic/running.phtml
+++ b/application/views/scripts/statistic/running.phtml
@@ -14,12 +14,32 @@
//fetch all poolevents of the selected #poolselectbox value
function fetchPoolEvents() {
poolID = $("#poolselectbox option:selected").val();
+ plot();
}
function setPoolIDtmp() {
poolIDtmp = $("#poolselectbox option:selected").val();
}
+function plot() {
+ $('#plot').empty();
+ var data = [['Commuting', 7], ['Orientation', 9]];
+ $.jqplot('plot', [data],
+ {
+ seriesDefaults: {
+ // Make this a pie chart.
+ renderer: jQuery.jqplot.PieRenderer,
+ rendererOptions: {
+ // Put data labels on the pie slices.
+ // By default, labels show the percentage of the slice.
+ showDataLabels: true,
+ lineLabels: true
+ }
+ }
+ //legend: { show:true, location: 'e' }
+ });
+}
+
$(document).ready(function(){
//fetch poollist from pbs database
@@ -30,4 +50,7 @@ $(document).ready(function(){
});
});
-</script> \ No newline at end of file
+</script>
+
+<div id="plot"
+ style="height: 300px; width: 300px;"></div>
diff --git a/public/media/css/style.css b/public/media/css/style.css
index ffbeaa2..3c7f44e 100755
--- a/public/media/css/style.css
+++ b/public/media/css/style.css
@@ -754,4 +754,17 @@ fieldset {
div.hidden {
visibility: hidden;
+}
+
+.left {
+float:left;
+width:300px;
+}
+.right {
+ float:right;
+width:300px;
+}
+
+.clear {
+clear:left;
} \ No newline at end of file