1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-16 00:00:03 +01:00
VILLASweb/app/components/line-chart.js

61 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-10-09 09:22:35 +02:00
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'div',
2015-10-09 09:22:35 +02:00
classNames: ['line-chart'],
2015-10-12 12:25:14 +02:00
xaxisLength: 60,
2015-10-09 09:22:35 +02:00
init: function() {
this._super();
this.addObserver('data', this.dataDidChange);
},
2015-10-09 09:22:35 +02:00
didInsertElement: function() {
this._drawPlot();
Ember.run.later(this, function() {
this._drawPlot();
}, 500);
},
dataDidChange: function() {
this._drawPlot();
},
2015-10-09 09:22:35 +02:00
_drawPlot: function() {
2015-10-12 12:25:14 +02:00
if (this.data) {
var element = this.get('element');
if (element && element.id) {
// calculate displayed xaxis
/*var length = this.data.length;
var startIndex = 0;
var endIndex = this.xaxisLength;
if (length > this.xaxisLength) {
startIndex = length - this.xaxisLength;
endIndex = length;
}
// display the chart
$.plot('#' + element.id, this.data, {
xaxis: {
min: startIndex,
max: endIndex
},
});*/
$.plot('#' + element.id, [this.data], {
xaxis: {
mode: 'time',
timeformat: '%H:%M:%S'
}
});
Ember.run.later(this, function() {
this._drawPlot();
}, 500);
}
}
2015-10-09 09:22:35 +02:00
}
});