'Google charts, I can't change bars color
I need to change the colors of the bars to red and blue. Red for the limit, blue for mining. An array with data is connected to the script. I was able to customize everything except the color
function drawChart() {
var data = google.visualization.arrayToDataTable(regiondata);
var options = {
chart: {
title: 'Реализация по годам',
subtitle: 'График реализации и добычи',
width: 100,
},
bars: 'vertical',
vAxis: {format: 'decimal'},
height: 280,
width: 610,
colors: ['red', 'blue'],
backgroundColor: '#F9F6F0',
};
var chart = new google.charts.Bar(document.getElementById('content-graf'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
Solution 1:[1]
According to the documentation, you can do it this way :
var data = google.visualization.arrayToDataTable([
['Element', 'Density', { role: 'style' }],
['Copper', 8.94, '#b87333'], // RGB value
['Silver', 10.49, 'silver'], // English color name
['Gold', 19.30, 'gold'],
['Platinum', 21.45, 'color: #e5e4e2' ], // CSS-style declaration
]);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom |
