# Dashboard 2.0 gauge

**URL:** <https://discourse.nodered.org/t/dashboard-2-0-gauge/94990>\
**Category:** Dashboard\
**Created:** [29 January 2025 18:18 UTC](https://discourse.nodered.org/t/dashboard-2-0-gauge/94990 "2025-01-29T18:18:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaarnou](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/klaarnou/32/97820_2.png) [@klaarnou](https://discourse.nodered.org/u/klaarnou)\
**Post date:** [29 January 2025 18:18 UTC](https://discourse.nodered.org/t/dashboard-2-0-gauge/94990/1 "2025-01-29T18:18:07Z")

</div>

Hello,

I want to set the gauge segment colors via function but cannot get it to work.  
This is my code:

```auto
msg.ui_update = 
{"segments" : 
    [
        { color: "blue", from: 0 },
        { color: "green", from: 15 },
        { color: "red", from: 35 }
    ]
};

```

What am I doing wrong?

And:

According to google this should work but it causes an error:

```auto
msg.ui_update.segments = [
  { color: "red", from: 0 },
  { color: "blue", from: 10 },
  { color: "green", from: 20 }
]

```

thanks for your help.

---

<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:** [29 January 2025 18:43 UTC](https://discourse.nodered.org/t/dashboard-2-0-gauge/94990/2 "2025-01-29T18:43:27Z")

</div>

> [@klaarnou](#):
>
> According to google this should work but it causes an error:

It is always helpful to include the error - however I imagine this one fails because `ui_update` is undefined. i.e. add `msg.ui_update = {}` on the line before so that `ui_update` is an object.

  

> [@klaarnou](#):
>
> This is my code:
> 
> ```auto
> msg.ui_update = 
> {"segments" : 
> [
> { color: "blue", from: 0 },
> { color: "green", from: 15 },
> { color: "red", from: 35 }
> ]
> };
> 
> ```

That looks ok, but what are you doing with it? Do you return the msg? have you checked with a debug node that the msg contains the "right stuff"? did you wire it into the gauge node? Have you tried sending a new value along with it in the `payload`?

---

<div class="post-metadata">

**Author:** ![klaarnou](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/klaarnou/32/97820_2.png) [@klaarnou](https://discourse.nodered.org/u/klaarnou)\
**Post date:** [29 January 2025 19:43 UTC](https://discourse.nodered.org/t/dashboard-2-0-gauge/94990/3 "2025-01-29T19:43:22Z")

</div>

Hello Steve.

Thanks for your help

msg.ui\_update = {} solved my problem.

cheers,

Bernard.

---

<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:** [12 February 2025 19:43 UTC](https://discourse.nodered.org/t/dashboard-2-0-gauge/94990/4 "2025-02-12T19:43:31Z")

</div>

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