summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/statistic/index.phtml
blob: 369a5a8eb09f0126712cf88426ceb2e5604391d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<h1>Category - Statistic</h1>

<link
	rel="stylesheet" type="text/css"
	href="/media/css/jquery.jqplot.min.css" />

<select id="poolselectbox" name="PoolSelectbox"
	onclick="setPoolIDtmp();" onChange="fetchPoolEvents();">
	<option value="default">Please choose a Pool</option>
</select>

<script>

var lecture = 0;
var boot = 0;
var shutdown = 0;
var maintenance = 0;

//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() {
	poolID = $("#poolselectbox option:selected").val();
	$.get("/statistic/categorylist/poolID/" + poolID + "/category/" + 1, function(data) {lecture = data;});
	$.get("/statistic/categorylist/poolID/" + poolID + "/category/" + 3, function(data) {boot = data;});
	$.get("/statistic/categorylist/poolID/" + poolID + "/category/" + 4, function(data) {shutdown = data;});
	$.get("/statistic/categorylist/poolID/" + poolID + "/category/" + 2, function(data) {maintenance = data; refreshPlot();});
}

function refreshPlot() {
	$('#plot').empty();
	$.jqplot('plot', [
	                  [[boot,'Boot'], [shutdown,'Shutdwon'], [maintenance,'Maintenance'], [lecture,'Lecture']]], {
        seriesDefaults: {
        renderer:$.jqplot.BarRenderer,
        // Show point labels to the right ('e'ast) of each bar.
        // edgeTolerance of -15 allows labels flow outside the grid
        // up to 15 pixels.  If they flow out more than that, they
        // will be hidden.
        pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
        // Rotate the bar shadow as if bar is lit from top right.
        shadowAngle: 135,
        // Here's where we tell the chart it is oriented horizontally.
        rendererOptions: {
            barDirection: 'horizontal'
        }
    },
    axes: {
        yaxis: {
            renderer: $.jqplot.CategoryAxisRenderer
        }
    }
    });
}

$(document).ready(function(){

	 //fetch poollist from pbs database
	  $.get("/event/getpoollist/", function(getpoollistresult){
	    $("#poolselectbox").append(getpoollistresult);
	    poolIDtmp = $("#poolselectbox option:selected").val();
	    fetchPoolEvents();
	    });
	    
    // For horizontal bar charts, x an y values must will be "flipped"
    // from their vertical bar counterpart.
});
</script>

<div id="plot"
	style="height: 400px; width: 700px;"></div>