summaryrefslogtreecommitdiffstats
path: root/application/views/scripts/statistics/success.phtml
blob: c12c636d5d3daec0bbfbf366cb45947b3bf7b947 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<h1>Statistics</h1>
<h2>How many events were successful?</h2>

<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>
	<option value="all">All Pools</option>
</select>

<script>

//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("/statistics/successlist/poolID/" + poolID, function(data) {
          if(data.dataBar == '0,Successful,0,Failed' && poolID != 'default') {
              $( "#noEventsDialog" ).dialog('open');
              $('#plotBar').empty();
              $('#plotPieS').empty();
              $('#plotPieT').empty();
            } else if (poolID == 'default') {
              $('#plotBar').empty();
              $('#plotPieS').empty();
              $('#plotPieT').empty();
            } else refreshPlot(data.dataBar, data.dataPieS, data.dataPieT, data.color);
        }, "json");
}

function refreshPlot(dataBar, dataPieS, dataPieT, color) {
    $('#plotBar').empty();
    $.jqplot('plotBar', dataBar, {
          seriesDefaults: {
          //renderer: $.jqplot.PieRenderer,
          renderer:$.jqplot.BarRenderer,
          pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
          shadowAngle: 135,
          rendererOptions: {
              //showDataLabels: true,
              barDirection: 'horizontal',
              varyBarColor : true
          }
      },
      axes: {
          yaxis: {
              renderer: $.jqplot.CategoryAxisRenderer
          }
      },
      seriesColors: color,
      highlighter: { show: false }
      });
    $('#plotPieS').empty();
    $.jqplot('plotPieS', dataPieS,
                    {
                      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,
                          varyBarColor : true
                        }
                      },
                      seriesColors: color
                      //legend: { show:true, location: 'e' }
                    });
    $('#plotPieT').empty();
    $.jqplot('plotPieT', dataPieT,
                    {
    	                title: 'Chart with ErrorType Labels',
                      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,
                          varyBarColor: true,
                          dataLabels: 'percent'
                        }
                      },
                    seriesColors: color
                      //legend: { show:true, location: 'ne' }
                    });
  }

$(document).ready(function(){

   //fetch poollist from pbs database
    $.get("/event/getpoollist/", function(getpoollistresult){
      $("#poolselectbox").append(getpoollistresult);
      poolIDtmp = $("#poolselectbox option:selected").val();
      fetchPoolEvents();
      });
});

$(function() {
    $( "#noEventsDialog" ).dialog({
            autoOpen: false,
            width: 600,
      modal: true,
      title: "No Events",
            buttons: { 
              "OK": function() { 
                $(this).dialog("close");
              }
            },
      open: function () {
                $(".ui-dialog-titlebar-close").hide();
                //$(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
            }
    });
  }); 

</script>

<div>
<div id="plotBar" class="spalte" style="height: 300px; width: 250px;"></div>
<div id="plotPieS" class="spalte" style="height: 300px; width: 250px;"></div>
<div id="plotPieT" class="spalte" style="height: 300px; width: 250px;"></div>
</div>

<!-- no events -->
<div id="noEventsDialog" style="display: none">
<p>There are no events in this pool to plot a statistic.</p>
</div>