this.point.properties未定义的highmaps

时间:2016-08-02 08:17:28

标签: javascript highcharts highmaps

我在highmaps中使用自定义地图。我的地图渲染得很好,当我尝试将点绑定到数据时,它可以正常工作。我的问题是我无法读取点属性或将事件附加到任何点。控制台上的错误是this.point.properties未定义。 https://jsfiddle.net/mwendakith/0tyfph44/

plotOptions: {
            map: {
            allAreas: false,
            dataLabels: {
                enabled : true,
              formatter: function(){
                if(this.point.properties){
                    return this.point.properties['name'];
                }
              }
            },
          },
      },

1 个答案:

答案 0 :(得分:2)

我发现在系列定义中可以访问点属性。 https://jsfiddle.net/mwendakith/0tyfph44/3/

series: [
    {
        "type": "map",
        "data": data,
        dataLabels: {
                enabled: true,
                color: '#FFFFFF',
                format: '{point.name}'
            },
    }
],