Stop moving X-axis of a chart if no data is received

Hi all,

as you can see in the screenshot below, I have a chart (the lower one in the screenshot) which stops drawing data correctly / by intention (at about 12 o'clock in this example) but the X-axis is moving on.

Is there a way to stop also moving the X-axis when not data is received?

grafik

Thank you very much!

Kind regards
Thomas

As far as I know the x-axis should not move if the chart is not receiving any messages, are you feeding in any null values? Add a debug to all nodes feeding into chart node to see if any messages are still coming in. a message will null value will move the chart on.

2 Likes

A simple chart (only one line) does not do that for me.
Are you sure you are not sending NULL values to the chart?

2 Likes

You were right, thank you both!
:clap:

And it was more than NULL values ...

Hi @E1cid & @jbudd,

unfortunately I was hasty with my answer two days ago.

As you can see in the screenshot below, the X-axis of the chart at the bottom is still moving, although no data is output to chart (=> no data is shown in the debug nodes msg_1 to msg_6 because in each function node the same code is implemented).

Any idea why the X-axis is still moving?
Maybe moving of the X-axis cannot be prevented on principle?

The X-axis is moving after switching from on dashboard tab node to another or after refreshing the dashboard web page.

Thank you and kind regards
Thomas

Yes, I think you have found a bug!

A simple flow that draws two charts on the same dashboard tag:

[{"id":"252a67bcee0134e1","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"bec378e992dc149c","type":"inject","z":"252a67bcee0134e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":100,"wires":[["8e6f715583b01f1d"]]},{"id":"8e6f715583b01f1d","type":"function","z":"252a67bcee0134e1","name":"payload += 1","func":"msg.payload = context.get(\"counter\") || 0;\ncontext.set(\"counter\", msg.payload +1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":100,"wires":[["dc24a0a56e1a425b"]]},{"id":"dc24a0a56e1a425b","type":"ui_chart","z":"252a67bcee0134e1","name":"","group":"0b2c5ed94dd5b6dc","order":5,"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":770,"y":100,"wires":[[]]},{"id":"bead04515b51eed6","type":"ui_chart","z":"252a67bcee0134e1","name":"","group":"0b2c5ed94dd5b6dc","order":5,"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":770,"y":160,"wires":[[]]},{"id":"ba425988e0c706a1","type":"switch","z":"252a67bcee0134e1","name":"Payload <= 10","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":620,"y":160,"wires":[["bead04515b51eed6"]]},{"id":"27fc9c1c49cbd2f0","type":"inject","z":"252a67bcee0134e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":160,"wires":[["f812d1fdab9aa949"]]},{"id":"f812d1fdab9aa949","type":"function","z":"252a67bcee0134e1","name":"payload += 1","func":"msg.payload = context.get(\"counter1\") || 0;\ncontext.set(\"counter1\", msg.payload +1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":160,"wires":[["ba425988e0c706a1"]]},{"id":"0b2c5ed94dd5b6dc","type":"ui_group","name":"Demo","tab":"4311353dbffb7643","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"4311353dbffb7643","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]

Both charts work for 10 data points, then the second one ceases to be updated. Correct so far.

Refresh the browser and the x axis is redrawn for both charts. Surely this is wrong?

Edit - well the chart is set to X axis 1 hour or 1000 points but I still wouldn't expect it to redraw the axis with no incoming data

1 Like

here are two work arounds to fix chart when you stop updating

[{"id":"2b3c5960.1660f6","type":"inject","z":"252a67bcee0134e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"toggle","payloadType":"str","x":270,"y":60,"wires":[["49339acd.b54774"]]},{"id":"49339acd.b54774","type":"gate","z":"252a67bcee0134e1","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"default","x":430,"y":80,"wires":[["8e6f715583b01f1d"]]},{"id":"cb2cb236.c9b3c","type":"inject","z":"252a67bcee0134e1","name":"toggle both","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"toggle","payloadType":"str","x":220,"y":140,"wires":[["49339acd.b54774","fb7be398.4546f"]]},{"id":"e0cd27f4.f7deb","type":"function","z":"252a67bcee0134e1","name":"","func":"msg.payload = flow.get(\"counter1\") || 0;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":140,"wires":[["49339acd.b54774","fb7be398.4546f"]]},{"id":"8e6f715583b01f1d","type":"function","z":"252a67bcee0134e1","name":"payload += 1","func":"if(msg.payload > 9) msg.payload = 0;\nflow.set(\"counter1\", msg.payload +1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":80,"wires":[["dc24a0a56e1a425b","d3a91b0d.f45e"]]},{"id":"fb7be398.4546f","type":"gate","z":"252a67bcee0134e1","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"default","x":430,"y":200,"wires":[["f812d1fdab9aa949"]]},{"id":"27fc9c1c49cbd2f0","type":"inject","z":"252a67bcee0134e1","name":"click to start injection","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"label","v":"line1","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"line1","payload":"","payloadType":"date","x":530,"y":140,"wires":[["e0cd27f4.f7deb"]]},{"id":"dc24a0a56e1a425b","type":"ui_chart","z":"252a67bcee0134e1","name":"","group":"0b2c5ed94dd5b6dc","order":5,"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":870,"y":80,"wires":[["8375836e.549898"]]},{"id":"d3a91b0d.f45e","type":"trigger","z":"252a67bcee0134e1","name":"","op1":"","op2":"chart","op1type":"nul","op2type":"flow","duration":"15","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":760,"y":20,"wires":[["dc24a0a56e1a425b"]]},{"id":"7987a2a6.9080ec","type":"inject","z":"252a67bcee0134e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"toggle","payloadType":"str","x":270,"y":220,"wires":[["fb7be398.4546f"]]},{"id":"f812d1fdab9aa949","type":"function","z":"252a67bcee0134e1","name":"payload += 1","func":"if(msg.payload > 9) msg.payload = 0;\nflow.set(\"counter1\", msg.payload +1);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":200,"wires":[["1a3e7791.634608"]]},{"id":"4e27aa0d.f93144","type":"inject","z":"252a67bcee0134e1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":410,"y":300,"wires":[["6aac4fef.05ad28","dc24a0a56e1a425b"]]},{"id":"8375836e.549898","type":"trigger","z":"252a67bcee0134e1","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1020,"y":80,"wires":[["33278488.e28394"]]},{"id":"1a3e7791.634608","type":"change","z":"252a67bcee0134e1","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\t   {\t       \"series\":[\"line1\"],\t       \"data\":[[$append([$flowContext(\"chart1\")],{\"x\": $millis(),\"y\": $$.payload})\t       ]],\t       \"labels\":[\"\"]\t   }\t]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":200,"wires":[["bead04515b51eed6"]]},{"id":"6aac4fef.05ad28","type":"change","z":"252a67bcee0134e1","name":"","rules":[{"t":"set","p":"chart1","pt":"flow","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":340,"wires":[[]]},{"id":"33278488.e28394","type":"change","z":"252a67bcee0134e1","name":"","rules":[{"t":"set","p":"chart","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":80,"wires":[["ba3a45b6.6b68d8"]]},{"id":"bead04515b51eed6","type":"ui_chart","z":"252a67bcee0134e1","name":"","group":"0b2c5ed94dd5b6dc","order":5,"width":0,"height":0,"label":"chart1","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":980,"y":200,"wires":[["b5d9f342.251d3"]]},{"id":"ba3a45b6.6b68d8","type":"debug","z":"252a67bcee0134e1","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":880,"y":360,"wires":[]},{"id":"b5d9f342.251d3","type":"change","z":"252a67bcee0134e1","name":"","rules":[{"t":"set","p":"chart1","pt":"flow","to":"payload[0].data[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":200,"wires":[[]]},{"id":"0b2c5ed94dd5b6dc","type":"ui_group","name":"Demo","tab":"4311353dbffb7643","order":1,"disp":true,"width":"10","collapse":false,"className":""},{"id":"4311353dbffb7643","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]

First will send chart history after no messages received for x seconds

The second createsthe chart from stored data and new incoming value.

@jbudd Thank you!

And who is responsible for fixing bugs in Node-RED?
:roll_eyes:

@E1cid Thank you, I will have a look on it as soon as I have enough time for it...
Kind regards
Thomas

I don't think anyone is "reponsible" for fixing bugs, but we do seem to rely a lot on just a few core developers.

One of the best things about Node-red is that those core developers often share their advice and knowledge in the forum.

The procedure is to raise an issue on github, then anyone is free to offer a fix.

1 Like

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