这是我的代码.我需要在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) 使用以下代码生成图表时,我无法将比例设置为从零开始,甚至设置该选项.
这是代码(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"标签?