我正在使用 Chart.js 来绘制圆环图。我尝试使用下面的代码更改标签字体大小,但它对我不起作用。
我还尝试将其换行成两行以显示完整标签,但换行也不起作用。
附件是图表示例,其中阿拉伯联合酋长国是标签,该标签正在剪切且未完全显示给我/
我的代码是:
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: 'Fruits',
data: ['one', 'two','three','three', 'four', 'five'],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderWidth: 1,
fontSize:18, // This is not working
wrap: true, // This is not working
itemWrap: true, // This is not working
}]
},
options: {
legend: {
display: false ,
},
}
});
有人有什么想法吗?谢谢
最佳答案
尝试使用这条线
// Global Options
Chart.defaults.global.defaultFontSize = 18;
var myChart = new Chart(ctx, {
rest of your code..
}
关于javascript - chat.js 圆环图字体大小不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49851900/