Function to get multiple arrays

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

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 :wink:

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

1 Like