在 ChartJS LineGraph 中隐藏点

最初,我为每个点设置了完全透明的填充颜色。如果我在图表上运行鼠标,点就会弹出来。我想隐藏所有的点,以便线图是平滑的。

95520 次浏览

You can achieve this by setting point's radius property in configuration options as follows:

var chartConfig = {
type: 'line',
options: {
elements: {
point:{
radius: 0
}
}
}
}

关于积分的工具提示也会消失。

您可以将 pointRadius设置为零。

var myChart = new Chart(
ctx, {
type: 'line',
data: {
labels: [...]
datasets: [
{
data: [...],
pointRadius: 0,  # <<< Here.
}
]
},
options: {}
})

我也有同样的问题,但我想保持悬停选项激活。 这就是我的解决办法:

const config = {
type: 'line',
data: {
datasets:[{
label: 'Température',
borderColor: 'rgb(255, 99, 132)',
data: tempE,
pointStyle: 'rect',
}]
},
options: {
elements:{
point:{
borderWidth: 0,
radius: 10,
backgroundColor: 'rgba(0,0,0,0)'
}
}
}
};