0
我試圖改變以更改Y和X軸的圖表標籤顏色爲白色。我試圖從其他線程的fontColour中添加代碼,但不會讓它工作。更改標籤顏色Y和X軸chart.js
這裏是我的代碼:
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
var lineChartData = {
labels : ['January','February','March','April','May','June','July'],
datasets : [
{
label: 'My First dataset',
fontColor : '#fff' ,
backgroundColor : 'rgba(220,220,220,0.2)',
borderColor : 'rgba(220,220,220,1)',
pointBackgroundColor : 'rgba(220,220,220,1)',
pointBorderColor : '#fff',
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
}
]
}
var options = {
maintainAspectRatio: false,
legend: {
fontColor: "white",
},
scales: {
xAxes: [{
ticks: {
fontColor: "white",
}
}],
yAxes: [{
ticks: {
fontColor: "white",
beginAtZero: true,
maxTicksLimit: 5,
stepSize: Math.ceil(250/5),
max: 250
}
}]
}
};
var ctx = document.getElementById('canvas-1');
var chart = new Chart(ctx, {
type: 'line',
data: lineChartData,
options: {
responsive: true
}
});
你'options'塊看起來不錯,應該更改標籤的顏色,但你實際上並沒有包括它建立在您的圖表 – Smittey
謝謝! :D工作 – 9minday