From 4746ef53670003de884182cee3ac4e731098c158 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Mon, 31 Mar 2025 12:21:57 +0300 Subject: [PATCH] UI: Fix chart settings not updating when switching between different chart type widgets in advanced mode --- .../time-series-chart-widget-settings.component.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.ts index dc56c2a328..68d849fd0c 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.ts @@ -105,6 +105,17 @@ export class TimeSeriesChartWidgetSettingsComponent extends WidgetSettingsCompon const params = widgetConfig.typeParameters as any; if (isDefinedAndNotNull(params.chartType)) { this.chartType = params.chartType; + } else { + this.chartType = TimeSeriesChartType.default; + } + if (this.timeSeriesChartWidgetSettingsForm) { + const isStateChartType = this.chartType === TimeSeriesChartType.state; + const hasStatesControl = this.timeSeriesChartWidgetSettingsForm.contains('states'); + if (isStateChartType && !hasStatesControl) { + this.timeSeriesChartWidgetSettingsForm.addControl('states', this.fb.control(widgetConfig.config.settings.states), { emitEvent: false }); + } else if (!isStateChartType && hasStatesControl) { + this.timeSeriesChartWidgetSettingsForm.removeControl('states', { emitEvent: false }); + } } }