Hi everyone,
I'm desperately trying to dynamically set the title of a dashboard chart.
I have a dashboard with several charts that are periodically updated with data from a DB, everything works fine.
I would like to set the title of the chart with the information of the last update timestamp, something like:
Laser PowerMeter measure [W] @[2020-03-06 13:50:59]
First of all I've set the "Label" field in the "Edit chart" node GUI as:
Laser PowerMeter measure [W] @[{{msg.last_check}}]
and I've provided as input:
var alert_threshold_low = flow.get('alert_threshold_low');
var alert_threshold_high = flow.get('alert_threshold_high');
var data_name = []
var data_val = []
for (ind = 0; ind < 3; ind++)
{
data_name[ind] = msg.payload[ind].topic
data_val[ind] = msg.payload[ind].payload
}
msg.payload = [{
series: data_name,
data: data_val
}]
msg.ui_control = {"ymin":alert_threshold_low, "ymax":alert_threshold_high}
msg.last_check = flow.get("last_check");
return msg
Results:
- At first injection the title is correctly updated to:
Laser PowerMeter measure [W] @[2020-03-06 13:50:59] - But if I refresh the page the title goes back to the "unitialized" state:
Laser PowerMeter measure [W] @[]
I've tryed the weirdest solutions for the title such as:
- Laser PowerMeter measure [W] @[{{flow.get(last_check)}}]
- Laser PowerMeter measure [W] @[{{context.flow.last_check}}]
with of course no results.
Setting the title directly from msg.ui_control
its not possible directly. Maybe it can be achieved digging in the msg.ui_control.options
fiels, nut I was not able to do that (source github).
Does exist some other solution or workaround?
Thanks