Silver
2 December 2020 13:36
1
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,
Jordan
1 Like
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.
Silver
2 December 2020 13:58
3
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,
To show historical data, the chart requires the data be formatted in certain way.
# Node-RED-Dashboard Charts
## Live data
To display live data just wire up an input with a `msg.payload` that contains a number.
### Line charts
To display two or more lines on the same chart then each `msg` must also contain `topic`
property that identifies which data series it belongs to - for example:
{topic:"temperature", payload:22}
{topic:"humidity", payload:66}
Each series will be represented by a different colour.
Alternatively you can use the property `series` instead of `topic` if you prefer.
It is possible to create "gaps" in line charts by sending either a null or boolean false as the payload.
This file has been truncated. show original
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)
system
Closed
1 January 2021 14:21
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.