# Multiple chart lines from single array

**URL:** <https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, database, function-node\
**Created:** [12 September 2022 15:33 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616 "2022-09-12T15:33:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![becsL](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@becsL](https://discourse.nodered.org/u/becsL)\
**Post date:** [12 September 2022 15:33 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616/1 "2022-09-12T15:33:14Z")

</div>

Hi there, I am losing my mind staring at this one problem and I think I am oh so very close but I just can't crack this nut. I think there is the need for a 'For Loop' within a 'For Loop'. Hopefully you can help!

What I am trying to plot is a join of 4 individual query results (torque) from my influxdb. I have managed to get the results mapped to the point where each tool has an array of x: time and y: torque. All the x values are the same for all tools and is is just the y values that I wish to overlay.

This is an example of the function that I used to map the JSON results from influx to the key:value pairs for plotting

```auto
s1 = msg.payload[0].map(obj => {return {x: obj._time, y: obj._value}})
msg.payload = s1;
return msg;

```

This is the resulting array, post-join, is what I am trying to plot. I have copied and pasted a sample of data. It is an array of 4, where each array has an array of 45 where each object has the x and a y value.

```auto
[[{"x":"2022-09-08T15:05:18.000Z","y":0},{"x":"2022-09-08T15:05:19.000Z","y":0},{"x":"2022-09-08T15:05:20.000Z","y":0},{"x":"2022-09-08T15:05:22.000Z","y":0},{"x":"2022-09-08T15:05:23.000Z","y":0},{"x":"2022-09-08T15:05:24.000Z","y":0},{"x":"2022-09-08T15:05:25.000Z","y":0},{"x":"2022-09-08T15:05:27.000Z","y":0},{"x":"2022-09-08T15:05:28.000Z","y":0},{"x":"2022-09-08T15:05:29.000Z","y":0},{"x":"2022-09-08T15:05:31.000Z","y":0},{"x":"2022-09-08T15:05:32.000Z","y":0},{"x":"2022-09-08T15:05:33.000Z","y":0},{"x":"2022-09-08T15:05:34.000Z","y":0},{"x":"2022-09-08T15:05:36.000Z","y":0},{"x":"2022-09-08T15:05:37.000Z","y":0},{"x":"2022-09-08T15:05:38.000Z","y":0},{"x":"2022-09-08T15:05:40.000Z","y":0},{"x":"2022-09-08T15:05:41.000Z","y":0},{"x":"2022-09-08T15:05:42.000Z","y":0},{"x":"2022-09-08T15:05:43.000Z","y":0},{"x":"2022-09-08T15:05:45.000Z","y":0},{"x":"2022-09-08T15:05:46.000Z","y":0},{"x":"2022-09-08T15:05:47.000Z","y":0},{"x":"2022-09-08T15:05:49.000Z","y":0},{"x":"2022-09-08T15:05:50.000Z","y":-0.01},{"x":"2022-09-08T15:05:51.000Z","y":0.027},{"x":"2022-09-08T15:05:53.000Z","y":0.002},{"x":"2022-09-08T15:05:54.000Z","y":0},{"x":"2022-09-08T15:05:56.000Z","y":0},{"x":"2022-09-08T15:05:57.000Z","y":0},{"x":"2022-09-08T15:05:58.000Z","y":0},{"x":"2022-09-08T15:05:59.000Z","y":0},{"x":"2022-09-08T15:06:01.000Z","y":0},{"x":"2022-09-08T15:06:02.000Z","y":0},{"x":"2022-09-08T15:06:03.000Z","y":0},{"x":"2022-09-08T15:06:05.000Z","y":0},{"x":"2022-09-08T15:06:06.000Z","y":0},{"x":"2022-09-08T15:06:07.000Z","y":0},{"x":"2022-09-08T15:06:09.000Z","y":0},{"x":"2022-09-08T15:06:10.000Z","y":0},{"x":"2022-09-08T15:06:11.000Z","y":0},{"x":"2022-09-08T15:06:13.000Z","y":0},{"x":"2022-09-08T15:06:14.000Z","y":0},{"x":"2022-09-08T15:06:16.000Z","y":0}],[{"x":"2022-09-08T15:05:18.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:19.000Z","y":0.068},{"x":"2022-09-08T15:05:20.000Z","y":0.063},{"x":"2022-09-08T15:05:22.000Z","y":0.049},{"x":"2022-09-08T15:05:23.000Z","y":0.068},{"x":"2022-09-08T15:05:24.000Z","y":0.068},{"x":"2022-09-08T15:05:25.000Z","y":0.096},{"x":"2022-09-08T15:05:27.000Z","y":0.068},{"x":"2022-09-08T15:05:28.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:29.000Z","y":0.063},{"x":"2022-09-08T15:05:31.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:32.000Z","y":0.065},{"x":"2022-09-08T15:05:33.000Z","y":0.065},{"x":"2022-09-08T15:05:34.000Z","y":0.065},{"x":"2022-09-08T15:05:36.000Z","y":0.049},{"x":"2022-09-08T15:05:37.000Z","y":0.065},{"x":"2022-09-08T15:05:38.000Z","y":0.065},{"x":"2022-09-08T15:05:40.000Z","y":0.063},{"x":"2022-09-08T15:05:41.000Z","y":0.065},{"x":"2022-09-08T15:05:42.000Z","y":0.068},{"x":"2022-09-08T15:05:43.000Z","y":0.065},{"x":"2022-09-08T15:05:45.000Z","y":0.06},{"x":"2022-09-08T15:05:46.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:47.000Z","y":0.077},{"x":"2022-09-08T15:05:49.000Z","y":0.077},{"x":"2022-09-08T15:05:50.000Z","y":0.053},{"x":"2022-09-08T15:05:51.000Z","y":0.065},{"x":"2022-09-08T15:05:53.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:54.000Z","y":0.049},{"x":"2022-09-08T15:05:56.000Z","y":0.079},{"x":"2022-09-08T15:05:57.000Z","y":0.079},{"x":"2022-09-08T15:05:58.000Z","y":0.049},{"x":"2022-09-08T15:05:59.000Z","y":0.063},{"x":"2022-09-08T15:06:01.000Z","y":0.065},{"x":"2022-09-08T15:06:02.000Z","y":0.065},{"x":"2022-09-08T15:06:03.000Z","y":0.065},{"x":"2022-09-08T15:06:05.000Z","y":0.079},{"x":"2022-09-08T15:06:06.000Z","y":0.075},{"x":"2022-09-08T15:06:07.000Z","y":0.065},{"x":"2022-09-08T15:06:09.000Z","y":0.065},{"x":"2022-09-08T15:06:10.000Z","y":0.046},{"x":"2022-09-08T15:06:11.000Z","y":0.079},{"x":"2022-09-08T15:06:13.000Z","y":0.06},{"x":"2022-09-08T15:06:14.000Z","y":0.063},{"x":"2022-09-08T15:06:16.000Z","y":0.07}],[{"x":"2022-09-08T15:05:18.000Z","y":-5.712},{"x":"2022-09-08T15:05:19.000Z","y":-4.752},{"x":"2022-09-08T15:05:20.000Z","y":-5.159},{"x":"2022-09-08T15:05:22.000Z","y":-4.752},{"x":"2022-09-08T15:05:23.000Z","y":-4.817},{"x":"2022-09-08T15:05:24.000Z","y":-5.179},{"x":"2022-09-08T15:05:25.000Z","y":-4.931},{"x":"2022-09-08T15:05:27.000Z","y":-5.8420000000000005},{"x":"2022-09-08T15:05:28.000Z","y":-5.607},{"x":"2022-09-08T15:05:29.000Z","y":-5.696},{"x":"2022-09-08T15:05:31.000Z","y":-5.224},{"x":"2022-09-08T15:05:32.000Z","y":-4.963},{"x":"2022-09-08T15:05:33.000Z","y":-4.915},{"x":"2022-09-08T15:05:34.000Z","y":-5.484},{"x":"2022-09-08T15:05:36.000Z","y":-5.4030000000000005},{"x":"2022-09-08T15:05:37.000Z","y":-5.8580000000000005},{"x":"2022-09-08T15:05:38.000Z","y":-4.752},{"x":"2022-09-08T15:05:40.000Z","y":-4.296},{"x":"2022-09-08T15:05:41.000Z","y":-6.607},{"x":"2022-09-08T15:05:42.000Z","y":-5.077},{"x":"2022-09-08T15:05:43.000Z","y":-5.452},{"x":"2022-09-08T15:05:45.000Z","y":-5.029},{"x":"2022-09-08T15:05:46.000Z","y":-5.354},{"x":"2022-09-08T15:05:47.000Z","y":-5.549},{"x":"2022-09-08T15:05:49.000Z","y":-5.061},{"x":"2022-09-08T15:05:50.000Z","y":-4.963},{"x":"2022-09-08T15:05:51.000Z","y":-5.94},{"x":"2022-09-08T15:05:53.000Z","y":-5.142},{"x":"2022-09-08T15:05:54.000Z","y":-4.996},{"x":"2022-09-08T15:05:56.000Z","y":-5.37},{"x":"2022-09-08T15:05:57.000Z","y":-5.305},{"x":"2022-09-08T15:05:58.000Z","y":-5.614},{"x":"2022-09-08T15:05:59.000Z","y":-5.224},{"x":"2022-09-08T15:06:01.000Z","y":-5.468},{"x":"2022-09-08T15:06:02.000Z","y":-5.647},{"x":"2022-09-08T15:06:03.000Z","y":-5.159},{"x":"2022-09-08T15:06:05.000Z","y":-5.4350000000000005},{"x":"2022-09-08T15:06:06.000Z","y":-5.045},{"x":"2022-09-08T15:06:07.000Z","y":-5.338},{"x":"2022-09-08T15:06:09.000Z","y":-5.256},{"x":"2022-09-08T15:06:10.000Z","y":-4.963},{"x":"2022-09-08T15:06:11.000Z","y":-4.882},{"x":"2022-09-08T15:06:13.000Z","y":-5.663},{"x":"2022-09-08T15:06:14.000Z","y":-6.168},{"x":"2022-09-08T15:06:16.000Z","y":-4.687}],[{"x":"2022-09-08T15:05:18.000Z","y":-2.262},{"x":"2022-09-08T15:05:19.000Z","y":-2.49},{"x":"2022-09-08T15:05:20.000Z","y":-1.367},{"x":"2022-09-08T15:05:22.000Z","y":-1.062},{"x":"2022-09-08T15:05:23.000Z","y":-2.213},{"x":"2022-09-08T15:05:24.000Z","y":-2.734},{"x":"2022-09-08T15:05:25.000Z","y":-2.0020000000000002},{"x":"2022-09-08T15:05:27.000Z","y":-2.1},{"x":"2022-09-08T15:05:28.000Z","y":-0.586},{"x":"2022-09-08T15:05:29.000Z","y":-0.782},{"x":"2022-09-08T15:05:31.000Z","y":-2.995},{"x":"2022-09-08T15:05:32.000Z","y":-2.23},{"x":"2022-09-08T15:05:33.000Z","y":-0.993},{"x":"2022-09-08T15:05:34.000Z","y":-2.49},{"x":"2022-09-08T15:05:36.000Z","y":-2.197},{"x":"2022-09-08T15:05:37.000Z","y":-2.605},{"x":"2022-09-08T15:05:38.000Z","y":-1.969},{"x":"2022-09-08T15:05:40.000Z","y":-0.635},{"x":"2022-09-08T15:05:41.000Z","y":-2.4250000000000003},{"x":"2022-09-08T15:05:42.000Z","y":-2.458},{"x":"2022-09-08T15:05:43.000Z","y":-0.684},{"x":"2022-09-08T15:05:45.000Z","y":-1.351},{"x":"2022-09-08T15:05:46.000Z","y":-2.213},{"x":"2022-09-08T15:05:47.000Z","y":-2.246},{"x":"2022-09-08T15:05:49.000Z","y":-1.416},{"x":"2022-09-08T15:05:50.000Z","y":-0.863},{"x":"2022-09-08T15:05:51.000Z","y":-2.116},{"x":"2022-09-08T15:05:53.000Z","y":-1.481},{"x":"2022-09-08T15:05:54.000Z","y":-1.6280000000000001},{"x":"2022-09-08T15:05:56.000Z","y":-2.083},{"x":"2022-09-08T15:05:57.000Z","y":0.178},{"x":"2022-09-08T15:05:58.000Z","y":-31.649},{"x":"2022-09-08T15:05:59.000Z","y":-0.245},{"x":"2022-09-08T15:06:01.000Z","y":-0.212},{"x":"2022-09-08T15:06:02.000Z","y":-0.228},{"x":"2022-09-08T15:06:03.000Z","y":-0.245},{"x":"2022-09-08T15:06:05.000Z","y":-0.228},{"x":"2022-09-08T15:06:06.000Z","y":-0.196},{"x":"2022-09-08T15:06:07.000Z","y":-0.228},{"x":"2022-09-08T15:06:09.000Z","y":-0.245},{"x":"2022-09-08T15:06:10.000Z","y":-0.245},{"x":"2022-09-08T15:06:11.000Z","y":-0.277},{"x":"2022-09-08T15:06:13.000Z","y":-0.179},{"x":"2022-09-08T15:06:14.000Z","y":-0.212},{"x":"2022-09-08T15:06:16.000Z","y":-0.212}]]

```

This is as far as I have gotten which I thought was bang on but it doesn't show up in the chart, it's just blank.

```auto
msg.payload =[
    {
        labels:["Torque"],
        series:["S1 Torque (Nm)", "S2 Torque (Nm)", "S4 Torque (Nm)","S5 Torque (Nm)"],
        data:[
            [msg.payload[0].map(obj => {return {x: obj.x, y: obj.y}})],
            [msg.payload[1].map(obj => {return {x: obj.x, y: obj.y}})],
            [msg.payload[2].map(obj => {return {x: obj.x, y: obj.y}})],
            [msg.payload[3].map(obj => {return {x: obj.x, y: obj.y}})]
        ]
    }
]

return msg;

```

result of which is:

```auto
[{"labels":["Torque"],"series":["S1 Torque (Nm)","S2 Torque (Nm)","S4 Torque (Nm)","S5 Torque (Nm)"],"data":[[[{"x":"2022-09-08T15:05:18.000Z","y":0},{"x":"2022-09-08T15:05:19.000Z","y":0},{"x":"2022-09-08T15:05:20.000Z","y":0},{"x":"2022-09-08T15:05:22.000Z","y":0},{"x":"2022-09-08T15:05:23.000Z","y":0},{"x":"2022-09-08T15:05:24.000Z","y":0},{"x":"2022-09-08T15:05:25.000Z","y":0},{"x":"2022-09-08T15:05:27.000Z","y":0},{"x":"2022-09-08T15:05:28.000Z","y":0},{"x":"2022-09-08T15:05:29.000Z","y":0},{"x":"2022-09-08T15:05:31.000Z","y":0},{"x":"2022-09-08T15:05:32.000Z","y":0},{"x":"2022-09-08T15:05:33.000Z","y":0},{"x":"2022-09-08T15:05:34.000Z","y":0},{"x":"2022-09-08T15:05:36.000Z","y":0},{"x":"2022-09-08T15:05:37.000Z","y":0},{"x":"2022-09-08T15:05:38.000Z","y":0},{"x":"2022-09-08T15:05:40.000Z","y":0},{"x":"2022-09-08T15:05:41.000Z","y":0},{"x":"2022-09-08T15:05:42.000Z","y":0},{"x":"2022-09-08T15:05:43.000Z","y":0},{"x":"2022-09-08T15:05:45.000Z","y":0},{"x":"2022-09-08T15:05:46.000Z","y":0},{"x":"2022-09-08T15:05:47.000Z","y":0},{"x":"2022-09-08T15:05:49.000Z","y":0},{"x":"2022-09-08T15:05:50.000Z","y":-0.01},{"x":"2022-09-08T15:05:51.000Z","y":0.027},{"x":"2022-09-08T15:05:53.000Z","y":0.002},{"x":"2022-09-08T15:05:54.000Z","y":0},{"x":"2022-09-08T15:05:56.000Z","y":0},{"x":"2022-09-08T15:05:57.000Z","y":0},{"x":"2022-09-08T15:05:58.000Z","y":0},{"x":"2022-09-08T15:05:59.000Z","y":0},{"x":"2022-09-08T15:06:01.000Z","y":0},{"x":"2022-09-08T15:06:02.000Z","y":0},{"x":"2022-09-08T15:06:03.000Z","y":0},{"x":"2022-09-08T15:06:05.000Z","y":0},{"x":"2022-09-08T15:06:06.000Z","y":0},{"x":"2022-09-08T15:06:07.000Z","y":0},{"x":"2022-09-08T15:06:09.000Z","y":0},{"x":"2022-09-08T15:06:10.000Z","y":0},{"x":"2022-09-08T15:06:11.000Z","y":0},{"x":"2022-09-08T15:06:13.000Z","y":0},{"x":"2022-09-08T15:06:14.000Z","y":0},{"x":"2022-09-08T15:06:16.000Z","y":0}]],[[{"x":"2022-09-08T15:05:18.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:19.000Z","y":0.068},{"x":"2022-09-08T15:05:20.000Z","y":0.063},{"x":"2022-09-08T15:05:22.000Z","y":0.049},{"x":"2022-09-08T15:05:23.000Z","y":0.068},{"x":"2022-09-08T15:05:24.000Z","y":0.068},{"x":"2022-09-08T15:05:25.000Z","y":0.096},{"x":"2022-09-08T15:05:27.000Z","y":0.068},{"x":"2022-09-08T15:05:28.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:29.000Z","y":0.063},{"x":"2022-09-08T15:05:31.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:32.000Z","y":0.065},{"x":"2022-09-08T15:05:33.000Z","y":0.065},{"x":"2022-09-08T15:05:34.000Z","y":0.065},{"x":"2022-09-08T15:05:36.000Z","y":0.049},{"x":"2022-09-08T15:05:37.000Z","y":0.065},{"x":"2022-09-08T15:05:38.000Z","y":0.065},{"x":"2022-09-08T15:05:40.000Z","y":0.063},{"x":"2022-09-08T15:05:41.000Z","y":0.065},{"x":"2022-09-08T15:05:42.000Z","y":0.068},{"x":"2022-09-08T15:05:43.000Z","y":0.065},{"x":"2022-09-08T15:05:45.000Z","y":0.06},{"x":"2022-09-08T15:05:46.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:47.000Z","y":0.077},{"x":"2022-09-08T15:05:49.000Z","y":0.077},{"x":"2022-09-08T15:05:50.000Z","y":0.053},{"x":"2022-09-08T15:05:51.000Z","y":0.065},{"x":"2022-09-08T15:05:53.000Z","y":0.051000000000000004},{"x":"2022-09-08T15:05:54.000Z","y":0.049},{"x":"2022-09-08T15:05:56.000Z","y":0.079},{"x":"2022-09-08T15:05:57.000Z","y":0.079},{"x":"2022-09-08T15:05:58.000Z","y":0.049},{"x":"2022-09-08T15:05:59.000Z","y":0.063},{"x":"2022-09-08T15:06:01.000Z","y":0.065},{"x":"2022-09-08T15:06:02.000Z","y":0.065},{"x":"2022-09-08T15:06:03.000Z","y":0.065},{"x":"2022-09-08T15:06:05.000Z","y":0.079},{"x":"2022-09-08T15:06:06.000Z","y":0.075},{"x":"2022-09-08T15:06:07.000Z","y":0.065},{"x":"2022-09-08T15:06:09.000Z","y":0.065},{"x":"2022-09-08T15:06:10.000Z","y":0.046},{"x":"2022-09-08T15:06:11.000Z","y":0.079},{"x":"2022-09-08T15:06:13.000Z","y":0.06},{"x":"2022-09-08T15:06:14.000Z","y":0.063},{"x":"2022-09-08T15:06:16.000Z","y":0.07}]],[[{"x":"2022-09-08T15:05:18.000Z","y":-5.712},{"x":"2022-09-08T15:05:19.000Z","y":-4.752},{"x":"2022-09-08T15:05:20.000Z","y":-5.159},{"x":"2022-09-08T15:05:22.000Z","y":-4.752},{"x":"2022-09-08T15:05:23.000Z","y":-4.817},{"x":"2022-09-08T15:05:24.000Z","y":-5.179},{"x":"2022-09-08T15:05:25.000Z","y":-4.931},{"x":"2022-09-08T15:05:27.000Z","y":-5.8420000000000005},{"x":"2022-09-08T15:05:28.000Z","y":-5.607},{"x":"2022-09-08T15:05:29.000Z","y":-5.696},{"x":"2022-09-08T15:05:31.000Z","y":-5.224},{"x":"2022-09-08T15:05:32.000Z","y":-4.963},{"x":"2022-09-08T15:05:33.000Z","y":-4.915},{"x":"2022-09-08T15:05:34.000Z","y":-5.484},{"x":"2022-09-08T15:05:36.000Z","y":-5.4030000000000005},{"x":"2022-09-08T15:05:37.000Z","y":-5.8580000000000005},{"x":"2022-09-08T15:05:38.000Z","y":-4.752},{"x":"2022-09-08T15:05:40.000Z","y":-4.296},{"x":"2022-09-08T15:05:41.000Z","y":-6.607},{"x":"2022-09-08T15:05:42.000Z","y":-5.077},{"x":"2022-09-08T15:05:43.000Z","y":-5.452},{"x":"2022-09-08T15:05:45.000Z","y":-5.029},{"x":"2022-09-08T15:05:46.000Z","y":-5.354},{"x":"2022-09-08T15:05:47.000Z","y":-5.549},{"x":"2022-09-08T15:05:49.000Z","y":-5.061},{"x":"2022-09-08T15:05:50.000Z","y":-4.963},{"x":"2022-09-08T15:05:51.000Z","y":-5.94},{"x":"2022-09-08T15:05:53.000Z","y":-5.142},{"x":"2022-09-08T15:05:54.000Z","y":-4.996},{"x":"2022-09-08T15:05:56.000Z","y":-5.37},{"x":"2022-09-08T15:05:57.000Z","y":-5.305},{"x":"2022-09-08T15:05:58.000Z","y":-5.614},{"x":"2022-09-08T15:05:59.000Z","y":-5.224},{"x":"2022-09-08T15:06:01.000Z","y":-5.468},{"x":"2022-09-08T15:06:02.000Z","y":-5.647},{"x":"2022-09-08T15:06:03.000Z","y":-5.159},{"x":"2022-09-08T15:06:05.000Z","y":-5.4350000000000005},{"x":"2022-09-08T15:06:06.000Z","y":-5.045},{"x":"2022-09-08T15:06:07.000Z","y":-5.338},{"x":"2022-09-08T15:06:09.000Z","y":-5.256},{"x":"2022-09-08T15:06:10.000Z","y":-4.963},{"x":"2022-09-08T15:06:11.000Z","y":-4.882},{"x":"2022-09-08T15:06:13.000Z","y":-5.663},{"x":"2022-09-08T15:06:14.000Z","y":-6.168},{"x":"2022-09-08T15:06:16.000Z","y":-4.687}]],[[{"x":"2022-09-08T15:05:18.000Z","y":-2.262},{"x":"2022-09-08T15:05:19.000Z","y":-2.49},{"x":"2022-09-08T15:05:20.000Z","y":-1.367},{"x":"2022-09-08T15:05:22.000Z","y":-1.062},{"x":"2022-09-08T15:05:23.000Z","y":-2.213},{"x":"2022-09-08T15:05:24.000Z","y":-2.734},{"x":"2022-09-08T15:05:25.000Z","y":-2.0020000000000002},{"x":"2022-09-08T15:05:27.000Z","y":-2.1},{"x":"2022-09-08T15:05:28.000Z","y":-0.586},{"x":"2022-09-08T15:05:29.000Z","y":-0.782},{"x":"2022-09-08T15:05:31.000Z","y":-2.995},{"x":"2022-09-08T15:05:32.000Z","y":-2.23},{"x":"2022-09-08T15:05:33.000Z","y":-0.993},{"x":"2022-09-08T15:05:34.000Z","y":-2.49},{"x":"2022-09-08T15:05:36.000Z","y":-2.197},{"x":"2022-09-08T15:05:37.000Z","y":-2.605},{"x":"2022-09-08T15:05:38.000Z","y":-1.969},{"x":"2022-09-08T15:05:40.000Z","y":-0.635},{"x":"2022-09-08T15:05:41.000Z","y":-2.4250000000000003},{"x":"2022-09-08T15:05:42.000Z","y":-2.458},{"x":"2022-09-08T15:05:43.000Z","y":-0.684},{"x":"2022-09-08T15:05:45.000Z","y":-1.351},{"x":"2022-09-08T15:05:46.000Z","y":-2.213},{"x":"2022-09-08T15:05:47.000Z","y":-2.246},{"x":"2022-09-08T15:05:49.000Z","y":-1.416},{"x":"2022-09-08T15:05:50.000Z","y":-0.863},{"x":"2022-09-08T15:05:51.000Z","y":-2.116},{"x":"2022-09-08T15:05:53.000Z","y":-1.481},{"x":"2022-09-08T15:05:54.000Z","y":-1.6280000000000001},{"x":"2022-09-08T15:05:56.000Z","y":-2.083},{"x":"2022-09-08T15:05:57.000Z","y":0.178},{"x":"2022-09-08T15:05:58.000Z","y":-31.649},{"x":"2022-09-08T15:05:59.000Z","y":-0.245},{"x":"2022-09-08T15:06:01.000Z","y":-0.212},{"x":"2022-09-08T15:06:02.000Z","y":-0.228},{"x":"2022-09-08T15:06:03.000Z","y":-0.245},{"x":"2022-09-08T15:06:05.000Z","y":-0.228},{"x":"2022-09-08T15:06:06.000Z","y":-0.196},{"x":"2022-09-08T15:06:07.000Z","y":-0.228},{"x":"2022-09-08T15:06:09.000Z","y":-0.245},{"x":"2022-09-08T15:06:10.000Z","y":-0.245},{"x":"2022-09-08T15:06:11.000Z","y":-0.277},{"x":"2022-09-08T15:06:13.000Z","y":-0.179},{"x":"2022-09-08T15:06:14.000Z","y":-0.212},{"x":"2022-09-08T15:06:16.000Z","y":-0.212}]]]}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6e9fe226bcd5d7752caa08a19026fc7f0b3b8d61.png)

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

---

<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:** [12 September 2022 15:40 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616/2 "2022-09-12T15:40:52Z")

</div>

> [@becsL](#):
>
> ```auto
> [msg.payload[0].map(obj => {return {x: obj.x, y: obj.y}})],
> [msg.payload[1].map(obj => {return {x: obj.x, y: obj.y}})],
> [msg.payload[2].map(obj => {return {x: obj.x, y: obj.y}})],
> [msg.payload[3].map(obj => {return {x: obj.x, y: obj.y}})]
> 
> ```

You are adding an extra [] around your map arrays, try removing them.  
e.g.

```auto
  msg.payload[1].map(obj => {return {x: obj.x, y: obj.y}}),

```

---

<div class="post-metadata">

**Author:** ![becsL](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@becsL](https://discourse.nodered.org/u/becsL)\
**Post date:** [12 September 2022 15:49 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616/3 "2022-09-12T15:49:10Z")

</div>

@E1cid you have come to my rescue yet again!!! Ican't believe that was all it was. I hate myself for not posting sooner 😂 !! I have been at this for an entire working day. The highs and lows of node red lol.

Needless to say, this works.  
For reference, what I had done was attempt to emulate [this node-red github info](https://github.com/node-red/node-red-dashboard/blob/master/Charts.md) thinking

```auto
data = [
         [torque mapping 1],
         [torque mapping 2],
         [torque mapping 4],
         [torque mapping 5]
]

```

Evidently not.

**THANK YOU!!**

---

<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:** [12 September 2022 16:14 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616/4 "2022-09-12T16:14:36Z")

</div>

I did say last time it is important to understand Json and Javascript objects, you will get better over time though.  
Glad it helped  
this function would work to (untested as no data to test against).

```auto
msg.payload =[
    {
        labels:["Torque"],
        series:["S1 Torque (Nm)", "S2 Torque (Nm)", "S4 Torque (Nm)","S5 Torque (Nm)"],
        data: msg.payload.map(arr => {
           return arr.map(obj => {
               return {x: obj.x, y: obj.y}
           })
        })
    }
]

return msg;

```

Notes  
would probably join as key value object, then you probably be able to create series dynaically from key. then in first map use `Object.values(msg.payload).map.....`. I say this as joining as array may cause issues, probably not with your code, but it's safer to join as object as you can not get repeeat items in array.  
I would also add an if statemennt around the function that creates the payload array for chart, to check if there is 4 elements to the array or object, and return null to msg to stop flow if the db has not return 4 arrays that are of equal length.

You did paste data but to use it i would have to edit it and i am feeling extra lazy today.

---

<div class="post-metadata">

**Author:** ![becsL](https://avatars.discourse-cdn.com/v4/letter/b/7ba0ec/32.png) [@becsL](https://discourse.nodered.org/u/becsL)\
**Post date:** [12 September 2022 16:20 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616/5 "2022-09-12T16:20:55Z")

</div>

I thought I had pasted useable data in the section 'code text box' but clealry I messed that up.  
I remeber you saying about understanding Json and Javascript objects. I think I am getting better but I'm still a long way off.

Thank you again.

---

<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:** [26 September 2022 16:20 UTC](https://discourse.nodered.org/t/multiple-chart-lines-from-single-array/67616/6 "2022-09-26T16:20:55Z")

</div>

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