I need to access data in this format to use it with Chart.js:
var dataArrays = {
id: 1,
time : [1543855884861,1543855889279],
parsetTimestamp: ["3 Dec 2018 17:51:24","3 Dec 2018 17:51:29"],
temperature: [23.4,24.4],
humidity: [38,40],
light: [1000,1100],
soil: [750,800],
fanIn: [1,0],
fanOut: [0,1],
ledIntensity: [1024,1024]
}
I need to get the data from a different js file, formatted like this:
var data = [{
name: 'tube',
time: 1546614557692,
temperature: 23,
humidity: 49,
light: 1718,
soil: 1024,
fanIn: 0,
fanOut: 0,
ledIntensity: 1024
},
{
name: 'tube',
time: 1546614557697,
temperature: 23,
humidity: 49,
light: 1721,
soil: 1024,
fanIn: 0,
fanOut: 0,
ledIntensity: 1024
}
]
I think I can add data from different variables like this:
var dataArrays.time = [data1.time, data2.time];
but I don't have two variables, I only have one with all the data, and it's located in a different file.
Is there a way to do this?