summaryrefslogtreecommitdiff
path: root/web-app/static/chart.js
blob: 23753ba16a9cb23059283e1daf279c76ce5fe0bb (plain)
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

function create_chart(div_name, branch, device, distro, version, max_results, f) {
   $.getJSON( "/results/tempest?count=" + max_results + "&branch=" + branch + "&device=" + device + "&osdistro=" + distro + "&osversion=" + version, function(data) {
      var failureDataPoints = [];
      var skippedDataPoints = [];
      var passingDataPoints = [];
      
      $.each(data, function (index, value) {
         if (value['t.all_tests'] > 0) {
            failureDataPoints.unshift({label: value['t.lava_job'], y: value['t.failing_tests']});
            skippedDataPoints.unshift({label: value['t.lava_job'], y: value['t.skipped_tests']});
            passingDataPoints.unshift({label: value['t.lava_job'], y: value['t.passing_tests']});
         }
      });

      if (failureDataPoints.length == 0 && skippedDataPoints.length == 0 && passingDataPoints.length == 0) {
         $('#' + div_name).hide();
         return;
      }

      var chart = new CanvasJS.Chart(div_name,
         {
            title: {
              fontSize: 20,
              text: "Branch \"" + branch + "\" on \"" + device + "\" running \"" + distro + "/" + version + "\" (up to last " + max_results + " results)"
            },
            legend: {
               cursor: "pointer",
               itemclick: function (e) {
                  if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
                     e.dataSeries.visible = false;
                  } else {
                     e.dataSeries.visible = true;
                  }
                  e.chart.render();
               }
            },
            axisY: {title: "# of Tests", titleFontSize: 18 },
            axisX: {
               title: "Test Job",
	       prefix: "Job ",
               titleFontSize: 18,
               interval: 1,
               labelFontSize: 12,
               labelAngle: 80
            },
            toolTip: { 
               content: function(e) {
                  var annotation_text = "";
		  
		  // check for matching job in global annotations data
		  if(e.entries[0].dataPoint.label in test_annotations_data) {
                     annotation_text = "<br/><hr/>" + test_annotations_data[e.entries[0].dataPoint.label];
                  }

                  var content;
                  content = e.entries[0].dataSeries.legendText + " <strong>" + e.entries[0].dataPoint.y + "</strong>" + annotation_text  ;
                  return content;
               }            
            },
            animationEnabled: true,
            zoomEnabled: true, 
            data: [
               {
                  name: "skip",
                  legendText: "Skipped Tests", showInLegend: true,
                  type: "stackedColumn",
                  color: "rgba(13,131,172,.8)",
                  dataPoints: skippedDataPoints,
                  click: function(e) {
                     f(e.dataPoint.label, e.dataSeries.name);
                  }
               },
               {
                  name: "fail",
                  legendText: "Failing Tests", showInLegend: true,
                  type: "stackedColumn",
                  color: "rgba(224,72,108,.8)",
                  dataPoints: failureDataPoints,
                  click: function(e) {
                     f(e.dataPoint.label, e.dataSeries.name);
                  }
               },
               {
                  name: "pass",
                  legendText: "Passing Tests", showInLegend: true,
                  type: "stackedColumn",
                  color: "rgba(159,204,64,.8)",
                  dataPoints: passingDataPoints,
                  click: function(e) {
                     f(e.dataPoint.label, e.dataSeries.name);
                  }
               }              
            ]
         });

         chart.render();
   });
}