dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Custom date selectio

Hi again!

When you use datetime type of axis you can't use categories. So you need to get rid of one of these elements.

Moreover please tell me in how does your data looks like. Maybe the x value of a point is in the wrong format.

Best regards!
Dominik Chudy
Highcharts Developer
Patto
Posts: 13
Joined: Fri Jun 25, 2021 7:03 am

Re: Custom date selectio

Hi
I think the problem lies in the highstock side as I run the same php code for 2 other charts using highcharts and the date is fine. I havent changed the php code only the code for highstock as per ypur help Dominik.
See the original code supplied.
Can some one help or send me somewhere that can help me
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Custom date selectio

Hi again!

When you ran your code with highcharts not highstock how did you set your axis type? To category or datetime? The main difference between them (in your case) is that in highstock the axis type is set to datetime by default and it might cause the problem.

Useful links:
https://www.highcharts.com/docs/chart-c ... axis-types
https://www.highcharts.com/docs/stock/u ... arts-stock

Best regards!
Dominik Chudy
Highcharts Developer
Patto
Posts: 13
Joined: Fri Jun 25, 2021 7:03 am

Re: Custom date selectio

Hi
Both my graphs have the x axis as datetime

Code: Select all

 xAxis: { 
  type: 'datetime',
  categories: reading_time
  },
  yAxis: {
  title: { text: 'Temp (C)' }
    },
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Custom date selectio

Hello Patto,

Wrong dates on x axis might be caused by incorrect data format or time settings.
Here you can find more informations about it: https://api.highcharts.com/highcharts/time
To help you more with this issue, I need you to provide me with sample of your data, preferably with working demo.
You can start here: https://jsfiddle.net/BlackLabel/jygun40k/

Best regards!
Mateusz Bernacik
Highcharts Developer
Patto
Posts: 13
Joined: Fri Jun 25, 2021 7:03 am

Re: Custom date selectio

Hi and thanks for your help.
I will end up with 5 values with charts for each.I am getting my data from a MySQL database and the JSON data looks like below.

I use the same data currently in a Highcharts graph, but when I go to Highstock graph it reads from Jan 1 as descussed earlier.
I'm very much a newby and I put the code on jsfiddle for you to look at. It does include some php so you can see what I am getting the data from

Code: Select all

{"id":"510","value1":"17.30","value2":"56.20","value3":"-127.00","value4":"-5.0","value5":"100.00","reading_time":"2021-08-24 16:29:49.991"},
{"id":"511","value1":"18.20","value2":"54.30","value3":"-127.00","value4":"-5.0","value5":"100.00","reading_time":"2021-08-24 16:59:43.637"},
{"id":"512","value1":"18.80","value2":"52.80","value3":"-127.00","value4":"-5.0","value5":"100.00","reading_time":"2021-08-24 17:29:32.572"},
{"id":"513","value1":"18.10","value2":"99.90","value3":"-127.00","value4":"-5.2","value5":"100.00","reading_time":"2021-08-24 20:39:05.335"},
{"id":"514","value1":"18.00","value2":"99.90","value3":"85.00","value4":"-5.2","value5":"100.00","reading_time":"2021-08-24 20:39:24.471"}
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Custom date selectio

Hello Patto,

I've tried to create a simple demo based on your sample data, and everything looks fine to me, date format too. Please compare our code and check what could go wrong, especially take into consideration fact, that dateFormat in Highcharts is based on UTC timestamp.
Here you can find more informations about it: https://api.highcharts.com/class-refere ... dateFormat
Demo: https://jsfiddle.net/BlackLabel/5wsL6euf/

Let me know if you have any further questions!
Best regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”