Jaws
Posts: 12
Joined: Wed May 25, 2022 6:31 am

Set absolute max and Min value to XAxis

I'm trying to set the xAxis max and min values and they're not exactly the values that I set. I tried setting the min value to 8/11/22, 5:00 AM and max value to 8/13/22, 5:00 AM but still the xaxis min started at 0:00, I want to set the min value to 5:00 and I need the chart axis to start at 5:00. PFB the stackblitz url. In the ngOnInit I've set the values.


https://angular-12-highcharts-svqeig.stackblitz.io


Also if you notice the navigator has moved for which I've not set any values.
I don't want my navigator to move and I want my max and min to be the values that I define.

TIA :)
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Set absolute max and Min value to XAxis

Hi there,

Thank you for contacting us!

Unfortunately, your demo link doesn't work - I think it points to the live server, not the code itself.
For now, I'd suggest setting the xAxis.startOnTick and xAxis.endOnTick to false, then set the min/max values.

Take a look at the min/max API definitions,
If the startOnTick option is true (default), the min value might be rounded down.
API Reference: https://api.highcharts.com/gantt/xAxis.min
https://api.highcharts.com/gantt/xAxis.max

If that won't help you, please share your code again and we will figure something out,
Best regards!
Kamil Musiałowski
Highcharts Developer
Jaws
Posts: 12
Joined: Wed May 25, 2022 6:31 am

Re: Set absolute max and Min value to XAxis

Sorry for the URL issue,

https://stackblitz.com/edit/angular-12- ... ponent.ts

This URL should be having the data and code. Also if you notice the navigator has moved. I don't want it to move unless user moves it.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Set absolute max and Min value to XAxis

Thank you for posting the correct demo link, it is working now indeed.

Since it's bit of an odd problem, I will consult this issue with our Angular development team, and I'll be back with an answer as soon as possible.

Thank you for your patience.
Kamil Musiałowski
Highcharts Developer
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Set absolute max and Min value to XAxis

Hello again,

Thank you for your patience.
We did some research, and to be honest it is hard to tell what exactly is causing this issue - but there might some some little bug in your code.

We have prepared a demo for you, with navigator and min/max set to a particular timestamp. Take a look at it, maybe it will inspire you to refactor your code and you will be able to fix the previously mentioned issue.

DEMO: https://stackblitz.com/edit/highcharts- ... mponent.ts

Best regards!
Kamil Musiałowski
Highcharts Developer
Jaws
Posts: 12
Joined: Wed May 25, 2022 6:31 am

Re: Set absolute max and Min value to XAxis

Hi

Thanks for the stackblitz demo link, If you notice the demo, the timeline header in the X-Axis the start time it is properly showing, but in case of end time it is just 12:00, can it also be showing the value that we set like 5:00 or whatever that is being set in the X-Axis max.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Set absolute max and Min value to XAxis

Hi there,

Thank you for your reply.

The demo is working correct, max is indeed set correctly. What you can observe is the time that is referring to the tick (vertical line) on the xAxis. Once you zoom in closer with the navigator, then you will see the 15:00 value. Setting the xAxis.endOnTick to true will help a bit. Or maybe change the max to a higher value, to have the 15:00 tick show up a bit earlier?

Let me know if you are satisfied with the current state of the chart,
Best regards!
Kamil Musiałowski
Highcharts Developer
Jaws
Posts: 12
Joined: Wed May 25, 2022 6:31 am

Re: Set absolute max and Min value to XAxis

Image

In the picture attached you can see that by deafult without zooming it shows 12:00, can I get it to show 15:00 without moving the navigator? My requirement is I'm trying to show 5:00 but it always shows 0:00 unless I use the navigator to zoom.

If the image is not available use this link : https://freeimage.host/i/spI3Hg
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Set absolute max and Min value to XAxis

Hi there,

The tick labels are generated automatically from your data, and their visibility is dependent on the zoom level, as I have mentioned previously.
So because of that, there is no easy and flexible solution for it. Here you can see how the chart behaves with one day added to the xAxis.max, the whole ticks functionality changes in comparison to your demo.
https://stackblitz.com/edit/highcharts- ... mponent.ts

As a workaround, you can try to play around with the xAxis.tickPositions or xAxis.tickPositioner, but I cannot guarantee that it will work for certain datasets.

In case of any other questions, feel free to contact us
Regards!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Gantt”