# Chart Dashboard 2 undefined legend

**URL:** <https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102>\
**Category:** Dashboard\
**Created:** [1 October 2024 12:14 UTC](https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102 "2024-10-01T12:14:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juntiedt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/juntiedt/32/58357_2.png) [@juntiedt](https://discourse.nodered.org/u/juntiedt)\
**Post date:** [1 October 2024 12:14 UTC](https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102/1 "2024-10-01T12:14:53Z")

</div>

I am ínitialising my chart with this lines of code:

```auto
node.send({ payload: [] });
node.send({ topic: "SZ", payload: 0 });
node.send({ topic: "AZ", payload: 0 });
node.send({ topic: "WZ", payload: 0 });
node.send({ topic: "BZ", payload: 0 });
node.status({ text: "chart initialisiert" });
return null;

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a2e7b33c75f8a0d8e354ca47f8ed20c90238f59b.png)

unfortunately it shows a 5th color as undefined.  
What I am doing wrong?

---

<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:** [1 October 2024 12:36 UTC](https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102/2 "2024-10-01T12:36:07Z")

</div>

Your screenshot shows that other data are being sent to the chart. If you disconnect all wires to the chart except for the ones from your function do you still see the fifth one? If not then I suspect there is a message with no topic getting through.

If not that, does it change it if you add one of the valid topics to the first message?

---

<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:** [1 October 2024 13:07 UTC](https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102/3 "2024-10-01T13:07:19Z")

</div>

Each payload you send with a topic is taken as a series, as one payload has an undefined topic it is taken as a new series `undefined`.

You can reset the chart using the msg.action `replace` and send all the reset data in one go. You add data by sending an object with same layout as reset data. The keys for the object is set in the chart config.

here is an example

```auto
[{"id":"071abfb923a2d4c0","type":"inject","z":"d1395164b4eec73e","name":"reset data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":7640,"wires":[["fcd2a48a9031f22f"]]},{"id":"fcd2a48a9031f22f","type":"function","z":"d1395164b4eec73e","name":"function 158","func":"msg.action = \"replace\";\nlet now = new Date().valueOf()\nmsg.payload = [\n { \n topic: \"SZ\", \n value: 0,\n time: now\n },{ \n topic: \"AZ\", \n value: 0,\n time: now \n },{ \n topic: \"WZ\", \n value: 0,\n time: now\n },{ \n topic: \"BZ\", \n value: 0,\n time: now \n }\n]\nnode.status({ text: \"chart initialisiert\" });\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":7640,"wires":[["5b9b55950e84d913","5583ee3f0a507d7f"]]},{"id":"5b9b55950e84d913","type":"debug","z":"d1395164b4eec73e","name":"debug 2576","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":7640,"wires":[]},{"id":"5583ee3f0a507d7f","type":"ui-chart","z":"d1395164b4eec73e","group":"9d83cd8b3d5ee33c","name":"","label":"chart","order":2,"chartType":"line","category":"topic","categoryType":"property","xAxisLabel":"","xAxisProperty":"time","xAxisPropertyType":"property","xAxisType":"time","xAxisFormat":"","xAxisFormatType":"auto","yAxisLabel":"","yAxisProperty":"value","ymin":"","ymax":"","action":"append","stackSeries":false,"pointShape":"circle","pointRadius":4,"showLegend":true,"removeOlder":1,"removeOlderUnit":"3600","removeOlderPoints":"","colors":["#0095ff","#ff0000","#ff7f0e","#2ca02c","#a347e1","#d62728","#ff9896","#9467bd","#c5b0d5"],"textColor":["#666666"],"textColorDefault":true,"gridColor":["#e5e5e5"],"gridColorDefault":true,"width":6,"height":8,"className":"","x":650,"y":7720,"wires":[[]]},{"id":"17909baf8ccbcf89","type":"inject","z":"d1395164b4eec73e","name":"add reading/value","props":[{"p":"payload.time","v":"","vt":"date"},{"p":"payload.value","v":"1","vt":"num"},{"p":"payload.topic","v":"SZ","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":310,"y":7760,"wires":[["5583ee3f0a507d7f"]]},{"id":"9d83cd8b3d5ee33c","type":"ui-group","name":"Group1","page":"c694d0ebe0d2b702","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"c694d0ebe0d2b702","type":"ui-page","name":"Page1","ui":"1805777f90e92057","path":"/page1","icon":"home","layout":"grid","theme":"a965ccfef139317a","order":2,"className":"","visible":"true","disabled":"false"},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"showPageTitle":true,"titleBarStyle":"default"},{"id":"a965ccfef139317a","type":"ui-theme","name":"HN Theme","colors":{"surface":"#5c5c5c","primary":"#00fdff","bgPage":"#383838","groupBg":"#4f4f4f","groupOutline":"#858585"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

```

---

<div class="post-metadata">

**Author:** ![juntiedt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/juntiedt/32/58357_2.png) [@juntiedt](https://discourse.nodered.org/u/juntiedt)\
**Post date:** [1 October 2024 13:16 UTC](https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102/4 "2024-10-01T13:16:51Z")

</div>

I found the problem. There was a initialisation routine that send a value of 0 to the chart.  
Thaks for the tips.

---

<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:** [31 October 2024 13:17 UTC](https://discourse.nodered.org/t/chart-dashboard-2-undefined-legend/92102/5 "2024-10-31T13:17:26Z")

</div>

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