2
I am filling a Columnchart with the data brought from mysql, only that I would like to put the columns of different colors, more unsuccessfully. Shows the same color in both columns, as you can see in the image below.
I’ve tried to: stackoverflow - Generate different colors Google Chart
</body>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Status', 'Total'],
<?php
$solicitacoes = "SELECT * FROM view_count_solicitacoes";
$result = mysqli_query($connProcessos, $solicitacoes);
while($row = mysqli_fetch_assoc($result)) {
echo "['".$row['status_nome']."',".$row['total']."],";
}
?>
]);
var options = {
legend: {position: 'none'},
series: {
0: { color: '#e2431e' },
1: { color: '#43459d' },
}
};
var chart = new google.visualization.ColumnChart(document.getElementById("solicitacoes"));
chart.draw(data, options);
google.visualization.events.addListener(chart, 'select', function() {
var row = chart.getSelection()[0].row;
console.log(row);
window.open('view-solicitacoes.php?id=' + row);
});
}
</script>
</html>
Can update the question and puts this part of the way the browser generates, for example press
Ctrl + u
and find that part and update the question with it. it’s easier to understand what your php is printing.– Bulfaitelo