我有下面给出的代码
<script type="text/javascript">
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["A1", "B1", "C1"],
datasets: [{
label: '',
datasets:[
<?php
$jumlah_A1 = mysqli_query($koneksi,"select * from mesin where LokasiMesin='A1'");
echo mysqli_num_rows($jumlah_A1);
?>,
<?php
$jumlah_B1 = mysqli_query($koneksi,"select * from mesin where LokasiMesin='B1'");
echo mysqli_num_rows($jumlah_B1);
?>,
<?php
$jumlah_C1 = mysqli_query($koneksi,"select * from mesin where LokasiMesin='C1'");
echo mysqli_num_rows($jumlah_C1);
?>,
backgroundColor: [ <!-- Error on here -->
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)'
],
borderWidth: 1;
]
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
浏览器控制台上的错误是“意外令牌:”(标记在代码行上),但是当我按照 Chart.js 的文档进行操作时,文档可能与我正在做的相同。
这是图片:
有什么帮助解决这个问题吗?
阿晨1998