ChartJS禁用图表区域外的网格线 [英] ChartJS disable gridlines outside chart area
本文介绍了ChartJS禁用图表区域外的网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图隐藏在图表区域之外绘制的网格线,所以基本上像下面的选项一样,但是对于图表区域之外的
I'm trying to hide the gridlines drawn outside the chart area, so basically like the option below, but for outside the chart area
gridLines: {
drawOnChartArea: false,
},
推荐答案
大概是您希望禁用刻度线,这可以通过 drawTicks
属性实现:
Presumably you are looking to disable the tick lines which can be achieved via the drawTicks
property:
new Chart(document.getElementById('canvas'), {
type: 'bar',
data: {
labels: ['a', 'b', 'c'],
datasets: [{
label: 'series1',
data: [1, 2, 4]
}]
},
options: {
scales: {
xAxes: [{
gridLines: {
drawTicks: false
},
ticks: {
padding: 10
}
}],
yAxes: [{
gridLines: {
drawTicks: false
},
ticks: {
beginAtZero: true,
padding: 10
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<canvas id="canvas">
gridLines:
drawTicks: false;
}
请参阅文档进一步的信息.
这篇关于ChartJS禁用图表区域外的网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文