2013-02-19 75 views
1

我正在使用最新的Jvectormap(1.2.2),但找不到設置所有國家顏色的任何示例。我相信在之前的版本中,它只是「顏色:」,但現在這已經停產了?Jvectormap 1.2.2顏色問題

下面的代碼工作,但顏色部分沒有。我在我的網站上使用了白色背景,因此所有國家/地區都默認使用不同顏色的

<script> 
    $(function(){ 
     $('#world-map').vectorMap({ 
    map: 'world_mill_en', 
    color: '#000000', 
     backgroundColor: '#ffffff', 
     series: { 
     regions: [{ 
      values: { 
       IN:'#33250B', 
       US:'#003366' 
     } 
     }] 
     } 
    }) 
    }); 
</script> 

回答

1

在jVectorMap期望的功能的1.x.x分支可以通過使用regionStyle配置參數來實現。有關詳細信息,請參見文檔here

3

我沒有安靜知道你的意思,而是將所有國家的顏色,你可以使用:

var regionStyling = {initial: {fill: '#128da7'},hover: {fill: "#A0D1DC"}}; 

jQuery('#world-map').vectorMap({ 
    map: 'world_mill_en', 
    normalizeFunction: 'polynomial', 
    regionStyle:regionStyling, 
    backgroundColor: '#383f47', 
    series: {regions: [{values: {},attribute: 'fill'}]} 
}); 

這個工作對我來說,如果你還希望每個國家指定可以使用:

jQuery('#world-map').vectorMap({ 
    map: 'world_mill_en', 
    normalizeFunction: 'polynomial', 
    backgroundColor: '#383f47', 
    series: {regions: [{values: {"US" : "#000"},attribute: 'fill'}]} 
}); 
0

要設置所有區域的默認顏色,請設置regionStyle.default.fill

這裏是你的代碼與變革:

<script> 
    $(function(){ 
     $('#world-map').vectorMap({ 
      map: 'world_mill_en', 
      regionStyle: { initial: { fill: '#000000' } }, //Changed this line 
      backgroundColor: '#ffffff', 
      series: { 
       regions: [{ 
        values: { 
         IN:'#33250B', 
         US:'#003366' 
        } 
       }] 
      } 
     }) 
    }); 
</script>