This doughnut is made of using SVG。
But chart.JS cannot support SVG's
那么有没有办法像上面的图片一样创建甜甜圈。
答案 0 :(得分:1)
可以这样做:
var canvas = document.getElementById('myChart');
var data = {
labels: ["1", "2"],
datasets: [{
data: [105, 20],
backgroundColor: ['da5d78', 'gray'],
}]
};
var options = {
rotation: 0,
cutoutPercentage: 85,
legend: {
display: false
},
tooltips: {
enabled: false
}
}
Chart.Doughnut(canvas, {
data: data,
options: options
});
HTML
<canvas id="myChart" width="400" height="200"></canvas>
了解工作jsfiddle
的效果有关选项的解释,请参阅docs(cutoutPercentage
,rotation
等)。