drmrbrewer
Posts: 248
Joined: Sat Sep 06, 2014 6:39 pm

Applying setExtremes() exactly with variwide series type

Consider the following example:

https://jsfiddle.net/6z4520fs/

In the load event I am trying to set the xAxis extremes as follows:

Code: Select all

this.xAxis[0].setExtremes(1, 4);
I want the x axis to start exactly at 1 and end exactly at 4, regardless of the data, and regardless of whether this chops a variwide column short. At present, highcharts is choosing to show me from 0.75 to 4.25... rather than what I have asked for.

In particular, how do I achieve this where the variwide widths are not constant (and not known in advance)... and sometimes there may not actually be a variwide series at all (the data is dynamic and changes all the time)... I want my setExtremes() to cope with all situations in a consistent way, so that an *exact* x axis range can be guaranteed.

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

Re: Applying setExtremes() exactly with variwide series type

Hello drmrbrewer!

We appreciate you reaching out to us!

I've checked it and I think that it might be a bug. Could you report it on our GitHub, so we'll take a closer look at this problem?
Here's a link: https://github.com/highcharts/highchart ... new/choose

Best regards!
Dominik Chudy
Highcharts Developer
drmrbrewer
Posts: 248
Joined: Sat Sep 06, 2014 6:39 pm

Re: Applying setExtremes() exactly with variwide series type

I think it may be intended behaviour for column series (and variwide is a type of column series)... see e.g. this related post:

viewtopic.php?p=161041#p161041

In there it is stated that "in the column chart, the xAxis ticks behave a bit differently".
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Applying setExtremes() exactly with variwide series type

Hi again!

You're right. As my colleague explained in the mentioned topic we need to set min and max values a bit closer to previous extremes. Like 0.75 and 4.25.

Thanks for pointing this out. :)

Best regards!
Dominik Chudy
Highcharts Developer
drmrbrewer
Posts: 248
Joined: Sat Sep 06, 2014 6:39 pm

Re: Applying setExtremes() exactly with variwide series type

But is it possible to do this correction "automatically" in some way, so that the x axis starts and ends where I actually want it to? It's not possible just to apply a fixed offset at either end, due to the variable nature of the data and the columns present.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Applying setExtremes() exactly with variwide series type

Hi again!

You can update the extremes like that: https://jsfiddle.net/BlackLabel/eyaxrn4k/

It's dynamic so you can adjust it to yourself.

Best regards!
Dominik Chudy
Highcharts Developer
drmrbrewer
Posts: 248
Joined: Sat Sep 06, 2014 6:39 pm

Re: Applying setExtremes() exactly with variwide series type

In your example the x axis does not start at exactly 1 and end at exactly 4. I know that the offsets can be adjusted at either end to make this happen, but the whole point of my question is whether there is a way to do this automatically, without knowing where the columns will be centered or how wide they will be. If I say I want the extremes to be from 1 to 4, then that is where they will be, regardless of the data.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Applying setExtremes() exactly with variwide series type

Hi again!

Unfortunately, there's no way to do update these extremes automatically. Maybe if the interval between the x coordinates of the points would be the same it would be easier to set one value and use it.

The same demo as earlier but the axis starts and ends exactly at 1 and 5: https://jsfiddle.net/BlackLabel/3oq0btc7/

Best regards!
Dominik Chudy
Highcharts Developer

Return to “Highcharts Usage”