2014-10-27 30 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