4
votes

Is there a way using the Google Charts Api (google.visualization.ColumnChart) to have a single series with a different color for each item in the series?

Basically I want to have a column chart where the columns are each a different color and each column is labeled.

Thanks

1

1 Answers

0
votes

Unfortunately, the Google Charts API does not support more than a single color per series.

You could possibly fake it by having several series, one value each:

function drawVisualization() {
// Create and populate the data table.
    var data = google.visualization.arrayToDataTable([
        ['Sequence', '1', '2', '3', '4', '5', '6'],
        ['', 1,1,2,3,5,8],
    ]);

// Create and draw the visualization.
new google.visualization.ColumnChart(document.getElementById('visualization')).
    draw(data,
         {title:"Fibonacci",
          width:600, height:400}
    );
}

Fibonacci sequence with distinct colors