2016-11-29 18 views
0

我基於我的項目的演示是here在jsfiddle上的高級搜索問題系列沒有在drillup上刪除

我改變了這個爲我自己的國家和信息,但這裏存在drillup函數的問題。

繁殖步驟: 打開鏈接中的的jsfiddle以上,並在地圖上點擊CA(加州),然後點擊按鈕「<回到美國」

下一步點擊西海岸別處看看加州鑽取並未從地圖上移除。一旦點擊後退按鈕,我需要刪除這些內容。

issue with old map showing outside selection

這裏是代碼的主體:

Highcharts.mapChart('container', { 
    chart: { 
     events: { 
      drilldown: function (e) { 

       if (!e.seriesOptions) { 
        var chart = this, 
         mapKey = 'countries/us/' + e.point.drilldown + '-all', 
         // Handle error, the timeout is cleared on success 
         fail = setTimeout(function() { 
          if (!Highcharts.maps[mapKey]) { 
           chart.showLoading('<i class="icon-frown"></i> Failed loading ' + e.point.name); 

           fail = setTimeout(function() { 
            chart.hideLoading(); 
           }, 1000); 
          } 
         }, 3000); 

        // Show the spinner 
        chart.showLoading('<i class="icon-spinner icon-spin icon-3x"></i>'); // Font Awesome spinner 

        // Load the drilldown map 
        $.getScript('https://code.highcharts.com/mapdata/' + mapKey + '.js', function() { 

         data = Highcharts.geojson(Highcharts.maps[mapKey]); 

         // Set a non-random bogus value 
         $.each(data, function (i) { 
          this.value = i; 
         }); 

         // Hide loading and add series 
         chart.hideLoading(); 
         clearTimeout(fail); 
         chart.addSeriesAsDrilldown(e.point, { 
          name: e.point.name, 
          data: data, 
          dataLabels: { 
           enabled: true, 
           format: '{point.name}' 
          } 
         }); 
        }); 
       } 


       this.setTitle(null, { text: e.point.name }); 
      }, 
      drillup: function() { 
       this.setTitle(null, { text: 'USA' }); 
      } 
     } 
    }, 

我知道這樣做的一種方式,這是做一個window.history.go(-1) drillup函數,但是這會刪除縮放圖形,並在點擊一次後中斷按鈕。 history.go(-1)不會中斷按鈕,但在單擊一次後無法正常工作。

我在這裏發現了一個類似的問題:Proper way to remove all series data from a highcharts chart?但是這涉及一個條形圖,所以代碼是不同的。

此問題的解決辦法是改變

for (var i = 0; i < chart.series.length; i++) 

while(chart.series.length > 0) 
chart.series[0].remove(true); 

我原以爲不保存緩存上的jsfiddle可能也解決了這一點,但我無法讓該工作無論是。

任何幫助將是偉大的。謝謝。

回答

1

這是5.0.3到5.0.4版本的迴歸bug。它是在最新的開發版本中修復的,所以使用5.0.3 /最新的github版本。

<script src="http://github.highcharts.com/master/highmaps.src.js"></script> 
<script src="http://code.highcharts.com/maps/modules/data.js"></script> 
<script src="http://github.highcharts.com/maps/modules/drilldown.js"></script> 
<script src="https://code.highcharts.com/mapdata/countries/us/us-all.js"></script> 

http://jsfiddle.net/dsjLp3h1/

<script src="http://code.highcharts.com/maps/5.0.3/highmaps.js"></script> 
<script src="http://code.highcharts.com/maps/modules/data.js"></script> 
<script src="http://code.highcharts.com/maps/5.0.3/modules/drilldown.js"></script> 
<script src="https://code.highcharts.com/mapdata/countries/us/us-all.js"></script> 

http://jsfiddle.net/dsjLp3h1/1/