Marin
Marin

Reputation: 1121

HighCharts color on each - columnrange bar

Question about Highcharts, how to set different color on each columnrange bar. I'v tried with some option but can't make it work.

Examples of my attempts:

Here is my code on JSFiddle:

https://jsfiddle.net/1abugmka/#&togetherjs=N72vHyNcPL

$(function () {

    $('#container').highcharts({

        chart: {
            type: 'columnrange',
            inverted: true,
            renderTo: 'container',
        },
        tooltip: {
          pointFormat: ""
        },
        title: {
            text: ''
        },
         credits: {
        enabled: false
      },
        xAxis: {
             type: 'datetime',
             categories:['1','2']
        },
        yAxis:{
          labels: {
            enabled: false
         },
         title: {
          text: 'Months'
        }
        },
         colors: ['#562F1E', '#AF7F24'],
        series: [{
           data: [
                [Date.UTC(2015, 10, 01),Date.UTC(2015, 02, 04)],
                [Date.UTC(2014, 10, 01),Date.UTC(2014, 02, 04)],

            ]

        }],

        legend: {
        enabled: false
      },
      exporting: {
        enabled: false
      }

    });

});

Upvotes: 2

Views: 1750

Answers (1)

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

One option is to use colorByPoint, which assigns a color per point, instead of a color per series. Example implementation (JSFiddle):

plotOptions: {
    columnrange: {
        colorByPoint: true
        colors: ['red', 'blue', 'yellow'] // if you want custom order of colors
    }
}

Another option is to define each point as an object, instead of an array. Then you can set the color option of each individual point object. Example implementation (JSFiddle):

series: [{
    data: [
        { low: Date.UTC(2015, 10, 01), high: Date.UTC(2015, 02, 04), color: 'red' },
        { low: Date.UTC(2014, 10, 01), high: Date.UTC(2014, 02, 04), color: 'blue' },
    ]
}]

Upvotes: 6

Related Questions