Cant change chart colours, please help.

38 views
Skip to first unread message

B

unread,
May 15, 2024, 10:03:26 AMMay 15
to Google Visualization API
Hello,

As the title states, I'm unable to change the chart colour for this donut chart, basically I want Slightly concerned to green, very concerned to orange and extremely concerned to red.

Wondering if anyone can tell me where I'm going wrong:

<!DOCTYPE html>
<html>
<head>
<title>Concern Levels about Cash Reserves</title>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
var data = google.visualization.arrayToDataTable([
['Answer Choices', 'Response Percent', { role: 'style' }],
['Not concerned', 21.89, '#0000FF'], // Blue using hex code
['Slightly concerned', 42.06, '#008000'], // Green using hex code
['Very concerned', 25.75, '#FFA500'], // Orange using hex code
['Extremely concerned', 10.3, '#FF0000'] // Red using hex code
]);

var options = {
title: 'Concern Levels about Cash Reserves',
pieHole: 0.4,
};

var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="donutchart" style="width: 900px; height: 500px;"></div>
</body>
</html>

B

unread,
May 15, 2024, 10:40:12 AMMay 15
to Google Visualization API
Looks like it's to do with the order of the answers, but to change the colour - the flow of the questions doesn't make sense.
Reply all
Reply to author
Forward
0 new messages