# Gauge - Dynamic min and max

**URL:** <https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132>\
**Category:** Dashboard\
**Created:** [12 June 2019 16:13 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132 "2019-06-12T16:13:56Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [12 July 2019 13:35 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/21 "2019-07-12T13:35:31Z")

</div>

The values are transferred from a controller every 500 ms and updated. The summarizing in my drawing with the JOIN should only show as an example what I intend to do.

So if a new value for Min or Max is passed from the controller, this should also affect the gauge. I can not open every time a value changes there Node Red and adjust the values so that the display is correct.

The dashboard runs permanently on a display and has only one indicating task. Interactions are not possible, it should only inform.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [12 July 2019 13:41 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/22 "2019-07-12T13:41:14Z")

</div>

So the min and max may also change twice in second? This kind of gauge does not have any meaning then. It just have no readability.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 July 2019 13:42 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/23 "2019-07-12T13:42:38Z")

</div>

Hopefully min and max do not change that rapidly - or at least you can use RBE node to remove non-changed values - otherwise the gauge will flash like a bad one. (and indeed as @hotNipi says will be almost meaningless to a user, who needs to be able to glance at it to derive information.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [13 July 2019 06:30 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/24 "2019-07-13T06:30:59Z")

</div>

The values do not change 2 times per second. It is displayed for a long time Recipe 1 and then after a product change Recipe 2 for a long time.

I still do not know how to dynamically adjust the 2 values for min and max.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 July 2019 06:42 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/25 "2019-07-13T06:42:02Z")

</div>

In your very first post you had a variable called min. Replace the slider in my example with that.. Same for max.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [13 July 2019 11:47 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/26 "2019-07-13T11:47:38Z")

</div>

Hallo dceejay,

that's exactly what I was looking for. Many, many thanks for your help and sorry if I have hired something stupid. is there also a possibility for sector to implement this? a copy of your function and change from min to seg1 did not work.

 ![Seg](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bb9f169d99b35ef514a1f3bb0456154848776e69.jpeg)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 July 2019 11:58 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/27 "2019-07-13T11:58:58Z")

</div>

I think as seg1 is our variable you set it one layer higher (outside of options) Also I nite the dotted lines. Dashboard widgets are NOT supported in subflows.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [13 July 2019 12:14 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/28 "2019-07-13T12:14:37Z")

</div>

Do I understand it correctly that it is not possible for seg1 and seg2?

