backgroundColor support query

  1. Is is possible to use hex colours other than red blue or green ?
backgroundColor : ["red", "green", "blue"],

  1. How do I get the colours to be red, blue, blue per graph column ?
    In this case it has all bars per coulmn the same colour.

Hi @anjanesh,

Yes, you can use hex colors instead of color names. You should just be able to replace those values.

To set colors per series, you should break your data into multiple datasets.

Here’s an example:

{
  type: 'bar',
  data: {
    labels: ['Q1', 'Q2', 'Q3', 'Q4'],
    datasets: [{
      label: 'Data 1',
      backgroundColor: 'red',
      data: [50, 60, 70, 180]
    }, {
      label: 'Data 2',
      backgroundColor: 'green',
      data: [100, 200, 300, 400]
    }, {
      label: 'Data 3',
      backgroundColor: 'blue',
      data: [150, 250, 350, 450]
    }]
  }
}

1 Like

This library is awesome - I managed to get this done (had to give different JavaScript based on a PHP condition)

1 Like