2015-10-09 09:22:35 +02:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
2015-10-09 11:35:31 +02:00
|
|
|
tagName: 'div',
|
2015-10-09 09:22:35 +02:00
|
|
|
classNames: ['line-chart'],
|
|
|
|
|
2015-10-09 11:35:31 +02:00
|
|
|
init: function() {
|
|
|
|
this._super();
|
|
|
|
this.addObserver('data', this.dataDidChange);
|
|
|
|
},
|
|
|
|
|
2015-10-09 09:22:35 +02:00
|
|
|
didInsertElement: function() {
|
2015-10-09 11:35:31 +02:00
|
|
|
this._drawPlot();
|
2015-10-09 12:29:32 +02:00
|
|
|
|
|
|
|
Ember.run.later(this, function() {
|
|
|
|
this._drawPlot();
|
|
|
|
}, 500);
|
2015-10-09 11:35:31 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
dataDidChange: function() {
|
|
|
|
this._drawPlot();
|
|
|
|
},
|
2015-10-09 09:22:35 +02:00
|
|
|
|
2015-10-09 11:35:31 +02:00
|
|
|
_drawPlot: function() {
|
|
|
|
var elementId = this.get('elementId');
|
2015-10-09 12:31:42 +02:00
|
|
|
if (elementId) {
|
|
|
|
$.plot('#' + elementId, this.data);
|
|
|
|
}
|
2015-10-09 12:29:32 +02:00
|
|
|
|
|
|
|
Ember.run.later(this, function() {
|
|
|
|
this._drawPlot();
|
|
|
|
}, 500);
|
2015-10-09 09:22:35 +02:00
|
|
|
}
|
|
|
|
});
|