我在用chart.js来表示爱奥尼亚。图表在根页上加载得很好,但是对于导航堆栈中根页之后的每一页,图表都显示为空白。
这是
.ts
代码:
ionViewDidLoad()
{
this.profile_donutCanvas = <HTMLCanvasElement> document.getElementById("profile_donutChart");
this.profile_donutCtx = this.profile_donutCanvas.getContext('2d');
this.profile_donutChart = new Chart(this.profile_donutCtx, {
type: 'doughnut',
data: {
labels: ['', ''],
datasets: [{
data: [100, 0],
backgroundColor: [
'rgba(182, 54, 235, 1)',
'rgba(255, 255, 255, 1)'
],
borderWidth: 0
}]
},
options: {
cutoutPercentage: 95,
legend:{
display:false
},
tooltips: {
enabled:false
}
}
});
}
这里是
.html
代码:
<canvas id="profile_donutChart" width="100" height="100" padding></canvas>
有人知道这可能是什么原因吗?
谢谢,
特洛伊