2015-10-16 48 views
1

在我的代碼中,我在圖表導航過程中加載了很多文件,但是我想包括諸如zoomType和hover以及mousever在一些特定文件中的feathure。例如,我通過讀取sample.json文件來更改圖表的zoomType ='x'。如何在Highchart中更改zoomType狀態?

$(function() { 
     var chart; 
     var options = { 
       chart : { 
         type : 'polygon', 
         renderTo : 'container', 
         zoomType:'' 
       }, 
       title : { 

         text : '' 
       }, 
       credits: { 
      enabled: false 
     }, 



      $.getJSON('sample.json', function(data) { 
       options.series=data; 
       options.chart.zoomType='x'; /*including zoom feature only for sample.json file*/ 
       var chart = new Highcharts.Chart(options); 
      }); 

但是這段代碼不起作用。我該如何解決這個錯誤?

+2

祈禱告訴你的是你的錯誤。或者我們可以通過在心裏調試你的代碼來推斷它! –

+2

你是什麼意思改變zoomtype? –

+1

我編輯了我的問題。 – logicstar

回答

2

See the working demo

我設置爲默認系列「X」和zoomtype「Y」的下一個JSON數據(當你點擊加號圖標),看你以前的代碼和演示在plunker鏈接

$("#container").html("<div style='style:margin:0 auto'>Loading Data</div>") ; 
    $.getJSON('data10.json', function(data) { 
    options.series=data; 
    options.chart.zoomType='x'; 
    chart = new Highcharts.Chart(options); 


});