# Pass segment values to DB2 chart widget

**URL:** <https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689>\
**Category:** Dashboard\
**Tags:** dashboard-2\
**Created:** [16 August 2025 05:09 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689 "2025-08-16T05:09:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 05:09 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/1 "2025-08-16T05:09:24Z")

</div>

I’ve read in the documentation on the DB2 Gauge widget where you can pass the segment values via msg.ui\_update.sectors using an array: [{ "start": 0, "color": "green"}, { "start": 5, "color": "skyblue"}]

I’m using a Change widget to pass other dynamic properties but can’t seem to get the segment values to work. What value type do I use for the array? Also, I need to pass this array where I’m using flow vars:

[{ "start": flow.PAVoltage.low, "color": "yellow"}, { "start": flow.PAVoltage.hi, "color": "red"}]

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 07:37 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/2 "2025-08-16T07:37:51Z")

</div>

> [@k5map](#):
>
> I’ve read in the documentation on the DB2 Gauge widget where you can pass the segment values via msg.ui\_update.sectors using an array: [{ "start": 0, "color": "green"}, { "start": 5, "color": "skyblue"}]

Can you show us where you read that? The help text says that it should be msg.ui\_update.segments and the data should be `[{ "from": 0, "color": "green"}, { "from": 5, "color": "skyblue"}]

Or perhaps you are not using the core DB2 gauge but the [classic gauge](https://flows.nodered.org/node/@colinl/node-red-dashboard-2-ui-gauge-classic). If so then feed the message you are sending into a degug node set to Output Complete Message and show us what it contains.

> [@k5map](#):
>
> [{ "start": flow.PAVoltage.low, "color": "yellow"}, { "start": flow.PAVoltage.hi, "color": "red"}]

For accessing flow variables you should use `flow.get()`, so for that case it should possibly be `[{ "start": flow.get("PAVoltage").low, "color": "yellow"}]`

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 12:42 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/3 "2025-08-16T12:42:41Z")

</div>

I’m using the DB2 Classis Gauge. I’m reading the documentation at this link:  
[@colinl/node-red-dashboard-2-ui-gauge-classic](https://flows.nodered.org/node/@colinl/node-red-dashboard-2-ui-gauge-classic)  
Under section Dynamic Properties, Sectors

When I use “flow.get("PAVoltage").low” in the Change widget to set msg.ui\_update.sectors, which type of value do I select it is? It does not work if I select String, JSON or J:?

---

<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:** [16 August 2025 14:16 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/4 "2025-08-16T14:16:04Z")

</div>

> [@k5map](#):
>
> r J:?

In the change node select J: and to use a flow context var use

```auto
$flowContext("PAVoltage")

```

There is a list of available functions in the JSONata editor dialogue

 ![Screenshot_20250816-151905](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/69b161a11405a0b181f8410e7839c9ccc72727ad.png)

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 14:47 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/5 "2025-08-16T14:47:58Z")

</div>

Since the flow vars are PAVoltage.low and PAVoltage.hi, should I use $flowContext(“PAVoltage.low”) instead?

---

<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:** [16 August 2025 14:50 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/6 "2025-08-16T14:50:11Z")

</div>

Yes, try it.

Or you can assign a var to the context object

```auto
($PAVoltage := $flowContext("PAVoltage);
    [
        { "start": $PAVoltage.low, "color": "yellow"},
        { "start": $PAVoltage.hi, "color": "red"}
    ]
)
```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 15:12 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/7 "2025-08-16T15:12:36Z")

</div>

I don't use JSONata except for very simple operations, so I would do it in a Function node using

```auto
msg.ui-update = [{ start: flow.get("PAVoltage").low, color: "yellow"},...]

```

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 15:20 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/8 "2025-08-16T15:20:16Z")

</div>

@E1cid … ok I confirmed with Debug widget I am successfully passing the array to the Gauge widget but for some d\*\*m reason it is not using it.

> {"valueDecimalPlaces":"1","min":0,"sectors":[{"start":10.5,"color":"yellow"},{"start":15,"color":"red"}],"max":17}

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 15:26 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/9 "2025-08-16T15:26:19Z")

</div>

What’s even more strange is in the above array… the min and max values are being displayed but the array and valueDecimalPlaces are not.

---

<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:** [16 August 2025 15:28 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/10 "2025-08-16T15:28:39Z")

</div>

Should the sectors start at 0. @colin is the author/maintainer of the node, so he's the man who should know.

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 15:31 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/11 "2025-08-16T15:31:08Z")

</div>

I was trying to keep it simple (lol) by using the Change widget but have no objection switching to the Function. Any idea why the valueDecimalPlaces is not being accepted (displays 2 digits)?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 15:38 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/12 "2025-08-16T15:38:45Z")

</div>

> [@k5map](#):
>
> Any idea why the valueDecimalPlaces is not being accepted (displays 2 digits)?

Try it with a number instead of a string, though it was sloppy of me if I don't allow a string.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 15:44 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/13 "2025-08-16T15:44:39Z")

</div>

> [@k5map](#):
>
> have no objection switching to the Function

If your brain can cope with JSONata then that is fine. Mine can't easily which is why I generally use functions.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 15:50 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/14 "2025-08-16T15:50:00Z")

</div>

> [@k5map](#):
>
> Any idea why the valueDecimalPlaces is not being accepted (displays 2 digits)?

Also make sure you are using the latest version of the node (1.4.0)

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 16:04 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/15 "2025-08-16T16:04:14Z")

</div>

@Colin confirmed I am running v1.4.0… ok I’m having major brain farts today… here is the code in my Function

> ```auto
> let sector1 = flow.get("PAVoltage.low");
> let sector2 = flow.get("PAVoltage.hi");
> let msg.ui_update = {};
> 
> msg.ui_update.valueDecimalPlaces = 1;
> msg.ui_update.min = 0;
> msg.ui_update.max = 17;
> msg.ui_update.sectors = [
> { "start": sector1, "color": "yellow" },
> { "start": sector2, "color": "red" }
> ];
> 
> ```
> 
> ```auto
> return msg;
> 
> ```

When I run this, I’m now getting TypeErrors on all the ui\_update. What am I overlooking?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 16:08 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/16 "2025-08-16T16:08:42Z")

</div>

> [@k5map](#):
>
> `let msg.ui_update = {};`

Take off the `let`. msg already exists  
`msg.ui_update = {}`

Also generally you don't need semicolons on the end of lines. They don't do any harm though, just wear on the fingers and keyboard.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 August 2025 16:11 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/17 "2025-08-16T16:11:52Z")

</div>

If it still doesn't work feed the output into a debug node set to Output Complete message and show us what it says. Expand the objects in there.

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 16:21 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/18 "2025-08-16T16:21:00Z")

</div>

Ok here is the output from Debug

> {  
> "topic":"RAD/334/+13.8A",  
> "meter":4,  
> "payload":13.49,  
> "\_msgid":"a6fc84d983db3836",  
> "ui\_update":{  
> "valueDecimalPlaces":1,  
> "min":0,  
> "max":17,  
> "sectors": [{"start":10.5,"color":"yellow"},{"start":15,"color":"red"}]  
> }  
> }

Using this output, the gauge widget does display min & max but the sectors and decimal places are not being shown correctly

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 16:21 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/19 "2025-08-16T16:21:55Z")

</div>

I guess me using semicolons shows how long I’ve been using NR 😂

---

<div class="post-metadata">

**Author:** ![k5map](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/k5map/32/47681_2.png) [@k5map](https://discourse.nodered.org/u/k5map)\
**Post date:** [16 August 2025 17:06 UTC](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689/20 "2025-08-16T17:06:53Z")

</div>

@Colin … on a somewhat related subject. In the documentation concerning Configuration, Sectors, it states that

> The colours may be recognised names such as "red" or "skyblue" or may be numerically specified

Where do you enter the color names? When I click on the color on the left, I’m only able to enter RGB values

[Next page](https://discourse.nodered.org/t/pass-segment-values-to-db2-chart-widget/98689.md?page=2)
