1

我正在使用自定义主题在 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
        }
    }
};

提前感谢您提供的任何帮助。

4

1 回答 1

1
$("#container").highcharts({
    plotOptions: {pie:{colors:[your colors here]}}
});
于 2014-01-20T11:42:19.937 回答