最佳答案
我正在使用 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
}
}]
}
}
});
如果你能帮忙,我将不胜感激。