# Gauge Type Level - Dynamically change Unit field

**URL:** <https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849>\
**Category:** Dashboard\
**Created:** [17 September 2022 13:07 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849 "2022-09-17T13:07:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mojgithub](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mojgithub/32/63532_2.png) [@mojgithub](https://discourse.nodered.org/u/mojgithub)\
**Post date:** [17 September 2022 13:07 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/1 "2022-09-17T13:07:42Z")

</div>

HI

i am trying to set this field in function before this node. Mililiters, Liters, Hectoliters or units ml, l, hl.  
 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/eb0367a767107aca9b81fe39e0c86abb02e7331e.png)

Function:  
msg.unit = "test";  
return msg;

I have tried with:  
{{unit}} {{msg.unit}} msg.unit

i have also tried with inserting in Value format field like this:  
{{value}} {{unit}}  
{{msg.payload}} {{msg.unit}}  
...

Not sure how to get this value.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 September 2022 13:22 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/2 "2022-09-17T13:22:49Z")

</div>

~~This works for me, `{{msg.unit}}` running on latest version dashboard 3.2.0~~

scratch that, i miss read , you are using level. Does not work for me.

---

<div class="post-metadata">

**Author:** ![Frida](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/frida/32/68250_2.png) [@Frida](https://discourse.nodered.org/u/Frida)\
**Post date:** [17 September 2022 16:28 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/3 "2022-09-17T16:28:05Z")

</div>

Try this.

```auto
[{"id":"d7f7ba999a0f5032","type":"ui_gauge","z":"829f16a2994adbca","name":"abc","group":"df87679bdeb6f942","order":0,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"{{msg.topic}}","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":590,"y":940,"wires":[]},{"id":"946733c3b656b537","type":"inject","z":"829f16a2994adbca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":940,"wires":[["b874f13ddcfc0514"]]},{"id":"b874f13ddcfc0514","type":"function","z":"829f16a2994adbca","name":"function 6","func":"let msg1= {}\n\nlet value = 86\n\nmsg1.topic = 'gallon' // Units\nmsg1.payload = value\n\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":940,"wires":[["d7f7ba999a0f5032","b19cb9342be806f5"]]},{"id":"b19cb9342be806f5","type":"debug","z":"829f16a2994adbca","name":"debug 15","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":600,"y":980,"wires":[]},{"id":"df87679bdeb6f942","type":"ui_group","name":"Default","tab":"34467927046a8b09","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"34467927046a8b09","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

 ![pic01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a4dcb61b5817718396e04ed6419376034f686c31.png)

It's all in the gauge help page.

---

<div class="post-metadata">

**Author:** ![mojgithub](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mojgithub/32/63532_2.png) [@mojgithub](https://discourse.nodered.org/u/mojgithub)\
**Post date:** [17 September 2022 16:43 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/4 "2022-09-17T16:43:26Z")

</div>

> [@Frida](#):
>
> ```auto
> [{"id":"d7f7ba999a0f5032","type":"ui_gauge","z":"829f16a2994adbca","name":"abc","group":"df87679bdeb6f942","order":0,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"{{msg.topic}}","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","className":"","x":590,"y":940,"wires":[]},{"id":"946733c3b656b537","type":"inject","z":"829f16a2994adbca","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":940,"wires":[["b874f13ddcfc0514"]]},{"id":"b874f13ddcfc0514","type":"function","z":"829f16a2994adbca","name":"function 6","func":"let msg1= {}\n\nlet value = 86\n\nmsg1.topic = 'gallon' // Units\nmsg1.payload = value\n\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":940,"wires":[["d7f7ba999a0f5032","b19cb9342be806f5"]]},{"id":"b19cb9342be806f5","type":"debug","z":"829f16a2994adbca","name":"debug 15","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":600,"y":980,"wires":[]},{"id":"df87679bdeb6f942","type":"ui_group","name":"Default","tab":"34467927046a8b09","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"34467927046a8b09","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
> 
> ```

Hey tnx for msg but this works only if u have type gauge but not when u have type "level".

---

<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:** [17 September 2022 17:06 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/5 "2022-09-17T17:06:38Z")

</div>

This is because of level type of gauge uses different library. It behaves differently, I cant say if it is possible to achieve different way but do explore the documents and you may find a way.

See notes from document bottom.

> <https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md>

---

<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:** [17 September 2022 17:09 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/6 "2022-09-17T17:09:45Z")

</div>

If the "Wave" animation is not main thing you are using the level gauge, it is easy enough to create your own level gauge.  
Here's the starting point.

> [@Dashboard tips. Let the ui\_text act as level gauge ... DIY gauge examples](https://discourse.nodered.org/t/dashboard-tips-let-the-ui-text-act-as-level-gauge-diy-gauge-examples/40878):
>
> A "poor-man" level gauge created with a few lines of jquery and css. [{"id":"36bcc3c8.68771c","type":"ui\_template","z":"a05ff4cd.1ae7e8","group":"19f5ed07.08a453","name":"loll","order":12,"width":"1","height":"0","format":"\<style\>\n .levelbody{\n background: #2626b4f7;\n height: 0%;\n position: absolute;\n width: 100%;\n bottom: 0;\n z-index:0;\n transition: height 1s;\n box-shadow: inset 0px 0px 10px 0px #00000080;\n \n }\n…

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [17 September 2022 17:59 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/7 "2022-09-17T17:59:18Z")

</div>

@dceejay @mojgithub

It **"looks"** like you could use - **symbol : string // special symbol to show next to value**  
However I cannot get this to work?

The docs above show `set msg.ui_control to JSON { "min":10, "max":50 }` this changes the gauge straight away.

`{"label":"test"} ` does work but only after refreshing the browser.

At the bottom of the docs it says -

```auto
The gauge options can accept any of the Justgage parameters for example:

 {"options":{"pointer":false,"gaugeWidthScale":1.5}}
 {"options":{"pointer":true,"gaugeWidthScale":0.4,"reverse":true}}

```

But `{"options":{"symbol":"K"}}` has no effect

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 October 2022 17:59 UTC](https://discourse.nodered.org/t/gauge-type-level-dynamically-change-unit-field/67849/8 "2022-10-17T17:59:29Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
