Browse Source

fixed errors

pull/14488/head
Maksym Tsymbarov 10 months ago
parent
commit
dd7972721a
  1. 10
      ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart.ts
  2. 3
      ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.html
  3. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/axis-scale-row.component.html
  4. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component.ts
  5. 60
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts

10
ui-ngx/src/app/modules/home/components/widget/lib/chart/time-series-chart.ts

@ -307,10 +307,12 @@ export class TbTimeSeriesChart {
const data = this.ctx.latestData.find(d => d.dataKey === yAxis.maxLatestDataKey); const data = this.ctx.latestData.find(d => d.dataKey === yAxis.maxLatestDataKey);
if (data?.data[0]) { if (data?.data[0]) {
const value = this.parseAxisLimitData(data.data[0][1], yAxis.unitConvertor); const value = this.parseAxisLimitData(data.data[0][1], yAxis.unitConvertor);
if (yAxis.option.max !== value) { // if (yAxis.option.max !== value) {
yAxis.option.max = value; // yAxis.option.max = value;
update = true; // update = true;
} // }
update = true;
yAxis.option.max = 124;
} }
} }
} }

3
ui-ngx/src/app/modules/home/components/widget/lib/settings/chart/time-series-chart-widget-settings.component.html

@ -62,6 +62,9 @@
</tb-time-series-chart-states-panel> </tb-time-series-chart-states-panel>
<tb-time-series-chart-y-axes-panel <tb-time-series-chart-y-axes-panel
formControlName="yAxes" formControlName="yAxes"
[aliasController]="aliasController"
[dataKeyCallbacks]="dataKeyCallbacks"
[datasource]="datasource"
(axisRemoved)="yAxisRemoved($event)" (axisRemoved)="yAxisRemoved($event)"
[supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion" [supportsUnitConversion]="widgetConfig.typeParameters.supportsUnitConversion"
advanced> advanced>

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/axis-scale-row.component.html

@ -35,7 +35,7 @@
formControlName="entityAlias"> formControlName="entityAlias">
</tb-entity-alias-input> </tb-entity-alias-input>
</div> </div>
<div class="flex-grow flex-shrink" [class]="isPanelView ? 'basis-1/2' : 'basis-40%'"> <div class="flex-grow flex-shrink max-w-5/12" [class]="isPanelView ? 'basis-1/2' : 'basis-40%'">
<mat-form-field *ngIf="limitForm.get('type').value === ValueSourceType.constant" <mat-form-field *ngIf="limitForm.get('type').value === ValueSourceType.constant"
appearance="outline" class="tb-inline-field !w-full number" subscriptSizing="dynamic" appearance="outline" class="tb-inline-field !w-full number" subscriptSizing="dynamic"
[class.tb-suffix-absolute]="!limitForm.get('value').value"> [class.tb-suffix-absolute]="!limitForm.get('value').value">

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axes-panel.component.ts

@ -250,6 +250,8 @@ export class TimeSeriesChartYAxesPanelComponent implements ControlValueAccessor,
const foundYAxisKeys: DataKey[] = []; const foundYAxisKeys: DataKey[] = [];
for(const yAxis of yAxes) { for(const yAxis of yAxes) {
console.log("yAxis",yAxis)
const min = yAxis.min as ValueSourceConfig; const min = yAxis.min as ValueSourceConfig;
const max = yAxis.max as ValueSourceConfig; const max = yAxis.max as ValueSourceConfig;
if (min.type === ValueSourceType.latestKey) { if (min.type === ValueSourceType.latestKey) {

60
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/chart/time-series-chart-y-axis-row.component.ts

@ -135,17 +135,19 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
writeValue(value: TimeSeriesChartYAxisSettings): void { writeValue(value: TimeSeriesChartYAxisSettings): void {
this.modelValue = value; this.modelValue = value;
this.axisFormGroup.patchValue( const min = this.normalizeLimit(value.min);
{ const max = this.normalizeLimit(value.max);
label: value.label,
position: value.position, this.axisFormGroup.patchValue({
units: value.units, label: value.label,
decimals: value.decimals, position: value.position,
min: value.min, units: value.units,
max: value.max, decimals: value.decimals,
show: value.show, min,
}, {emitEvent: false} max,
); show: value.show,
}, { emitEvent: false });
this.updateValidators(); this.updateValidators();
this.cd.markForCheck(); this.cd.markForCheck();
} }
@ -223,7 +225,8 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
} }
private updateModel() { private updateModel() {
const value = this.axisFormGroup.value; const value = this.axisFormGroup.getRawValue();
console.log("value", value);
this.modelValue.label = value.label; this.modelValue.label = value.label;
this.modelValue.position = value.position; this.modelValue.position = value.position;
this.modelValue.units = value.units; this.modelValue.units = value.units;
@ -238,7 +241,36 @@ export class TimeSeriesChartYAxisRowComponent implements ControlValueAccessor, O
return this.fb.group({ return this.fb.group({
type: [ValueSourceType.constant, []], type: [ValueSourceType.constant, []],
value: [null, []], value: [null, []],
entityAlias: [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,
};
} }
} }

Loading…
Cancel
Save