2015-10-16 00:36:02 +02:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
classNames: ['line-chart'],
|
|
|
|
attributeBindings: ['style'],
|
|
|
|
xaxisLength: 300,
|
|
|
|
height: '100%',
|
2015-10-21 00:22:54 +02:00
|
|
|
data: [],
|
|
|
|
options: {},
|
2015-10-16 00:36:02 +02:00
|
|
|
|
|
|
|
didInsertElement: function() {
|
|
|
|
this._drawPlot();
|
|
|
|
},
|
2015-10-21 00:22:54 +02:00
|
|
|
|
2015-10-16 00:36:02 +02:00
|
|
|
style: function() {
|
|
|
|
return "height: " + this.get('height') + ";";
|
|
|
|
}.property('height'),
|
|
|
|
|
|
|
|
_drawPlot: function() {
|
|
|
|
var element = this.get('element');
|
|
|
|
if (element && element.id) {
|
|
|
|
// draw plot
|
2015-10-21 00:22:54 +02:00
|
|
|
$.plot('#' + element.id, this.get('data'), this.get('options'));
|
2015-10-16 00:36:02 +02:00
|
|
|
}
|
2015-10-21 00:22:54 +02:00
|
|
|
}.observes('data')
|
2015-10-16 00:36:02 +02:00
|
|
|
});
|