mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 08:20:13 +01:00
fix(charts): unsubscribe when destroy component
This commit is contained in:
parent
08851fdfed
commit
549be765f0
19 changed files with 152 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, AfterViewInit } from '@angular/core';
|
||||
import { Component, AfterViewInit, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
|
||||
@Component({
|
||||
|
|
@ -7,14 +7,15 @@ import { NbThemeService } from '@nebular/theme';
|
|||
<div echarts [options]="options" class="echart"></div>
|
||||
`,
|
||||
})
|
||||
export class EchartsMultipleXaxisComponent implements AfterViewInit {
|
||||
export class EchartsMultipleXaxisComponent implements AfterViewInit, OnDestroy {
|
||||
options: any = {};
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private theme: NbThemeService) {
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.theme.getJsTheme().subscribe(config => {
|
||||
this.themeSubscription = this.theme.getJsTheme().subscribe(config => {
|
||||
|
||||
const colors: any = config.variables;
|
||||
const echarts: any = config.variables.echarts;
|
||||
|
|
@ -158,4 +159,8 @@ export class EchartsMultipleXaxisComponent implements AfterViewInit {
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue