1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Fix for Gauge Widget: Widget now doesn't look broken if no signal is selected #221

This commit is contained in:
Laura Fuentes Grau 2020-06-12 19:17:43 +02:00
parent 6568056198
commit 3065ef8889

View file

@ -75,7 +75,7 @@ class WidgetGauge extends Component {
static getDerivedStateFromProps(props, state){
if(props.widget.signalIDs.length === 0){
return{ value: 0};
return{ value: 0, minValue: 0, maxValue: 10};
}
// get the signal with the selected signal ID
@ -103,8 +103,7 @@ class WidgetGauge extends Component {
|| props.data[icID] == null
|| props.data[icID].output == null
|| props.data[icID].output.values == null) {
returnState["value"] = 0;
return returnState;
return{ value: 0, minValue: 0, maxValue: 10};
}
// memorize if min or max value is updated
@ -202,7 +201,7 @@ class WidgetGauge extends Component {
for (let i = 0; i < labelCount; i++) {
labels.push(minValue + labelStep * i);
}
// calculate zones
let zones = this.props.widget.customProperties.colorZones ? this.props.widget.customProperties.zones : null;
if (zones != null) {
@ -214,6 +213,7 @@ class WidgetGauge extends Component {
});
}
if(this.state.signalID !== ''){
this.gauge.setOptions({
staticLabels: {
font: '10px "Helvetica Neue"',
@ -224,6 +224,7 @@ class WidgetGauge extends Component {
staticZones: zones
});
}
}
computeGaugeOptions(widget) {
return {