Reading from an Array into a chart

Hi there,

I am experiencing issues trying to write my data from this array into a chart, I have looked at similar issues but I can not seem to come to a solution. I am not strong at all in Javascript.

Here is a screenshot of my flow,

Kind Regards,

Hi and welcome to forum.
Based on data I thing there will be line chart ...
First I recommend to reduce the amount of data you are trying to send to chart. You probably will kill the browser with that many entries.

Show what you try to do in the function just before the chart.

Hi there, I tried to filter through the array with a for loop, but I had absolutely no idea where to send the data too, image

To show historical data, the chart requires the data be formatted in certain way.

You have data for one series so the payload to send to chart should be like this:

"series": ["A"],
"data": [
     { "x": 1504029632890, "y": 5 },
     { "x": 1504029636001, "y": 4 },
     { "x": 1504029638656, "y": 2 }
"labels": [""]

The data object is an array of series
The series is an array of objects
Those objects have properties x (timestamp) and y (value)

Your data is already an array of objects but the property names are wrong for chart
So that needs to be changed

You could use this solution as a starting point.

PS, use TOP or LIMIT clause in your query (rather than bringing 50000+ records to node-red, just limit the data coming from the database)

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