RogerESA
Posts: 6
Joined: Mon Jun 07, 2021 1:17 pm

could we fix time interval of x-axis

Mon Sep 18, 2023 9:16 pm

Hi There,

We've recently noticed that as more data points are added to the time series chart, the tick interval is automatically updated, which is acceptable. However, is it possible to manually set and lock a specific time interval regardless of the amount of data being loaded?

Thanks for the support in advance!

jakub.s
Posts: 984
Joined: Fri Dec 16, 2022 11:45 am

Re: could we fix time interval of x-axis

Tue Sep 19, 2023 7:34 am

Hi,

Welcome to our forum & thanks for the question!

You can set the tick interval with the xAxis.tickInterval option. You're right, however, that this is not "fixed" which means that when the "density" of the data on the x-axis increases, the tickInterval automatically increases as well.

We could set it to "fixed" via a custom solution, but in this case, when you add "X" points or decrease the width of the chart, the ticks will cover each other (or be extremely close to each other) which is something we usually want to avoid.

Could you please share more details about your particular use case? Why would you like the tickInterval to be fixed? Wouldn't this be a problem if ticks were extremely close to each other?

Other options you can explore:
- tickPixelInterval - https://api.highcharts.com/highcharts/x ... elInterval
- tickPositioner - https://api.highcharts.com/highcharts/x ... Positioner
- tickPositions - https://api.highcharts.com/highcharts/x ... kPositions

Best regards!
Jakub
Highcharts Developer

RogerESA
Posts: 6
Joined: Mon Jun 07, 2021 1:17 pm

Re: could we fix time interval of x-axis

Fri Sep 22, 2023 3:39 pm

Hi Jakub,

Our use case is that we want to provide our users with a chart editor interface, and for axis editing, allow the users to choose things like axis maximums, minimums, and tick intervals.

So in the case of tick interval, what we'd love to offer our users is:

- A check box that says "automatic", where, if that was checked, HighCharts would choose the appropriate tick density depending on chart size, tick font label size, etc.

OR

- They can uncheck the box that says "automatic" and specify their own tick interval that is truly fixed. It's "buyer beware" for them at that point, but at least they get to choose exactly the formatting that they want on a chart by chart basis.

At the moment, it's a bit confusing from an end user standpoint, because you allow the tick interval to be specified, but then that specification gets overridden according to HighCharts internal logic.

We see similar behaviour with vertical axis maximum settings, for example.

I guess what we're looking for is a way for us (or our users) to make a binary choice between either "full auto" mode (i.e. HighCharts decides everything), or a true "manual" mode, where the user gets to specify everything (even if what they choose does not look nice).

jakub.s
Posts: 984
Joined: Fri Dec 16, 2022 11:45 am

Re: could we fix time interval of x-axis

Mon Sep 25, 2023 9:18 am

Hi,

Thanks! Now I understand.

The real tickInterval is calculated in the Axis.prototype.setTickInterval function which is proceeded by the setTickPositions function (which, as the name suggests, sets the tick positions on the axis).

If you want to override the calculations made in the setTickInterval and set a tick interval which is based on the option you've set manually in the config, you can do a simple wrap function.

Here's a demo: https://jsfiddle.net/BlackLabel/zk6eyrv4/
Here's an article: https://www.highcharts.com/docs/extendi ... highcharts

Let me know if that helps.

I think you can easily integrate this approach in your project, but please let me know if you encounter any problems.

Best regards!
Jakub
Highcharts Developer

RogerESA
Posts: 6
Joined: Mon Jun 07, 2021 1:17 pm

Re: could we fix time interval of x-axis

Tue Sep 26, 2023 2:50 pm

Thanks Jakub, this looks EXACTLY like what we want! :mrgreen:

Return to “Highcharts Usage”