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,
|
this.settings = mergeDeep({} as TimeSeriesChartSettings,
|
||||||
timeSeriesChartDefaultSettings,
|
timeSeriesChartDefaultSettings,
|
||||||
this.inputSettings as TimeSeriesChartSettings);
|
this.inputSettings as TimeSeriesChartSettings);
|
||||||
const dashboardPageElement = this.ctx.$containerParent.parents('.tb-dashboard-page');
|
const $dashboardPageElement = this.ctx.$containerParent.parents('.tb-dashboard-page');
|
||||||
this.darkMode = this.settings.darkMode || dashboardPageElement.hasClass('dark');
|
const dashboardPageElement = $dashboardPageElement.length ? $($dashboardPageElement[$dashboardPageElement.length-1]) : null;
|
||||||
|
this.darkMode = this.settings.darkMode || dashboardPageElement?.hasClass('dark');
|
||||||
this.setupYAxes();
|
this.setupYAxes();
|
||||||
this.setupData();
|
this.setupData();
|
||||||
this.setupThresholds();
|
this.setupThresholds();
|
||||||
@ -154,15 +155,17 @@ export class TbTimeSeriesChart {
|
|||||||
});
|
});
|
||||||
this.shapeResize$.observe(this.chartElement);
|
this.shapeResize$.observe(this.chartElement);
|
||||||
}
|
}
|
||||||
|
if (dashboardPageElement) {
|
||||||
this.darkModeObserver = new MutationObserver(mutations => {
|
this.darkModeObserver = new MutationObserver(mutations => {
|
||||||
for(let mutation of mutations) {
|
for (const mutation of mutations) {
|
||||||
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
||||||
const darkMode = dashboardPageElement.hasClass('dark');
|
const darkMode = dashboardPageElement.hasClass('dark');
|
||||||
this.setDarkMode(darkMode);
|
this.setDarkMode(darkMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.darkModeObserver.observe(dashboardPageElement[0], { attributes: true });
|
this.darkModeObserver.observe(dashboardPageElement[0], {attributes: true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public update(): void {
|
public update(): void {
|
||||||
@ -269,7 +272,7 @@ export class TbTimeSeriesChart {
|
|||||||
}
|
}
|
||||||
this.yMinSubject.complete();
|
this.yMinSubject.complete();
|
||||||
this.yMaxSubject.complete();
|
this.yMaxSubject.complete();
|
||||||
this.darkModeObserver.disconnect();
|
this.darkModeObserver?.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public resize(): void {
|
public resize(): void {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user