# Change chart label to message topic

**URL:** https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546
**Category:** Dashboard
**Created:** [25 April 2019 15:11 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546 "2019-04-25T15:11:08Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Louise](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Louise](https://discourse.nodered.org/u/Louise)
#### Post date: [25 April 2019 15:11 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/1 "2019-04-25T15:11:08Z")

</div>

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! 🙂

---

<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: [25 April 2019 15:28 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/2 "2019-04-25T15:28:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Louise](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Louise](https://discourse.nodered.org/u/Louise)
#### Post date: [26 April 2019 09:29 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/3 "2019-04-26T09:29:40Z")

</div>

Thank you!! That solved my problem 🙂 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.

---

<div class="post-metadata">

### Author: ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)
#### Post date: [15 May 2020 00:50 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/4 "2020-05-15T00:50:15Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b52846e060893a05a99ce3e946dafdebe3a7e803.png)

Here is the flow as you see it.

```auto
[{"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.

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [15 May 2020 04:29 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/5 "2020-05-15T04:29:41Z")

</div>

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

```auto
[{"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.

---

<div class="post-metadata">

### Author: ![thebaldgeek](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thebaldgeek/32/93523_2.png) [@thebaldgeek](https://discourse.nodered.org/u/thebaldgeek)
#### Post date: [15 May 2020 13:27 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/6 "2020-05-15T13:27:43Z")

</div>

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.

---

<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: [29 May 2020 13:27 UTC](https://discourse.nodered.org/t/change-chart-label-to-message-topic/10546/7 "2020-05-29T13:27:49Z")

</div>

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