您好,我正在尝试减小我拥有的所有图表的点大小,在 documentation 中它说要设置
Chart.defaults.global.elements.rectangle.radius = 2
但是点大小不会改变,尽管它已经通过在声明时手动设置来更改大小,但最好在全局范围内执行此操作,因为我必须在网站的某个阶段动态更改
相关代码如下:
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
//Some looong data here
});
var ctx2 = document.getElementById('myChart2').getContext('2d');
var myChart2 = new Chart(ctx2, {
//Some looong data here
});
var ctx3 = document.getElementById('myChart3').getContext('2d');
var myChart3 = new Chart(ctx3, {
//Some looong data here
});
Chart.defaults.global.elements.rectangle.radius = 2
最佳答案
使用global point options而不是global rectangle options .
// Chart.defaults.global.elements.rectangle.radius = 2; // remove this line
Chart.defaults.global.elements.point.radius = 2;
You also have to move this line on top of your code. It should be performed prior to create your charts.
关于javascript - Chart.js 设置全局点大小不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61387306/