2012-09-18 23 views
5

私はJqPlotを使用して円グラフを表示しています。私はスライスの実際の色を変えることに興味があり、今まで運がなかった。JqPlot円グラフ - 円グラフの色を変更する

私はthis linkに出くわしましたが、解決策を試しましたが、間違った場所に置いているかどうかはわかりません(コード内のいくつかの場所に挿入しました)円グラフは表示されなくなります(実際には、ページ上の残りのグラフは表示されなくなります)。ここで

は、円グラフのためのJavaScriptコードです:

$(document).ready(function() { 
     var data = [['US',33], ['IE',30], ['GB',23], ['AU',7], ['CA',4], ['RoW',7]]; 
     var plot1 = jQuery.jqplot('Countries', [data], 
     { 
      seriesDefaults: { 
       // Make this a pie chart. 
       renderer: jQuery.jqplot.PieRenderer, 
       rendererOptions: { 
        // Put data labels on the pie slices. 
        // By default, labels show the percentage of the slice. 
        sliceMargin: 5, 
        showDataLabels: true, 
       } 
      }, 
      legend: { show: true, border: false, /*placement: 'outsideGrid', location: 'w'*/location: 'e', border: 'none' }, 
      grid: {borderWidth:0, shadow:false, background: '#FFFFFF'} 

     } 
    ); 
    }); 

誰がどんな考えを持っていますか?

+1

で発見することができますがseriesColorsを見てファイル/ jqPlotOptions-txt.html – Neil

+1

@Neilこれは完全に機能しました。あなたの答えとしてあなたのリンクを入れたいと思います、私はそれを正しいとマークしますか? – 109221793

答えて

16

あなたはoptionsオブジェクトなどにseriesColorsを適用することができます - http://www.jqplot.com/docs/

options = 
{ 
    seriesColors: [ "#4bb2c5", "#c5b47f", "#EAA228", "#579575" ] 
} 

関連文書がjqPlot Options.

+1

は私のために働いています。ありがとう – andy

+0

jqPlotドキュメントの "Options"セクションが時折古くなることがあります。ヘッダーで警告を発するものを確認してください。 – Bern

+0

残念ながら、そのような色を「透明」に設定することはできません... –