我尝试过诸如 maxRotate
和 rotate
之类的东西,将它们放在 scaleLabel
等中。我在文档中找不到任何内容,谷歌上的搜索结果也没有多大帮助。
var myChart = new Chart(ctx, {
type: 'line',
data: chartData,
options: {
elements: {
point: {
radius: 0
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero:true
},
scaleLabel: {
display: true,
labelString: 'MW',
},
}],
xAxes: [
{
gridLines: {
display: false ,
color: "#FFFFFF"
},
ticks: {
callback: function(tick, index, array) {
return (index % 2) ? "" : tick;
}
}
}]
}
}
});
最佳答案
您可以使用tick属性在Chart.js 2.0中旋转Y轴。这里有一个链接。
yAxes: [{
ticks : {
minRotation : 90
}
}]
在这里摆弄:https://jsfiddle.net/acmfk5p8/
有一个重复的问题 here但它也还没有答案。
关于chart.js - 图表 : trying to rotate the y-Axis label,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45306604/