Fix time series charts initialization
This commit is contained in:
parent
2355ebc852
commit
79803292b6
@ -139,8 +139,9 @@ export class TbTimeSeriesChart {
|
||||
this.settings = mergeDeep({} as TimeSeriesChartSettings,
|
||||
timeSeriesChartDefaultSettings,
|
||||
this.inputSettings as TimeSeriesChartSettings);
|
||||
const dashboardPageElement = this.ctx.$containerParent.parents('.tb-dashboard-page');
|
||||
this.darkMode = this.settings.darkMode || dashboardPageElement.hasClass('dark');
|
||||
const $dashboardPageElement = this.ctx.$containerParent.parents('.tb-dashboard-page');
|
||||
const dashboardPageElement = $dashboardPageElement.length ? $($dashboardPageElement[$dashboardPageElement.length-1]) : null;
|
||||
this.darkMode = this.settings.darkMode || dashboardPageElement?.hasClass('dark');
|
||||
this.setupYAxes();
|
||||
this.setupData();
|
||||
this.setupThresholds();
|
||||
@ -154,8 +155,9 @@ export class TbTimeSeriesChart {
|
||||
});
|
||||
this.shapeResize$.observe(this.chartElement);
|
||||
}
|
||||
if (dashboardPageElement) {
|
||||
this.darkModeObserver = new MutationObserver(mutations => {
|
||||
for(let mutation of mutations) {
|
||||
for (const mutation of mutations) {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
||||
const darkMode = dashboardPageElement.hasClass('dark');
|
||||
this.setDarkMode(darkMode);
|
||||
@ -164,6 +166,7 @@ export class TbTimeSeriesChart {
|
||||
});
|
||||
this.darkModeObserver.observe(dashboardPageElement[0], {attributes: true});
|
||||
}
|
||||
}
|
||||
|
||||
public update(): void {
|
||||
for (const item of this.dataItems) {
|
||||
@ -269,7 +272,7 @@ export class TbTimeSeriesChart {
|
||||
}
|
||||
this.yMinSubject.complete();
|
||||
this.yMaxSubject.complete();
|
||||
this.darkModeObserver.disconnect();
|
||||
this.darkModeObserver?.disconnect();
|
||||
}
|
||||
|
||||
public resize(): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user