highchartshighmaps

Coloring a country in lat-long highmap


I am working with highmaps and got stuck in one requirement .

I want to color a country with a particular color in lat-long world-map .

Let's say I need US color to be blue and Russia color to be Red on the following map fiddle .

Is there any API in highmaps to support the same ?

`http://jsfiddle.net/dnbtkmyz/`

Thanks


Solution

  • You could do this with manipulation of load events like this:

    chart: {
      events: {
        load: function() {
          this.series[0].data = this.series[0].data.map((el) => {
            if (el['hc-key'] == "us") {
              el.color = "#ff0000";
              return el;
            }
            if (el['hc-key'] == "ru") {
              el.color = "#0000ff";
              return el;
            }
            return el
          })
    
          this.update({
            series: [{
              data: this.series[0].data
            }]
          })
        }
      }
    }
    

    Working example: http://jsfiddle.net/ewolden/dnbtkmyz/42/