【发布时间】:2017-10-07 09:04:30
【问题描述】:
如何使用 Chart.js 和 Angular2 在环形图中添加文本标签? 我看到了有关此主题的一些答案,但由于我正在使用 Ionic2 应用程序,因此没有一个对我有用。 这是我的简化代码:
import { Chart } from 'chart.js';
@ViewChild('doughnutCanvas') doughnutCanvas;
ionViewDidEnter() {
this.doughnutChart = new Chart(this.doughnutCanvas.nativeElement, {
type: 'doughnut',
data: {
labels: this.titles,
datasets: [{
label: '# of Work',
data: this.times,
backgroundColor: [
'rgba(255, 99, 132, 0.5)',
'rgba(54, 162, 235, 0.5)'
],
hoverBackgroundColor: [
"#FF6384",
"#36A2EB"
]
}]
},
options: {
responsive: true,
legend: {
display: false
}
}
});
}
【问题讨论】:
标签: javascript angular charts ionic2 chart.js