Last active
December 5, 2022 21:17
-
-
Save kagklis/d11014e314604bcc54cae59a0949f035 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
// ... | |
}) | |
export class ChartComponent implements AfterViewInit { | |
@ViewChild('chartCanvas') chartCanvas!: any; | |
private dataSubscription!: Subscription; | |
public isLoading: boolean = true; | |
constructor(private dataService: DataService) {} | |
ngAfterViewInit(): void { | |
this.dataSubscription = this.dataService.data$.subscribe( | |
(data: ChartData) => { | |
// Do something with the generated data! | |
if (typeof Worker !== undefined) { | |
this.renderWithWorker(data); | |
} else { | |
this.renderChart(data); | |
this.isLoading = false; | |
} | |
} | |
); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment