summaryrefslogtreecommitdiffstats
path: root/public/media/js/typePlot.js
blob: 09f12adba28e1f7212b0a55cb85eb7d094905a18 (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
//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/typeplot/poolID/" + poolID, function(data) {
          if(data.dataBar == '0,other,0,repeat,0,immediate' && poolID != 'default') {
              $('#plotBar').empty();
              $('#plotPie').empty();
              $( "#noEventsDialog" ).dialog('open');
            } else if (poolID == 'default') {
              $('#plotBar').empty();
              $('#plotPie').empty();
            } else refreshPlot(data.dataBar, data.dataPie);
        }, "json");
}

function refreshPlot(dataBar, dataPie) {
    $('#plotBar').empty();
    $.jqplot('plotBar', dataBar, {
          seriesDefaults: {
          renderer:$.jqplot.BarRenderer,
          pointLabels: { show: true, location: 'e', edgeTolerance: -15 },
          shadowAngle: 135,
          rendererOptions: {
              barDirection: 'horizontal',
              varyBarColor : true
          }
      },
      axes: {
          yaxis: {
              renderer: $.jqplot.CategoryAxisRenderer
          }
      }
      });
    $('#plotPie').empty();
    $.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
                        }
                      }
                    });
  }

$(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");
            }
    });
  });