小编Pha*_*alt的帖子

Chart.js标签颜色

我正在使用chart.js创建条形图,似乎无法更改标签颜色或图例颜色.我想出了如何更改刻度颜色,但我不知道在哪里放'scaleFontColor',如果这确实是我需要使用的.

这是现在看起来的链接. http://imgur.com/nxaH1mk

这是我的代码:

var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
    scaleFontColor: "white",
    type: "bar",
    data: {
        labels: <?php echo json_encode($timeSlice); ?>, 
        datasets: [{
            label: "A Label",
            backgroundColor: "rgba(159,170,174,0.8)",
            borderWidth: 1,
            hoverBackgroundColor: "rgba(232,105,90,0.8)",
            hoverBorderColor: "orange",
            scaleStepWidth: 1,
            data: <?php echo json_encode($myCount); ?>
        }]
    },
    options: {
        legend: {
            fontColor: "white"
        },
        scales: { 
            yAxes: [{
                ticks: {
                    fontColor: "white",
                    stepSize: 1,
                    beginAtZero: true
                }
            }]
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

javascript chart.js

35
推荐指数
2
解决办法
5万
查看次数

标签 统计

chart.js ×1

javascript ×1