2012-03-08 15 views
3

ハイチャートを初めて使用しています。それは涼しくて、私が欲しいものをほとんどやっている。私はpiechartを使用し、毎秒データをリフレッシュします。それは作品の色だけが毎秒変化している作業です。どのように私は同じ色を保つことができますか?ハイチャートで同じ色を維持する方法

は、これは私のコード

var chart; 
$(document).ready(function() { 
chart = new Highcharts.Chart({ 
    chart: { 
     renderTo: 'container', 
     plotBackgroundColor: null, 
     animation: false, 
     plotBorderWidth: null, 
     plotShadow: false, 
     events: { 
      load: function() { 

       // set up the updating of the chart each second 
       var series = this.series[0]; 
       setInterval(function() { 
        $.getJSON("opencont.php", function (data) { 
         $.each(data.vragen, function (index, value) { 
         series.addPoint([value.short, value.antwoorden], true, true); 
         }) 
         }) 
       }, 1000); 
      } 
      } 
    }, 
    title: { 
     text: '' 
    }, 
    tooltip: { 
     formatter: function() { 
      return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; 
     } 
    }, 
    plotOptions: { 
     pie: { 
      allowPointSelect: true, 
      cursor: 'pointer', 
      dataLabels: { 
       enabled: true, 
       color: '#000000', 
       connectorColor: '#000000', 
       formatter: function() { 
        return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; 
       } 
      } 
     } 
    }, 


    series: [{ 
     type: 'pie', 
     name: 'Browser share', 
     data: [ 
     ['a', 0], ['b', 0], ['c', 0] 
     ] 
    }] 
}); 
}); 
+0

でそれがここで回答されていますhttp://stackoverflow.com/questions/17802509/how-can-i-reset-the-styles-given-to-series-in-highcharts – Aximili

答えて

1

は、あなたが本当に円グラフに新しいポイントを追加しますか、またはあなたが新しい値で既存のポイントを交換したいのですか?

これが後である場合は、Series setDataメソッドを参照するとよいでしょう。例http://jsfiddle.net/ebuTs/22/

0

あなたはchart.colorsオプションを試してみましたでしょうか?

http://www.highcharts.com/ref/#colors

私はあなたのデータポイントとして色の同じ番号を持っている必要があります信じています。私のために働くようだ:

http://jsfiddle.net/X9XYK/

+0

はい私は試してみました: Highchartsを.setOptions({ colors:[#058DC7 '、'#50B432 '、'#ED561B '] }); しかし、色を変え続ける –