答案 0 :(得分:0)
选项->轴->勾号具有字体属性,您可以在此属性之前或之后进行设置/更改。
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: 'some numbers',
data: [5, 1, 3, 2, 4, 1],
backgroundColor: ["red", "blue", "yellow", "green", "purple", "orange"],
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}],
yAxes: [{
ticks: {
fontSize: "14"
}
}]
}
}
});
document.getElementById("testbtn").addEventListener("click", function() {
myChart.options.scales.yAxes[0].ticks.fontStyle = "bold";
myChart.options.scales.xAxes[0].ticks.fontFamily = "Verdana";
myChart.options.scales.xAxes[0].ticks.fontColor = "red";
myChart.update();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<canvas id="myChart" height="50"></canvas>
<br>
<button id="testbtn">change font</button>