i want to build a bar chart with chartJS and database mysql with two different query, but bar chart not showing. can anyone help me to correct the code?
this my query and javascript:
<?php
$a = mysqli_query("select count(a) as total1 from tbl");
$b = mysqli_query("select count(b) as total2 from tbl");
?>
<body>
<div>
<canvas id="chart"></canvas>
</div>
<script>
var ctx = document.getElementById("chart");
var chartdata = {
labels: 'CHART',
datasets: [{
label: "A",
data: [<?php while ($data1 = mysqli_fetch_array($a)) {echo '"''.$data1['total1'].'",';}?>],
backgroundColor: "#000000"
},{
data: [<?php while ($data2 = mysqli_fetch_array($b)) {echo '"''.$data2['total2'].'",';}?>],
backgroundColor: "#ffffff"
}]
};
var chart = new Chart(ctx, {
type: 'bar',
data: chartdata
});
</script>
</body>