我正在使用自定义主题在Highcharts中构建一些图表。我写了一个主题,将颜色表重建为一组渐变,它对于条形和列看起来很棒。唯一的问题是饼图现在看起来像垃圾。
有没有办法设置主题,以便为不同的图表类型指定不同的颜色集?我想为条形图和列条设置渐变颜色,但我不想为我生成的每个图表设置这些选项......
我正在做的事情的例子: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 :(得分:1)
$("#container").highcharts({
plotOptions: {pie:{colors:[your colors here]}}
});