Page 1 of 1

Weird Chart dates

Posted: Wed 01 Feb 2023 10:36 am
by water01
OK I have a really weird result in my Historical Charts for my Lightning data.

This is what is being returned in the chart.

Image

As you can see the data goes from the 24th Sept to the 24th Dec. But the actual data on my database goes for 3 months up until 31st January (i.e. October 31st to January 31st) and the column of 32 strikes actually happened on the 11th January 2023 not the 4th December 2022.

I have ran the SQL Query used in the PHP manually on the database table and it returns all the data with the right dates see below.

Image

Somehow (and for the life of me I cannot see how) the right data is getting moved 38 days backwards in time and given the incorrect dates. There is even the right number of columns after the 32 strikes on the chart to bring you to the 31st January (i.e. 20 days).

Anybody got any bright ideas as to how this may be happening?

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 2:46 pm
by Mapantz
This isn't very helpful, but I had this problem once with another graph. For the life of me, I cannot remember what the problem was :lol:

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 3:00 pm
by water01
Mapantz wrote: Wed 01 Feb 2023 2:46 pm This isn't very helpful, but I had this problem once with another graph. For the life of me, I cannot remember what the problem was :lol:
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:

Well that made me laugh, so when you remember please let me know as it's driving me nuts!!

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 3:34 pm
by mcrossley
Do you have a link to the page?

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 4:19 pm
by freddie

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 4:34 pm
by mcrossley
The lightning data is being sent to the graph as a start datetime, plus the readings for each day. CMX sends each data point as a datetime/value pair.

The start for the lightning data is 1630540800 = 2 September 2021.

The problem with the data format being used (and why CMX does it differently), is by just sending start date, HighCharts assumes that there will be data for every day for then until present, if a day is missing then the data from that point onwards will be shifted one day out, on so on.

So do you have any missing days?

If you do have missing days, then the SQL query you are using must insert null values for the missing days.

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 6:43 pm
by water01
Well spotted Mark I have missing days but why they are missing I am not sure!!

By the way is there an easy way to look at the json data returned by a php routine using mysql, can it be seen in the developer tools?

Re: Weird Chart dates

Posted: Wed 01 Feb 2023 7:42 pm
by freddie
water01 wrote: Wed 01 Feb 2023 6:43 pm By the way is there an easy way to look at the json data returned by a php routine using mysql, can it be seen in the developer tools?
Yes, should be able to. PHP will just be returning http responses to your browser that you can inspect using developer tools.