A different color for each column highcharts

0

I have a horizontal bar chart of Highcharts, I would like each bar to have a color, but I only set them with a series using a bank query, in which case I can only pass one color to the whole chart.

I searched in various places, I did not find anything from Highcharts to help me with this.

    
asked by anonymous 01.12.2017 / 19:12

2 answers

1

To put a different color for each column use the colors attribute within a series:

series: [{       

        type: 'column',
        colorByPoint: true,
        colors: '#fff',
        name: 'Numero de Chamados',
        data: {[0,1,2,3,4,3,5,4,3,3,3,33,3,3,3,3,3,2]},
        showInLegend: true
    },{       

        type: 'column',
        colorByPoint: true,
        colors: '#000',
        name: 'Numero de Chamados2',
        data: {[0,1,2,13,4,3,1511,4,3,31,3,133,3,13,3,3,3,2]},
        showInLegend: true
    }]

If you only use one series, just put this code:

colorByPoint: true,
    
01.12.2017 / 19:15
0

Set the colorByPoint option to true and set the desired color sequence.

options = {
    chart: {...},
    plotOptions: {
        column: {
            colorByPoint: true
        }
    },
    colors: [
        '#ff0000',
        '#00ff00',
        '#0000ff'
    ]
}

example - jsfiddle

Font

    
01.12.2017 / 19:35