我正在尝试减少填充并增加标题文本字体大小,我浏览了几个示例,但似乎不起作用。即使将参数放置在多个位置。
const labels1_1 = ['1','2','3', '4', '5','6','7', '8','9+'];
const data1_1 = {
labels: labels1_1,
datasets: [{
label: 'Trucks',
data: [1,2,3, 4, 5,6,7, 8,9],
backgroundColor: '#4472C4',
borderColor: '#4472C4',
borderWidth: 1
}]
};
const config1_1 = {
type: 'bar',
data: data1_1,
options: {
title:{
padding:5,
fontSize:18
},
plugins: {
title: {
display: true,
text: 'Number of SS vs Number of Trucks',
padding:5,
fontSize:18
},
datalabels: {
align: 'end',
anchor: 'end',
backgroundColor: '#3472C4'
},
},
scales: {
y: {
display:true,
beginAtZero: true,
title: {
display: true,
text: 'SS'
}
},
}
},
};
const myChart1_1 = new Chart(
document.getElementById('myChart1_1'), config1_1);
Run Code Online (Sandbox Code Playgroud)
我浏览了https://www.chartjs.org/docs/2.8.0/configuration/title.html但没有帮助。以及如何在全球范围内提及它,以便所有标题都有更大的字体。文本:标题是“SS 数量与卡车数量”。
小智 7
标题选项在 Chartjs v2 中发生了很大变化。我发现标题完全隐藏,直到我添加填充 - 例如
options: {
plugins: {
title: {
display: true,
text: "Title" ,
padding: {
top: 10,
bottom: 10
},
font: {
size: 24,
style: 'italic',
family: 'Helvetica Neue'
}
}
},
... other options here
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9450 次 |
| 最近记录: |