Change chart label to message topic

Hello,

In my project I'm dealing with a lot of charts and my life would become a lot easier if I can change the chart label to my message topic so that the title displayed above my chart changes automatically depending on the data that I receive.

Thank you! :slight_smile:

The info tab includes " The label can also be set by a message property by setting the field to the name of the property, for example {{msg.topic}} ", though I haven't tried it. It is possible that applies to the Blank Label field, it is a bit ambiguous.

1 Like

Thank you!! That solved my problem :slight_smile: I did have to put a delay of five seconds between the message containing my plot data and my chart because for some reason it did otherwise not show my message topic as chart name. I think that has to do with the time needed to load the chart.

I did put the {{msg:topic}} in the label field.

I would be really appreciative for some help on how to do this....
I am trying to change the chart label with a switch.
Trying to follow this thread, I have put the msg.topic in the chart label field.
I then change the msg.payload (from the switch) to msg.topic.

I found that I needed to delete msg.payload otherwise it will get plotted on the graph. (And distort the data)

Here is how it looks.

Here is the flow as you see it.

[{"id":"1db2e2c0.c00cfd","type":"ui_switch","z":"fa1bd60e.5b6d3","name":"","label":"switch","tooltip":"","group":"aaf2913b.d4fb2","order":12,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"6559","onvalueType":"str","onicon":"","oncolor":"","offvalue":"6543","offvalueType":"str","officon":"","offcolor":"","x":370,"y":2360,"wires":[["d788e3b7.9dd4"]]},{"id":"d788e3b7.9dd4","type":"change","z":"fa1bd60e.5b6d3","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":2360,"wires":[["2eb581c9.f1164e"]]},{"id":"2eb581c9.f1164e","type":"change","z":"fa1bd60e.5b6d3","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":2360,"wires":[["34929f9c.2a704"]]},{"id":"34929f9c.2a704","type":"ui_chart","z":"fa1bd60e.5b6d3","name":"radio","group":"7fb7ae04.feeca","order":2,"width":7,"height":4,"label":"{{msg:topic}}","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"15","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":910,"y":2360,"wires":[[]]},{"id":"a6763656.1d7948","type":"inject","z":"fa1bd60e.5b6d3","name":"data to plot","topic":"","payload":"22","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":750,"y":2300,"wires":[["34929f9c.2a704"]]},{"id":"aaf2913b.d4fb2","type":"ui_group","z":"","name":"SDR VFO A - San Francisco Memory Bank","tab":"3dfdfe5c.067752","order":3,"disp":true,"width":"7","collapse":false},{"id":"7fb7ae04.feeca","type":"ui_group","z":"","name":"Reciver Status","tab":"3dfdfe5c.067752","order":1,"disp":false,"width":"15","collapse":false},{"id":"3dfdfe5c.067752","type":"ui_tab","z":"","name":"HF ACARS","icon":"flight","order":7,"disabled":false,"hidden":false}]

(Using the inject node to simulate the data, of course it comes from a live msg.payload).

EDIT. It works for 1 second. Each time I flip the switch, the new title shows for 1 second then goes blank.

Don't use msg.topic cos the other input has empty string
The label field should not have {{msg.something}} but just {{something}}

[{"id":"a8ff4456.e2ebd8","type":"ui_switch","z":"3dd56201.af994e","name":"","label":"switch","tooltip":"","group":"ac0391bf.644ae","order":12,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"6559","onvalueType":"str","onicon":"","oncolor":"","offvalue":"6543","offvalueType":"str","officon":"","offcolor":"","x":380,"y":640,"wires":[["1aa580fc.5fa91f"]]},{"id":"1aa580fc.5fa91f","type":"change","z":"3dd56201.af994e","name":"","rules":[{"t":"set","p":"label","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":640,"wires":[["8ac3229c.397b1"]]},{"id":"8ac3229c.397b1","type":"ui_chart","z":"3dd56201.af994e","name":"radio","group":"4c5d2071.a6ffd","order":2,"width":7,"height":"6","label":"{{label}}","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"15","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":750,"y":640,"wires":[[]]},{"id":"36258542.2aab0a","type":"inject","z":"3dd56201.af994e","name":"data to plot","topic":"","payload":"22","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":590,"wires":[["8ac3229c.397b1"]]},{"id":"ac0391bf.644ae","type":"ui_group","z":"","name":"SDR VFO A - San Francisco Memory Bank","tab":"cfe7d05f.a23b8","order":3,"disp":true,"width":"7","collapse":false},{"id":"4c5d2071.a6ffd","type":"ui_group","z":"","name":"Reciver Status","tab":"cfe7d05f.a23b8","order":1,"disp":false,"width":"15","collapse":false},{"id":"cfe7d05f.a23b8","type":"ui_tab","z":"","name":"HF ACARS","icon":"flight","order":7,"disabled":false,"hidden":false}]

You will need also to send initial data for label when dashboard connects.

2 Likes

Thank you so much.
Working very well.
No way I would have figured that out on my own!

Wish I could mark your post as the actual working solution.

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