javascript 如何在 ChartJS 中更改点的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46194039/
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-10-29 06:31:01  来源:igfitidea点击:

how to change size of point in ChartJS

javascriptchart.js

提问by Vba_Beg

I'd like to change a size of the point in my chart. enter image description here

我想更改图表中点的大小。 在此处输入图片说明

The point should be as small as possible. Was trying to use

该点应尽可能小。正在尝试使用

pointHoverRadius: 1

But it doesn't work.

但它不起作用。

Thanks in advance,

提前致谢,

回答by ?????

You would have to set the pointRadiusproperty to 1as well (so the point becomes small initially), along with the pointHoverRadius(remains small on hover)

您还必须将pointRadius属性设置1(因此该点最初变小)以及(在悬停时保持小)pointHoverRadius

pointRadius: 1,
pointHoverRadius: 1

回答by av01d

It indeed needs to go in the dataset, like so:

它确实需要进入数据集,如下所示:

{
    type: 'scatter',
    data: {
        labels: ['2015', '2016', '2017', '2018', '2019', '2020'],
        datasets: [
            {
                label: 'Cars',
                data: [{x:-10,y:0}, {x:0,y:10}, {x:10,y:5}, {x:4,y:8}],
                pointRadius: 10,
                ....
            },
            {
                label: 'Bikes',
                data: [{x:10,y:3}, {x:-2,y:6}, {x:9,y:3}, {x:11,y:6}],
                pointRadius: 10,
                ...
            }
        ]
    },
    options: {
       ...
    }

}