[英]How to render ng2 chart after it's disabled
我有以下條形圖在onInit上被禁用
<div style="display: block" *ngIf="showBar">
<canvas baseChart height="75"
[data]="barChartData"
[labels]="barChartLabels"
[chartType]="'bar'"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
</div>
bar-graph.component.ts文件:
export class BarGraphComponent implements OnInit {
showBar: boolean;
ngOnInit() {
this.showBar = false;
}
我想使用switch語句在app.components.ts文件中啟用此圖表(根據上一張圖表傳遞的內容進行更改)。 但是在應用程序component.ts文件中,如果我執行此操作。showBar = true(使用發射器),它仍然不起作用。 任何指導將不勝感激。
今天早上解決了這個問題。 而不是在bar-graph.component.html中聲明* ngIf。 應該在app.component.html中聲明
<app-bar-graph *ngIf="showBarGraph" [config]="barConfig" (notify)="onNotify($event)"></app-bar-graph>
然后在app.component.ts里面
export class AppComponent implements OnInit {
showBarGraph: boolean;
... logic goes here ....
this.showBarGraph = true;
希望這可以幫助某人
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.