# Store different values of the same payload, and then release them in order of arrival in the graph?

**URL:** <https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, database, function-node\
**Created:** [11 January 2023 21:11 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566 "2023-01-11T21:11:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [11 January 2023 21:11 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/1 "2023-01-11T21:11:34Z")

</div>

How can I store different values ​​of the same payload, and then release them in order of arrival in the graph?

---

<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:** [11 January 2023 22:23 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/2 "2023-01-11T22:23:39Z")

</div>

If there are multiple values in the same payload, won't they all have arrived at the same time?

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [11 January 2023 22:26 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/3 "2023-01-11T22:26:59Z")

</div>

No, I have a variable that changes the value over time, so I wanted to store these values ​​and then throw them into a char to see the difference in the peaks

---

<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:** [11 January 2023 22:53 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/4 "2023-01-11T22:53:49Z")

</div>

Can you show us an example of this payload with different values in it?

---

<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:** [12 January 2023 00:46 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/5 "2023-01-12T00:46:28Z")

</div>

Why not save each value along with the current time in an array of objects in the payload.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 January 2023 07:11 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/6 "2023-01-12T07:11:59Z")

</div>

Could you just feed them into the chart as they arrive, rather than saving them and then building the chart?

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [12 January 2023 12:43 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/8 "2023-01-12T12:43:14Z")

</div>

It is a sensor that returns the value in a string, but I am still using an inject for the tests, And the graph only appears when I press the button  
My flow:

