对于那些有类似问题的人。我需要将数据com_作为数组传递,而不是像这样的整数。
var com_passed = rows[rows.length-2]["# Common Passed"];
var com_failed = rows[rows.length-2]["# Common Failed"];
var ctx = document.getElementById("common_chart");
ctx.height = 50;
var historicalChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Passed", "Failed"],
datasets: [
{
data: [com_passed],
label: "Passed",
fillColor: "red"
},
{
data: [com_failed],
label: "Failed",
fillColor: "green"
}
]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true,
responsive: false,
maintainAspectRatio: true
}
}]
}
}
});