import { ElementRef } from '@angular/core' ; import * as Highcharts from 'highcharts/highcharts-gantt' ; import { AsyncSubject , Observable } from 'rxjs' ; license export class HighchartsGantt { private refSubject : AsyncSubject < Highcharts . Chart > = new AsyncSubject ( ) ; ref$ : Observable < Highcharts . Chart > = this . refSubject . asObservable ( ) ; ref : Highcharts . Chart ; constructor ( private options = { series : [ ] } ) { } init ( el ) { if ( ! this . ref ) { Highcharts . ganttChart ( el . nativeElement , this . options , chart => { if ( ! this . ref ) { this . refSubject . next ( chart ) ; this . ref = chart ; this . refSubject . complete ( ) ; } } ) ; } } destroy ( ) { if ( this . ref ) { this . options = this . ref . options ; this . ref . destroy ( ) ; this . ref = undefined ; this . refSubject = new AsyncSubject ( ) ; this . ref$ = this . refSubject . asObservable ( ) ; } } }