# Chart gone crazy - kind of. Missing time

**URL:** <https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091>\
**Category:** Dashboard\
**Created:** [13 April 2019 06:31 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091 "2019-04-13T06:31:20Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 06:31 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/1 "2019-04-13T06:31:20Z")

</div>

I have a NodeMCU with a DHT11 connected.  
It also has a 8 digit 7 segment display connected.

It sends data to my system via MQTT and it is displayed on a gauge and chart.

A couple of times how I've seen the display "spit the dummy" and go all weird.  
(Crazy things on the display)  
Then it clears and starts to display correctly again.

I thought I would see if the unit is actually dieing (yeah, ok how do you spell it? I seem to have forgotten.)

So I powered up this machine and looked at the NR main machine (.99) and what the dashboard says.

**problem**

It is 16:24 and the chars only shows data until 15:58. (See attached.)

The gauge and chart are getting real data as I see the gauge change as the value displayed on the _Arduino_ changes. So the data is getting through.

But why the _missing time_?

 ![Screenshot%20from%202019-04-13%2016-24-12](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/ceb41e8d912234b51ba65b9fee47a1abf72a6c21.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2019 06:38 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/2 "2019-04-13T06:38:30Z")

</div>

Do you have debug node connected to the same output as your chart? If not, add one and see what data is being sent to the chart. Perhaps it's malformed somehow?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 06:44 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/3 "2019-04-13T06:44:07Z")

</div>

Well, as best I can see it isn't.

Granted it doesn't have a timestamp in there.  
Which I guess is a problem.

But I thought (Yeah: dangerous) that the chart displayed data as it got it.  
So if it gets a value "now" it shows it as "now" on the time time which I have the chart set up on the X axis.

 ![Screenshot%20from%202019-04-13%2016-40-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bf042676cbfc57ea96fbd24a40c401b64f8f8f45.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2019 06:54 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/4 "2019-04-13T06:54:05Z")

</div>

I see you have a function labeled "ensure first". At a guess, this function is blocking or mutating data before sending to chart.

Add a debug node after that (to the same output your chart is connected).

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 06:59 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/5 "2019-04-13T06:59:39Z")

</div>

Sorry, no, that is so the humidity and temperature have the _correct_ colours on the chart.

So it waits for the temperature data to arrive first before allowing the data to flow.

I am really thinking that I need to set the timestamp in the message.  
(But that needs to be done upstream of here.

I'm looking at this site: [How to timestamp messages](https://github.com/node-red/node-red-dashboard/blob/master/Charts.md) but I am not understanding it.

It goes on with:

> You can also insert extra data points by specifying the `timestamp` property. This must be in either epoch time (in miliseconds, not seconds), or ISO8601 format.

> ```auto
> {topic:"temperature", payload:22, timestamp:1520527095000}
> 
> ```

But I am not getting how to inject the number/value.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2019 07:19 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/6 "2019-04-13T07:19:28Z")

</div>

Pretty sure you don't need to add timestamp to your message for the chart to populate.

However, for academic reasons...  
`var ts = Date.now();`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 07:21 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/7 "2019-04-13T07:21:51Z")

</div>

So simply adding the `var ts = Date.now();` into the function node will timestamp the message?

I have just (actually) noticed that ALL my charts are at the wrong time. About 30 minutes behind _now_, yet they are getting real time data.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2019 07:27 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/8 "2019-04-13T07:27:36Z")

</div>

Maybe you have a resource issue?

Try reopening your browser?  
Try redeploy your full flow?

Can't help without seeing more tbh.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 April 2019 07:29 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/9 "2019-04-13T07:29:50Z")

</div>

As Steve says, you don't need to attach the time. You just send a number to the chart. The debug you show isn't for the chart as the debug button is disabled. Please add a debug as Steve suggested and show us that output..

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 07:43 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/10 "2019-04-13T07:43:02Z")

</div>

(Hi DCeeJay.)

(Read your reply.)  
**for clarity with the DEBUG node**  
Yes, it is disabled.

I injected the data and _habitually_ disabled it when done, so if I needed to get back to it **status quo** the data would still be there.

The data in the screen shot is from that debug node.

