# How to create chart node for each item in array?

**URL:** <https://discourse.nodered.org/t/how-to-create-chart-node-for-each-item-in-array/28499>\
**Category:** Dashboard\
**Created:** [17 June 2020 21:39 UTC](https://discourse.nodered.org/t/how-to-create-chart-node-for-each-item-in-array/28499 "2020-06-17T21:39:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [17 June 2020 21:39 UTC](https://discourse.nodered.org/t/how-to-create-chart-node-for-each-item-in-array/28499/1 "2020-06-17T21:39:53Z")

</div>

I have a comma delimited string of device names, I split this, loop per payload defined on split, this works great. In the split loop, if you will, I ping each device, report ping result to debug, send email if failed ping, all good so far.

Now, for the question in the topic title, I want to create a chart for each ping result per device, i.e. a chart per device. If I add a chart node, in the split loop, the same existing chart object is used over and over. Not what I want. I want to create a unique chart option per item in the array as noted above.

I can't seem to find a qualified example of this or similar via google?

---

<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:** [17 June 2020 22:05 UTC](https://discourse.nodered.org/t/how-to-create-chart-node-for-each-item-in-array/28499/2 "2020-06-17T22:05:25Z")

</div>

You either need to create a chart per device. Or you could use a single bar chart and ensure each device reports on a different topic

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [17 June 2020 22:33 UTC](https://discourse.nodered.org/t/how-to-create-chart-node-for-each-item-in-array/28499/3 "2020-06-17T22:33:39Z")

</div>

Or I guess write a complex function that basically creates a way to create a chart per device. I was afraid I already knew the answer to my question. For the sake of completeness, what I did was create switch node, that tests for the host name (from the ping node output), and sends ping return value to the appropriate chart. Anyone that knows what a case or switch statement is in C or Visual Basic .NET will understand how this works. It is not elegant, but easy to understand. Just have to remember is I change the device list, I have to change the list of chart nodes, add or remove as needed.

---

<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:** [1 July 2020 22:39 UTC](https://discourse.nodered.org/t/how-to-create-chart-node-for-each-item-in-array/28499/4 "2020-07-01T22:39:02Z")

</div>

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