Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: status/res/imp/bar-chart-sk.html

Issue 1051173003: Add controls to buildbot dashboard (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Simplify promise Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « status/elements.html ('k') | status/res/imp/buildbot-dash-sk.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!-- 1 <!--
2 The common.js file must be included before this file. 2 The common.js file must be included before this file.
3 3
4 This in an HTML Import-able file that contains the definition 4 This in an HTML Import-able file that contains the definition
5 of the following elements: 5 of the following elements:
6 6
7 <bar-chart-sk> 7 <bar-chart-sk>
8 8
9 To use this file import it: 9 To use this file import it:
10 10
11 <link href="/res/imp/bar-chart-sk.html" rel="import" /> 11 <link href="/res/imp/bar-chart-sk.html" rel="import" />
12 12
13 Usage: 13 Usage:
14 14
15 <bar-chart-sk heading="My Chart"></bar-chart-sk> 15 <bar-chart-sk heading="My Chart"></bar-chart-sk>
16 <script> 16 <script>
17 myChart.draw(columns, data); 17 myChart.draw(columns, data);
18 </script> 18 </script>
19 19
20 Properties: 20 Properties:
21 heading: string; title of the chart. 21 heading: string; title of the chart.
22 colors: array of strings; colors to use in the chart. 22 colors: array of strings; colors to use in the chart.
23 columns: array of arrays indicating the types and names of the columns, eg:
24 [["string", "seriesName"], ["number", "dataPoint"]].
25 data: array of arrays containing data for each column, eg:
26 [["series1", 42], ["series2", 7]].
23 27
24 Methods: 28 Methods:
25 draw: render the chart using the given columns and data. The 'columns' 29 draw: render the chart.
26 parameter is an array of arrays indicating the types and names of the
27 columns, eg: [["string", "seriesName"], ["number", "dataPoint"]].
28 The 'data' parameter is an array of arrays containing data for each
29 column, eg: [["series1", 42], ["series2", 7]].
30 --> 30 -->
31 <polymer-element name="bar-chart-sk"> 31 <polymer-element name="bar-chart-sk">
32 <template> 32 <template>
33 <style> 33 <style>
34 .chart { 34 .chart {
35 border: 1px solid #eeeeee; 35 border: 1px solid #eeeeee;
36 margin: 5px; 36 margin: 5px;
37 padding: 10px; 37 padding: 10px;
38 font-size: 12px;
39 }
40 h2 {
41 font-size: 16px;
38 } 42 }
39 .collapseHeader { 43 .collapseHeader {
40 cursor: pointer; 44 cursor: pointer;
41 } 45 }
42 .collapseBody { 46 .collapseBody {
43 padding: 10px; 47 padding: 10px;
44 } 48 }
45 </style> 49 </style>
46 <div class="chart"> 50 <div class="chart" id="host">
47 <div class="collapseHeader" on-click="{{toggle}}"> 51 <div class="collapseHeader" on-click="{{toggle}}" horizontal layout center >
48 {{heading}} 52 <h2 flex>{{heading}}</h2>
53 <core-icon icon="{{icon}}"></core-icon>
49 </div> 54 </div>
50 <core-collapse id="collapse"> 55 <core-collapse id="collapse" on-core-collapse-open="{{collapseOpen}}">
51 <div class="collapseBody" id="chartcontainer"></div> 56 <div class="collapseBody" id="chartcontainer"></div>
52 </core-collapse> 57 </core-collapse>
53 </div> 58 </div>
54 59
55 </template> 60 </template>
56 <script> 61 <script>
62 (function() {
63 var chartsReady = new Promise(function(resolve, reject) {
64 google.setOnLoadCallback(resolve);
65 });
66
57 Polymer({ 67 Polymer({
58 publish: { 68 publish: {
59 heading: { 69 heading: {
60 value: null, 70 value: null,
61 reflect: true, 71 reflect: true,
62 }, 72 },
63 colors: { 73 colors: {
64 value: [], 74 value: [],
65 reflect: false, 75 reflect: false,
66 }, 76 },
77 columns: {
78 value: null,
79 reflect: false,
80 },
81 data: {
82 value: null,
83 reflect: false,
84 },
85 },
86
87 created: function() {
88 this.icon = "arrow-drop-down";
89 },
90
91 ready: function() {
92 var that = this;
93 window.addEventListener("resize", function() {
94 that.draw();
95 });
67 }, 96 },
68 97
69 toggle: function() { 98 toggle: function() {
70 this.$.collapse.toggle(); 99 this.$.collapse.toggle();
71 }, 100 },
72 101
73 draw: function(columns, data) { 102 colorsChanged: function() {
74 var table = new google.visualization.DataTable(); 103 this.draw();
75 for (var i = 0; i < columns.length; i++) { 104 },
76 table.addColumn(columns[i][0], columns[i][1]); 105
106 columnsChanged: function() {
107 this.draw();
108 },
109
110 dataChanged: function() {
111 this.draw();
112 },
113
114 collapseOpen: function() {
115 if (this.$.collapse.opened) {
116 this.icon = "arrow-drop-up";
117 } else {
118 this.icon = "arrow-drop-down";
77 } 119 }
78 table.addRows(data); 120 },
79 121
80 var headerHeight = 0; 122 draw: function() {
81 var chartWidth = 400; 123 if (!this.columns || !this.data) {
82 var chartHeight = 15 * data.length; 124 return;
83 var labelWidth = 410;
84 var options = {
85 "chartArea": {
86 "top": headerHeight,
87 "left": labelWidth,
88 "width": chartWidth,
89 "height": chartHeight,
90 },
91 "legend": { "position": "none" },
92 "width": labelWidth + chartWidth,
93 "height": headerHeight + chartHeight,
94 "fontSize": 12,
95 "titleTextStyle": { "fontSize": 18 },
96 };
97 if (this.colors) {
98 options["colors"] = this.colors;
99 } 125 }
126 var that = this;
127 chartsReady.then(function() {
128 var table = new google.visualization.DataTable();
129 for (var i = 0; i < that.columns.length; i++) {
130 table.addColumn(that.columns[i][0], that.columns[i][1]);
131 }
132 table.addRows(that.data);
100 133
101 var chart = new google.visualization.BarChart(this.$.chartcontainer); 134 var totalWidth = that.$.host.offsetWidth;
102 chart.draw(table, options); 135 var headerHeight = 0;
136 var labelWidth = 410;
137 var chartWidth = totalWidth - labelWidth;
138 var chartHeight = 15 * that.data.length;
139 var options = {
140 "chartArea": {
141 "top": headerHeight,
142 "left": labelWidth,
143 "width": chartWidth,
144 "height": chartHeight,
145 },
146 "legend": { "position": "none" },
147 "width": totalWidth,
148 "height": headerHeight + chartHeight,
149 "fontSize": 12,
150 "titleTextStyle": { "fontSize": 18 },
151 };
152 if (that.colors) {
153 options["colors"] = that.colors;
154 }
155
156 var chart = new google.visualization.BarChart(that.$.chartcontainer);
157 chart.draw(table, options);
158 });
103 }, 159 },
104 }); 160 });
161 })();
105 </script> 162 </script>
106 </polymer-element> 163 </polymer-element>
OLDNEW
« no previous file with comments | « status/elements.html ('k') | status/res/imp/buildbot-dash-sk.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698