Chart timestamp on x-axis not accurate

Hi, I am having an issue displaying proper timing on my x-axis and was wondering if someone could please help. Here is my flow, please let me know if additional data is needed:

[{"id":"83afaffb.3b3b8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"5b05e4d0.376cbc","type":"ui_date_picker","z":"83afaffb.3b3b8","d":true,"name":"","label":"date","group":"f2049ccb.8069d","order":3,"width":0,"height":0,"passthru":true,"topic":"","x":90,"y":200,"wires":[[]]},{"id":"34e601e9.f5a0fe","type":"ui_text","z":"83afaffb.3b3b8","d":true,"group":"f2049ccb.8069d","order":1,"width":0,"height":0,"name":"","label":"Customer Tracker","format":"{{msg.payload}}","layout":"row-spread","x":330,"y":160,"wires":[]},{"id":"49a290d7.b57b2","type":"ui_text","z":"83afaffb.3b3b8","d":true,"group":"f2049ccb.8069d","order":2,"width":0,"height":0,"name":"","label":"Current visitors: ","format":"{{msg.currentVisitors}}","layout":"row-spread","x":120,"y":160,"wires":[]},{"id":"5dac79d1.b216c8","type":"ui_chart","z":"83afaffb.3b3b8","d":true,"name":"","group":"f2049ccb.8069d","order":4,"width":0,"height":0,"label":"Visitors in the Store","chartType":"line","legend":"false","xformat":"dd HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"500","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":250,"y":200,"wires":[[]]},{"id":"9a93de94.d4315","type":"ui_toast","z":"83afaffb.3b3b8","d":true,"position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":true,"topic":"","name":"Attendant needed for Cart Collection","x":330,"y":240,"wires":[]},{"id":"fc31e116.b524b","type":"ui_text_input","z":"83afaffb.3b3b8","d":true,"name":"","label":"","tooltip":"","group":"f2049ccb.8069d","order":5,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":100,"y":240,"wires":[["9a93de94.d4315"]]},{"id":"a90dcc8a.b385d","type":"inject","z":"83afaffb.3b3b8","d":true,"name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":400,"wires":[["5b7951c7.b0fa5"]]},{"id":"77bf8b0.fc7be74","type":"debug","z":"83afaffb.3b3b8","d":true,"name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":290,"y":500,"wires":[]},{"id":"5b7951c7.b0fa5","type":"function","z":"83afaffb.3b3b8","d":true,"name":"","func":"for (var i=0; i<400; i++){\n    node.send({payload:i});\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":100,"y":460,"wires":[["2241e549.57e14a"]]},{"id":"2241e549.57e14a","type":"delay","z":"83afaffb.3b3b8","d":true,"name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":110,"y":520,"wires":[["77bf8b0.fc7be74"]]},{"id":"af5a72c.966599","type":"inject","z":"83afaffb.3b3b8","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":80,"y":760,"wires":[["a17bdf83.68828"]]},{"id":"a17bdf83.68828","type":"function","z":"83afaffb.3b3b8","d":true,"name":"","func":"m = msg.payload;\nt = msg.topic;\n\nif (m === null) {\n        n = 0;\n    }\n\n  /*  \n  var n = localStorage.getItem('on_load_counter');\n\n    if (n === null) {\n        n = 0;\n    }\n\n    n++;\n\n    localStorage.setItem(\"on_load_counter\", n);\n\n    document.getElementById('CounterVisitor').innerHTML = n;\n*/\n\n/*\nif (value > 0) {\n        counter = value;\n    } else {\n        counter = 0;\n    }*/ \n    \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":760,"wires":[["6cd49acb.8b2dc4"]]},{"id":"6cd49acb.8b2dc4","type":"debug","z":"83afaffb.3b3b8","d":true,"name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":760,"wires":[]},{"id":"4e0aab3b.54ee74","type":"trigger","z":"83afaffb.3b3b8","d":true,"name":"Notification","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":false,"units":"min","reset":"42","bytopic":"all","topic":"topic","outputs":1,"x":550,"y":1143,"wires":[["7e85fea1.df0e3"]]},{"id":"4c7bfad1.4188f4","type":"switch","z":"83afaffb.3b3b8","d":true,"name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Empty","vt":"str"},{"t":"eq","v":"Full","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":800,"wires":[[],[]]},{"id":"7365a220.e6887c","type":"inject","z":"83afaffb.3b3b8","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":80,"y":800,"wires":[[]]},{"id":"7e85fea1.df0e3","type":"ui_toast","z":"83afaffb.3b3b8","d":true,"position":"dialog","displayTime":"1","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"CLOSE","raw":false,"topic":"","name":"","x":730,"y":1143,"wires":[[]]},{"id":"df16ba6f.b5ed98","type":"function","z":"83afaffb.3b3b8","d":true,"name":"","func":"inside = msg.payload;\noutside = msg.topic;\n\nvisitors = inside - outside\n\n/* if (inside === null) {\n        inside = 0;\n    }\n    \n    else if \n    */\n\n  /*  \n  var n = localStorage.getItem('on_load_counter');\n\n    if (n === null) {\n        n = 0;\n    }\n\n    n++;\n\n    localStorage.setItem(\"on_load_counter\", n);\n\n    document.getElementById('CounterVisitor').innerHTML = n;\n*/\n\n/*\nif (value > 0) {\n        counter = value;\n    } else {\n        counter = 0;\n    }*/ \n    \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":720,"wires":[[]]},{"id":"af32e6bf.d49b88","type":"ui_template","z":"83afaffb.3b3b8","d":true,"group":"754f26ec.f54098","name":"fileInput","order":0,"width":"6","height":"1","format":"<div class=\"fileContainer\">\n    <input type=\"file\" name=\"file\" id=\"file\" class=\"inputfile\" />\n    <label for=\"file\">File</label>\n    <p style=\"margin:auto\" id=\"fileName\"></p>\n    <button class=\"vibrate filled touched smallfont rounded greybuttons\" ng-click=\"clear()\"> \n       <ng-md-icon style=\"color: #fff;\" icon=\"clear\">\n            <md-tooltip md-direction=\"bottom\">CLEAR</md-tooltip>\n        </ng-md-icon>\n    </button> \n</div>\n\n<style>\n    .fileContainer {\n        display: flex;\n    }\n    .inputfile {\n\twidth: 0.1px;\n\theight: 0.1px;\n\topacity: 0;\n\toverflow: hidden;\n\tposition: absolute;\n\tz-index: -1;\n}\n\n.inputfile + label {\n    font-size: 1.25em;\n    font-weight: 700;\n    color: white;\n    text-align: center;\n    padding: 5px;\n    width: 60px;\n    background-color: black;\n}\n\n.inputfile:focus + label,\n.inputfile + label:hover {\n    background-color: red;\n}\n\n.inputfile + label {\n\tcursor: pointer; /* \"hand\" cursor */\n}\n\n.inputfile:focus + label {\n\toutline: 1px dotted #000;\n\toutline: -webkit-focus-ring-color auto 5px;\n}\n\n.inputfile + label * {\n\tpointer-events: none;\n}\n\n</style>\n\n<script>\n(function(scope) {\n   var fileInput = $('#file')\n   var fileName = $('#fileName')\n   \n   scope.clear = function() {\n       fileInput.val('').trigger('change')\n   }\n   \n   fileInput.on('change', function(event) {\n        var file = fileInput[0].files[0]; \n        \n        fileName.text(file ? file.name : '')\n        \n        if(file) {\n       \n            var reader = new FileReader();\n            reader.readAsBinaryString(file);\n        \n            reader.onload = function() {\n                scope.send({payload: reader.result, file: file.name})\n            };\n            reader.onerror = function() {\n                console.log('Error while reading files');\n            };\n        } else\n            scope.send({payload: null})\n   })\n    \n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":80,"y":900,"wires":[["ddc659f0.778d98","c10c65d7.4485f8"]]},{"id":"c10c65d7.4485f8","type":"function","z":"83afaffb.3b3b8","d":true,"name":"","func":"var toDelete = !msg.payload\n\nif(!toDelete) {\n    var buffer = new Buffer(msg.payload, \"binary\");\n    node.send({topic: 'create', payload: buffer, filename: 'files/' + msg.file})\n    flow.set('file', msg.file.name)\n}\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":283,"y":901,"wires":[["e4e08715.d78618"]]},{"id":"e4e08715.d78618","type":"file","z":"83afaffb.3b3b8","d":true,"name":"","filename":"","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":519,"y":902,"wires":[[]]},{"id":"ddc659f0.778d98","type":"exec","z":"83afaffb.3b3b8","d":true,"command":"rm -rf files/*","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":307,"y":970,"wires":[[],[],[]]},{"id":"5ff0f263.c62e1c","type":"comment","z":"83afaffb.3b3b8","d":true,"name":"Just a live view of cameras","info":"","x":190,"y":1618,"wires":[]},{"id":"a8975bf6.441168","type":"inject","z":"83afaffb.3b3b8","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"checkWeb","payloadType":"str","x":150,"y":1718,"wires":[["59e4e15d.ac81c"]]},{"id":"59e4e15d.ac81c","type":"ui_template","z":"83afaffb.3b3b8","d":true,"group":"e56f5108.01102","name":"Just a view of cameras","order":1,"width":"35","height":"12","format":"<!DOCTYPE html>\n<html>\n<style>\nimg {\n    border: 1px solid #ddd;\n    border-radius: 8px;\n    padding: 2px;\n    width: 405px;\n}\n</style>\n\n<script type=\"text/javascript\">\nscope.$watch('msg', function(msg) {\n    inMessage(msg.payload);\n});\n\nfunction updatePic() {\n    document.getElementById('c51').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c52').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c53').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c54').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c55').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c56').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c57').src = \"http://192.168.0.234:8081/1/stream\";\n    document.getElementById('c58').src = \"http://192.168.0.234:8081/1/stream\";\n    //alert('updated pics');\n}\n\nfunction inMessage(event) {\n    if (event.match('checkWeb')) {\n        updatePic();\n    }\n}\n\n</script>\n<center>\n<table>\n    <tr><!-- Row 1 -->\n    \t\t<td style=\"text-align: center\"><img src=\"\" id=\"c51\" /></td>\n   \t\t    <td style=\"text-align: center\"><img src=\"\" id=\"c52\" /></td>\n    \t\t<td style=\"text-align: center\"><img src=\"\" id=\"c53\" /></td>\n    \t\t<td style=\"text-align: center\"><img src=\"\" id=\"c54\" /></td>\n    </tr>\n    <tr><!-- Row 2 -->\n    \t\t<td style=\"text-align: center\"><img src=\"\" id=\"c55\" /></td>\n   \t\t    <td style=\"text-align: center\"><img src=\"\" id=\"c56\" /></td>\n    \t\t<td style=\"text-align: center\"><img src=\"\" id=\"c57\" /></td>\n    \t\t<td style=\"text-align: center\"><img src=\"\" id=\"c58\" /></td>\n    </tr>\n</table>\n</center>\n</html>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":380,"y":1718,"wires":[[]]},{"id":"921878c7.455d08","type":"ui_template","z":"83afaffb.3b3b8","d":true,"group":"e56f5108.01102","name":"Clock Toolbar","order":5,"width":"0","height":"0","format":"\n<script id=\"titleScript\" type=\"text/javascript\">\n    $('#clock').remove();\n    var toolbar = $('.md-toolbar-tools');\n    var div = $('<div></div>');\n    var p = $('<p/ id=\"clock\">');\n    $('#titleScript').parent().hide();\n    div.append(p);\n    div[0].style.margin = '5px 5px 5px auto';\n    toolbar.append(div);\n\n    function displayTitle(lh) {\n        p.text(lh); \n    }\n    \n    function upTime() {\n        var d = new Date();\n        p.text(d.toLocaleTimeString('de-AT'));\n    }\n\n    // Watch the payload and update the title\n    (function(scope) {\n        scope.$watch('msg.payload', function(data) {\n            if (data.match(\"systemsummary\")) { //Systemstatus\n                m = data;\n                n = m.split(':');\n                //alert(n[1]);\n                var sSummary = parseInt(n[1], 10);\n                if(sSummary === 14){\n                    document.getElementById(\"clock\").style.backgroundColor =\"transparent\";\n                }\n                if(sSummary < 14){\n                    document.getElementById(\"clock\").style.backgroundColor =\"#FF0033\";\n                }\n            }else{\n                displayTitle(data);\n            }\n        });\n        setInterval(upTime,1000);\n    })(scope);\n</script>","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":160,"y":1658,"wires":[[]]},{"id":"bcf31f4d.05939","type":"inject","z":"83afaffb.3b3b8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"start","payload":"1","payloadType":"num","x":110,"y":1183,"wires":[["d9f00969.4b65f8"]]},{"id":"33aea16c.1ec5be","type":"ui_chart","z":"83afaffb.3b3b8","name":"","group":"31698392.1d898c","order":4,"width":0,"height":0,"label":"chart","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"2","removeOlderPoints":"1000","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":true,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":550,"y":1443,"wires":[[]]},{"id":"5ecc35a3.c4cc0c","type":"debug","z":"83afaffb.3b3b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":1263,"wires":[]},{"id":"d9f00969.4b65f8","type":"file in","z":"83afaffb.3b3b8","name":"","filename":"realtest.txt","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":210,"y":1263,"wires":[["78aa41ff.b3d2f","5ecc35a3.c4cc0c","e1f987d3.f065f8"]]},{"id":"78aa41ff.b3d2f","type":"csv","z":"83afaffb.3b3b8","name":"","sep":",","hdrin":true,"hdrout":"","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":false,"include_null_values":false,"x":310,"y":1343,"wires":[["c4a5cccc.3b04","5ecc35a3.c4cc0c"]]},{"id":"c4a5cccc.3b04","type":"function","z":"83afaffb.3b3b8","name":"graph generate","func":"\nfunction toTimestamp(strDate){\n     var datum = Date.parse(strDate);\n     return datum/1000;\n    }\nvar payload=msg.payload;\n\n\nvar data_out=[];\nvar a1=[];\nfor(let i=0;i<payload.length;i++)\n{\n  \nvar Data= payload[i].Data.split(\"-\");\nvar t=Data[2]+\"/\"+Data[1]+\"/\"+Data[0];\nvar timestamp=toTimestamp(t+\" \"+payload[i][\"Godzina\"]);\n//var timestamp=toTimestamp(\"Godzina\");\n//console.log(t);\n\n/*\n// Requiring fs module in which\n// writeFile function is defined.const\nfs = require('fs')  \n// Data which will write in a file.\nlet data =\"Learning how to write in a file.\"  \n// Write data in 'Output.txt' .\nfs.writeFile('Output.txt', data, (err) => {      \n// In case of a error throw err.   \nif (err) throw err; })\n\n*/\n\nvar total={ \"x\": timestamp, \"y\":parseInt( payload[i][\"Total\"]) };\n\n\na1.push(total);\n\n/*if (total = 42){\nvar MAX = new Boolean(false);\n}\n */\n \n}\n\ndata_out=[a1];\nmsg.payload=[{\n\"series\": [\"Total\"],\n\"data\":data_out,\n\"labels\": [\"Total\"]\n}];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":1463,"wires":[["5ecc35a3.c4cc0c","33aea16c.1ec5be","4e0aab3b.54ee74"]]},{"id":"e1f987d3.f065f8","type":"function","z":"83afaffb.3b3b8","d":true,"name":"notification function","func":"var payload=msg.payload;\n\n\nfor(let i=0;i<payload.length;i++)\n{\n// var Data= payload[i].Data.split(\"-\");\nvar total= parseInt( payload[i][\"Total\"]);\nmsg.payload=total;\n}\n\n//return msg;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":1143,"wires":[[]]},{"id":"9b612191.edbff","type":"ui_toast","z":"83afaffb.3b3b8","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":710,"y":1363,"wires":[]},{"id":"f2049ccb.8069d","type":"ui_group","z":"","d":true,"name":"Visitor Count","tab":"36e2a801.ed67a8","order":1,"disp":true,"width":"16","collapse":false},{"id":"754f26ec.f54098","type":"ui_group","z":"","name":"New Message","tab":"","order":1,"disp":true,"width":"6","collapse":false},{"id":"e56f5108.01102","type":"ui_group","z":"","name":"LiveVideo","tab":"","order":1,"disp":false,"width":"35","collapse":false},{"id":"31698392.1d898c","type":"ui_group","z":"","name":"","tab":"36e2a801.ed67a8","order":2,"disp":true,"width":"16","collapse":false},{"id":"36e2a801.ed67a8","type":"ui_tab","z":"","name":"Welcome to SHOP ANALYTICS","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

What is wrong with the timestamps?

It is displaying 11:35 for the x values (timestamp), but from the data I have in my .txt, it should be reading 14:30, 14:35, etc.

Is you time zone 3 hours from UTC?
Show us what the timestamp is like in the file and what value that is sending to the chart. Note that timestamps should be javascript timestamps, which are UTC.

No, it is 6 hours behind. This is what I have in my .txt and this is what it is displaying

.

Additionally I am reading another .txt created by an Arduino UNO R3,

Currently that.txt is displaying like this:
2020-11-02 18:28:37 4

However, I want to change the function for that particular graph so that it can see and display on the graph the
Date Time Total

After the timestamp calculation add
node.warn("t = " + t " timestamp = " + timestamp)
and show us what you get.

Are those timestamps in UTC-6 then?

[Edit] Why are you dividing the timestamp by 1000? It should be a javascript timestamp, which is milliseconds.

The timestamp shows the UNIX timestamp and time shows normal time; however when I modify x in my code to read time, it does not work. I have modified my code; yet it only works in reading timestamp, when I get it to read time for my x-axis from the .txt, my screen goes blank

Please don't post photos they are useless. Post screenshots instead.
Does the data you are trying to load into the chart look like the example in the docs for the chart? https://github.com/node-red/node-red-dashboard/blob/master/Charts.md#stored-data

Note that you have to send the data for the complete chart in one message.
If you think you are please show us what it looks like in a debug node.

Okay, noted.

Yes, it is in that format.

That isn't showing the data you are feeding to the chart. Add a debug node showing what you are feeding to the chart and show us that, after comparing it to the example in the link I posted.

This topic was automatically closed after 60 days. New replies are no longer allowed.