如何更改馅饼切片的颜色?

时间:2015-01-31 18:25:58

标签: javascript

我正在尝试更改jsfiddle中制作的饼图的颜色。我已经尝试更改添加其他系列数据的颜色,但它不起作用。

这是小提琴:http://jsfiddle.net/jpotLvt7/

$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'Skittle Pack 20oz'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %',
                    style: {
                        color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                    },
                    connectorColor: 'silver'
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Color %',
            data: [
                ['Red',    45.0],
                ['Yellow',       26.8],
                {
                    name: 'Green',
                    y: 12.8,
                    sliced: true,
                    selected: true

                },
                ['Orange',    8.5],
                ['Purple',     6.2],

            ]
        }]
    });
});

2 个答案:

答案 0 :(得分:0)

http://jsfiddle.net/jpotLvt7/1/

   Highcharts.setOptions({
        colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4']
    });

请参阅:http://api.highcharts.com/highcharts#colors

答案 1 :(得分:0)

指定每个饼时,在数据数组中

,使用颜色参数:

{
     name: 'Green',
     y: 12.8,
     sliced: true,
     selected: true,
     color: '#00ff00'
}