@@ -471,22 +471,37 @@ var FusionChartsComponent = /** @class */ (function () {
471471 this . chartObj . chartType ( this . type ) ;
472472 }
473473 } ;
474- FusionChartsComponent . prototype . attachChartEventListener = function ( chartObj , eventName ) {
475- var _this_1 = this ;
476- chartObj . addEventListener ( eventName , function ( eventObj , dataObj ) {
477- var fEventObj = { eventObj : { } , dataObj : { } } ;
478- if ( eventObj )
479- fEventObj . eventObj = eventObj ;
480- if ( dataObj )
481- fEventObj . dataObj = dataObj ;
482- _this_1 [ eventName ] . emit ( fEventObj ) ;
474+ /*
475+ // Removed as some events will be fired
476+ attachChartEventListener(chartObj: any, eventName: string){
477+ chartObj.addEventListener(eventName, (eventObj:any, dataObj:any) => {
478+ let fEventObj:FusionChartsEvent = { eventObj:{}, dataObj:{} };
479+ if(eventObj) fEventObj.eventObj = eventObj;
480+ if(dataObj) fEventObj.dataObj = dataObj;
481+ this[eventName].emit(fEventObj);
483482 });
484- } ;
485- FusionChartsComponent . prototype . attachAllChartEvents = function ( chartObj , eventList$$1 ) {
483+ }
484+
485+ attachAllChartEvents(chartObj:any, eventList:Array<string>){
486+ eventList.forEach(eventName => {
487+ this.attachChartEventListener(chartObj, eventName);
488+ });
489+ }
490+ */
491+ FusionChartsComponent . prototype . generateEventsCallback = function ( eventList$$1 ) {
486492 var _this_1 = this ;
493+ var events = { } ;
487494 eventList$$1 . forEach ( function ( eventName ) {
488- _this_1 . attachChartEventListener ( chartObj , eventName ) ;
495+ events [ eventName ] = function ( eventObj , dataObj ) {
496+ var fEventObj = { eventObj : { } , dataObj : { } } ;
497+ if ( eventObj )
498+ fEventObj . eventObj = eventObj ;
499+ if ( dataObj )
500+ fEventObj . dataObj = dataObj ;
501+ _this_1 [ eventName ] . emit ( fEventObj ) ;
502+ } ;
489503 } ) ;
504+ return events ;
490505 } ;
491506 FusionChartsComponent . prototype . ngAfterViewInit = function ( ) {
492507 var _this = this , params = _this . constructerParams , configObj = _this . configObj || ( _this . configObj = { } ) ;
@@ -502,13 +517,19 @@ var FusionChartsComponent = /** @class */ (function () {
502517 }
503518 }
504519 if ( configObj [ 'type' ] ) {
520+ var events = _this . generateEventsCallback ( _this . eventList ) ;
521+ if ( ! configObj [ 'events' ] ) {
522+ configObj [ 'events' ] = events ;
523+ }
524+ else {
525+ configObj [ 'events' ] = Object . assign ( events , configObj [ 'events' ] ) ;
526+ }
505527 _this . chartObj = FusionChartsConstructor ( _this . fusionchartsService , configObj ) ;
506528 this . initialized . emit ( { chart : _this . chartObj } ) ;
507529 // configObj['renderAt'] = 'container-' + _this.chartObj.id;
508530 // _this.containerId = _this.chartObj.id;
509531 this . zone . runOutsideAngular ( function ( ) {
510532 setTimeout ( function ( ) {
511- _this . attachAllChartEvents ( _this . chartObj , _this . eventList ) ;
512533 _this . chartObj . render ( _this . element . nativeElement . querySelector ( 'div' ) ) ;
513534 } , 1 ) ;
514535 } ) ;
0 commit comments