blaine.bell
Posts: 3
Joined: Tue Jan 07, 2025 5:44 am

Discrete quantized legend for maps

This might be a general legend question, but we are trying to generate.an interactive legend that looks like the attached image. I have tried to build this using Highcharts with legend parameters, but fail to add the ticks and the labels correctly. Does anyone know of a solution to move the labels correctly without separating the segments/legend items?

thanks in advance!

Blaine Bell
Attachments
legend_attempt.png
legend_attempt.png (115.97 KiB) Viewed 2047 times
Screenshot 2025-01-06 at 9.49.51 PM.png
Screenshot 2025-01-06 at 9.49.51 PM.png (23.1 KiB) Viewed 2047 times
andrzej.b
Site Moderator
Posts: 576
Joined: Mon Jul 15, 2024 12:34 pm

Re: Discrete quantized legend for maps

Hi Blaine,

Welcome to our forum and thanks for contacting us with your question!

I believe you simply need to use colorAxis, please see one of the official demos, and note the part of the config related to legend and colorAxis: https://jsfiddle.net/BlackLabel/hzdcwv15/

You can find more adjustment options here: https://api.highcharts.com/highmaps/colorAxis

Feel free to reach out if you have any further questions.

Kind regards,
Andrzej
Highcharts Developer
blaine.bell
Posts: 3
Joined: Tue Jan 07, 2025 5:44 am

Re: Discrete quantized legend for maps

thanks for your quick response!
I believe you simply need to use colorAxis,

We want to be able to:
- use quantization levels of color, not a continuous color, so that values in the same range/group will show the same color
- select a range to highlight all of the locations that have that specific range

this is why I am trying to use the categorical legend instead. Is there a way to control the text?

thanks in advance
andrzej.b
Site Moderator
Posts: 576
Joined: Mon Jul 15, 2024 12:34 pm

Re: Discrete quantized legend for maps

Ok, now I have a better grasp of your needs.
With the legend API, you cannot get exactly the design you shared initially. However, this example shows the closest you can get: https://jsfiddle.net/BlackLabel/2uxkrp7f/
Also, colorAxis can be used in the way you want functionally: https://jsfiddle.net/BlackLabel/q0kb1f4e/

I hope you will find it useful.

Kind regards,
Andrzej
Highcharts Developer
blaine.bell
Posts: 3
Joined: Tue Jan 07, 2025 5:44 am

Re: Discrete quantized legend for maps

Andrzej, thank you so much for this, amazing! However, its pretty fragile, if the number of digits change, then the layout gets messed up. It definitely seems like we would be going against the grain, for now, we will use the default continuous color legends. Thank you!
andrzej.b
Site Moderator
Posts: 576
Joined: Mon Jul 15, 2024 12:34 pm

Re: Discrete quantized legend for maps

Hi Blaine,

Thanks for the update. If you think such a feature would be useful for more users, you can request it here: https://github.com/highcharts/highchart ... new/choose You can expect possible updates or workarounds there. However, if you need a customized solution for yourself without waiting for us to resolve the request, please contact us directly.

Kind regards,
Andrzej
Highcharts Developer
Nehakumari
Posts: 13
Joined: Wed Mar 13, 2024 6:07 am
Location: INDIA
Contact: Website

Re: Discrete quantized legend for maps

I appreciate the workaround and the suggestion to request a feature. It would definitely be great if Highcharts could support discrete quantized legends more easily in the future. For now, I’ll explore the provided examples and see how far I can get.
andrzej.b
Site Moderator
Posts: 576
Joined: Mon Jul 15, 2024 12:34 pm

Re: Discrete quantized legend for maps

You're welcome! In case of any further questions, feel free to contact us again.
Andrzej
Highcharts Developer

Return to “Highcharts Maps”