首页 文章

如何更改图表中列的颜色?

提问于
浏览
0

我正在使用高图库制作一个skacked柱形图 . 我们可以改变图表的颜色吗?有三种颜色显示(蓝色,黑色,绿色)..有没有办法改变默认颜色像(黄色,粉红色,红色)

我需要改变列的颜色吗?

小提琴http://jsfiddle.net/cr91t8wj/

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Stacked column chart'
        },
        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Total fruit consumption'
            },
            stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            }
        },
        legend: {
            align: 'right',
            x: -30,
            verticalAlign: 'top',
            y: 25,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
            borderColor: '#CCC',
            borderWidth: 1,
            shadow: false
        },
        tooltip: {
            headerFormat: '<b>{point.x}</b>
', pointFormat: '{series.name}: {point.y}
Total: {point.stackTotal}' }, plotOptions: { column: { stacking: 'normal', dataLabels: { enabled: true, color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', style: { textShadow: '0 0 3px black' } } } }, series: [{ name: 'John', data: [5, 3, 4, 7, 2] }, { name: 'Jane', data: [2, 2, 3, 2, 1] }, { name: 'Joe', data: [3, 4, 4, 2, 5] }] }); });

1 回答

  • 2

    使用如下数据指定颜色:

    name: 'Joe',
    data: [3, 4, 4, 2, 5],
    color: '#FF0000'
    

相关问题