Skip to content

Instantly share code, notes, and snippets.

@kagklis
Last active December 5, 2022 21:17
Show Gist options
  • Save kagklis/d11014e314604bcc54cae59a0949f035 to your computer and use it in GitHub Desktop.
Save kagklis/d11014e314604bcc54cae59a0949f035 to your computer and use it in GitHub Desktop.
@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