| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 # Copyright 2015 The LUCI Authors. All rights reserved. | |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | |
| 4 # that can be found in the LICENSE file. | |
| 5 | |
| 6 --> | |
| 7 | |
| 8 <!-- | |
| 9 @group Swarming Elements | |
| 10 | |
| 11 `stats-time-chart' encapsulates a 'google-chart' element and data formating | |
| 12 logic specific for Time chart of the Swarming statistics app. | |
| 13 This element exposes a 'data' attribute which is JSON serialized | |
| 14 `google.visualization.DataTable` object and a `resolution` attribute that is | |
| 15 'minutes', 'hours', or 'days'. | |
| 16 | |
| 17 Example: | |
| 18 <stats-time-chart data="{{data_table}}"></stats-time-chart> | |
| 19 | |
| 20 @element stats-time-chart | |
| 21 --> | |
| 22 | |
| 23 <link rel="import" href="bower_components/polymer/polymer.html"> | |
| 24 <link rel="import" href="stats-chart-base.html"> | |
| 25 | |
| 26 <polymer-element name="stats-time-chart" extends="stats-chart-base" attributes="
data resolution isDimension"> | |
| 27 <script> | |
| 28 Polymer('stats-time-chart', { | |
| 29 isDimension: false, | |
| 30 titleText: 'Times (s)', | |
| 31 | |
| 32 populate: function() { | |
| 33 this.resetFormattedData(); | |
| 34 | |
| 35 // These indexes are relative to stats_gviz._Summary.ORDER. | |
| 36 this.getKeyFormatter().format(this.dataTable, 0); | |
| 37 | |
| 38 var round3 = new google.visualization.NumberFormat( | |
| 39 {decimalSymbol:'.', fractionDigits:3}); | |
| 40 // These indexes are relative to stats_gviz._GVIZ_COLUMNS_ORDER. | |
| 41 if (this.isDimension) { | |
| 42 round3.format(this.dataTable, 6); | |
| 43 round3.format(this.dataTable, 7); | |
| 44 round3.format(this.dataTable, 8); | |
| 45 } else { | |
| 46 round3.format(this.dataTable, 8); | |
| 47 round3.format(this.dataTable, 9); | |
| 48 round3.format(this.dataTable, 10); | |
| 49 } | |
| 50 | |
| 51 var view = new google.visualization.DataView(this.dataTable); | |
| 52 if (this.dimension) { | |
| 53 view.setColumns([0, 6, 7, 8]); | |
| 54 } else { | |
| 55 view.setColumns([0, 8, 9, 10]); | |
| 56 } | |
| 57 | |
| 58 this.attachView(view); | |
| 59 } | |
| 60 }); | |
| 61 </script> | |
| 62 </polymer-element> | |
| OLD | NEW |