You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Chart.js雷达图中设置Y轴刻度标签的字号

如何增大雷达图Y轴刻度数字的字号

要实现这个需求,直接在雷达图的刻度配置里启用fontSize属性就行——你代码里已经写了这个配置,只是被注释掉了。

修改步骤:

  • 找到scales.r.ticks下的//fontSize: 200行
  • 去掉前面的注释符号//,并把数值调整到合适大小(200字号过大,建议用14、16这类常用值)

修改后的完整代码如下:

const myChart = new Chart(ctx, {
    type: 'radar',
    data: data,
    options: {
        responsive: true,
        elements: {
                line: {
                    borderWidth: 3
                }
            },
        
        plugins: {
            legend: {
                display: false,
            }
        },
        scales: {
                    r: {
                        max: 50,
                        min: 0,
                        ticks: {
                            stepSize: 5,
                            textStrokeColor: 'rgb(54, 162, 235)',
                            color: 'rgba(0, 0, 0, 1)',
                            //backdropColor: 'rgb(47, 56, 62)'
                            fontSize: 16 // 设置你需要的字号
                            
                        },
                        angleLines: {
                            color: 'rgba(0, 0, 0,0.65)',
                        },

                        grid: {
                            color: "darkgray",
                        },
                        
                    },
                    
                },      
    },
});

内容的提问来源于stack exchange,提问作者Biplob Mudi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 21:35:09