cgilbert
Posts: 10
Joined: Fri Jul 29, 2022 1:20 pm

Create a custom legend for a pie chart with drilldowns

I've successfully created a custom legend for a pie chart following this example http://jsfiddle.net/N3KAC/1/

I've fleshed it out so I also have `mouseover` and `mouseout` event listeners which toggle the state to and from "hover" / "normal" of the series and this works great. However the pie chart has drilldown data and this means the legend needs to be updated when viewing the drilldowns to reflect the drilldown data - can anyone point me in the direction to get that working?

The drilldown data is supplied in the `drilldown` part of the JS object as opposed to fetched async.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Create a custom legend for a pie chart with drilldowns

Hi there,

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

I think I know what you need to achieve but it would be much easier to help you if you could provide a working demo with your custom legend, so that I can suggest some solutions.

Please recreate your issue in an online code editor and we can talk through it,
Regards!
Kamil Musiałowski
Highcharts Developer
cgilbert
Posts: 10
Joined: Fri Jul 29, 2022 1:20 pm

Re: Create a custom legend for a pie chart with drilldowns

Yes I will do in due course - thank you.
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Create a custom legend for a pie chart with drilldowns

Awesome! I'm waiting for your reply.
Kamil Musiałowski
Highcharts Developer
cgilbert
Posts: 10
Joined: Fri Jul 29, 2022 1:20 pm

Re: Create a custom legend for a pie chart with drilldowns

Hey Kamil,

Here is a fiddle of what I have done so far http://jsfiddle.net/chrisgilbert/at1ogkL6/20/

The crux of the issue is:
- when the "Chrome" pie segment is clicked and the user views the the drilldown, the legend needs to be updated to show the drilldown data categories.
- when the user reverts back to the top level pie chart, the legend should then show the top level categories, as it does always at the moment.

Worth noting that in the version in my app the drilldown is another pie chart, not sure why in this version a line chart is rendered for it but it doesn't matter in this instance - i'm purely curious on how I can get the legend to be updated to show the drilldown data.

Is that possible?

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

Re: Create a custom legend for a pie chart with drilldowns

Hi there,

Thank you for the detailed explanation and the demo. Now I know what you want to achieve.

In fact, we had a very similar topic on our forum, and I think that it might be exactly what you are looking for.
Take a look at this topic: viewtopic.php?t=43040

Feel free to contact us anytime,
Regards!
Kamil Musiałowski
Highcharts Developer
cgilbert
Posts: 10
Joined: Fri Jul 29, 2022 1:20 pm

Re: Create a custom legend for a pie chart with drilldowns

Thanks Kamil - I will have a go using the example in the post and let you know how I get on.

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

Re: Create a custom legend for a pie chart with drilldowns

Sure thing, keep me updated and in case of any questions feel free to ask!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Usage”