Google column chart colors

Im trying to change the colors of this bar chart without any success. Ive tried everything I can find online. Nothing works. The chart displays the data correctly but uses Googles default colors…not mine

   function drawChart1() {
      console.log(chart1);  
      var data = google.visualization.arrayToDataTable(chart1);
      var date = new Date().getFullYear();
      
      var options = {
        chart: {
          title: 'Current Subscription Numbers',
          colors: ['green', 'red'],  
          subtitle: 'Data for ' + date 
          
      }
    };

    var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
    chart.draw(data, google.charts.Bar.convertOptions(options));

When I look at the documentation I see that options has a colors property. What you’ve done looks to be different from that.

I looked at exactly this document and applied the code without success.

Looking at your code, the colors are incorrectly a property of the chart object, which is not the correct place to put the colors.
The colors should be a direct property of the options object instead.

1 Like