From 3065ef88894055fe54ef2480e6c7cd9270841d49 Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Fri, 12 Jun 2020 19:17:43 +0200 Subject: [PATCH] Fix for Gauge Widget: Widget now doesn't look broken if no signal is selected #221 --- src/widget/widgets/gauge.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/widget/widgets/gauge.js b/src/widget/widgets/gauge.js index b273701..00ffa93 100644 --- a/src/widget/widgets/gauge.js +++ b/src/widget/widgets/gauge.js @@ -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 {