๐:0
You can build your var pieData
object in your php code โ
$result = mysqli_query($con, "SELECT Dealaytype, COUNT(1) as cnt FROM delays
GROUP BY Delaytype; ");
$pieData = array();
while($row = mysqli_fetch_array($result))
{
$pieData[] = array('value'=>$row['cnt'], 'color'=>'some color');
}
and then use it in your js code
<canvas id='buy'></canvas>
var pieData = <?php echo json_encode($pieData); ?>;
var pieOptions = {
segmentShowStroke : false,
animateScale : true
};
var countries = document.getElementById("buy").getContext("2d");
new Chart(countries).Pie(pieData, pieOptions);