Search code examples
anychart

How to set a legend item for unbound regions?


I am using AnyMap and my client wants to display some information in the legend for unbound regions.

Because I can just add a legend item for a series I am implementing an empty series and then adding a legend item on this. However as there is no country to select I do not want my legend item to be selectable. How can I prevent this?

The only solution I found for this is applying "disabled:true" to my legendItem, but then the color changes..

This is how my code looks so far

var unboundRegions = anyMap.choropleth();
      unboundRegions.legendItem({text: data.unbound, iconType: "square", iconFill: '#ffffff', iconStroke: '#e8e8e9', disabled: true});

Any ideas?


Solution

  • You can prevent legend icon selection using "legendItemMouseDown" legend event listener - just prevent its default behavior using e.preventDefault();

    jsfiddle example