(Annoyed that you can't put extra blank lines in for separation of paragraphs other than one line)

This is weird.

(Not to you Steve)

I've decided to _minimalise_ the problem.

This is my test flow:  
(Sorry it has a `fan` node in it to simplify switching what is connected to what.  
See below screen shots.)

```auto
[{"id":"b8cb4c65.14521","type":"function","z":"baf80d2f.6bd538","name":"Add time","func":"var temperature = msg.payload;\nvar now = Date.now();\nmsg = {temperature: temperature, timestamp:now};\nreturn msg;\n","outputs":1,"noerr":0,"x":280,"y":2930,"wires":[[]]},{"id":"4aafd22.8baa5ac","type":"inject","z":"baf80d2f.6bd538","name":"","topic":"","payload":"foo","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":2860,"wires":[["1a3051b4.30cfce"]]},{"id":"d6c6250d.65fbe","type":"debug","z":"baf80d2f.6bd538","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":2930,"wires":[]},{"id":"1a3051b4.30cfce","type":"random","z":"baf80d2f.6bd538","name":"","low":"1","high":"10","inte":"true","property":"payload","x":280,"y":2860,"wires":[["b8cb4c65.14521","e6a6b5c1.9777b8"]]},{"id":"200ee33d.e3cf4c","type":"ui_chart","z":"baf80d2f.6bd538","name":"","group":"2c2e8aab.1813b6","order":0,"width":0,"height":0,"label":"Test","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"Test","dot":false,"ymin":"","ymax":"","removeOlder":"4","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#010305","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":650,"y":2980,"wires":[[]]},{"id":"e6a6b5c1.9777b8","type":"fan","z":"baf80d2f.6bd538","x":510,"y":2930,"wires":[["d6c6250d.65fbe","200ee33d.e3cf4c"]]},{"id":"5fa25e69.6b3a4","type":"inject","z":"baf80d2f.6bd538","name":"wipe","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":3060,"wires":[["b5c422f.8706c6"]]},{"id":"b5c422f.8706c6","type":"function","z":"baf80d2f.6bd538","name":"","func":"msg.payload = null;\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":3060,"wires":[["200ee33d.e3cf4c"]]},{"id":"2c2e8aab.1813b6","type":"ui_group","name":"Group 2","tab":"ce4bcacd.5cc46","order":2,"disp":true,"width":6},{"id":"ce4bcacd.5cc46","type":"ui_tab","z":"","name":"VTEMP","icon":"dashboard","order":36,"disabled":false,"hidden":false}]

```

Forgive the FAN node. It just makes it easier to swap inputs to the chart and debug node.  
Here's the weird thing.

`inject` -- `random` (1-10 integer) -- `chart` and `debug`.

Setting the chart up for 4 minutes and slowly pressing the inject a few times with a few seconds apart, the char **did** show a a line. **note** it is (say) 17:30. The chart time was 17:00.

I then tried to add the `function` node and _timestamp_ the data.  
Didn't work. Dunno why. But indulge me for a second.

So, I disconnected the `function` node to the `chart` and connected the `chart` to the `random` node.

Pressed the `inject` node a few times as before.  
**nothing!!!**

I don't get it.

I added a `msg.payload = null;` on the second `inject` node to wipe the chart.  
That isn't working, other than I don't have any traces on it, but as I am not repeatedly pressing that `inject` node, the `chart` isn't showing any more lines when I press the original `inject` node to inject random data.

Screen shots for clarity.

 ![Screenshot%20from%202019-04-13%2017-35-26](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/10c4fd68b9aae030924dc40062a25214e865a524.png) ![Screenshot%20from%202019-04-13%2017-35-33](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e64f98d48e12a2e6e841b8d41e7b8c33ac3c541e.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 07:45 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/11 "2019-04-13T07:45:37Z")

</div>

To save time editing.....

Please read this.

It is (typically) now working with the basic stuff.

And looking at the times, they too are correct.

ON THIS chart.

(Minor edit...)  
Well, maybe not 100% correct time, but definitely not 30 minutes off.  
Maybe 1 minute or so.

Going back to **real** chart now.

(See pictures now)

 ![Screenshot%20from%202019-04-13%2017-45-22](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/cb874675770cbfe60ff2c2fc6ae205ec265702e6.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 07:50 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/12 "2019-04-13T07:50:32Z")

</div>

This is on the **real** machine with the real code.

 ![Screenshot%20from%202019-04-13%2017-47-32](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bcf63c9d7a1b5f4bd7650cd5382bb6b99cf36406.jpeg)

Flow code:  
(Injection of pules every .... 20 seconds to get value.)

```auto
[{"id":"d1173d22.231328","type":"exec","z":"e2bd5a4e.5597e8","command":"/opt/vc/bin/vcgencmd measure_temp| sed 's/[^0-9]*//g'","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Check Temp","x":1000,"y":360,"wires":[["eb4e770c.f31eb8","ca612501.b6c82"],[],[]]},{"id":"ca612501.b6c82","type":"function","z":"e2bd5a4e.5597e8","name":"Make number and set Topic","func":"msg.payload = Number(msg.payload)/10;\nmsg.topic=global.get('myDeviceName');\nmsg.topic =\"TEMP/\" + msg.topic;\nreturn msg;\n","outputs":1,"noerr":0,"x":1230,"y":360,"wires":[["a387d257.1f70e8","10449e73.e11b42","f7b5b05b.86162","8e79ab07.9c2fd8","879b04aa.db0d2"]]},{"id":"10449e73.e11b42","type":"ui_gauge","z":"e2bd5a4e.5597e8","name":"","group":"f1986590.13afa8","order":1,"width":"5","height":"4","gtype":"gage","title":"Temp","label":"Celcius","format":"{{value}}","min":"10","max":"80","colors":["#00b500","#e6e600","#ca3838"],"seg1":"56","seg2":"60","x":1480,"y":400,"wires":[]},{"id":"f7b5b05b.86162","type":"ui_chart","z":"e2bd5a4e.5597e8","name":"","group":"f1986590.13afa8","order":4,"width":"5","height":"3","label":"History","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#000000","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":1491.5,"y":443,"wires":[[],[]]},{"id":"f1986590.13afa8","type":"ui_group","z":"","name":"TimePi Local Telemetry","tab":"173dcde5.96e88a","order":1,"disp":true,"width":"8","collapse":false},{"id":"173dcde5.96e88a","type":"ui_tab","z":"","name":"Local Readings","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2019 07:56 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/13 "2019-04-13T07:56:03Z")

</div>

I'm no expert on the chart nodes but it was my understanding you simply pass the value in msg.payload and set the msg.topic to the axis title.

Nothing more than that is necessary I believe.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 08:04 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/14 "2019-04-13T08:04:27Z")

</div>

Yes.  
And looking at my

> [@Trying\_to\_learn](#):
>
> To save time editing.....

post, you can see there is a small time difference from the time (top centre) of the screen and the time on the chart.

17:45 and 17:44:07. Though it seems that even the 17:44:07 is _future_ on the chart's axis.

Then going to my next post you can see that the time is 17:47 (top of screen) yet if I go down to the chart and look at the **last** point plotted, it is 17:18:39  
That's nearly 30 minutes behind.

I posted the flow (part) which has the node which gets the temperature, _formats_ it and the chart, etc.

There isn't any _sneaky stuff_ going on here.  
Granted the other one I have shown has the other `function` node to sequence the messages - since discovered I could set the topic as series (or something) to negate that _problem_ where the first set of data gets colour 1 and the second gets colour 2. Anyway.....

Outside the scope here.

So, this is situation as it stands with about 30 minutes difference between the real time and the data time on the chart.

🤷‍♂️

I am (probably and typically) missing an elephant somewhere.

---

<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:** [13 April 2019 08:43 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/15 "2019-04-13T08:43:01Z")

</div>

Are you running the browser on the machine running node red (a pi?) or on another machine? If not the same then check the system time on the machine running node-red.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 April 2019 08:48 UTC](https://discourse.nodered.org/t/chart-gone-crazy-kind-of-missing-time/10091/16 "2019-04-13T08:48:35Z")

</div>

I'm am idiot.

And that is my NTP machine!

SHAME ON ME!

 ![Screenshot%20from%202019-04-13%2018-47-25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/65336cacdad53bce2f3ee82505540f3317997c22.png)
