Input order in the Chart node

Every time I tweek my chart the order of the inputs changes. So on one instance the order is setpoint, brewbox, brewbucket, cool switch, heat switch; and the next tweek the order might be reversed with the colors assigned to different inputs.
Is there a way to specify the order that inputs displayed along with their assigned colors?

have you tried to assign different topic for each line? Take a look on the wiki http://noderedguide.com/tutorial-node-red-dashboards-multiple-lines-on-a-chart/

I am. It doesn't seem to make any difference. I don't see how the chart node is deciding on the arrangement.


Charles

If you are speaking about the arrangement of the color line for each message... I have no idea, I guess on the order of arrival at start, maybe you can make a test with 4 inject nodes with different topics and see if going always on the same order at start the color is always the same, if is like this then you already have some idea how to proceed to have always the same color for each assignament.

Regards

I just made the test and is exactly like this, the color is assigned per order of arrival at first message on the graph, first is dark blue, second light blue etc....

image

So if you wanted to have a specific order you only need to force this to happen and you will have always same color lines per each channel.

Apparenlty the color order is predefined but seems you can change it on the chart node config

image

I don't know if is any chance to set is on the in message but seems not, anyway you can play with the orders as mentioned, can do it very easy.

Another option is made the graf on a template and you define the color based on msg.topic but for me this seems difficult to do with my knowledge but I know you can find some info googleing a bit.

Regards

If you don’t mind to lose the first values until all had send on the proper order… then you can do something like this, this will be the easiest otherwise will require to store each value on a variable and pull an array with the full set of values for each channel.


[{"id":"b760cc80.74102","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 1","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":159,"y":1786,"wires":[["55e9bfe7.f8158"]]},{"id":"9fc62eae.c5871","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 1","payload":"3","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":153,"y":1822,"wires":[["55e9bfe7.f8158"]]},{"id":"70ecfdc2.4d5134","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 2","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":163,"y":1916,"wires":[["8ff68a06.e3d998"]]},{"id":"28a6009b.04aff","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 2","payload":"4","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":156,"y":1958,"wires":[["8ff68a06.e3d998"]]},{"id":"35dee5b7.25882a","type":"ui_chart","z":"c1bcf04c.5b249","name":"","group":"f4e44dd4.78f0b","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":785,"y":2014,"wires":[[],[]]},{"id":"87cfca7e.62a678","type":"inject","z":"c1bcf04c.5b249","name":"delete graph","topic":"","payload":"[]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":480,"y":2138,"wires":[["35dee5b7.25882a"]]},{"id":"b20af301.28a51","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 3","payload":"7","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":176,"y":2053,"wires":[["b7fe84e5.5ebce8"]]},{"id":"8ac6e84d.2523f8","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 3","payload":"9","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":169,"y":2095,"wires":[["b7fe84e5.5ebce8"]]},{"id":"513c8978.b63e18","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 4","payload":"6","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":182,"y":2190,"wires":[["8c6ffee4.46344"]]},{"id":"56b30b28.e7c144","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 4","payload":"8","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":175,"y":2232,"wires":[["8c6ffee4.46344"]]},{"id":"1c1b74cc.baaeab","type":"comment","z":"c1bcf04c.5b249","name":"blue","info":"","x":125,"y":1729,"wires":[]},{"id":"f0fc49f6.8676f8","type":"comment","z":"c1bcf04c.5b249","name":"red","info":"","x":121,"y":1872,"wires":[]},{"id":"4139bab0.ac0f04","type":"comment","z":"c1bcf04c.5b249","name":"orange","info":"","x":121,"y":1998,"wires":[]},{"id":"b2bc9e40.4f703","type":"comment","z":"c1bcf04c.5b249","name":"green","info":"","x":112,"y":2137,"wires":[]},{"id":"55e9bfe7.f8158","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":315,"y":1809,"wires":[["35dee5b7.25882a","f9c38afa.af19e8"]]},{"id":"f9c38afa.af19e8","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"first","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":489,"y":1769,"wires":[[]]},{"id":"8ff68a06.e3d998","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":318,"y":1932,"wires":[["d86896c4.335a18"]]},{"id":"b7fe84e5.5ebce8","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":323,"y":2076,"wires":[["71f66b82.b85934"]]},{"id":"8c6ffee4.46344","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":336,"y":2214,"wires":[["c9266f5.6b64c9"]]},{"id":"d86896c4.335a18","type":"switch","z":"c1bcf04c.5b249","name":"","property":"first","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":446,"y":1931,"wires":[["35dee5b7.25882a","964acc6a.1b494"]]},{"id":"964acc6a.1b494","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"second","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":606,"y":1883,"wires":[[]]},{"id":"71f66b82.b85934","type":"switch","z":"c1bcf04c.5b249","name":"","property":"second","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":453,"y":2074,"wires":[["35dee5b7.25882a","54f93a9a.279f74"]]},{"id":"54f93a9a.279f74","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"third","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":588,"y":2021,"wires":[[]]},{"id":"c9266f5.6b64c9","type":"switch","z":"c1bcf04c.5b249","name":"","property":"third","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":465,"y":2214,"wires":[["35dee5b7.25882a"]]},{"id":"c96b01c3.6ce13","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":188,"y":1661,"wires":[["82a08cf3.23ffa","6cbc3c0b.0750e4","ab6ed172.5f79b"]]},{"id":"82a08cf3.23ffa","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"first","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":412,"y":1627,"wires":[[]]},{"id":"6cbc3c0b.0750e4","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"second","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":419,"y":1665,"wires":[[]]},{"id":"ab6ed172.5f79b","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"third","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":1709,"wires":[[]]},{"id":"f4e44dd4.78f0b","type":"ui_group","z":"","name":"TEST","tab":"2ba72fb4.e9cb","disp":true,"width":"9","collapse":false},{"id":"2ba72fb4.e9cb","type":"ui_tab","z":"","name":"GRID","icon":"dashboard"}]

