gevgeny / angular2-highcharts

:bar_chart: :chart_with_upwards_trend: Highcharts for your Angular project
MIT License
379 stars 113 forks source link

Is it possible to call chart.reflow? #198

Closed ChrisDevinePimss closed 7 years ago

ChrisDevinePimss commented 7 years ago

Having issues with sizing of a highchart inside a bootstrap 4 tab.

I am trying to call chart.reflow (http://api.highcharts.com/highcharts/Chart.reflow) inside the typescript but not sure on how this would be done, especially without getting a typescript error. Any advice would be great thanks

ChrisDevinePimss commented 7 years ago

turns out its because the size of the chart is being set to 100% of the page and not the tab. Probably because the chart is rendering before the tab. is there a way to delay the rendering of the chart to test this theory

DualCatStudio commented 7 years ago

use the dynamic instance in ngAfterViewInit()

ngAfterViewInit() {
       setTimeout(() => {
        if(this.chart) {
            this.chart.reflow();
        }
     },100);
  }
ChrisDevinePimss commented 7 years ago

Not possible due to it being redrawn on a *ngif, also you should not use setTimeout in angular due to AOT (so iv read in the past).

I solved it using observable and a subscribe with a debounce time.