i successfully manage to display a live graph but i faced a problem, when i want to get the GMT time zone, i mean, by passing the timestamp to x axis i don't want it to convert it to my local time zone.for example in python i had to use "utcfromtimestamp()" function.
as you can see in this photo the time zone here is GMT+1 which refer to my local time zone
and the timestamp i'm receiving from the client is "1585559327997" which is 30/03/2020 09:08:47:997
i'm not sure if this information would help but this is an example of the data i pass to the chart
[{
labels:,
series:['a', 'b'],
data:[
[{y:0.9, x:1585559327997},{y:0.8, x:1585559328297}],
[{y:0.02, x:1585559327997},{y:0.01, x:1585559328297}]
]
}]
X axis label is "HH:mm:ss SSS DD/MM/YYYY"
i did some research but nothing was helpful, most of people was asking for the local time zone which is the opposite of what i'm looking or and i tried this solution from this link
add the moment and moment-timezone library and then update the settings.js file:
and that's what i don't want to do
i don't want to change the browser settings or the machine setting to correct the node red program.
i was looking for a solution more like in the moment node, where i can just set the output TZ to "ETC/GMT+0"
yes, i'm showing a live data but the thing is, the time is come from the client itself, i get the time and the value, and because the client could be in somewhere else around the world, so it's better to display the time in GMT (to be precise, i should use the time i receive from the client in his time zone) so i need no GMT conversion.
When you chart live data you don't give it a time at all, you just give it a value and it uses the current time. So nothing you can do with a timestamp will change what it shows.
i'm not sure if i understand what you saying or not, but in my node i'm passing both and it woks fine, and to prove that, when i change the time zone of the client machine (add 1 hour), the time in the chart will change, i mean if the client machine send me a timestamp of (7:00 AM) (which is GMT+1) the chart display (8:00 AM) which will lead to add 2 hours in total. sorry for the bad example.
because if i do that, then the chart will use the local time zone (my time zone) the machine time zone, and i don't need that, i just want to convert the timestamp a GMT timezone and using the X axis, (i could use the moment node and convert in to string instead of using the chart time conversion but i couldn't pass string type )
The timestamps you are giving it (eg 1504029640317) are in GMT. The chart stores them in GMT and converts them to your local timezone when you display the chart.
The chart always shows 'now' at the right hand side and always shows the timescale in local time. That is the problem you have to address. You would need a change to the chart code to not convert it to local time for display.
You can check what I am saying by viewing the same chart from browsers on two different PCs, configured with different timezones. They will both show the most recent data at the right hand side but the timestamps will be the local time for that machine. So the problem is not in the data stored by node-red in the chart (which is in the machine running node-red not in the machines running the browsers) but in the way the timestamps are displayed by the browser.
You could fork the github repository for the dashboard nodes and edit the code.
If you don't know what that means then I don't think this is a solution.
so you want to say, the solution is to change the timezone of the machine?
maybe if i get the local time zone and subtract it from the timestamp and pass it the the chart node, in this way maybe it's the better solution