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/bar-chart.js
2015-10-26 14:56:29 -04:00

44 lines
1,019 B
JavaScript

import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'div',
classNames: ['bar-chart'],
attributeBindings: ['style'],
minValue: '',
maxValue: '',
width: 150,
height: 300,
didInsertElement: function() {
this._drawChart();
},
style: function() {
return 'width: ' + this.get('width') + '; height: ' + this.get('height') + ';';
}.property('width', 'height'),
_drawChart: function() {
// get element
var element = this.get('element');
if (element && element.id) {
if (this.data) {
// chart options
var options = { xaxis: { show: false }, yaxis: {} };
if (this.get('minValue') !== '') {
options.yaxis.min = this.get('minValue');
}
if (this.get('maxValue') !== '') {
options.yaxis.max = this.get('maxValue');
}
// draw chart
$.plot('#' + element.id, this.data, options);
} else {
// draw empty chart
$.plot('#' + element.id, [[]], { xaxis: { show: false }, yaxis: { show: false }});
}
}
}.observes('data')
});