Mike
Mike

Reputation: 755

Highcharts: stacked bar -> How to change color?

i like to change the color of the bars in a stacked bar chart in highchart. I did not found the option where i can set the color foreach value. Joe should be red, Jane yellow, and John black.

Highcharts.chart('container', {
chart: {
    type: 'bar'
},
title: {
    text: 'Stacked bar chart'
},
xAxis: {
    categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
    min: 0,
    title: {
        text: 'Total fruit consumption'
    }
},
legend: {
    reversed: true
},
plotOptions: {
    series: {
        stacking: 'normal'
    }
},
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]
}]

});

Upvotes: 0

Views: 417

Answers (1)

Xtof
Xtof

Reputation: 425

You can add the field color in your serie like:

series: [{
  name: 'John',
  color: '#ff8080',
  data: [5, 3, 4, 7, 2]
  }, {
  name: 'Jane',
  color: '#ffff00',
  data: [2, 2, 3, 2, 1]
  }, {
  name: 'Joe',
  color: '#000000',
  data: [3, 4, 4, 2, 5]
  }]

Upvotes: 1

Related Questions