| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 --> | 5 --><html><head><link rel="import" href="../lib/chart-loader.html"> |
| 6 | 6 |
| 7 <link rel="import" href="../lib/chart-loader.html"> | 7 <dom-module id="ct-chart"> |
| 8 | |
| 9 <polymer-element name="ct-chart" attributes="table options width height"> | |
| 10 <template> | 8 <template> |
| 11 <canvas id='chart' width="{{ width }}" height="{{ height }}"></canvas> | 9 <canvas id="chart" width="{{ width }}" height="{{ height }}"></canvas> |
| 12 </template> | 10 </template> |
| 13 <script> | 11 <script> |
| 14 Polymer({ | 12 Polymer({ |
| 15 table: null, | 13 is: 'ct-chart', |
| 16 options: null, | 14 properties: { |
| 17 observe: { | 15 height: { notify: true }, |
| 18 options: 'updateChart', | 16 options: { |
| 19 table: 'updateChart' | 17 value: null, |
| 18 notify: true, |
| 19 observer: 'updateChart' |
| 20 }, |
| 21 table: { |
| 22 value: null, |
| 23 notify: true, |
| 24 observer: 'updateChart' |
| 25 }, |
| 26 width: { notify: true } |
| 20 }, | 27 }, |
| 21 updateChart: function() { | 28 updateChart: function () { |
| 22 if (this.table == null || this.options == null) { | 29 if (this.table == null || this.options == null) { |
| 23 return; | 30 return; |
| 24 } | 31 } |
| 25 var ctx = this.$.chart.getContext("2d"); | 32 var ctx = this.$.chart.getContext('2d'); |
| 26 new Chart(ctx).Bar(this.table, this.options); | 33 new Chart(ctx).Bar(this.table, this.options); |
| 27 } | 34 } |
| 28 }); | 35 }); |
| 29 </script> | 36 </script> |
| 30 </template> | 37 </dom-module> |
| OLD | NEW |