2013-03-07 80 views
1

我正在用自定義主題在Highcharts中構建一些圖表。我寫了一個主題,將顏色表重建爲一組漸變,並且它看起來棒極了。唯一的問題是現在餅圖看起來像廢話。Highcharts Theming:如何爲某些圖表類型設置漸變顏色?

有什麼辦法可以設置主題,以便爲不同的圖表類型指定不同的顏色集合?我想設置漸變顏色只是酒吧和列,但我不希望有設置這些選項在所有圖表我產生......我在做什麼

例子:http://jsfiddle.net/K7YPF/5/

var colors = ["#AFD8F8", "#F6BD0F", "#8BBA00", "#FF8E46", "#008E8E", "#D64646", "#8E468E", "#588526", 
    "#B3AA00", "#008ED6", "#9D080D", "#A186BE", "#CC6600", "#FDC689", "#ABA000", "#F26D7D", 
    "#FFF200", "#0054A6", "#F7941C", "#CC3300", "#006600", "#663300", "#6DCFF6"]; 
var gradientColors = []; 
//rebuild all of the colors into gradients for the 3d effect 
$.each(colors, function (i, color) { 
    gradientColors[i] = { 
     linearGradient: { 
      x1: 0, 
      y1: 0, 
      x2: 1, 
      y2: 0 
     }, 
     stops: [ 
      [0, Highcharts.Color(color).brighten(-0.08).get('rgb')], 
      [0.2, Highcharts.Color(color).brighten(0.24).get('rgb')], 
      [0.4, Highcharts.Color(color).brighten(-0.02).get('rgb')], 
      [0.5, color], 
      [0.8, Highcharts.Color(color).brighten(0.12).get('rgb')], 
      [1, Highcharts.Color(color).brighten(-0.08).get('rgb')] 
     ] 
    }; 
}); 
Highcharts.theme = { 
    colors: colors, 
    plotOptions: { // This does not work, but this is how I'd like to be able to do it. 
     column: { 
      colors: gradientColors 
     }, 
     pie: { 
      colors: colors 
     } 
    } 
}; 

在此先感謝您提供的任何幫助。

+0

如果按主題或使用setOptions定義顏色,則所有圖表都將具有此架構。在其他情況下,您需要分別爲每個圖表設置顏色。 – 2014-01-20 14:34:46

回答

1
$("#container").highcharts({ 
    plotOptions: {pie:{colors:[your colors here]}} 
}); 
相關問題