Display multiple past values in chart

I've tried to display multiple values with timestamps from the past in a chart.
I used the JSON-Format
[{"series": [" "], "data": [[{ "x": timestamp, "y": value }]],"labels": [""]}]
(timestamp/value-pairs received via MQTT; put in the right format in a function node).
The problem is that the chart only shows the last timestamp/value instead of the last 60 seconds. So I tried to use an array that holds the last 60 values (because I receive them every second), but it still shows only one value.

Did I miss something important?

Did I miss something important?

You could use a debug node to show you (and us) the data that the your funtcion node passes to the chart.

This is the output I get

Your timestamps are strings not numbers convert them to integers with possibly parseInt(). Also you may want to convert your y values to floats with parseFloat().

@Catelyna instead of changing the values in NR, you might be able to change them before publishing them via mqtt.

I never thought about parsing, but it's working now with an array.
The values are displayed correctly, but the time is wrong. I set it to automatic, but it only moves in milliseconds and not in secoend, even though the timestamp does. It also looks like the timestamp is from 1970? I checked the source of the timestamp and it shows the correct time. So to me there is no indicator why it happens.

@Catelyna Your timestamps when parsed to integers are unix in seconds. You would need to convert to a js timestamp in milliseconds, by multiplying by 1000.

Thank you!

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