From 7b50cd169d83f1154566ad534c6cb6e11788dd9f Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Wed, 11 Oct 2017 17:03:17 +0100 Subject: [PATCH] Fix Cannot read property 'chart' of undefined error Fixes #75 --- src/ng2-highcharts-base.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ng2-highcharts-base.ts b/src/ng2-highcharts-base.ts index 2b0630a..9fdb87b 100644 --- a/src/ng2-highcharts-base.ts +++ b/src/ng2-highcharts-base.ts @@ -26,8 +26,10 @@ export abstract class Ng2HighchartsBase implements OnDestroy, DoCheck { var duration = parseFloat(getComputedStyle(this.hostElement.nativeElement).transitionDuration); var interval = setInterval(() => { if (duration < 0) { clearInterval(interval); } - this.pChart.reflow(); duration -= 50; + try { + this.pChart.reflow(); + } catch (e) {} }, duration); } @@ -55,4 +57,4 @@ export abstract class Ng2HighchartsBase implements OnDestroy, DoCheck { } abstract draw(opt: any /*HighchartsOptions*/): void; -} \ No newline at end of file +}