向图表添加内部填充[chart.js v3]

k3fezbri  于 2022-11-23  发布在  Chart.js
关注(0)|答案(1)|浏览(149)

我正在尝试向图表添加额外的填充(“橙子”列右侧的额外空间):

但是使用图表3.7.0似乎不起作用,我怎么才能做到这一点呢?
chart.options.scales

scales: {
    x: {
        afterFit(axis) {
            axis.paddingLeft = 50; //doesn't work
            axis.paddingRight = 50; //doesn't work
        },
    },
},

Full Runnable example

tzxcd3kk

tzxcd3kk1#

Chart.js docs状态遵循

let chart = new Chart(ctx, {
    type: 'line',
    data: data,
    options: {
        layout: {
            padding: {
                right: 50
            }
        }
    }
});

相关问题