Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Reversed Grouped Categories

Hi there!
I am trying to make use of the "Grouped Categories" module from here: https://blacklabel.github.io/grouped_categories/
I understand that this module might not be 100% conventional, but still, I do not have any other place to ask my question :)
In my use case my data might have a different structure, then in demo:
https://jsfiddle.net/Cortez/v74hme3f/
As you can see - on level 2 of grouping I have "America" three times and "Europe" three times. Is there a way to have the three cells combined into one?
Thanks!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hello,

The easiest way is to reverse their order and group them as in the attached demo, additionally it is more intuitive and legible for users.

Demo: https://jsfiddle.net/BlackLabel/y0rLut7x/

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Re: Reversed Grouped Categories

Hi michal,
thanks for your reply. You are right, that is more intuitive and legible for users. However, I used that data only as an example. In my situation there are legit cases when data can have such a structure and there are no ways of machine reversing it. Am I right supposing that there is no easy way to achieve what I seek for with "grouped-categories" module? Tanks!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hi,

This module does not have the ability to generate categories in this way, but you can add logic that will generate additional labels where you give an array of strings as the name.

Demo: https://jsfiddle.net/BlackLabel/eu9hb1q7/

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Re: Reversed Grouped Categories

michal
wow man, you are awesome! That looks like what I need! Thank you!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hi Cortez,

I'm glad I could help.

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Re: Reversed Grouped Categories

Hi michal!
Here I am once again :)
It turned out that the code proposed has some error:
https://jsfiddle.net/Cortez/sctkzbfp/

As you can see, on the last level categories are overlapped.
Can you please help me with that?
Thank you!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hello,

I forgot to take into account the offsets of the next group of categories by the length of the previous one. Now it should work properly.

Demo: https://jsfiddle.net/BlackLabel/yhar4gts/

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Re: Reversed Grouped Categories

michal
that is perfect!
One more thing:
https://jsfiddle.net/Cortez/qvpsjL07/

Is it possible to merge cells with duplicated labels on 0-level? By modifying your custom code? Or by changing data structure somehow?
Thanks!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hi,

Unfortunately, at level 0 it's not that easy, it would require writing much more custom code. If this is to be the case as you sent when there are 2 levels, in my opinion it misses the point and is an exaggeration. Using the default generation of grouped categories here will be more readable for users.

Regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Re: Reversed Grouped Categories

michal
you turned out to be totally right. This is what I was able to convert my example by using grouping:
https://jsfiddle.net/Cortez/3bd0r2ou/

Also, another question: grouped categories don't seem to work with stock charts. Is it because stock charts doesn't support categories? Is there any workaround for this?
Thank you
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hi,
grouped categories don't seem to work with stock charts. Is it because stock charts doesn't support categories? Is there any workaround for this
It doesn't work because HighStock has only one type of axis which is datetime. xAxis.type: 'category' is only available for Highcharts. I don't think there is any workaround. The question is why do you want to use a stock chart?

Regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/
Cortez
Posts: 85
Joined: Fri May 29, 2020 9:41 am

Re: Reversed Grouped Categories

michal
The question is why do you want to use a stock chart?
You are right, that doesn't make much sense.


I'm sorry to bother you once again. however I bumped into another issue:
https://jsfiddle.net/Cortez/fknjq7ba/

It turned out that your solution only works well if categories on different levels can be distributed evenly. As you can see, in this example I removed last column ("Munich"). And now categories on level 2 doesn't match categories on level 0. ("London" and "Liverpool" on level 0 should match "United Kingdom" on level 2, "Paris" and "Marseille" on level 0 should match "France" on level 2, "Berlin" on level 0 should match "Germany" on level 2. But all categories on level 2 are shifted.

Another example:
https://jsfiddle.net/Cortez/bah8fmso/
I added one more UK city - Birmingham. So now "London", "Liverpool" and "Birmingham" on level 0 should match"United Kingdom" on level 2 and so on.

I do not see how I can change my categories data structure in a way this can display correctly.
Is there any way to do something about this?
Thanks!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Reversed Grouped Categories

Hi,

Unfortunately, this is not a perfect solution because in such cases it will not work, it would have to be refined and rewritten, but unfortunately it is already beyond the scope of support and begins to be a more custom functionality.

You can try to modify this logic to suit your needs, but if you have a problem with it, you can suggest adding such functionality to the core code of the library.

You can create a feature request here: https://github.com/highcharts/highchart ... new/choose

Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Usage”