【发布时间】:2021-06-24 21:51:39
【问题描述】:
有谁知道这是否是charts.js 2.X 中的错误?在折线图下,它不会显示网格线。我已经在 Charts.js 3.X 中对此进行了测试,它运行良好,但我需要使用 2.X 来支持 IE11...我尝试了很多没有运气的事情,我认为这个选项将是一个 gridLines 选项,但是看起来这可能是一个错误。
options: {
responsive: true,
maintainAspectRatio: true,
elements: {
line: {
tension: 0
}
},
layout: {
padding: 16
},
legend: {
display: false
},
plugins: {
datalabels: {
display: false
}
},
scales: {
xAxes: [{
id: 'x',
display: true,
ticks: {
display: true,
beginAtZero: false,
fontFamily: 'Roboto',
fontColor: '#000',
fontStyle: 'bold',
fontSize: 12
},
scaleLabel: {
display: true,
labelString: 'Year',
fontFamily: 'Roboto',
fontColor: '#000',
fontStyle: 'bold',
fontSize: 12,
lineHeight: 0,
padding: {top: 15, right: 0, bottom: 5, left: 0 }
},
gridLines: {
display: true,
drawOnChartArea: true
}
}],
yAxes: [{
id: 'y',
display: true,
ticks: {
display: true,
beginAtZero: false,
fontFamily: 'Roboto',
fontColor: '#000',
fontStyle: 'normal',
fontSize: 12,
},
scaleLabel: {
display: true,
labelString: 'Speed (MB/s)',
fontFamily: 'Roboto',
fontColor: '#000',
fontStyle: 'bold',
fontSize: 12,
lineHeight: 0,
padding: {top: 10, right: 0, bottom: 10, left: 0 }
},
gridLines: {
display: true,
drawOnChartArea: true
}
}]
}
}
【问题讨论】: