Help with charts RESOVED (sorry) Solution at top

Solution:
I wasn’t checking the msg.topic.

That was causing the problem, so after a bit of coding, I added the extra lines to set the topic and it is now working as required.

Original post:
I am so close with a node I have worked on for a long time.

I keep adding functionality to it and now I think it is at the summit of what I need, but it is not quite working with the graph.

Back story:
(This is a bit long)
I have remote devices which are pinged.
It also sends temperature data on an MQTT channel.
This happens every TEN seconds.

From what I gather all the data is TEXT mode - rather than number.

In the flow, it sees the PING reply and so a message is created saying ON-LINE.
The temperature data is received and the two messages are sent to this node.

(Originally there were more nodes, but now with optimising it is one.)

If OFF-LINE is received, the out going message is set to ZERO - I think that is text, rather than a number. In the debug window to the right it is “0” and red.
If a second OFF-LINE is received the message is blanked.

Originally that went to a gauge and chart, and another node there to format the message to wipe the chart.

Now, I have set the node with two outputs. One to the gauge and one to the chart.
The idea is that when the data stops all the gauges and charts are wiped.
It seems silly keeping the old value showing.

The big idea is that at the first OFF-LINE message, the gauge is set to zero and the graph is set to zero.
At the second time the OFF-LINE message is received the graph gets a blank sent to it - as per its settings.

The charts are set that if nothing is received the show a message.
The gauge is set to zero.

Thing is the graph somehow isn’t getting changed to zero.

I have tried sending both formats out the output and the graph isn’t going to zero.

I don’t get what is going on.

Here is the entire flow - not too big.
The node of interest is TIMEPI TEMP.
Pressing the TEST button, I get a second trace of the graph.

[{"id":"816cc9ca.0cf1c8","type":"function","z":"788d09c7.f35328","name":"TimePi temp","func":"context.message;\ncontext.mtopic1 = msg.topic;\nvar count = context.get('count') || 0;\nvar mtopic2;\nvar mpayload = msg.payload;\nvar device = 'TEMP/TimePi';           ///////    NAME OF COMPUTER HERE!\nif (context.mtopic1 == device)\n{\n    context.message = msg.payload;\n    node.status({fill:\"yellow\",shape:\"dot\",text:\"message received\"});\n}\n\nif (mpayload === 'On-line')\n{\n    node.status({fill:\"green\",shape:\"dot\",text:\"On-line\"});\n    count = 0;\n    context.set('count',count);\n    msg.payload = context.message;\n    msg.topic = context.mtopic1;\n    return [msg, msg];\n}\nelse\nif (mpayload === 'Off-line')\n{\n    count = count + 1;\n    context.set('count',count);\n    msg.topic = count;\n    node.status({fill:\"red\",shape:\"dot\",text:\"Off-line\"});\n\n    if (count === 1)\n    {\n        var msg2 = { payload:\"0\" };\n    \tmsg.payload = \"0\";  //   You will have to make another payload here!!\n    \treturn [msg, msg2];\n    }\n    if (count === 2)\n    {\n        msg.payload = [];\n        var msg2 = { payload:\"N/C\" };\n        return [msg2, msg];\n    }\n    else\n    {\n    \t//msg.payload = null;\n        //return msg;\n    }\n}\n","outputs":2,"noerr":0,"x":370,"y":1040,"wires":[["3685dd79.61ae02","d51945b9.193"],["1eda86c4.cdf469","8a8b1bf6.3db12"]]},{"id":"d51945b9.193","type":"ui_gauge","z":"788d09c7.f35328","name":"","group":"db60a195.48e3e","order":0,"width":0,"height":0,"gtype":"gage","title":"gauge","label":"units","format":"{{value}}","min":0,"max":"70","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":630,"y":1020,"wires":[]},{"id":"8a8b1bf6.3db12","type":"ui_chart","z":"788d09c7.f35328","name":"","group":"db60a195.48e3e","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"No comms","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":630,"y":1060,"wires":[[],[]]},{"id":"52d0f6b8.a57a3","type":"inject","z":"788d09c7.f35328","name":"","topic":"","payload":"Off-line","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":920,"wires":[["816cc9ca.0cf1c8"]]},{"id":"8e26a8c4.831da8","type":"mqtt in","z":"788d09c7.f35328","name":"TimePi","topic":"TEMP/TimePi","qos":"2","broker":"3f12fa81.11a276","x":130,"y":1040,"wires":[["57419e48.c5ca6","816cc9ca.0cf1c8"]]},{"id":"57419e48.c5ca6","type":"debug","z":"788d09c7.f35328","name":"TimePi Temp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":110,"y":1000,"wires":[]},{"id":"e5cc4270.34ce5","type":"link in","z":"788d09c7.f35328","name":"","links":["41d30e81.9dac"],"x":275,"y":840,"wires":[["816cc9ca.0cf1c8","f1930988.6b661"]]},{"id":"f1930988.6b661","type":"debug","z":"788d09c7.f35328","name":"Status","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":410,"y":840,"wires":[]},{"id":"3685dd79.61ae02","type":"debug","z":"788d09c7.f35328","name":"Gauge","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":660,"y":960,"wires":[]},{"id":"1eda86c4.cdf469","type":"debug","z":"788d09c7.f35328","name":"Graph","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":660,"y":1120,"wires":[]},{"id":"a197dc44.3e8108","type":"ui_button","z":"788d09c7.f35328","name":"","group":"db60a195.48e3e","order":0,"width":0,"height":0,"passthru":false,"label":"button","color":"","bgcolor":"","icon":"","payload":"Off-line","payloadType":"str","topic":"","x":120,"y":880,"wires":[["816cc9ca.0cf1c8"]]},{"id":"db60a195.48e3e","type":"ui_group","name":"Group 1","tab":"e65419d5.fe97b","order":1,"disp":true,"width":6},{"id":"3f12fa81.11a276","type":"mqtt-broker","z":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"20","cleansession":true,"willTopic":"EOM","willQos":"2","willPayload":"'TelePi telemetry failure'","birthTopic":"SOM","birthQos":"2","birthPayload":"'Awaiting Pi Face'"},{"id":"e65419d5.fe97b","type":"ui_tab","z":"","name":"Testing","icon":"build","order":9}]