# Function to get multiple arrays

**URL:** https://discourse.nodered.org/t/function-to-get-multiple-arrays/27457
**Category:** General
**Created:** [28 May 2020 19:52 UTC](https://discourse.nodered.org/t/function-to-get-multiple-arrays/27457 "2020-05-28T19:52:31Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)
#### Post date: [29 May 2020 11:14 UTC](https://discourse.nodered.org/t/function-to-get-multiple-arrays/27457/9 "2020-05-29T11:14:29Z")

</div>

Ah, OK...didn't get that while browsing from my mobile 😉

I tried and quickly modify an example I use for another case, that might work for you.  
At least it should give you some hints on how this might work.  
Maybe @Paul-Reed is able to comment or improve, as I am not a JS guy 😉

```auto
let array = msg.payload.trip.track_points;
var time=0;
var elevation=0;
var speed=0;
var grade=0;

var i=0;
var chartarray = [[]];

for(let i = 0; i < array.length; i++) {
    time = array[i].t;
    elevation = array[i].e;
    speed = array[i].x;
    grade = array[i].y;
    chartarray[0][i] = {"x":time,"y":elevation};
    chartarray[1][i] = {"x":time,"y":speed};
    chartarray[2][i] = {"x":time,"y":grade};
}

var chart = [{
    "series":["Elevation", "Speed", "Grade"],
    "data":chartarray,
    "labels":[""]
}];

msg.payload = chart;
msg.topic = "trip"

return msg;

```

Info on how a dashboard chart works can be found here: [https://github.com/node-red/node-red-dashboard/blob/master/Charts.md](https://github.com/node-red/node-red-dashboard/blob/master/Charts.md)

---

_[View the full topic](https://discourse.nodered.org/t/function-to-get-multiple-arrays/27457)._
