# A big lag in chart data visualization

**URL:** <https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554>\
**Category:** Dashboard\
**Created:** [13 November 2022 22:51 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554 "2022-11-13T22:51:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [13 November 2022 22:51 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/1 "2022-11-13T22:51:36Z")

</div>

Hello All,

I would like to stream sensor data (in Real-time) on a chart in the Node-red dashboard. The rate that the data is read from the sensor is about 0.2 seconds. But I can see a lag of 1 second when seeing the data on the chart. Can anyone help with this?

Thank you

---

<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:** [14 November 2022 14:10 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/2 "2022-11-14T14:10:44Z")

</div>

What hardware are you running node-red and the browser on? Is the browser running on the same machine as node-red?

Does the lag start immediately or does it only show when the chart fills up with data?  
What time range have you configured the chart for?

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [14 November 2022 15:48 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/3 "2022-11-14T15:48:26Z")

</div>

Hi Colin,

I am running node-red and the chrome browser on my laptop (core i7, 16 GB RAM, intel IrisX).  
I need it for a course of, for example, 2 min. The lag starts from the beginning. It does not show the data in real-time mode, I feel. It is like that for example, my sensor is changing gradually from 10 to 5 (like 10, 9, 8, 7, 6, and then 5, each change in one second (so in total, it takes 5 seconds)), but node-red receives and shows all of the changes in one second.

---

<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:** [14 November 2022 16:05 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/4 "2022-11-14T16:05:28Z")

</div>

In the Chart node have you got Interpolate set to Step? If not then try that and see what the chart looks like. You can paste an image here.

---

<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:** [14 November 2022 16:13 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/5 "2022-11-14T16:13:32Z")

</div>

Does this work for you, it does for me.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/0495e5d2969da9bb152a4c6653b6bd91d44ce094.png)

