Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 22:af4397ca4561, committed 2017-01-09
- Comitter:
- Micha? ?azowik
- Date:
- Mon Jan 09 19:00:05 2017 +0100
- Parent:
- 21:959de2c64d28
- Child:
- 23:e643afa16ad1
- Commit message:
- Use provided range in charts
Changed in this revision
| frontend/kubus.js | Show annotated file Show diff for this revision Revisions of this file |
--- 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);