# Help with line Chart plotting 2 separate lines instead of one

**URL:** https://discourse.nodered.org/t/help-with-line-chart-plotting-2-separate-lines-instead-of-one/20926
**Category:** Dashboard
**Created:** [27 January 2020 20:15 UTC](https://discourse.nodered.org/t/help-with-line-chart-plotting-2-separate-lines-instead-of-one/20926 "2020-01-27T20:15:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Argus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/argus/32/16156_2.png) [@Argus](https://discourse.nodered.org/u/Argus)
#### Post date: [27 January 2020 20:15 UTC](https://discourse.nodered.org/t/help-with-line-chart-plotting-2-separate-lines-instead-of-one/20926/1 "2020-01-27T20:15:06Z")

</div>

Hi

Still learning, I trying to create a remote test application where I can toggle the I/O's on an external device using a Rpi which so far is going well. The simple switch and on/off buttons is working fine and was a good intro.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/3518d1a26b52a89d655248626f73468a0bd620f0.png)

But for the the automatic switching the chart is displaying two separate lines. I'm trying to figure out how to get a single line. Any idea's?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f2392a9290b3760a32e79793b7832ead2c204b7.png)

My code so far is here.

```auto
[{"id":"92c9a219.972d7","type":"dsm","z":"7f79a8fd.2964d8","name":"blinking","sm_config":"{\n \"currentState\": \"idle\",\n \"states\": {\n \"idle\": {\n \"start\": \"on\",\n \"stop\": \"idle\"\n },\n \"on\": {\n \"turn_off\": \"off\",\n \"stop\": \"idle\"\n },\n \"off\": {\n \"turn_on\": \"on\",\n \"stop\": \"idle\"\n }\n },\n \"data\": {\n \"on\": 1,\n \"off\": 0,\n \"on_time\": 2000,\n \"off_time\": 2000,\n \"blinks\": \"continuing\",\n \"count\": 0\n },\n \"methods\": {\n \n \"setOn\": [\n\t\t\"sm.data.on_time = msg.payload;\",\n\t\t\"sm.fill = 'blue';\",\n\t\t\"sm.text = 'On time = '+sm.data.on;\"\n\t\t],\n\t\t\"setOff\": [\n\t\t\"sm.data.off_time = msg.payload;\",\n\t\t\"sm.fill = 'purple';\"\n\t\t],\n \"init\": [\n \"sm.schedule = function(tran, delay, msg) {\",\n \" timeout.id = setTimeout(function() {\",\n \" resume(tran, msg)\",\n \" },delay);\",\n \"};\",\n \"sta.fill = 'grey';\"\n],\n \"onBeforeTransition\": [\n \"if (!msg.topic) msg.topic = 'start';\",\n \"if (msg.blinks) sm.data.blinks = msg.blinks;\",\n \"if (msg.on_time) sm.data.on_time = msg.on_time;\",\n \"if (msg.off_time) sm.data.off_time = msg.off_time;\"\n],\n \"start\": [\n \"sm.data.count = sm.data.blinks;\",\n \"resume('turn_on', msg);\",\n \"output = false;\"\n],\n \"turn_on\": [\n \"if (sm.data.count) {\",\n \" sm.schedule('turn_off', sm.data.on_time, msg);\",\n \" if(sm.data.blinks !== 'continuing') sm.data.count--;\",\n \" sm.fill = 'green';\",\n \" msg.payload = sm.data.on;\",\n \" output = true;\",\n \"} else {\",\n \" sm.currentState = 'idle';\",\n \" sm.fill = 'grey';\",\n \" output = false;\",\n \"}\"\n],\n \"turn_off\": [\n \"sm.schedule('turn_on', sm.data.off_time, msg);\",\n \"sm.fill = 'red';\",\n \"msg.payload = sm.data.off;\"\n],\n \"stop\": [\n \"clearTimeout(timeout.id);\",\n \"sm.fill = 'red';\",\n \"msg.payload = sm.data.off;\"\n],\n \"status\": {\n \"fill\": {\n \"get\": \"sm.fill;\"\n },\n \"shape\": \"dot\",\n \"text\": {\n \"get\": \"sm.currentState;\"\n }\n }\n }\n}","x":1540,"y":140,"wires":[["4f6b7b5e.cb3a34","76d67a20.bed444"]]},{"id":"362b0416.37f27c","type":"inject","z":"7f79a8fd.2964d8","name":"","topic":"stop","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1320,"y":160,"wires":[["92c9a219.972d7"]]},{"id":"6c703d91.b92384","type":"inject","z":"7f79a8fd.2964d8","name":"","topic":"start","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1320,"y":120,"wires":[["92c9a219.972d7"]]},{"id":"11f47898.4ce3c7","type":"ui_button","z":"7f79a8fd.2964d8","name":"","group":"dbfb559b.006638","order":1,"width":1,"height":1,"passthru":false,"label":"On","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"start","x":1320,"y":20,"wires":[["92c9a219.972d7"]]},{"id":"f1922118.3b239","type":"ui_button","z":"7f79a8fd.2964d8","name":"","group":"dbfb559b.006638","order":2,"width":1,"height":1,"passthru":false,"label":"Off","tooltip":"","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"stop","x":1320,"y":60,"wires":[["92c9a219.972d7"]]},{"id":"4f6b7b5e.cb3a34","type":"ui_chart","z":"7f79a8fd.2964d8","name":"","group":"dbfb559b.006638","order":3,"width":10,"height":4,"label":"chart I/O 3","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":true,"ymin":"","ymax":"","removeOlder":"10","removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1720,"y":140,"wires":[[]]},{"id":"b163281f.82f738","type":"ui_text_input","z":"7f79a8fd.2964d8","name":"","label":"On Time","tooltip":"","group":"dbfb559b.006638","order":4,"width":2,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"setOn","x":1030,"y":240,"wires":[["63a60d37.210c14"]]},{"id":"6b8e0493.a294dc","type":"function","z":"7f79a8fd.2964d8","name":"","func":"msg.payload *= 60000;\nreturn msg;","outputs":1,"noerr":0,"x":1340,"y":240,"wires":[["92c9a219.972d7"]]},{"id":"63a60d37.210c14","type":"change","z":"7f79a8fd.2964d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":240,"wires":[["6b8e0493.a294dc"]]},{"id":"13deee38.d9e842","type":"function","z":"7f79a8fd.2964d8","name":"","func":"msg.payload *= 60000;\nreturn msg;","outputs":1,"noerr":0,"x":1340,"y":300,"wires":[["92c9a219.972d7","8e8ec056.f86bf"]]},{"id":"7512720b.603fec","type":"change","z":"7f79a8fd.2964d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":300,"wires":[["13deee38.d9e842","a21b55b9.f90b88"]]},{"id":"76d67a20.bed444","type":"rpi-gpio out","z":"7f79a8fd.2964d8","name":"","pin":"7","set":"","level":"0","freq":"","out":"out","x":1710,"y":100,"wires":[]},{"id":"9ee9f99f.3fc6d8","type":"ui_text_input","z":"7f79a8fd.2964d8","name":"","label":"Off Time","tooltip":"","group":"dbfb559b.006638","order":5,"width":2,"height":1,"passthru":true,"mode":"text","delay":"0","topic":"setOff","x":1020,"y":300,"wires":[["7512720b.603fec"]]},{"id":"a21b55b9.f90b88","type":"debug","z":"7f79a8fd.2964d8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1500,"y":340,"wires":[]},{"id":"8e8ec056.f86bf","type":"debug","z":"7f79a8fd.2964d8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1500,"y":380,"wires":[]},{"id":"dbfb559b.006638","type":"ui_group","z":"","name":"I/O 3","tab":"7bc03c24.5ef4a4","order":3,"disp":true,"width":12,"collapse":false},{"id":"7bc03c24.5ef4a4","type":"ui_tab","z":"","name":"Automated Controls","icon":"fa-cogs","order":5}]

```

---

<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 January 2020 20:25 UTC](https://discourse.nodered.org/t/help-with-line-chart-plotting-2-separate-lines-instead-of-one/20926/2 "2020-01-27T20:25:15Z")

</div>

Line chart creates one line for each topic it gets. If you'll need only one line, make sure that the messages going into chart node have same topic.  
You may also find [node-red-contrib-ui-state-trail](https://flows.nodered.org/node/node-red-contrib-ui-state-trail) as useful node to display state changes.

---

<div class="post-metadata">

### Author: ![Argus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/argus/32/16156_2.png) [@Argus](https://discourse.nodered.org/u/Argus)
#### Post date: [7 February 2020 19:21 UTC](https://discourse.nodered.org/t/help-with-line-chart-plotting-2-separate-lines-instead-of-one/20926/3 "2020-02-07T19:21:36Z")

</div>

Awesome, finally had time to get back to this. Thanks for pointing me in the right direction.

---

<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: [8 March 2020 19:21 UTC](https://discourse.nodered.org/t/help-with-line-chart-plotting-2-separate-lines-instead-of-one/20926/4 "2020-03-08T19:21:41Z")

</div>

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