admin管理员组文章数量:1430941
In chart.js how can I set the set the font size of the axis labels? I tried lots of codes, but none of them worked. I use a simple bar chart. I importing:
<script src=".js"></script>
The code:
options: {
scales: {
x: {
display: true,
size: 30
}
}
}
On chart.js I have read, that the namespace is : options.scales[scaleId].title but it also didnt worked, when I modify my code. .3.2/axes/labelling.html
In chart.js how can I set the set the font size of the axis labels? I tried lots of codes, but none of them worked. I use a simple bar chart. I importing:
<script src="https://cdn.jsdelivr/npm/chart.js"></script>
The code:
options: {
scales: {
x: {
display: true,
size: 30
}
}
}
On chart.js I have read, that the namespace is : options.scales[scaleId].title but it also didnt worked, when I modify my code. https://www.chartjs/docs/3.3.2/axes/labelling.html
Share Improve this question asked Aug 2, 2021 at 18:42 JohnJohn 832 silver badges7 bronze badges1 Answer
Reset to default 4You have to configure it in the font
options for the label like so:
var options = {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderColor: 'pink'
}]
},
options: {
scales: {
x: {
ticks: {
font: {
size: 20
}
},
title: {
display: true,
text: 'titleX',
font: {
size: 25
}
}
},
y: {
ticks: {
font: {
size: 20
}
},
title: {
display: true,
text: 'titleY',
font: {
size: 20
}
}
}
}
}
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare./ajax/libs/Chart.js/3.5.0/chart.js"></script>
</body>
EDIT: Since you want to make the ticks bigger you still need to do that with the font object but than in the ticks sub category
本文标签: javascriptHow to change font size of labeled scales in ChartjsStack Overflow
版权声明:本文标题:javascript - How to change font size of labeled scales in Chart.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745561285a2663486.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论