jonasf
Posts: 3
Joined: Wed Nov 30, 2022 7:47 am

Let datetime chart start from minimum of data instead of pointStart

Hello,

I am trying to create a chart with a datetime x axis.
The chart will be used on multiple datasets, but the x data received will always be the number of milliseconds since the 1st of January.
To model this I have set the plotOptions.series.pointStart to 0 and have set the 'x' value of each data point to this number of milliseconds since the 1st of January.

I am of course only interested in seeing data as I receive it from the dataset (i.e. starting somewhere in 2022 atm), and not starting from 1970. which would just show a big empty part in the chart.
To avoid this I tried to put the xAxis.min to the minimum if my x data, but this does not seem to be taken into account.

I have reproduced it in the link below. I could not reproduce it on a very simple example, so I did it using my actual current setup, but hopefully it is still useable:

https://jsfiddle.net/60bmhuqz/7/

You can see two things:
1. In the top right corner the range goes back to 1970.
2. When starting to move the navigator bar, you can also see on the x axis that the range goes back to 1970.

Is it normal that the xAxis.min is not taken into account here?
Is there a way to let my chart start at the minimum of my x data?

Thanks!
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Let datetime chart start from minimum of data instead of pointStart

Hi there,

Welcome to our forum and thank you for contacting us with your question!

Actually, this is a default Highcharts behaviour. Simply remove the pointStart property, and chart should take your first timestamp as a first data point.

Take a look at the simple demo here: https://jsfiddle.net/BlackLabel/Lbxspvcw/

Let me know if you have managed to fix this issue, and in case of any other questions, do not hesitate to contact us again!
Best regards
Kamil Musiałowski
Highcharts Developer
jonasf
Posts: 3
Joined: Wed Nov 30, 2022 7:47 am

Re: Let datetime chart start from minimum of data instead of pointStart

Hello,

Thank you for your reply.
I tried to remove that property in my jsfiddle, but it doesn't seem to help.
This is the link with the commented out property:

https://jsfiddle.net/jwfvyLcr/1/

I btw also noticed I was using highstock in the previous jsfiddle, while I am actually using highcharts.
So that has also changed in the above link, but the issue remains the same.

Kind regards
jonasf
Posts: 3
Joined: Wed Nov 30, 2022 7:47 am

Re: Let datetime chart start from minimum of data instead of pointStart

Hello,

It looks like I have set my xAxis.min value in seconds instead of milliseconds.
Changing this in combination with removing the pointStart property seems to solve my issue, many thanks!
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Let datetime chart start from minimum of data instead of pointStart

That's amazing!

If you'll need anything else, you know where to find us :)

Have a great day!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Usage”