I'm using chart.js for making pie chart. I'd like to have different colors for every slice that the while loop generates.
$pull_request = 'SELECT * FROM `oc_aa_affiliatecollclicktracking`';
$sqli = $db->query($pull_request);
$num_rows=mysqli_num_rows($sqli);
$cur_row=0;
var pieData = [
<?php
while ($row = mysqli_fetch_array($sqli)) {
$color=intval(256*$cur_row/($num_rows-1));
$cur_row++;
echo '{
value: '.$row["product_clicks"].',
color: "rgb(256,'.$color.')", // NEED TO BE RANDOM FOR EVERY ROW/SLICE
highlight: "#333",
label: "' .$row["product_id"].'"
},';
}
?>
];
var ctx = document.getElementById("chart-area").getContext("2d");
window.myPie = new Chart(ctx).Pie(pieData);
} );
what I found makes random colors that changes on page refresh for the whole chart but not for the individual slice. Any idea?