```auto
[{"id":"5f4b328f464177a0","type":"ui_chart","z":"bdd7be38.d3b55","name":"","group":"903a6ab8.4f4ca8","order":4,"width":0,"height":0,"label":"Fast chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":330,"y":3300,"wires":[[]]},{"id":"c57ee6549d3ddf4f","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.2","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":3300,"wires":[["5f4b328f464177a0"]]},{"id":"903a6ab8.4f4ca8","type":"ui_group","name":"Home","tab":"e2e6f4f5.56f91","order":1,"disp":false,"width":"6","collapse":false,"className":""},{"id":"e2e6f4f5.56f91","type":"ui_tab","name":"Homet","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [14 November 2022 16:41 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/6 "2022-11-14T16:41:06Z")

</div>

The speed in the one you sent is perfect. Therefore, the problem is not because of the hardware or browser. Is that possible that the lag is because of MTQQ speed in transferring data?

Here is a snapshot of my nodes:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80a3cbd1aafc3ffc5d9d08781f5b4f7f2c1877bb.png)

---

<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:** [14 November 2022 16:44 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/7 "2022-11-14T16:44:01Z")

</div>

> [@Colin](#):
>
> In the Chart node have you got Interpolate set to Step? If not then try that and see what the chart looks like. You can paste an image here.

Do that and show us the chart.  
Let it run for just a few seconds after clearing the chart before the screenshot.

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [14 November 2022 16:50 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/8 "2022-11-14T16:50:12Z")

</div>

Sure.  
For example, when I took this screenshot, the sensor reading was on 4095, but nothing was showing in the chart:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/627cae9c0820b71bd3c93df7b30c55ec13b96aa4.png)

until it was shown up after a lag as below:

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

---

<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:** [14 November 2022 17:05 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/9 "2022-11-14T17:05:02Z")

</div>

What do you see in the log from the debug node at that time?

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [14 November 2022 17:06 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/10 "2022-11-14T17:06:50Z")

</div>

I can see that the data reaches node-red with that lag. That is why I think the lag is not because of the nodes in the node-red itself.

---

<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:** [14 November 2022 17:10 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/11 "2022-11-14T17:10:59Z")

</div>

> [@masoudhyundai](#):
>
> I can see that the data reaches node-red with that lag.

Do you mean that the lag is there coming out of the MQTT node? Are there the right number of messages (five per second)?

Try using something like MQTTExplorer (which is a very useful tool to install) whether you see the lag there.

Also check in the system monitor (or using `top` if you are using a Linux system) that nothing is hogging the processor.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 November 2022 19:48 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/12 "2022-11-14T19:48:04Z")

</div>

Your second graph looks odd, it appears to jump back and forward in time.  
Presumably data arriving at the two MQTT-in nodes has different topics?  
Are you trying to draw two lines on one chart?  
Can you show us a sample of the data that you are feeding into the chart?

---

<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:** [14 November 2022 20:37 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/13 "2022-11-14T20:37:09Z")

</div>

> [@jbudd](#):
>
> Your second graph looks odd, it appears to jump back and forward in time.

If you look back at the flows image it can be seen that it is being fed from two MQTT nodes, so one would expect there to be two lines.

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [14 November 2022 21:26 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/14 "2022-11-14T21:26:48Z")

</div>

Yes Colin. I see the lag on MQTTExplorer too. I am using an MQTT broker on my android. The application name is "MQTT broker app". Maybe that is not a wise choice.

---

<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:** [14 November 2022 21:42 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/15 "2022-11-14T21:42:20Z")

</div>

> [@masoudhyundai](#):
>
> I am using an MQTT broker on my android. The application name is "MQTT broker app". Maybe that is not a wise choice.

No, probably not. Why have you done that?  
I suggest using Mosquitto on the PC as the broker.

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [14 November 2022 22:34 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/16 "2022-11-14T22:34:51Z")

</div>

I tried for a whole two days trying to connect my ESP32 to the mosquito. It was not possible in the end. The node-red was completely fine with mosquito (127.0.0.1, port 1883). But I was always receiving this error in my Arduino IDE serial monitor:  
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

I searched for the error through the net, and I did everything that everyone suggested as a solution. No success. That is why I tried a broker on my phone.

---

<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:** [15 November 2022 07:12 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/17 "2022-11-15T07:12:01Z")

</div>

> [@masoudhyundai](#):
>
> I tried for a whole two days trying to connect my ESP32 to the mosquito

Did you configure mosquitto to allow remote access? If so then show us exactly what you did.

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [15 November 2022 08:35 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/18 "2022-11-15T08:35:05Z")

</div>

I am not sure how to configure it for remote access. These are what I read through the web as solutions and I tried so far.

1. I added two lines in the mosquito config file as below:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e76d0f5ae91dd0ae8e2a177a8bbcb57d399f2857.png)
2. I disabled the firewall on my PC completely.
3. I tried other listener ports instead (127.0.0.1) that I can see through netstat -a in CMD.
4. I added an incoming and outgoing rule in my firewall to allow all TCP ports.

---

<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:** [15 November 2022 09:17 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/19 "2022-11-15T09:17:03Z")

</div>

> [@masoudhyundai](#):
>
> the mosquito config file

Exactly which file is that? It doesn't look like the default config file.

How are you running mosquitto?

---

<div class="post-metadata">

**Author:** ![masoudhyundai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/masoudhyundai/32/70662_2.png) [@masoudhyundai](https://discourse.nodered.org/u/masoudhyundai)\
**Post date:** [15 November 2022 14:34 UTC](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554/20 "2022-11-15T14:34:20Z")

</div>

This is where the file is located:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/333418eef41e2509dde07197a1421e66f09f4096.png)  
I open a command prompt, and I run these code one by one:

> > cd "C:\Program Files\mosquitto"  
> > mosquito  
> > net start mosquitto

[Next page](https://discourse.nodered.org/t/a-big-lag-in-chart-data-visualization/70554.md?page=2)
