# Change dashboard chart title dynamically

**URL:** <https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722>\
**Category:** Dashboard\
**Created:** [6 March 2020 14:33 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722 "2020-03-06T14:33:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gambafrolla](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gambafrolla/32/18054_2.png) [@gambafrolla](https://discourse.nodered.org/u/gambafrolla)\
**Post date:** [6 March 2020 14:33 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/1 "2020-03-06T14:33:35Z")

</div>

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:

```auto
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:

1. At first injection the title is correctly updated to:  
**Laser PowerMeter measure [W] @[2020-03-06 13:50:59]**
2. 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:

1. Laser PowerMeter measure [W] @[{{flow.get(last\_check)}}]
2. 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](https://github.com/node-red/node-red-dashboard/blob/master/config-fields.md)).

Does exist some other solution or workaround?

Thanks

---

<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:** [6 March 2020 14:47 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/2 "2020-03-06T14:47:02Z")

</div>

Sould be `msg.ui_control.options.title.text`  
[https://www.chartjs.org/docs/latest/configuration/title.html](https://www.chartjs.org/docs/latest/configuration/title.html)

---

<div class="post-metadata">

**Author:** ![gambafrolla](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gambafrolla/32/18054_2.png) [@gambafrolla](https://discourse.nodered.org/u/gambafrolla)\
**Post date:** [6 March 2020 15:26 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/3 "2020-03-06T15:26:02Z")

</div>

Thanks for the super fast reply @hotNipi.

Unfortunately I'v digged too in chart.js documentation and I've tried

```auto
msg.ui_control = {
  "ymin": 18,
  "ymax": 26,
  "options": {
    "title": {
      "text": "xxxxxxxxx"
    }
  }
}

```

leaving the GUI title form empty, without any success.

---

<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:** [6 March 2020 15:36 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/4 "2020-03-06T15:36:46Z")

</div>

Oh yes, the thing you want to change is the chart node's **label**.  
I dont know if it has any dynamic control options, the config-fields document says NO.  
@dceejay maybe can say something more solid about it...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 March 2020 15:52 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/5 "2020-03-06T15:52:22Z")

</div>

it's fixed in master...

---

<div class="post-metadata">

**Author:** ![gambafrolla](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gambafrolla/32/18054_2.png) [@gambafrolla](https://discourse.nodered.org/u/gambafrolla)\
**Post date:** [6 March 2020 16:27 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/6 "2020-03-06T16:27:34Z")

</div>

So the only way to change it is using the GUI editor?

I've tried also to insert in the GUI form:

Laser PowerMeter measure [W] @[**{{msg.last\_check}}**]

it works when the node in injected, as I've said, but refreshing the page resets the `msg.last_check` parameter.

---

<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:** [6 March 2020 17:17 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/7 "2020-03-06T17:17:52Z")

</div>

> [@gambafrolla](#):
>
> So the only way to change it is using the GUI editor?

Currently yes.

As it is made possible already in git, you can install the dashboard from git.  
Or you can wait for next release of dashboard....

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 March 2020 18:37 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/8 "2020-03-06T18:37:07Z")

</div>

Note - it still requires a refresh of the browser to update - it is not 100% dynamic.

---

<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:** [5 April 2020 18:37 UTC](https://discourse.nodered.org/t/change-dashboard-chart-title-dynamically/22722/9 "2020-04-05T18:37:10Z")

</div>

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