Chart.Js雷达-隐藏标签编号



我想从库Chart.js(v3.7(中删除雷达上显示的数字。

我已经尝试将legend选项设置为display:false

plugins: {
legend: {
display: false
}
}

但它只隐藏了数据集标签。如果有人能解决这个问题,我将感谢他。

可以通过在options.scales.r.pointLabels.display中将显示选项设置为false来移除外部的标签。通过在options.scales.r.ticks.display中将显示选项设置为假,可以隐藏中间的勾号

const options = {
type: 'radar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderColor: 'orange'
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderColor: 'pink'
}
]
},
options: {
scales: {
r: {
pointLabels: {
display: false // Hides the labels around the radar chart 
},
ticks: {
display: false // Hides the labels in the middel (numbers)
}
}
}
}
}
const ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.js"></script>
</body>

最新更新