简体   繁体   English

如何在 ChartJS 中更改点的大小

[英]how to change size of point in ChartJS

I'd like to change a size of the point in my chart.我想更改图表中点的大小。 在此处输入图片说明

The point should be as small as possible.该点应尽可能小。 Was trying to use正在尝试使用

pointHoverRadius: 1

But it doesn't work.但它不起作用。

Thanks in advance,提前致谢,

You would have to set the pointRadius property to 1 as well (so the point becomes small initially) , along with the pointHoverRadius (remains small on hover)您还必须将pointRadius属性设置为1 (因此该点最初变小)以及pointHoverRadius (悬停时仍然很小)

pointRadius: 1,
pointHoverRadius: 1

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: {
       ...
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM