Hello
I am trying to create a bar chart in nodered. I have a function which every 60 seconds, adds to an existing variable. At midnight every night, the variable is reset to 0.
For example,
at 0:00 - value = 0
at 0:01 - value = 5
at 0:02 - value = 8
... eventually resetting back to 0 at 0:00.
The process then repeats itself.
I need to plot a bar for each 24 hour period, updated every 60 seconds with the revised value. Then after midnight, a new bar is created and the old bar is left where it is.
I can handle the timers, variable increasing etc. I'm just not sure how to get this data into the chart dynamically.
I have read that the bar chart accepts a payload as follows:
[{
"series": [ "X" ],
"data": [ [5,6,9] ],
"labels": [ "Mon", "Tue", "Wed" ]
}]
In my case, a new data number and label would need to be created every 24 hours. If this were an array I would be able to do it, but I don't think it is? What is the least painful way to update the payload to the chart dynamically as described above?