2016-12-23 42 views
1

我有2個系列,你可以看到下面。Highmaps多個系列不能看到沒有禁用一個

<script src="https://code.highcharts.com/maps/highmaps.js"></script> 
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script> 
<script src="https://code.highcharts.com/mapdata/countries/tr/tr-all.js"></script> 

<div id="container"></div> 


$(function() { 

    Highcharts.mapChart('container', { 
     chart: { 
      spacingBottom: 20 
     }, 
     title: { 
      text: 'Multiple Map Series' 
     }, 

     legend: { 
      enabled: true 
     }, 

     plotOptions: { 
      map: { 
       allAreas: true, 
       // joinBy: 'code', 
       mapData: Highcharts.maps['countries/tr/tr-all'], 
       tooltip: { 
        headerFormat: '', 
        pointFormat: '{series.name}-{point.name}: <b>{point.value}</b>' 
       } 

      } 
     }, 

     series: [{ 
      name: 'AAA', 
      data: $.map(['tr-an','tr-iz'], function (code) { 
       return { "hc-key": code , value : 150}; 
      }) 
     }, 
     { 
      name: 'BBB', 
      data: $.map(['tr-ib','tr-or'], function (code) { 
       return { "hc-key": code , value : 122}; 
      }) 
     } 
     ] 
    }); 
}); 

jsfiddle is here; http://jsfiddle.net/usrt1Lrr/5/

第一個系列(AAA)包含2個城市的'tr-an'和'tr-iz'。

第二個系列(BBB)包含2個城市的'tr-ib'和'tr-or'。

2系列不能被看到,除非我通過圖例禁用一個。如果您禁用BBB系列; AAA將可見。這是沒有意義的。

我該如何解決這個問題?所有系列必須一起看

在此先感謝。

回答

1

既然你得到了plotOptions.map.allAreas: true它繪製了兩個系列的所有區域,這意味着該系列繪製在彼此的頂部(隱藏下面的系列的顏色)。

的另一種方法是將有你的選擇:

plotOptions: { 
    map: { 
     allAreas: false, 
     // ... 
    } 
} 

並增加了「背景」系列,你躲起來,像這樣:

series: [{ 
     allAreas: true, // only show all areas for this series (as a "background") 
     showInLegend: false // hide it from the legend 
    }, 
    { 
     name: 'AAA', 
     data: $.map(['tr-an','tr-iz'], function (code) { 
      return { "hc-key": code , value : 150}; 
     }) 
    }, 
    { 
     name: 'BBB', 
     data: $.map(['tr-ib','tr-or'], function (code) { 
      return { "hc-key": code , value : 122}; 
     }) 
    }] 

看到它this JSFiddle demonstration在行動。

+0

謝謝,解決了我的問題 – user2761286

相關問題