# \[SOLVED\] Invisible line in graph due to null data returned from influxdb query

**URL:** <https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517>\
**Category:** Dashboard\
**Tags:** node-red-dashboard, chart, ui-widgets\
**Created:** [17 February 2022 08:45 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517 "2022-02-17T08:45:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [17 February 2022 08:45 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/1 "2022-02-17T08:45:59Z")

</div>

Hello All,  
I've working with influxdb to plot data from last few hour.  
As i query for last 8 hour i'm getting "null" where missing values are.  
below image shows value which are recorded into influx db generate line and null point not generating line inbetween.

Any idea how to ignore null point.  
i need to keep X axis stable as possible

referance [tutrial](https://funprojects.blog/2020/02/01/influxdb-with-node-red/)

Node red version 2.2.1: Maintenance Release  
node-red-contrib-influxdb : 0.6.1  
node-red-dashboard : 3.1.5

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

---

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [17 February 2022 08:48 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/2 "2022-02-17T08:48:40Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/66bc681b0f49a5f65c6f0b7eea363ac437c73b43.png)  
Another example of missing line

---

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [17 February 2022 08:52 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/3 "2022-02-17T08:52:18Z")

</div>

Solution!!!

Post last value instead null

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/98a5c6dbe75220faa8c6d3a5d672a1cb6e8a2eae.png)

---

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [17 February 2022 08:53 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/4 "2022-02-17T08:53:26Z")

</div>

```auto
if(value == null)
    {
        value = last_not_null_val
    }
    else
    {
        last_not_null_val = value
    }
    data += '{ "x":"' + thetime + '", "y":' + value + '}';

```

---

<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:** [17 February 2022 09:00 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/5 "2022-02-17T09:00:49Z")

</div>

If you send last known not null value, you just increase the amount of data-points for chart to render.  
Chart does the interpolation job without the extra data-point.  
Just ignore null values

```auto
if(value != null){

    data += '{ "x":"' + thetime + '", "y":' + value + '}';

```

---

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [17 February 2022 09:14 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/6 "2022-02-17T09:14:29Z")

</div>

Hi @hotNipi,  
Thanks for input! 😀  
Example code is generating json error while skiping null value.  
I'm figuring out that part which will keep X axis intact as intented.

---

<div class="post-metadata">

**Author:** ![sdrshnptl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sdrshnptl/32/40446_2.png) [@sdrshnptl](https://discourse.nodered.org/u/sdrshnptl)\
**Post date:** [22 February 2022 11:59 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/7 "2022-02-22T11:59:58Z")

</div>

Actual reason is i've selected storage precision in influxdb to milisecond. turned it to second and probem gone.

---

<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 2022 12:00 UTC](https://discourse.nodered.org/t/solved-invisible-line-in-graph-due-to-null-data-returned-from-influxdb-query/58517/8 "2022-03-08T12:00:00Z")

</div>

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