summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/statistic/index.phtml
blob: d6c9ca9106a75cb0b4f09997a45bcb7de848119f (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
79
80
81
82
83
84
85
86
87
88
<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;
var foo;

//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/" + 2, function(data) {
//      lecture = data.lecture;
//      boot = data.boot;
//      shutdown = data.shutdown;
//      maintenance = data.maintenance;
	    refreshPlot(data);
//	    $.ajax({
//	        type: 'POST',
//	        url: "/statistic/dump",
//	        data:  {data: [[[boot,'Boot'], [shutdown,'Shutdwon'], [maintenance,'Maintenance'], [lecture,'Lecture']]]},
//	        success: function(){alert("done");},
//	        dataType: "json"
//	    });
	    
	  }, "json");
}

function refreshPlot(data) {
	$('#plot').empty();
//	  $.jqplot('plot', [
//	                    [[boot,'Boot'], [shutdown,'Shutdwon'], [maintenance,'Maintenance'], [lecture,'Lecture']]], {
	$.jqplot('plot', data, {
        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();
	    });
});
</script>

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