Skip to content

Commit

Permalink
Added optionsError output to give control over error handling in .set…
Browse files Browse the repository at this point in the history
…Option() (#240)

Co-authored-by: trajnisz <TomaszRajnisz@DESKTOP-7SFS8I0.com>
  • Loading branch information
trajnisz and trajnisz authored Jul 24, 2020
1 parent 05f3e86 commit 535bb6c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions projects/ngx-echarts/src/lib/ngx-echarts.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class NgxEchartsDirective implements OnChanges, OnDestroy, OnInit, DoChec

// ngx-echarts events
@Output() chartInit = new EventEmitter<any>();
@Output() optionsError = new EventEmitter<Error>();

// echarts mouse events
@Output() chartClick = this.createLazyEvent('click');
Expand Down Expand Up @@ -166,7 +167,13 @@ export class NgxEchartsDirective implements OnChanges, OnDestroy, OnInit, DoChec

private setOption(option: any, opts?: any) {
if (this.chart) {
this.chart.setOption(option, opts);
try {
this.chart.setOption(option, opts);
}
catch (e){
console.error(e);
this.optionsError.emit(e);
}
}
}

Expand Down Expand Up @@ -206,7 +213,7 @@ export class NgxEchartsDirective implements OnChanges, OnDestroy, OnInit, DoChec
this.chartInit.emit(this.chart);
}

this.chart.setOption(this.options, true);
this.setOption(this.options, true);
}
}

Expand Down

0 comments on commit 535bb6c

Please sign in to comment.