我使用 chart js 为我的项目绘制漂亮的图表。现在我需要像这样在圆环图中绘制饼图:
圆环图中的数据不依赖于内部饼图中的数据。颜色也无所谓。有没有人有想法?
我只能分别画饼图和圆环图))
function drawOperatorStatusChart(labels, data, title, colors) {
new Chart(document.getElementById("pie_chart_operator"), {
type: 'pie',
data: {
labels: labels,
datasets: [{
label: data,
backgroundColor: colors,
data: data
}]
},
options: {
tooltips: {
callbacks: {
label: function (tooltipItem, data) {
return secondsToHHMMSS(data['datasets'][0]['data'][tooltipItem['index']]);
}
}
},
title: {
display: true,
text: title
}
}
});
}
function drawReportDetailedDoughnutChart(labels, data, title, colors) {
var ctx = document.getElementById('operator_detailed_doughnut_chart').getContext('2d');
new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
label: "",
backgroundColor: colors,
data: data
}]
},
options: {
responsive: true,
legend: {
position: 'top',
},
title: {
display: true,
text: title
},
animation: {
animateScale: true,
animateRotate: true
}
}
});
}
最佳答案
关于javascript - 使用图表 js 的圆环图中的饼图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50273100/