k5map
16 August 2025 05:09
1
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"}]
Colin
16 August 2025 07:37
2
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 . If so then feed the message you are sending into a degug node set to Output Complete Message and show us what it contains.
For accessing flow variables you should use flow.get()
, so for that case it should possibly be [{ "start": flow.get("PAVoltage").low, "color": "yellow"}]
k5map
16 August 2025 12:42
3
I’m using the DB2 Classis Gauge. I’m reading the documentation at this link:
@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:?
E1cid
16 August 2025 14:16
4
k5map:
r J:?
In the change node select J: and to use a flow context var use
$flowContext("PAVoltage")
There is a list of available functions in the JSONata editor dialogue
k5map
16 August 2025 14:47
5
Since the flow vars are PAVoltage.low and PAVoltage.hi, should I use $flowContext(“PAVoltage.low”) instead?
E1cid
16 August 2025 14:50
6
Yes, try it.
Or you can assign a var to the context object
($PAVoltage := $flowContext("PAVoltage);
[
{ "start": $PAVoltage.low, "color": "yellow"},
{ "start": $PAVoltage.hi, "color": "red"}
]
)
Colin
16 August 2025 15:12
7
I don't use JSONata except for very simple operations, so I would do it in a Function node using
msg.ui-update = [{ start: flow.get("PAVoltage").low, color: "yellow"},...]
k5map
16 August 2025 15:20
8
@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}
k5map
16 August 2025 15:26
9
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.
E1cid
16 August 2025 15:28
10
Should the sectors start at 0. @colin is the author/maintainer of the node, so he's the man who should know.
k5map
16 August 2025 15:31
11
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)?
Colin
16 August 2025 15:38
12
Try it with a number instead of a string, though it was sloppy of me if I don't allow a string.
Colin
16 August 2025 15:44
13
If your brain can cope with JSONata then that is fine. Mine can't easily which is why I generally use functions.
Colin
16 August 2025 15:50
14
Also make sure you are using the latest version of the node (1.4.0)
k5map
16 August 2025 16:04
15
@Colin confirmed I am running v1.4.0… ok I’m having major brain farts today… here is the code in my Function
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" }
];
return msg;
When I run this, I’m now getting TypeErrors on all the ui_update. What am I overlooking?
Colin
16 August 2025 16:08
16
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.
Colin
16 August 2025 16:11
17
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.
k5map
16 August 2025 16:21
18
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
k5map
16 August 2025 16:21
19
I guess me using semicolons shows how long I’ve been using NR
k5map
16 August 2025 17:06
20
@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