Skip to content

Commit

Permalink
no-issue Fixed issues after review and fixed duplicate realtime and aggr
Browse files Browse the repository at this point in the history
  • Loading branch information
eniosultan committed Nov 12, 2024
1 parent b710e86 commit 050838c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/app/datapoints-graph/charts/y-axis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ export class YAxisService {
const range =
min !== undefined && max !== undefined ? max - min : undefined;

if (range !== undefined && range < 1) {
return val.toFixed(2); // Format to two decimal places for narrow ranges
if (range !== undefined) {
const decimalPlaces = this.getDecimalPlaces(range);
return val.toFixed(decimalPlaces);
}

return new Intl.NumberFormat(this.intlNumberFormatCompliantLocale, {
Expand Down Expand Up @@ -141,6 +142,15 @@ export class YAxisService {
});
}

private getDecimalPlaces(num: number): number {
const numStr = num.toString();
const decimalIndex = numStr.indexOf('.');
if (decimalIndex === -1) {
return 0;
}
return numStr.length - decimalIndex - 1;
}

private getYAxisPlacement(
datapointsWithValues: DatapointWithValues[]
): Map<DatapointWithValues, { position: DatapointAxisType; offset: number }> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,22 @@ export class DatapointsGraphWidgetConfigComponent

dateSelectionChange(dateSelection: DATE_SELECTION): void {
this.dateSelection = dateSelection;

if (dateSelection === DATE_SELECTION.CONFIG) {
this.formGroup.controls.displayDateSelection.enable();
this.formGroup.patchValue({
widgetInstanceGlobalTimeContext: false,
});
} else {
this.formGroup.controls.displayDateSelection.disable();
this.formGroup.patchValue({
widgetInstanceGlobalTimeContext: true,
realtime: false,
});
return;
}

//displayDateSelection should be false and disabled when dateSelection is not CONFIG
this.formGroup.controls.displayDateSelection.disable();
this.formGroup.patchValue({
widgetInstanceGlobalTimeContext: true,
realtime: false,
displayDateSelection: false,
});
}

private assignContextFromContextDashboard(datapoint: KPIDetails) {
Expand Down Expand Up @@ -235,10 +239,11 @@ export class DatapointsGraphWidgetConfigComponent
private initDateSelection(): void {
if (!this.config?.widgetInstanceGlobalTimeContext) {
this.dateSelection = DATE_SELECTION.CONFIG;
} else {
this.dateSelection = DATE_SELECTION.DASHBOARD_CONTEXT;
this.formGroup.controls.displayDateSelection.disable();
return;
}

this.dateSelection = DATE_SELECTION.DASHBOARD_CONTEXT;
this.formGroup.controls.displayDateSelection.disable();
}

private setActiveDatapointsExists() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div class="p-l-16 p-r-16">
<div class="d-flex gap-16 a-i-start">
<div class="btn-group btn-group-sm flex-no-shrink">
<div
class="btn-group btn-group-sm flex-no-shrink"
*ngIf="!displayConfig?.widgetInstanceGlobalTimeContext"
>
<button
type="button"
class="btn btn-default"
Expand Down

0 comments on commit 050838c

Please sign in to comment.