OLD | NEW |
---|---|
(Empty) | |
1 <!-- | |
2 Copyright 2014 The Chromium Authors. All rights reserved. | |
3 Use of this source code is governed by a BSD-style license that can be | |
4 found in the LICENSE file. | |
5 --> | |
6 | |
7 | |
8 <polymer-element name="ct-trooper-card" attributes="group"> | |
9 <template> | |
10 <style> | |
11 #failure { | |
12 flex: 1; | |
13 margin-left: 10px; | |
14 } | |
15 | |
16 #details { | |
17 font-weight: bold; | |
18 } | |
19 | |
20 #chart { | |
21 height: 100px; | |
22 width: 400px; | |
23 } | |
24 </style> | |
25 <div id="failure"> | |
26 <div id="details"> | |
27 {{ group.tree }}: {{ group.details }} | |
28 </div> | |
29 <div id='chart'></div> | |
30 </div> | |
31 </template> | |
32 <script> | |
33 Polymer({ | |
34 group: null, | |
35 fromPercent: function(v) { | |
36 return Number(v.substring(0, v.length - 1)); | |
37 }, | |
38 groupChanged: function() { | |
ojan
2014/09/04 02:58:44
Are there any tests for this code? I'd at least li
shans
2014/09/05 00:08:20
Done.
| |
39 if (!this.group) { | |
40 return; | |
41 } | |
42 switch (this.group.type) { | |
43 case 'cq_latency': | |
44 var dataTable = google.visualization.arrayToDataTable([ | |
45 ['Percentile', 'Limit', 'Actual', {role: 'style'}], | |
46 ['p50', 60, this.group.data.p50, this.group.data.p50 > 60 ? 'red' : 'green'], | |
47 ['p90', 180, this.group.data.p90, this.group.data.p90 > 180 ? 'red' : 'green'] | |
48 ]); | |
49 | |
50 var options = { | |
51 title: 'cq latency', | |
52 hAxis: {title: 'Percentile'}, | |
53 series: [{color: 'grey'}, {color: 'red'}] | |
54 }; | |
55 break; | |
56 case 'tree_status': | |
57 var dataTable = google.visualization.arrayToDataTable([ | |
58 ['', 'Minimum', 'Actual'], | |
59 ['Open', 80, this.group.data.percent_open] | |
60 ]); | |
61 | |
62 var options = { | |
63 title: 'tree status', | |
64 series: [{color: 'grey'}, {color: 'red'}] | |
65 }; | |
66 break; | |
67 case 'cycle_time': | |
68 var dataTable = google.visualization.arrayToDataTable([ | |
69 ['', 'Median', 'Max'], | |
70 ['percent of builds', | |
71 this.fromPercent(this.group.data.percent_over_median_slo), | |
72 this.fromPercent(this.group.data.percent_over_max_slo)] | |
73 ]); | |
74 | |
75 var options = { | |
76 title: 'cycle times over SLO', | |
77 series: [{color: 'orange'}, {color: 'red'}] | |
78 }; | |
79 break; | |
80 default: | |
81 return; | |
ojan
2014/09/04 02:58:44
Should we console.error here?
shans
2014/09/05 00:08:20
Done.
| |
82 } | |
83 options.height = 100; | |
84 options.vAxis = {minValue: 0}; | |
85 options.chartArea = {width: 200}; | |
86 var chart = new google.visualization.ColumnChart(this.$.chart); | |
87 chart.draw(dataTable, options); | |
88 }, | |
89 }); | |
90 </script> | |
91 </polymer-element> | |
OLD | NEW |