1
我正在使用Chart.js我想要一個半圓環圖,就像下圖所示。但我沒有改變派的厚度。我試過財產innerRadius但它仍然不工作Chart.js(甜甜圈圖)中的內半徑沒有變化
這裏是我的代碼
public getHalfDoughnutChart(records) {
let data = {
labels: ["Worked Hours","Remaining Hours"],
datasets: [{
label: 'Today\'s Worked Hours',
data: [records.length? records[0].duration.hour: 0,9],
backgroundColor: [
'rgba(75, 174, 79, 1)',
'rgba(255, 255, 255, 0)'
]
}]
};
let options = {
circumference: Math.PI,
rotation: 1.0 * Math.PI,
innerRadius: "10%",
legend: {
display: false
},
layout:{
padding:40
},
}
return this.getChart(this.halfDoughnutCanvas.nativeElement, "doughnut", data, options);
}
getChart(context, chartType, data, options?) {
return new Chart(context, {
type: chartType,
data: data,
options: options
});
}
已經嘗試過,但沒有工作:( –
什麼chart.js之版本你使用? – Leguest
它的工作感謝:) –