I created a bar graph, but I only see 5 values from the 6 labels that I created. Even on the charts.js website, the bar graph example they used only shows 6 values out of the 7 created labels.
我创建了一个条形图,但我只看到了我创建的6个标签中的5个值。即使在charts.js网站上,他们使用的条形图示例仅显示7个创建标签中的6个值。
My code
'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
});
});
2 个解决方案
#1
3
I found this from the reference you provided..
我从您提供的参考文献中找到了这个..
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
}
}]
}
}
try that out.
试试看。
#2
4
I actually came up with this:
我实际想出了这个:
var options = {
scales: {
yAxes: [{
display: true,
ticks: {
suggestedMin: 0, // minimum will be 0, unless there is a lower value.
// OR //
beginAtZero: true // minimum value will be 0.
}
}]
}
};
#1
3
I found this from the reference you provided..
我从您提供的参考文献中找到了这个..
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
}
}]
}
}
try that out.
试试看。
#2
4
I actually came up with this:
我实际想出了这个:
var options = {
scales: {
yAxes: [{
display: true,
ticks: {
suggestedMin: 0, // minimum will be 0, unless there is a lower value.
// OR //
beginAtZero: true // minimum value will be 0.
}
}]
}
};