# Consistency on Chart Colors With Live Data

**URL:** <https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530>\
**Category:** General\
**Created:** [30 November 2021 19:47 UTC](https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530 "2021-11-30T19:47:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aa0z](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@aa0z](https://discourse.nodered.org/u/aa0z)\
**Post date:** [30 November 2021 19:47 UTC](https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530/1 "2021-11-30T19:47:24Z")

</div>

I've got quite a few charts & bar graphs in my dashboard that populate with live data.

Being a newbie to charts and populating them with live data, no matter at the time interval the data gets pushed to a chart node, how can I ensure the same msg.topics get set to the same color in every chart or bar graph?

I have the following function right before my chart to populate the chart.

```auto
let total = msg.payload.total;
let band = msg.payload.band;

if (band == '1.8')
{
    band = '160M'
}
if (band == '3.5')
{
    band = '80M'
}
if (band == '7')
{
    band = '40M'
}
if (band == '14')
{
    band = '20M'
}
if (band == '21')
{
    band = '15M'
}
if (band == '28')
{
    band = '10M'
}

msg.topic = band;
msg.payload = total;

return msg;

```

Thanks  
Kyle

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 November 2021 20:46 UTC](https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530/2 "2021-11-30T20:46:10Z")

</div>

Here is one way

> [@Chart line color](https://discourse.nodered.org/t/chart-line-color/13427/2):
>
> No super simple way to do that. But what you can do is preset them in the order you want. The colours are set in the config. The first topic to arrive gets first colour, etc. So create an inject that sends a null message on each topic in order you want at deploy time. Then when real data arrives it will pick up the colour you want.

---

<div class="post-metadata">

**Author:** ![aa0z](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@aa0z](https://discourse.nodered.org/u/aa0z)\
**Post date:** [30 November 2021 20:51 UTC](https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530/3 "2021-11-30T20:51:55Z")

</div>

Ugh...that is nasty. Ok, thanks for the reply.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [1 December 2021 09:45 UTC](https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530/4 "2021-12-01T09:45:31Z")

</div>

Not really.

All you do is have an inject node and create a message which has an empty message with the same structure as your incoming messages with their data and have the fields set to blanks.

One node, one message injected at the start.

If you want to get more complicated there are other ways of doing with with the `join` node.  
But that has it's own set of problems.

---

<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:** [30 January 2022 09:46 UTC](https://discourse.nodered.org/t/consistency-on-chart-colors-with-live-data/54530/5 "2022-01-30T09:46:00Z")

</div>

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