2014-10-27 41 views
0

这是我的一系列系列。如何在highchart中动态更改数组?

var newData = [{ 
     name: 'All', 
     data: myVar, 
     grouping: false, 
     zIndex: 1, 
     color: '#999966', 
     stack: 1, 
     dataLabels: { 
       enabled: true, 

       shadow: false, 

       useHTML: true, 
       formatter: function() { 
        if (this.y != 0) return '<div class=\'amount\'>' + this.y + '</div>'; 
       }, 
       y: 0, 

      }, 
    },{ 
     name: 'Negative', 
     data: mySeries[0], 
     grouping: true, 
     zIndex: 2, 
     color: '#FF3030', 
     dataLabels: { 
       enabled: true, 

       shadow: false, 

       useHTML: true, 
       formatter: function() { 
        if (this.y != 0) return '<div class=\'amount\'>' + this.y + '<img src="img/neg.png"></div>'; 
       }, 
       y: 0 
      }, 
    }, { 
     name: 'Positive', 
     data: mySeries[1], 
     grouping: true, 
     zIndex: 2, 
     color: '#7ACC29', 
     dataLabels: { 
       enabled: true, 

       shadow: false, 

       useHTML: true, 
       formatter: function() { 
        if (this.y != 0) return '<div class=\'amount\'>' + this.y + '<img src="img/pos.png"></div>'; 
       }, 
       y: 0 
      }, 
    } 
    ]; 

在配置中我指向这个数组。

series: newData, 

问题:如何动态地将highchart指向不同的数组?例如“oldData”。 使这样:

series: oldData, 

在此先感谢!

回答

0

相反的话,你可以使用series.update/setData

+0

我试图使用setData。但我确实需要保存属性。并深入到另一个情节并回到主要情节。这个名为“newData”的数组是主要的。它有一个深入的数据。例如在myVar中。我深入这样[链接] http://stackoverflow.com/questions/17004614/highcharts-drilldown-from-bar-pie-or-bar-column – 2014-10-27 12:51:14

+0

谢谢!我用setData改变了它。但它的代码是巨大的。是否有可能制作每个系列的属性图案? – 2014-10-27 13:30:02

+0

应该是可以的,但是在setData中你只有一些点数,你有没有例子呢?我会更深入地检查它。 – 2014-10-28 07:35:48