[英]chart.js: hide specific ticks in y-axis and hide all x-axis grid line
[英]Hide y-axis without hiding grid in chart.js
我想顯示水平網格線而不顯示 y 軸。 可能嗎?
如果我設置:
y: {
display: false,
grid: {
display: true
}
}
網格線被隱藏。
您可以創建一個僅返回空字符串的自定義刻度回調:
const chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
scales: {
y: {
ticks: {
callback: function(value, index, ticks) {
return '';
}
}
}
}
}
});
您還可以在網格中禁用刻度線和 drawTicks:
const chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
scales: {
y: {
grid: {
drawTicks: false
},
ticks: {
display: false
}
}
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.