Google Charts Api - Single Multiple Colors

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

Basically, I want to have a column chart where each column has different colors and each column is marked as.

thank

+5
source share
1 answer

Unfortunately, the Google Graphics API does not support more than one color for each series.

You could fake it, having several rows, one value:

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

0
source

All Articles