IoT - Kubus
/
Kubus
JNP3 16/17
Diff: frontend/kubus.js
- Revision:
- 22:af4397ca4561
- Parent:
- 21:959de2c64d28
- Child:
- 23:e643afa16ad1
--- a/frontend/kubus.js Mon Jan 09 18:49:48 2017 +0100 +++ b/frontend/kubus.js Mon Jan 09 19:00:05 2017 +0100 @@ -102,6 +102,13 @@ xAxes: [{ type: 'time', position: 'bottom' + }], + yAxes: [{ + display: true, + ticks: { + max: 100, + min: 0 + } }] }, legend: { @@ -113,9 +120,21 @@ } class NumberChart extends SensorChart { + constructor(name, options) { + super(name); + this.range = options.range; + } + render() { this.chart = new Chart(this.canvas, this._getConfig([])); } + + _getConfig(data) { + const config = super._getConfig(data); + config.options.scales.yAxes[0].ticks.max = this.range[1]; + config.options.scales.yAxes[0].ticks.min = this.range[0]; + return config; + } } class BoolChart extends SensorChart { @@ -126,6 +145,8 @@ _getConfig(data) { const config = super._getConfig(data); config.data.datasets[0].steppedLine = true; + config.options.scales.yAxes[0].ticks.max = 1; + config.options.scales.yAxes[0].ticks.min = 0; return config; } } @@ -134,7 +155,9 @@ static create(sensor) { switch (sensor.type) { case "number": - return new NumberChart(sensor.name); + return new NumberChart(sensor.name, { + "range": sensor.range + }); break; case "bool": return new BoolChart(sensor.name);