# Display multiple past values in chart

**URL:** <https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, function-node, mqtt\
**Created:** [15 April 2022 10:40 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327 "2022-04-15T10:40:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catelyna](https://avatars.discourse-cdn.com/v4/letter/c/edb3f5/32.png) [@Catelyna](https://discourse.nodered.org/u/Catelyna)\
**Post date:** [15 April 2022 10:40 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/1 "2022-04-15T10:40:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 April 2022 11:20 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/2 "2022-04-15T11:20:05Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Catelyna](https://avatars.discourse-cdn.com/v4/letter/c/edb3f5/32.png) [@Catelyna](https://discourse.nodered.org/u/Catelyna)\
**Post date:** [15 April 2022 11:37 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/3 "2022-04-15T11:37:49Z")

</div>

This is the output I get  
 ![Forum1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/4248ad7ed37987549a6517f469c6491921438bbc.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 April 2022 12:03 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/4 "2022-04-15T12:03:43Z")

</div>

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().

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 April 2022 12:31 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/5 "2022-04-15T12:31:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Catelyna](https://avatars.discourse-cdn.com/v4/letter/c/edb3f5/32.png) [@Catelyna](https://discourse.nodered.org/u/Catelyna)\
**Post date:** [15 April 2022 13:34 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/6 "2022-04-15T13:34:04Z")

</div>

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.  
 ![Forum2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bb77e3178e264fa97907712af3ab50169b1190cb.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 April 2022 13:55 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/7 "2022-04-15T13:55:38Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Catelyna](https://avatars.discourse-cdn.com/v4/letter/c/edb3f5/32.png) [@Catelyna](https://discourse.nodered.org/u/Catelyna)\
**Post date:** [15 April 2022 14:56 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/8 "2022-04-15T14:56:28Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 May 2022 14:57 UTC](https://discourse.nodered.org/t/display-multiple-past-values-in-chart/61327/9 "2022-05-15T14:57:25Z")

</div>

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