I am putting all my values into a json array now for writing to a file. I wonder if sending the json data to the chart would work?
msg also has a property, “series” but it doesn’t change anything either. my order was 15432. :frowning:

I’m testing your solution now. I don’t think it will be to much of an extra load on my raspberry Pi3.
Charles

Hi david;

inserted your flows into my UI flow and it seems to have stabilized my order, though not in the order I would have guessed based on the “set flow.first” nodes. I even switched two nodes and it didn’t change their order but at least they don’t change around on me. At lest I hope…

more to come…

Charles

You just need to set based on topic which one is first, which one the second etc... then go to the graphic node and set the colors as you wish,. you have some order predefined, first message will be dark blue, second light blue, third orange etc.....

image

However you can change this, just click on the color and select from the palette the color you wanted on this specific position.

Happy to know that helped you somehow.

Regards

I switched two sources rather. I switched brewbox and brewbucket between 2nd and 3rd but they remained in the original order.

The colors aren’t a big deal, it was the order that was confounding. I have changed the colors to match the data, ie. red for heat, blue for cool etc. The problem was that my order would change but the colors stayed the same order, so setpoint was red, heat was blue, etc…

Oh, sorry, just cleared my chart and the order changed. I may have changed a setting or something.
What triggers the timestamp inject to the change to off nodes? Would clearing the chart do that?

Charles

Hello Charles

You told me you wanted to ensure as soon as the system is started or deployed.
In order to do that if you see at start I set all flow variables to off to initiate the sequence on this part:

image

If you wanted this to happen also when you push on delete the data you just need to wire this also from wherever you use to clean the chart to set to "off" again the variables.

like this on the example flow I gave you:

image

This will restart the sequence on the same way that happens on deploy/restart and colors will be again respected.

Regards

Sorry about the miscommunication. I’m new to js and node-red and am not up to speed on the terminology. I knew I wasn’t getting my point across but couldn’t make my point. :frowning:

I really appreciate your input and I’m trying to understand how your flow works.
I changed the inject nodes to interval 3seconds and got a nice graph and it refreshes in the correct order now. Thanks!

So when I want to chart my own data I should delete your inject nodes for each channel and insert links to my data if I understand how your flow works. I’m refreshing data every 5 seconds with a global timestamp inject which should replace the 3 second interval in your channel 1-4 inject modules, correct?
The function node between the channel(s) and the switch doesn’t serve any purpose that I can see. Can you elaborate?

Thanks again for your input and patience.
Charles

Hello Charles

Is just one example or idea how you can solve the problem, maybe I can add you an explanation to better understand....

image

1 - I added this only for testing purpose, you need to remove this and add your 4 input channels however take into consideration you need to set in advance as msg.topic (channel1,channel2....) in advance.

2- at restart or deploy all flow variables at set to "off" to restart the sequence.
3- Is just a cascade, the first channel will enable the pass of the msg on the flow from second channel only once you get a message on this first channel.
Second will enable third.
Third will enable fourth.
At start /deploy only channel 1 is able to pass.

