我创建了一个条形图,但我只看到我创建的 6 个标签中的 5 个值。即使在 charts.js website 上,他们使用的条形图示例仅显示了 7 个创建的标签中的 6 个值。
我的代码
'use strict'
$(function () {
var data = {
labels: ["HTML", "CSS", "JavaScript", "Java", "Wordpress", "Boostrap"],
datasets: [
{
label: "My Skill Set",
backgroundColor: "rgba(255,99,132,0.2)",
borderColor: "rgba(255,99,132,1)",
borderWidth: 1,
hoverBackgroundColor: "rgba(255,99,132,0.4)",
hoverBorderColor: "rgba(255,99,132,1)",
data: [100, 90, 80, 82, 85, 88],
}
]
};
var options = {};
var ctx = document.getElementById("myChart").getContext('2d');
var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: options
});
});
最佳答案
我从你提供的引用中找到了这个..
ar myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3]
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
尝试一下。
关于javascript - 最后一个值未显示在 charts.js-library 的条形图中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37080011/