```auto
[{"id":"80a580d7de110e16","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"9b57470c0e8b9afc","type":"inject","z":"80a580d7de110e16","name":"","props":[{"p":"payload.one","v":"565","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":140,"wires":[["df99a0281ba442b9"]]},{"id":"df99a0281ba442b9","type":"change","z":"80a580d7de110e16","name":"","rules":[{"t":"set","p":"one","pt":"global","to":"payload.one","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":140,"wires":[[]]},{"id":"2796898c17b42270","type":"ui_dropdown","z":"80a580d7de110e16","name":"","label":"Energia","tooltip":"","place":"Escolha","group":"5e5b90ffc9f1961a","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Ar comprimido","value":"one","type":"str"},{"label":"Eletricidade","value":"two","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":720,"y":280,"wires":[["e11f77c661257953"]]},{"id":"e11f77c661257953","type":"change","z":"80a580d7de110e16","name":"","rules":[{"t":"set","p":"chartSelection","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":280,"wires":[[]]},{"id":"e03220e22f79dcf1","type":"ui_button","z":"80a580d7de110e16","name":"","group":"5e5b90ffc9f1961a","order":3,"width":0,"height":0,"passthru":false,"label":"Gerar gráfico","tooltip":"","color":"White","bgcolor":"Purple","className":"","icon":"","payload":"chartSelection","payloadType":"global","topic":"topic","topicType":"msg","x":530,"y":400,"wires":[["cae43270e7b65063"]]},{"id":"cae43270e7b65063","type":"function","z":"80a580d7de110e16","name":"function 3","func":"if(msg.payload==\"one\"){\n msg.payload= global.get('one')\n}\n\nif(msg.payload==\"two\"){\n msg.payload= global.get('two')\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":400,"wires":[["95756422e3978770","7a20928810935731"]]},{"id":"95756422e3978770","type":"debug","z":"80a580d7de110e16","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":340,"wires":[]},{"id":"2f085db112552c25","type":"ui_ui_control","z":"80a580d7de110e16","name":"","events":"all","x":220,"y":400,"wires":[["ba93ac6de9587685"]]},{"id":"ba93ac6de9587685","type":"delay","z":"80a580d7de110e16","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":370,"y":400,"wires":[["e03220e22f79dcf1"]]},{"id":"2b06d6d38cdcf97e","type":"change","z":"80a580d7de110e16","name":"","rules":[{"t":"set","p":"two","pt":"global","to":"payload.two","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":200,"wires":[[]]},{"id":"7a20928810935731","type":"ui_chart","z":"80a580d7de110e16","name":"","group":"5e5b90ffc9f1961a","order":4,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":950,"y":420,"wires":[[]]},{"id":"f5642e2e8a6814f4","type":"inject","z":"80a580d7de110e16","name":"","props":[{"p":"payload.two","v":"515","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":220,"wires":[["2b06d6d38cdcf97e"]]},{"id":"b2b15be1bb0f4d05","type":"comment","z":"80a580d7de110e16","name":"This is an example of the data, but I will use a sensor later to receive the payload instead of this inject","info":"","x":360,"y":80,"wires":[]},{"id":"5e5b90ffc9f1961a","type":"ui_group","name":"Rampa_1","tab":"338878ddae580b7e","order":1,"disp":true,"width":20,"collapse":false,"className":""},{"id":"338878ddae580b7e","type":"ui_tab","name":"B","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<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:** [12 January 2023 12:48 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/9 "2023-01-12T12:48:28Z")

</div>

So your incoming data is a single value (565 or 515 in the example), not "different values ​​[in] the same payload".

In which case you can just pass msg.payload (not msg.payload.one) to the chart node as it arrives, as @Colin suggests.  
The chart will draw a graph using each value and the timestamp of it's arrival.

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [12 January 2023 12:58 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/10 "2023-01-12T12:58:05Z")

</div>

But if I do it this way, the graph will be showing the data all the time, right? I need the graph to only appear when I press the button, Oh and these values ​​(515,565) are representing two sensors, the truth values ​​will not be fixed.

---

<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:** [12 January 2023 13:03 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/11 "2023-01-12T13:03:52Z")

</div>

> [@Erissin\_Industria4.0](#):
>
> But if I do it this way, the graph will be showing the data all the time, right?

Yes.

> [@Erissin\_Industria4.0](#):
>
> I need the graph to only appear when I press the button

Do you mean in a popup?  
How do you propose to make it disappear again?

> [@Erissin\_Industria4.0](#):
>
> Oh and these values ​​(515,565) are representing two sensors

Do you want two different graphs or two lines on the same graph?

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [12 January 2023 13:13 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/12 "2023-01-12T13:13:19Z")

</div>

I need the same graph to show the two peak changes of the two sensors, When I want to change the value by the dropdown I need to reset the graph to show the value without the conflict of the previous value, I'm thinking of just playing [{"0"}], and yes, it's basically a "popup"

---

<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:** [12 January 2023 13:16 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/13 "2023-01-12T13:16:54Z")

</div>

This might achieve some of what you are after.  
It draws a graph of either electricidade or ar comprindo (or neither).  
Not very exciting graphs though, since the data never changes.

 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/62703eb8febab1a8dd682b47163e69604deac31a.jpeg)

```auto
[{"id":"d6a0a91d477d81c8","type":"tab","label":"Flow 4","disabled":false,"info":"","env":[]},{"id":"db119705f2449c79","type":"inject","z":"d6a0a91d477d81c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"one","payload":"565","payloadType":"num","x":600,"y":160,"wires":[["5b7837e0a87e326c"]]},{"id":"fda65ce4465f99e5","type":"ui_dropdown","z":"d6a0a91d477d81c8","name":"","label":"Energia","tooltip":"","place":"Escolha","group":"5e5b90ffc9f1961a","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"Ar comprimido","value":"one","type":"str"},{"label":"Eletricidade","value":"two","type":"str"},{"label":"","value":"Neither","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":200,"y":300,"wires":[["0c9e06e4660f2c4b"]]},{"id":"0c9e06e4660f2c4b","type":"change","z":"d6a0a91d477d81c8","name":"","rules":[{"t":"set","p":"chartSelection","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":300,"wires":[["7143e0b6f0d4495e"]]},{"id":"57d550fc449b0edc","type":"inject","z":"d6a0a91d477d81c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"two","payload":"515","payloadType":"num","x":600,"y":200,"wires":[["5b7837e0a87e326c"]]},{"id":"516e34868b758de1","type":"ui_chart","z":"d6a0a91d477d81c8","name":"","group":"5e5b90ffc9f1961a","order":4,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":890,"y":180,"wires":[[]]},{"id":"5b7837e0a87e326c","type":"switch","z":"d6a0a91d477d81c8","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"chartSelection","vt":"global"}],"checkall":"true","repair":false,"outputs":1,"x":750,"y":180,"wires":[["516e34868b758de1"]]},{"id":"7143e0b6f0d4495e","type":"rbe","z":"d6a0a91d477d81c8","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":610,"y":300,"wires":[["6495b98bd6dc7955"]]},{"id":"6495b98bd6dc7955","type":"change","z":"d6a0a91d477d81c8","name":"Clear Chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":300,"wires":[["516e34868b758de1"]]},{"id":"5e5b90ffc9f1961a","type":"ui_group","name":"Rampa_1","tab":"338878ddae580b7e","order":1,"disp":true,"width":20,"collapse":false,"className":""},{"id":"338878ddae580b7e","type":"ui_tab","name":"B","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Erissin\_Industria4.0](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@Erissin\_Industria4.0](https://discourse.nodered.org/u/Erissin_Industria4.0)\
**Post date:** [12 January 2023 13:30 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/14 "2023-01-12T13:30:17Z")

</div>

That's basically what I need Thx, I just have to learn a way to save the data together with a time, so that the graph will show all the differences in values ​​in the last 10 minutes.  
Ah, the way you did it, it shows the graph just by selecting it in the dropdown, it needs to be after pressing the button

---

<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:** [12 January 2023 13:44 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/15 "2023-01-12T13:44:42Z")

</div>

> [@Erissin\_Industria4.0](#):
>
> I just have to learn a way to save the data together with a time, so that the graph will show all the differences in values ​​in the last 10 minutes.

You keep on giving us new glimpses of the specification!

What I would do is store sensor readings in a database.  
Personally I use Mariadb, but others prefer InfluxDB for sensor data like this.  
The chart can then be populated from an SQL query which can hopefully accomodate changed requirements.  
But the data you pass for a stored data chart has to be in a spcific format with x,y values.

---

<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:** [11 February 2023 13:44 UTC](https://discourse.nodered.org/t/store-different-values-of-the-same-payload-and-then-release-them-in-order-of-arrival-in-the-graph/73566/16 "2023-02-11T13:44:45Z")

</div>

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