相关疑难解决方法(0)

如何在chartjs中将起始值设置为"0"?

这是我的代码.我需要在x和y轴刻度中将初始值设置为"0".我尝试过最新的版本比例选项.

graphOptions = {               
            ///Boolean - Whether grid lines are shown across the chart
            scaleShowGridLines: false,    
            tooltipTitleTemplate: "<%= label%>",
            //String - Colour of the grid lines
            scaleGridLineColor: "rgba(0,0,0,.05)",
            //Number - Width of the grid lines
            scaleGridLineWidth: 1,
            //Boolean - Whether to show horizontal lines (except X axis)
            scaleShowHorizontalLines: true,
            //Boolean - Whether to show vertical lines (except Y axis)
            scaleShowVerticalLines: true,
            //Boolean - Whether the line is curved between points
            bezierCurve: true,
            //Number - Tension of the bezier curve between …
Run Code Online (Sandbox Code Playgroud)

charts chart.js

88
推荐指数
4
解决办法
8万
查看次数

无法在Charts.js v2.1.4上使y轴从零开始

使用以下代码生成图表时,我无法将比例设置为从零开始,甚至设置该选项.

这是代码(JSFiddle)

var simpleChart = new Chart(document.getElementById('chart'), {
    type: 'bar',
    data: {
      labels: ['Online', 'Offline'],
      datasets: [{
        label: "# of servers",
        data: [1, 7],
        backgroundColor: [
            '#009245',
            '#c02a31'
        ]
      }]
    },
    options: {
        title: {
            display: false
        },
        scales: {
            yAxes: [{
                beginAtZero: true
            }]
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

这是一个错误吗?我该怎么做才能将比例设置为真正从0开始?

另外,如何禁用该"# of servers"标签?

chart.js

1
推荐指数
1
解决办法
5365
查看次数

标签 统计

chart.js ×2

charts ×1