Javascript 在 ChartJS LineGraph 中隐藏点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35073734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 17:15:14  来源:igfitidea点击:

Hide points in ChartJS LineGraph

javascriptchart.js

提问by Dan

Originally I set the fill color for each point to be completely transparent. If I run my mouse over the graph, the points pop up. I want to hide all points so that the line graph is smooth.

最初我将每个点的填充颜色设置为完全透明。如果我将鼠标移到图形上,点会弹出。我想隐藏所有点,以便折线图平滑。

回答by Shivam

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

您可以通过在配置选项中设置点的半径属性来实现这一点,如下所示:

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

Tooltips for the points will also gone off.

积分的工具提示也将消失。

回答by Alexander

You can set the pointRadiusto zero.

您可以将 设置pointRadius为零。

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