2012-10-17 10 views
0

我正在使用jqplot。有沒有辦法爲我的餅圖的每個片段設置一個自定義漸變顏色?我正在使用seriescolor選項:jqplot gradientcolor

seriesColors: ["#F3CBBF", "#BFDDE5", "#CF3501"], 

回答

0

確保將'seriesColors'選項放入'seriesDefaults'對象中。

一個簡單的例子:

 var plot1 = $.jqplot('div1', [['a', 8], ['b', 12], ['c', 6]], { 
     title: 'Chart 1', 

      seriesDefaults:{ 
       renderer:$.jqplot.PieRenderer, 
      rendererOptions:{ 
        showDataLabels: true, 
        dataLabels:'percent' 
      } 
      }, 
      seriesColors: ["#F3CBBF", "#BFDDE5", "#CF3501"], 
      highlighter: { 
       show: true 
     }, 
      legend: { 
         show:true, 
         location: 's', 
         placement: 'outsideGrid'} 
     }); 

確保包括餡餅渲染JavaScript文件還有jqplot-css文件(如果你想顯示圖例)

0

jqPlot餅圖不要」 t支持漸變開箱即用。 API中沒有屬性設置(http://www.jqplot.com/docs/files/plugins/jqplot-pieRenderer-js.html)。您很可能必須在CSS,HTML 5和/或畫布對象中執行此操作。不幸的是,你也會碰到不同的瀏覽器以不同的方式處理漸變。 jqPlot氣泡圖有一個漸變屬性,但我知道除了讓你知道有一個圖表類型可以做到這一點(http://www.jqplot.com/docs/files/plugins/jqplot-bubbleRenderer-js.html)之外沒有任何幫助。

seriesDefaults: { 
    renderer: $.jqplot.BubbleRenderer, 
    rendererOptions: { 
     bubbleAlpha: 0.7, 
     varyBubbleColors: false, 
     bubbleGradients: true 
    } 
}