nichemedia
Posts: 6
Joined: Wed Aug 31, 2022 8:55 am

Dynamically Change Legend Label

Hi there

I have a map that loads a different series when a user selects a dropdown.

Each series uses the same 5 point colorAxis to determine what color each point should be.

However, currently the labels just show using the colorAxis DataClass Name (e.g. 1 to 1, 2 to 2, etc).

I would like to show different legend labels when a different series is loaded.

For example, the initial series, green may indicate a product of £1 (for example).

However, when you select 'Aperol Spritz' (third in dropdown), the green will indicate '£6'

I cannot figure out how to update the legend names.

Any assistance will be greatly appreciated.

JSFiddle here:

https://jsfiddle.net/sfour/46uoLz0e/3/

Thank you
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Dynamically Change Legend Label

Hi nichemedia!
We appreciate you reaching out to us!

I would like to point out that you have based your logic of coloring points on the property from your data called value. I think, that it is a little mistake because you have a property called price, which I think should be used - in that case you should change the property colorKey: to 'price'. By setting that, colors from legend will work as they should and will show color based on the price of drinks.

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

Let me know if that was what you were looking for and if not let me know and I will find a solution for you :)
Kind regards!
Hubert Kozik
Highcharts Developer

Return to “Highcharts Maps”