1<!DOCTYPE html>
2<!--
3Copyright 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/model/event_set.html">
9<link rel="import" href="/tracing/ui/base/table.html">
10<link rel="import" href="/tracing/value/ui/scalar_span.html">
11<link rel="import" href="/tracing/value/unit.html">
12
13<polymer-element name="tr-ui-a-power-sample-table">
14  <template>
15    <style>
16    :host {
17      display: flex;
18    }
19    </style>
20    <tr-ui-b-table id="table"></tr-ui-b-table>
21  </template>
22</polymer-element>
23
24<script>
25'use strict';
26var EventSet = tr.model.EventSet;
27
28Polymer('tr-ui-a-power-sample-table', {
29  ready: function() {
30    this.$.table.tableColumns = [
31      {
32        title: 'Time',
33        width: '100px',
34        value: function(row) {
35          return tr.v.ui.createScalarSpan(row.start, {
36            unit: tr.v.Unit.byName.timeStampInMs
37          });
38        }
39      },
40      {
41        title: 'Power',
42        width: '100%',
43        value: function(row) {
44          return tr.v.ui.createScalarSpan(row.power / 1000, {
45            unit: tr.v.Unit.byName.powerInWatts
46          });
47        }
48      }
49    ];
50    this.samples = new EventSet();
51  },
52
53  get samples() {
54    return this.samples_;
55  },
56
57  set samples(samples) {
58    this.samples_ = (samples === undefined) ? new EventSet() : samples;
59    this.updateContents_();
60  },
61
62  updateContents_: function() {
63    this.$.table.tableRows = this.samples.toArray();
64    this.$.table.rebuild();
65  }
66});
67</script>
68