[{"id":"b760cc80.74102","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 1","payload":"5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":159,"y":1786,"wires":[["55e9bfe7.f8158"]]},{"id":"9fc62eae.c5871","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 1","payload":"3","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":153,"y":1822,"wires":[["55e9bfe7.f8158"]]},{"id":"70ecfdc2.4d5134","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 2","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":163,"y":1916,"wires":[["8ff68a06.e3d998"]]},{"id":"28a6009b.04aff","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 2","payload":"4","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":156,"y":1958,"wires":[["8ff68a06.e3d998"]]},{"id":"35dee5b7.25882a","type":"ui_chart","z":"c1bcf04c.5b249","name":"","group":"f4e44dd4.78f0b","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#ff0000","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":785,"y":2014,"wires":[[],[]]},{"id":"87cfca7e.62a678","type":"inject","z":"c1bcf04c.5b249","name":"delete graph","topic":"","payload":"[]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160.0000228881836,"y":1546.3333377838135,"wires":[["35dee5b7.25882a","82a08cf3.23ffa","6cbc3c0b.0750e4","ab6ed172.5f79b"]]},{"id":"b20af301.28a51","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 3","payload":"7","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":176,"y":2053,"wires":[["b7fe84e5.5ebce8"]]},{"id":"8ac6e84d.2523f8","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 3","payload":"9","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":169,"y":2095,"wires":[["b7fe84e5.5ebce8"]]},{"id":"513c8978.b63e18","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 4","payload":"6","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":182,"y":2190,"wires":[["8c6ffee4.46344"]]},{"id":"56b30b28.e7c144","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"channel 4","payload":"8","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":175,"y":2232,"wires":[["8c6ffee4.46344"]]},{"id":"1c1b74cc.baaeab","type":"comment","z":"c1bcf04c.5b249","name":"blue","info":"","x":125.00000762939453,"y":1692.3332948684692,"wires":[]},{"id":"f0fc49f6.8676f8","type":"comment","z":"c1bcf04c.5b249","name":"red","info":"","x":121,"y":1872,"wires":[]},{"id":"4139bab0.ac0f04","type":"comment","z":"c1bcf04c.5b249","name":"orange","info":"","x":121,"y":1998,"wires":[]},{"id":"b2bc9e40.4f703","type":"comment","z":"c1bcf04c.5b249","name":"green","info":"","x":112,"y":2137,"wires":[]},{"id":"55e9bfe7.f8158","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":315,"y":1809,"wires":[["35dee5b7.25882a","f9c38afa.af19e8"]]},{"id":"f9c38afa.af19e8","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"first","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":489,"y":1769,"wires":[[]]},{"id":"8ff68a06.e3d998","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":318,"y":1932,"wires":[["d86896c4.335a18"]]},{"id":"b7fe84e5.5ebce8","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":323,"y":2076,"wires":[["71f66b82.b85934"]]},{"id":"8c6ffee4.46344","type":"function","z":"c1bcf04c.5b249","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":336,"y":2214,"wires":[["c9266f5.6b64c9"]]},{"id":"d86896c4.335a18","type":"switch","z":"c1bcf04c.5b249","name":"","property":"first","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":446,"y":1931,"wires":[["35dee5b7.25882a","964acc6a.1b494"]]},{"id":"964acc6a.1b494","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"second","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":606,"y":1883,"wires":[[]]},{"id":"71f66b82.b85934","type":"switch","z":"c1bcf04c.5b249","name":"","property":"second","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":453,"y":2074,"wires":[["35dee5b7.25882a","54f93a9a.279f74"]]},{"id":"54f93a9a.279f74","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"third","pt":"flow","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":588,"y":2021,"wires":[[]]},{"id":"c9266f5.6b64c9","type":"switch","z":"c1bcf04c.5b249","name":"","property":"third","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":465,"y":2214,"wires":[["35dee5b7.25882a"]]},{"id":"c96b01c3.6ce13","type":"inject","z":"c1bcf04c.5b249","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":188.00000762939453,"y":1624.3332948684692,"wires":[["82a08cf3.23ffa","6cbc3c0b.0750e4","ab6ed172.5f79b"]]},{"id":"82a08cf3.23ffa","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"first","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":528.6666488647461,"y":1590.3333206176758,"wires":[[]]},{"id":"6cbc3c0b.0750e4","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"second","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":535.6666488647461,"y":1628.3333206176758,"wires":[[]]},{"id":"ab6ed172.5f79b","type":"change","z":"c1bcf04c.5b249","name":"","rules":[{"t":"set","p":"third","pt":"flow","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":531.6666488647461,"y":1672.3333206176758,"wires":[[]]},{"id":"f4e44dd4.78f0b","type":"ui_group","z":"","name":"TEST","tab":"2ba72fb4.e9cb","disp":true,"width":"9","collapse":false},{"id":"2ba72fb4.e9cb","type":"ui_tab","z":"","name":"GRID","icon":"dashboard"}]

Afterwards you need to go and edit the graph node and configure the proper order on the color you wanted, click on top of the color and define the proper one

image

Hope this helps to clarify

Yes, that does clarify.
My problem, I found after your message, was that I was using a non-refreshing input for channel 1 so it was not turning the subsequent channels on. I fetched my variable from global context and added an inject interval and it works fine.
I was also able to change the series name in the legend and add a 5th channel, so I’m good to go!

Awesome, Thanks!

Charles