如何在Highchart中更改zoomType状态?

时间:2015-10-16 00:33:55

标签: highcharts zoom

在我的代码中,我在图表导航期间加载了很多文件,但我想在某些特定文件中包含像zoomType和hover and mousever这样的功能。例如,我正在更改zoomType =' x'通过读取sample.json文件获取图表。

 $(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);
          });

但是这段代码不起作用。我该如何解决这个错误?

1 个答案:

答案 0 :(得分:2)

See the working demo

我为默认系列设置'x',为下一个json数据设置zoomtype'y'(当你点击加号图标时),在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);


});