The final payload has to be an array and to feed stored data you need to add a a time, I simulated this by using the count in the loop and timesing by 60 so all data is 60 seconds apart, you can edit and change if you wish.
The data sets has to be an array of objects in this form
[{
"series": ["A", "B"],
"data": [
[{ "x": 1504029632890, "y": 5 },
{ "x": 1504029636001, "y": 4 },
{ "x": 1504029638656, "y": 2 }
],
[{ "x": 1504029633514, "y": 6 },
{ "x": 1504029636622, "y": 7 },
{ "x": 1504029639539, "y": 6 }
]
],
"labels": [""]
}]
here is an example of the function
[{"id":"a14ba8c4.e546c8","type":"function","z":"b779de97.b1b46","name":"","func":"//1. lets create a variable to hold the finished article...\nlet chartData = []; //See #1 - create an empty array\n\n//2. lets create a variable to hold the everything...\nlet element1 = {}; //create element1 as an empty object {}\n\n//3, now add the .property \"series\" to the element1 {object}\nelement1.series = []; // add a .property called series of type [array]\nelement1.series.push(\"Intensity\");\nelement1.series.push(\"Wavelength\");//add 1st array element \"A\"\n\n\n//4. now add the .property \"data\" to the element1 {object}\nelement1.data = [[],[]]; // add a .property called data of type [array]\n\n\n\n/*********** NEXT - ADDING DATA ***************************\n NORMALLY, ADDING DATA WOULD BE DYNAMIC \n PERHAPS LOOPING THROUGH AN ARRAY\n THIS EXAMPLE SHOWS ADDING HARD CODED VALUES\n************************************************************/\n//4b. now we add 3 arrays to the data [array]\n\n//4c. now add the 3 {objects} inside each of the dataElements\nconst data = msg.payload\nfor(let x = 0; x < data.length; x++){\n \n element1.data[0][x] = {x: x*60, y: data[x][0]}\n element1.data[1][x] = {x: x*60, y: data[x][1]}\n}\n\n//5. now add a labels [array] to element1\nelement1.labels = [\"\"]; // add a .property called labels of type [array]\n\n//Lastly, return the chartData as the payload \nmsg.payload = [element1];\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":175,"y":980,"wires":[["c45068de.10c3e8"]],"l":false}]
Output