# 2 flows data combined into 1 graph

**URL:** <https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593>\
**Category:** Dashboard\
**Created:** [27 May 2019 10:47 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593 "2019-05-27T10:47:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![orandaadnaro](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/orandaadnaro/32/8734_2.png) [@orandaadnaro](https://discourse.nodered.org/u/orandaadnaro)\
**Post date:** [27 May 2019 10:47 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/1 "2019-05-27T10:47:31Z")

</div>

In order to keep each of my projects separate and easy to edit, I have created two flows in node red. One generating external temperature data and the other internal temperature data.

In a third flow I am trying to create a graph which combines the other two sets of temperatures together with two separate lines.

How do I call/reference the A - the external temperature, and B - the interior temperature to be plotted in C - the chart from the other flows?

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 May 2019 10:56 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/2 "2019-05-27T10:56:55Z")

</div>

The `chart` node creates different lines for different `topic`s. So you'll need to manage topics correctly and then you probably don't even need third flow (if you don't need to do some other fancy stuff before charting the data)

---

<div class="post-metadata">

**Author:** ![orandaadnaro](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/orandaadnaro/32/8734_2.png) [@orandaadnaro](https://discourse.nodered.org/u/orandaadnaro)\
**Post date:** [27 May 2019 11:43 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/3 "2019-05-27T11:43:43Z")

</div>

> [@hotNipi](#):
>
> . So you'll need to manage topics correctly and then you probably don't even need third flow (if you don'

Sorry I don't understand.

I can create a standalone graph with random data containing two sets of lines.

What I need help with is a function (I think) to combine the two other flows to send to the chart node.

at the moment I have this function which fails

[{"id":"b6e2b6b7.80539","type":"function","z":"257ed035.563748","name":"2 line chart","func":"var msg = {};\nvar msg2 = {};\nmsg.payload=global.get("DarkSky").currently.temperature;\nmsg.topic = 'External';\nmsg2.payload = global.get("Mysql Heatmiser").string[4];\nmsg2.topic = 'Internal';\nreturn [msg, msg2];","outputs":2,"noerr":0,"x":610,"y":680,"wires":[["7c3b88d2.484c5"],]}]

at the moment on position 5 - my other two flows named: 'Darksky' - for the external temperature/s and 'Mysql Heatmiser' for the internal temp. I've cobbled this together from adapting other node examples on the net, so I may have made a very basic mistake somewhere

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 May 2019 11:48 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/4 "2019-05-27T11:48:44Z")

</div>

Read this [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and edit your previous post to make the code part importable

---

<div class="post-metadata">

**Author:** ![orandaadnaro](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/orandaadnaro/32/8734_2.png) [@orandaadnaro](https://discourse.nodered.org/u/orandaadnaro)\
**Post date:** [27 May 2019 12:02 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/5 "2019-05-27T12:02:29Z")

</div>

Thanks for pointing that out:-)

```auto
[{"id":"b6e2b6b7.80539","type":"function","z":"257ed035.563748","name":"2 line chart","func":"var msg = {};\nvar msg2 = {};\nmsg.payload=global.get(\"DarkSky\").currently.temperature;\nmsg.topic = 'External';\nmsg2.payload = global.get(\"Mysql Heatmiser\").string[4];\nmsg2.topic = 'Internal';\nreturn [msg, msg2];","outputs":2,"noerr":0,"x":610,"y":680,"wires":[["7c3b88d2.484c5"],[]]}]

```

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 May 2019 15:32 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/6 "2019-05-27T15:32:26Z")

</div>

You can not have `space` in Object property name. "Mysql Heatmiser" is not valid name.  
See node-red log, it should log the errors

---

<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:** [27 May 2019 15:49 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/7 "2019-05-27T15:49:32Z")

</div>

Not sure whether spaces are allowed there or not. You can have spaces in property names but then you have to use `myobject["some name"]` to access it rather than the dot notatation. I would have expected it to work ok in context variables, though I haven't tried it.  
Put a debug node showing the messages coming from the function and see what they show.  
@orandaadnaro it might be easier (and avoid global context) if you use Link nodes to connect direct from the other flows to this flow and feed the values straight to the chart (via Change nodes to set the topics).

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 May 2019 16:20 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/8 "2019-05-27T16:20:13Z")

</div>

> [@Colin](#):
>
> I would have expected it to work ok in context variables, though I haven't tried it.

I tried. With no success.

---

<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:** [27 May 2019 16:33 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/9 "2019-05-27T16:33:59Z")

</div>

I see you are right. I wonder why. Perhaps the implementer just did not think of that possibility. Objects can certainly have property names with spaces.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 May 2019 16:36 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/10 "2019-05-27T16:36:50Z")

</div>

Well it is kind of bad practice anyway. If you are creating variables, you can create them in the way it does not lead you into some kind of trouble afterwards. But lets keep the topic clear for the main issue.

---

<div class="post-metadata">

**Author:** ![orandaadnaro](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/orandaadnaro/32/8734_2.png) [@orandaadnaro](https://discourse.nodered.org/u/orandaadnaro)\
**Post date:** [27 May 2019 18:53 UTC](https://discourse.nodered.org/t/2-flows-data-combined-into-1-graph/11593/11 "2019-05-27T18:53:55Z")

</div>

In the end this worked for me - set up two global variables elsewhere - intTempC and extTempc

Then

```auto
[{"id":"2afdd8e9.d5149","type":"inject","z":"257ed035.563748","name":"","topic":"","payload":"","payloadType":"date","repeat":"300","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":300,"wires":[["17a78faa.3500b"]]},{"id":"7c3b88d2.484c5","type":"ui_chart","z":"257ed035.563748","name":"Ext. & Int. Temperatures","group":"3d3c0588.3499e2","order":8,"width":"12","height":"6","label":"External & Internal Temperatures Celsius","chartType":"line","legend":"true","xformat":"D-M-Y","interpolate":"linear","nodata":"","dot":false,"ymin":"-10","ymax":"35","removeOlder":1,"removeOlderPoints":"1000","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":670,"y":300,"wires":[[]]},{"id":"17a78faa.3500b","type":"function","z":"257ed035.563748","name":"get ext & int temps","func":"var msg = {};\nvar msg1 = {};\n\nvar UseextTempC = global.get(\"extTempC\");\nmsg.payload = UseextTempC;\nmsg.topic = 'External';\n\nvar UseintTempC =global.get(\"intTempC\");\nmsg1.payload = UseintTempC;\nmsg1.topic = 'Internal';\n\n\n\n\nreturn [msg, msg1];","outputs":2,"noerr":0,"x":310,"y":300,"wires":[["7c3b88d2.484c5","57ae702e.d90bf"],["7c3b88d2.484c5","57ae702e.d90bf"]]},{"id":"57ae702e.d90bf","type":"debug","z":"257ed035.563748","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":340,"wires":[]},{"id":"3d3c0588.3499e2","type":"ui_group","z":"","name":"Heatmiser PRT","tab":"216ba00f.9d297","disp":true,"width":"12","collapse":false},{"id":"216ba00f.9d297","type":"ui_tab","z":"","name":"Weather Forecast","icon":"wb_sunny","order":4,"disabled":false,"hidden":false}]

```
