最后值未显示在Charts.js-library的条形图中

Cod*_*316 3 html javascript css jquery chart.js

我创建了一个条形图,但是我只能从创建的6个标签中看到5个值。即使在Charts.js网站上,他们使用的条形图示例也仅显示了创建的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
  });
});
Run Code Online (Sandbox Code Playgroud)

Gri*_*zly 5

我从您提供的参考中找到了这一点。

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
            }
        }]
    }
}
Run Code Online (Sandbox Code Playgroud)

试试看。


Cod*_*316 5

我实际上想出了这个:

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.
            }
        }]
    }
};
Run Code Online (Sandbox Code Playgroud)