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

Chart.js图表边框去除求助:仍有一处可见边框未消除

解决Chart.js移除所有边框的问题

你当前的配置只关闭了网格的边框(grid.showBorder),但坐标轴自身的边框还处于开启状态,这就是残留边框的原因。只需在x轴和y轴的配置里分别添加border: { display: false }即可彻底移除所有边框,修改后的配置如下:

const options = {
    type: 'line',
    radius: 5,
    responsive: true,
    maintainAspectRatio: false,
    scales: {
        x: {
            grid: {
                display: false,
                showBorder: false,
            },
            // 关闭x轴自身的边框
            border: {
                display: false
            },
            ticks: {
                color: '#2D4059',
                font: {
                    size: 14,
                    family: 'Lexend-SemiBold'
                }
            }
        },
        y: {
            grid: {
                display: false,
                showBorder: false,
            },
            // 关闭y轴自身的边框
            border: {
                display: false
            },
            ticks: {
                display: false,
                stepSize: 53
            },
            min: 0,
        }
    },
    legend: {
        display: false
    },
    plugins: {
        legend: {
            display: false
        },
        datalabels: {
            anchor: 'end',
            align: 'top',
            color: '#2D4059',
                font: {
                    size: 14,
                    family: 'Lexend-SemiBold'
                }
        }
    }
}

补充说明:

  • grid.showBorder控制的是网格区域的外边框,而坐标轴本身的独立边框需要通过border.display来控制,两者是分开的配置项。
  • 同时关闭x、y轴的自身边框后,图表就不会有任何残留边框了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 16:24:58