Chart in Angular not displayed until windows resize

0đź‘Ť

âś…

There’s a reason why you’re seeing that chart after resize because you’re nesting your API calls and angular change-detection doesn’t work well with nested functions. There’re 2 solutions to this problem.

  1. You can flatten your API calls and remove nesting or

  2. you can use changeDetectorRef to trigger the change detection by

    constructor(
              private cdr: ChangeDetectorRef
    
    ) {}
    

    use the below statement after your calculation is finished.

    this.cdr.markForCheck();

I’d advise you to go for the first option.

đź‘Ť:0

Maybe, you can try it with setTimeout. Because while the the chart rendering, the container has no size

Leave a comment