我正在使用Chart.js v2绘制一个简单的折线图。一切看起来都很好,除了有一些我不想要的网格线:
折线图的文档在这里:https://nnnick.github.io/Chart.js/docs-v2/#line-chart,但是我找不到任何关于隐藏这些“网格线”的东西。
如何删除网格线?
发布于 2016-04-18 19:22:37
我找到了一个在折线图中隐藏网格线的解决方案。
将gridLines
颜色设置为与div的背景色相同。
var options = {
scales: {
xAxes: [{
gridLines: {
color: "rgba(0, 0, 0, 0)",
}
}],
yAxes: [{
gridLines: {
color: "rgba(0, 0, 0, 0)",
}
}]
}
}
或使用
var options = {
scales: {
xAxes: [{
gridLines: {
display:false
}
}],
yAxes: [{
gridLines: {
display:false
}
}]
}
}
发布于 2018-08-20 21:33:10
options: {
scales: {
xAxes: [{
gridLines: {
drawOnChartArea: false
}
}],
yAxes: [{
gridLines: {
drawOnChartArea: false
}
}]
}
}
发布于 2021-06-10 06:15:40
从版本3.x开始,使用此语法。请参阅chart.js迁移指南:https://www.chartjs.org/docs/latest/getting-started/v3-migration.html
scales: {
x: {
grid:{
display:false
}
},
y:
{
grid:{
display:false
}
}
}
https://stackoverflow.com/questions/36676263
复制相似问题