admin管理员组文章数量:1425819
This is the code that I used:
var ctx = document.getElementById("pages_breakdown").getContext('2d');
ctx.width = 400;
ctx.height = 300;
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['Primary pages {{ $array_pages_breakdown[0] }}',
'Dupliacte pages {{ $array_pages_breakdown[1] }}',
'Paginated 2+ {{ $array_pages_breakdown[2] }}',
'Mobile alternates {{ $array_pages_breakdown[3] }}',
'Non-indexable pages {{ $array_pages_breakdown[4] }}',
'Non-200 pages {{ $array_pages_breakdown[5] }}',
'Failed URL {{ $array_pages_breakdown[6] }}'],
datasets: [{
data: [ {{ $array_pages_breakdown[0] }}, {{ $array_pages_breakdown[1] }}, {{ $array_pages_breakdown[2] }}, {{ $array_pages_breakdown[3] }}, {{ $array_pages_breakdown[4] }}, {{ $array_pages_breakdown[5] }}, {{ $array_pages_breakdown[6] }}],
backgroundColor: [
'rgba(59, 153, 129, 1.0)',
'rgba(232, 179, 58, 1.0)',
'rgba(214, 212, 209, 1.0)',
'rgba(75, 192, 192, 1.0)',
'rgba(122, 120, 117, 1.0)',
'rgba(224, 33, 81, 1.0)',
'rgba(244, 90, 39, 1.0)'
]
}]
},
options: {
rotation: (0.5 * Math.PI) - (95/180 * Math.PI),
responsive: false,
legend: {
position: 'left'
},
layout: {
padding:{
left: 30,
right: 0,
top: 0,
bottom: 0
}
}
}
});
This is the output:
Expected output was this:
How can I fix my label to make it a little bigger and decrease the size of my pie? I tried to put fontSize
inside my option but it didn't change anything. I want to have those % as well and I tried this, but when I use datapoints on my chart it crashes.
This is the code that I used:
var ctx = document.getElementById("pages_breakdown").getContext('2d');
ctx.width = 400;
ctx.height = 300;
var myChart = new Chart(ctx, {
type: 'pie',
data: {
labels: ['Primary pages {{ $array_pages_breakdown[0] }}',
'Dupliacte pages {{ $array_pages_breakdown[1] }}',
'Paginated 2+ {{ $array_pages_breakdown[2] }}',
'Mobile alternates {{ $array_pages_breakdown[3] }}',
'Non-indexable pages {{ $array_pages_breakdown[4] }}',
'Non-200 pages {{ $array_pages_breakdown[5] }}',
'Failed URL {{ $array_pages_breakdown[6] }}'],
datasets: [{
data: [ {{ $array_pages_breakdown[0] }}, {{ $array_pages_breakdown[1] }}, {{ $array_pages_breakdown[2] }}, {{ $array_pages_breakdown[3] }}, {{ $array_pages_breakdown[4] }}, {{ $array_pages_breakdown[5] }}, {{ $array_pages_breakdown[6] }}],
backgroundColor: [
'rgba(59, 153, 129, 1.0)',
'rgba(232, 179, 58, 1.0)',
'rgba(214, 212, 209, 1.0)',
'rgba(75, 192, 192, 1.0)',
'rgba(122, 120, 117, 1.0)',
'rgba(224, 33, 81, 1.0)',
'rgba(244, 90, 39, 1.0)'
]
}]
},
options: {
rotation: (0.5 * Math.PI) - (95/180 * Math.PI),
responsive: false,
legend: {
position: 'left'
},
layout: {
padding:{
left: 30,
right: 0,
top: 0,
bottom: 0
}
}
}
});
This is the output:
Expected output was this:
How can I fix my label to make it a little bigger and decrease the size of my pie? I tried to put fontSize
inside my option but it didn't change anything. I want to have those % as well and I tried this, but when I use datapoints on my chart it crashes.
- 1 You need to create your own legend, otherwise using chart.js legend this looks difficult. – Kunal Khivensara Commented Oct 11, 2018 at 3:54
- @KunalKhivensara is it? Thank you for the advice. – Christian Gallarmin Commented Oct 11, 2018 at 14:20
2 Answers
Reset to default 3I don't know whether you looked the documentations on chart.js
anyway here I'm posting some ideas that you are looking for.
options: {
legend: {
display: true,
labels: {
fontColor: 'rgb(255, 99, 132)'
}
}
}
for enhancement please look at this
You can add this:
options: {
**maintainAspectRatio : true**, // make the pie small
legend: {
display: true,
labels: {
**fontSize: 15** //change the size of the labels
}
}
}
good luck
版权声明:本文标题:javascript - How to Increase the label font size and decrease the size of my pie using chart.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745446752a2658698.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论