2

I'm using Highmaps to show the number of relevant users from each individual country. This should then be displayed in a gradient, so that the more users there are from a country, the darker the color. I have it running in Highmaps so that it loads the data, but for some reason it's displaying all the countries in black, despite the gradient legend being white to blue. Any idea why that is? Thanks!

$(document).ready(function(){
  // Basic highcharts initialization
  Highcharts.setOptions({
    lang: {
      thousandsSep: ','
    }
  });

  var analytics_map = new AnalyticsMap('#container');
  analytics_map.setTitle('# of Signups');
  analytics_map.load([
   ["AE","31"],
    ["AR","51"],
    ["AT","71"],
    ["AU","81"],
    ["BE","91"],
    ["BG","9"],
    ["BO","22"],
    ["BR","37"],
    ["US","173"],
    ["UY","5"],
    ["ZA","19"]
  ]);
  
  function AnalyticsMap(selector){
    this.selector = selector,
    this.title = 'Default Title',
    this.setTitle = function (title){
      this.title = title;
    },
    this.load = function(data){
      $(this.selector).highcharts('Map', {
        title: {
          text: this.title
        },
        mapNavigation: {
          enabled: true,
          buttonOptions: {
            verticalAlign: 'bottom'
          }
        },
        colorAxis: { 
        },
        series: [{
          data: data,
          mapData: Highcharts.maps['custom/world'],
          joinBy: ['iso-a2', 0],
          keys: ['iso-a2', 'value'],
          name: this.title,
          dataLabels: {                 
            //enabled: true, 
            //format: '{point.code}'
          },
          tooltip: {
            pointFormat: '{point.iso-a2}: {point.value} signups'
          }
        }]
      });
    }
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>

<div id="container"></div>
zojwek
  • 121
  • 9
  • Why is your [colorAxis](http://api.highcharts.com/highmaps/colorAxis) element empty? That is where the colors get set. See [their examples](http://www.highcharts.com/maps/demo/all-maps) – Larry Shatzer Oct 06 '16 at 22:22
  • It's still all black with colorAxis set, but I left it out b/c looking at http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/maps/demo/geojson/ it seems as though it has default behavior that works just fine. – zojwek Oct 06 '16 at 22:28

1 Answers1

2

You have an issue with the datatypes.

Do not convert your integers to strings by putting quotes around them.

var data = [ ['DE.SH', 728], ['DE.BE', 710], ['DE.MV', 963], ['DE.HB', 541], ['DE.HH', 622], ['DE.RP', 866], ['DE.SL', 398], ['DE.BY', 785], ['DE.SN', 223], ['DE.ST', 605], ['DE.NW', 237], ['DE.BW', 157], ['DE.HE', 134], ['DE.NI', 136], ['DE.TH', 704], ['DE.', 361] ];

Duniyadnd
  • 4,013
  • 1
  • 22
  • 29