```auto
msg = {ui_control:{seg1:msg.payload}};
return msg;

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 July 2019 13:08 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/29 "2019-07-13T13:08:19Z")

</div>

you can set both if you want to

```
msg = {ui_control:{seg1:msg.payload, seg2:msg.somethingelse}};
return msg;
```

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [15 July 2019 06:53 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/30 "2019-07-15T06:53:58Z")

</div>

> [@dceejay](#):
>
> msg = {ui\_control:{seg1:msg.payload, seg2:msg.somethingelse}}; return msg;

it does not work. in the information of the gauge the value for seg1 and seg2 is always empty.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [15 July 2019 07:43 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/31 "2019-07-15T07:43:35Z")

</div>

you need to set some defaults, but it is working fine.

```auto
[{"id":"f03f3202.91e12","type":"ui_gauge","z":"adc578f5.614308","name":"","group":"cc1b923d.14259","order":3,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"20","seg2":"80","x":530,"y":1280,"wires":[]},{"id":"f541a866.024408","type":"function","z":"adc578f5.614308","name":"","func":"\nmsg = {ui_control:{min:msg.payload}};\nreturn msg;\n","outputs":1,"noerr":0,"x":350,"y":1340,"wires":[["f03f3202.91e12"]]},{"id":"4f5ad74c.0c4a18","type":"ui_slider","z":"adc578f5.614308","name":"","label":"data slider","tooltip":"","group":"cc1b923d.14259","order":4,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":170,"y":1280,"wires":[["f03f3202.91e12","89e6c9e5.a17318"]]},{"id":"d9ae1c43.b5801","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Min slider","tooltip":"","group":"cc1b923d.14259","order":5,"width":0,"height":0,"passthru":true,"outs":"end","topic":"min","min":0,"max":"40","step":1,"x":160,"y":1340,"wires":[["f541a866.024408"]]},{"id":"6b9aabc0.ddb044","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Max slider","tooltip":"","group":"cc1b923d.14259","order":6,"width":0,"height":0,"passthru":true,"outs":"end","topic":"max","min":"60","max":"100","step":1,"x":170,"y":1400,"wires":[["2a4eb1e2.a022ae"]]},{"id":"2a4eb1e2.a022ae","type":"function","z":"adc578f5.614308","name":"","func":"\nmsg = {ui_control:{max:msg.payload}};\nreturn msg;\n","outputs":1,"noerr":0,"x":350,"y":1400,"wires":[["f03f3202.91e12"]]},{"id":"5a6e3554.a86fcc","type":"function","z":"adc578f5.614308","name":"","func":"\nmsg = {ui_control:{seg1:msg.payload, seg2:(100-msg.payload)}};\nreturn msg;\n","outputs":1,"noerr":0,"x":350,"y":1460,"wires":[["f03f3202.91e12"]]},{"id":"ce01db4.aa12528","type":"ui_slider","z":"adc578f5.614308","name":"","label":"Seg slider","tooltip":"","group":"cc1b923d.14259","order":7,"width":0,"height":0,"passthru":true,"outs":"end","topic":"min","min":0,"max":"40","step":1,"x":180,"y":1460,"wires":[["5a6e3554.a86fcc"]]},{"id":"cc1b923d.14259","type":"ui_group","z":"","name":"Default","tab":"28f4e723.1c8a68","disp":true,"width":"6","collapse":false},{"id":"28f4e723.1c8a68","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Ragoth](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@Ragoth](https://discourse.nodered.org/u/Ragoth)\
**Post date:** [21 June 2021 21:19 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/34 "2021-06-21T21:19:37Z")

</div>

Thank you Mr. Dceejay I learned a useful lesson, I was looking for a Variable Range Gauge and I can readily adapt yours. Thank you.

---

<div class="post-metadata">

**Author:** ![ryan1998](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@ryan1998](https://discourse.nodered.org/u/ryan1998)\
**Post date:** [12 July 2021 13:02 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/35 "2021-07-12T13:02:45Z")

</div>

I read the docs on github.  
What is missing for me is a conditional approach:

`if(msg.payload>ui_gauge.max) ui_gauge.max=msg.payload;`

If would appreciate if anyone could let me know how this could be done.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 July 2021 14:34 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/36 "2021-07-12T14:34:27Z")

</div>

You could save the last max value in context & compare to that....

```javascript
var max = context.get("max") || 1; //get max value from memory context
if(msg.payload > max ) {
  max = msg.payload; //update max 
  context.set("max", max); //store max value
  node.send( {ui_control:{max: max}} ); //send update
}
return msg; 

```

---

<div class="post-metadata">

**Author:** ![reinuke](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@reinuke](https://discourse.nodered.org/u/reinuke)\
**Post date:** [26 September 2022 23:49 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/38 "2022-09-26T23:49:10Z")

</div>

Hi

Any idea how I could feed a gauge two diferent sets of values?  
And only Display set\_A IF Value \<= X kWH and set\_B if Value \>= X MWh ?  
And maybe.. possibly.. toggle between them? I have already found the Switch function but I'm frankly at a loss... Just started with NodeRed 😄

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b5af940b292ba83b5cf7e897fd9754799510b99d.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f06cb220d3a3d40d689ab4150e1b9084fbf52754.png)  
I also played around with an idea to have two Gauges and make either of them to go appear/hide IF payload = .... but the GUI doesn't offer that kind of functionality as far as I can tell and I have a feeling that might be out of my league.  
I tried to look around the flows.json file but couldn't see how I could make that last idea to work either.

Ideas, tips and or tricks are much appreciated.

---

<div class="post-metadata">

**Author:** ![allacmc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allacmc/32/73549_2.png) [@allacmc](https://discourse.nodered.org/u/allacmc)\
**Post date:** [3 January 2023 05:00 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/39 "2023-01-03T05:00:36Z")

</div>

First of all thank you very much for providing this help:

In which library's reference manual can I find all the properties of this gauge object? What about the other objects on the dasboard?

I only found this Seg1 and Seg2 here in this thread ... and that was after a lot of research.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 January 2023 07:52 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/40 "2023-01-03T07:52:29Z")

</div>

There is a list of all the config fields in the docs here [node-red-dashboard/config-fields.md at master · node-red/node-red-dashboard · GitHub](https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md)

---

<div class="post-metadata">

**Author:** ![davidz](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@davidz](https://discourse.nodered.org/u/davidz)\
**Post date:** [4 January 2023 00:51 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/41 "2023-01-04T00:51:47Z")

</div>

This is perfect Dave.

I was thinking about the dynamic range for ui\_slider the other day 😁

---

<div class="post-metadata">

**Author:** ![allacmc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allacmc/32/73549_2.png) [@allacmc](https://discourse.nodered.org/u/allacmc)\
**Post date:** [4 January 2023 01:57 UTC](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132/42 "2023-01-04T01:57:11Z")

</div>

Now yes, all the properties of the dashboard object.

Note 10. Thank you very much.

[Previous page](https://discourse.nodered.org/t/gauge-dynamic-min-and-max/12132.md?page=1)
