I recently updated my charts.js library to the most updated version (2.5.0).
This version doesn't show the labels on the chart.
I have an example of working one on fiddler: http://jsfiddle.net/g6fajwg8 .
However, I defined my chart exactly as in the example but still can not see the labels on the chart.
Note: There are a lot of questions like this on Google and Stackoverflow but most of them are about previous versions which is working well on them.
var config = {
type: 'pie',
data: {
datasets: [{
data: [
1200,
1112,
533,
202,
105,
],
backgroundColor: [
"#F7464A",
"#46BFBD",
"#FDB45C",
"#949FB1",
"#4D5360",
],
label: 'Dataset 1'
}],
labels: [
"Red",
"Green",
"Yellow",
"Grey",
"Dark Grey"
]
},
options: {
responsive: true,
legend: {
position: 'top',
},
title: {
display: true,
text: 'Chart.js Doughnut Chart'
},
animation: {
animateScale: true,
animateRotate: true
}
}
};
window.pPercentage = new Chart(ChartContext, config);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…