2015-10-07 60 views
0

我用highmaps创建了一张世界地图。下面是代码http://jsfiddle.net/zhaojun08/jnmoyzgL/2/如何使用highmaps创建世界地图并禁用部分图例?

$(function() { 

    // Prepare demo data 
    var data = [ 
     { 
      "hc-key": "fo", 
      "value": 0 
     }, 
     { 
      "hc-key": "um", 
      "value": 1 
     }, 
     { 
      "hc-key": "us", 
      "value": 2 
     } 
    ]; 

    // Initiate the chart 
    $('#container').highcharts('Map', { 

     title : { 
      text : 'Highmaps basic demo' 
     }, 

     subtitle : { 
      text : 'Source map: <a href="http://code.highcharts.com/mapdata/custom/world-highres.js">World, Miller projection, high resolution</a>' 
     }, 

     mapNavigation: { 
      enabled: true, 
      buttonOptions: { 
       verticalAlign: 'bottom' 
      } 
     }, 

     colorAxis: { 
      min: 0 
     }, 
     legend: { 
      enabled: true 
     }, 
     series : [{ 
      data : data, 
      mapData: Highcharts.maps['custom/world-highres'], 
      joinBy: 'hc-key', 
      name: 'Region', 
      states: { 
       hover: { 
        color: '#BADA55' 
       } 
      }, 
      dataLabels: { 
       enabled: false, 
       format: '{point.name}' 
      }, 
      tooltip: { 
       pointFormat: '{point.name}' 
      } 
     },{ 
      type: 'mappoint', 
      name: 'Cities', 
      marker: { 
       fillColor: 'white', 
       lineColor: 'black', 
       lineWidth: 1, 
       radius: 2 
      }, 
      data: [{ 
       name: 'Mountain View', 
       lon: -122.07, 
       lat: 37.40 
      }] 
     }] 
    }); 
}); 

但地图的图例有两个部分,一个是dataRange左侧部分,另一部分是“服务器”右侧部分。我想删除左边的部分并保留正确的部分,因为我想创建一个纯粹的地图。

我该怎么办?谢谢!

回答

0

我已经通过使用showInLegend选项来解决这个问题。