Chart.js设置标题,图例,网格和刻度线的方法

官方的demo里没有这类的配置,我是在看github的 issue 看到的一个类似的问题 https://github.com/chartjs/Chart.js/issues/4245

options: {
    title: { //标题
        display: true,
        text: '访问统计',
        fontColor: "#f00",
    },
    legend: { //图例
        display: true,
        color: tick_color,
        labels: {
            fontColor: "#f00",
        }
    },
    scales: {
        xAxes: [{
            gridLines: { //网格
                color: "#f00",
            },
            ticks: { //刻度
                fontColor: "#f00",
            }
        }],
    }
}

具体请看文档: https://github.com/chartjs/Chart.js/blob/master/docs/axes/styling.md

猜你喜欢

转载自my.oschina.net/zhupengdaniu/blog/1648911