+
-
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts
index ebc24ddd22..83f1b6623a 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts
@@ -42,6 +42,8 @@ import {
import { deepClone } from '@core/utils';
import { TranslateService } from '@ngx-translate/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import { TimeSeriesChartYAxesPanelComponent } from '@home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component';
+import { ValueSourceType } from '@shared/models/widget-settings.models';
@Component({
selector: 'tb-time-series-chart-y-axis-row',
@@ -85,6 +87,7 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
constructor(private fb: UntypedFormBuilder,
private translate: TranslateService,
private popoverService: TbPopoverService,
+ private timeSeriesChartYAxesPanel: TimeSeriesChartYAxesPanelComponent,
private renderer: Renderer2,
private viewContainerRef: ViewContainerRef,
private cd: ChangeDetectorRef,
@@ -97,8 +100,8 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
position: [null, []],
units: [null, []],
decimals: [null, []],
- min: [null, []],
- max: [null, []],
+ min: this.createLimitFormGroup(),
+ max: this.createLimitFormGroup(),
show: [null, []]
});
this.axisFormGroup.valueChanges.pipe(
@@ -132,17 +135,19 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
writeValue(value: TimeSeriesChartYAxisSettings): void {
this.modelValue = value;
- this.axisFormGroup.patchValue(
- {
- label: value.label,
- position: value.position,
- units: value.units,
- decimals: value.decimals,
- min: value.min,
- max: value.max,
- show: value.show,
- }, {emitEvent: false}
- );
+ const min = this.normalizeLimit(value.min);
+ const max = this.normalizeLimit(value.max);
+
+ this.axisFormGroup.patchValue({
+ label: value.label,
+ position: value.position,
+ units: value.units,
+ decimals: value.decimals,
+ min,
+ max,
+ show: value.show,
+ }, { emitEvent: false });
+
this.updateValidators();
this.cd.markForCheck();
}
@@ -165,7 +170,10 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
axisType: 'yAxis',
panelTitle: this.translate.instant('widgets.time-series-chart.axis.y-axis-settings'),
axisSettings: deepClone(this.modelValue),
- advanced: this.advanced
+ advanced: this.advanced,
+ aliasController: this.timeSeriesChartYAxesPanel.aliasController,
+ dataKeyCallbacks: this.timeSeriesChartYAxesPanel.dataKeyCallbacks,
+ datasource: this.timeSeriesChartYAxesPanel.datasource
},
isModal: true
});
@@ -190,6 +198,10 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
}
}
+ checkIsConstantLimit(limit: 'min' | 'max') {
+ return this.axisFormGroup.get(`${limit}.type`)?.value === ValueSourceType.constant;
+ }
+
private updateValidators() {
const show: boolean = this.axisFormGroup.get('show').value;
if (show) {
@@ -203,10 +215,21 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
this.axisFormGroup.get('units').disable({emitEvent: false});
this.axisFormGroup.get('decimals').disable({emitEvent: false});
}
+ if(!this.checkIsConstantLimit('min')){
+ this.axisFormGroup.get('min').disable({emitEvent: false});
+ } else {
+ this.axisFormGroup.get('min').enable({emitEvent: false});
+ }
+ if(!this.checkIsConstantLimit('max')){
+ this.axisFormGroup.get('max').disable({emitEvent: false});
+ } else {
+ this.axisFormGroup.get('max').enable({emitEvent: false});
+ }
+
}
private updateModel() {
- const value = this.axisFormGroup.value;
+ const value = this.axisFormGroup.getRawValue();
this.modelValue.label = value.label;
this.modelValue.position = value.position;
this.modelValue.units = value.units;
@@ -216,4 +239,39 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
this.modelValue.show = value.show;
this.propagateChange(this.modelValue);
}
+
+ private createLimitFormGroup() {
+ return this.fb.group({
+ type: [ValueSourceType.constant, []],
+ value: [null, []],
+ latestKey: [null, []],
+ latestKeyType: [null, []],
+ entityAlias: [null, []],
+ entityKey: [null, []],
+ entityKeyType: [null, []]
+ });
+ }
+
+ private normalizeLimit(limit: any) {
+ const base = {
+ type: ValueSourceType.constant,
+ value: null,
+ latestKey: null,
+ latestKeyType: null,
+ entityAlias: null,
+ entityKey: null,
+ entityKeyType: null
+ };
+
+ if (limit == null) return base;
+
+ if (typeof limit === 'number' || typeof limit === 'string') {
+ return { ...base, type: ValueSourceType.constant, value: Number(limit) };
+ }
+
+ return {
+ ...base,
+ ...limit,
+ };
+ }
}
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts
index 233b202684..385bc55495 100644
--- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts
+++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/widget-settings-common.module.ts
@@ -267,6 +267,7 @@ import {
import {
ShapeFillStripeSettingsPanelComponent
} from '@home/components/widget/lib/settings/common/map/shape-fill-stripe-settings-panel.component';
+import { AxisScaleRowComponent } from './axis-scale-row.component';
@NgModule({
declarations: [
@@ -372,7 +373,8 @@ import {
DataKeysComponent,
DataKeyConfigDialogComponent,
DataKeyConfigComponent,
- WidgetSettingsComponent
+ WidgetSettingsComponent,
+ AxisScaleRowComponent
],
imports: [
CommonModule,
@@ -453,7 +455,8 @@ import {
DataKeysComponent,
DataKeyConfigDialogComponent,
DataKeyConfigComponent,
- WidgetSettingsComponent
+ WidgetSettingsComponent,
+ AxisScaleRowComponent
],
providers: [
ColorSettingsComponentService,
diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json
index 54492e06b5..5a786e28a8 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -8050,6 +8050,14 @@
"update-animation-delay": "Update animation delay"
},
"chart-axis": {
+ "limit":"Limit",
+ "source": "Source",
+ "key-value": "Key / Value",
+ "value-required": "Value is required.",
+ "entity-key-required": "Entity key is required.",
+ "key-required": "Key is required.",
+ "scale-limits": "Scale limits",
+ "scale-appearance": "Scale appearance",
"scale": "Scale",
"scale-min": "min",
"scale-max": "max",
diff --git a/ui-ngx/tailwind.config.js b/ui-ngx/tailwind.config.js
index d675da4cda..bc516ddf40 100644
--- a/ui-ngx/tailwind.config.js
+++ b/ui-ngx/tailwind.config.js
@@ -84,7 +84,8 @@ module.exports = {
'25': '6.25rem',
'37.5': '9.375rem',
'62.5': '15.625rem',
- '72.5': '18.125rem'
+ '72.5': '18.125rem',
+ '40%': '40%'
},
flex: {
full: '1 1 100%'