From: Afreen Misbah Date: Tue, 21 Apr 2026 20:14:31 +0000 (+0530) Subject: mgr/dashboard: Round off y-axis value of area chart X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a6012c3954830f4b60ef49218d40d4e8ed3bd14c;p=ceph.git mgr/dashboard: Round off y-axis value of area chart - by default y-axos set to 1 for all - the value round off for area chart is seperated from y-axis ticks - also fixes a bug where all IOPS y-ticks being repeated 1,1,0,0 The following values are set for now: IOPS: valueDecimals=0, axisDecimals=1 Latency: valueDecimals=2, axisDecimals=1 Throughput: valueDecimals=2, axisDecimals=1 Consumption: valueDecimals=2, axisDecimals=1 Fixes https://tracker.ceph.com/issues/76191 Signed-off-by: Afreen Misbah --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html index a2e9437cd31b..b6bccde8964f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html @@ -80,6 +80,7 @@ [rawData]="consumptionTrendData" [subHeading]="'Shows last 7 days of storage consumption trends based on recent usage'" [height]="'200px'" + [decimals]="2" [chartType]="'area'"> diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/area-chart/area-chart.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/area-chart/area-chart.component.ts index f6308b59d46f..28b33601bef6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/area-chart/area-chart.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/area-chart/area-chart.component.ts @@ -41,6 +41,7 @@ export class AreaChartComponent implements OnChanges { @Input() rawData!: ChartPoint[]; @Input() chartKey = ''; @Input() decimals = DECIMAL; + @Input() axisDecimals?: number = 1; @Input() customOptions?: Partial; @Input() legendEnabled = true; @Input() subHeading = ''; @@ -150,9 +151,9 @@ export class AreaChartComponent implements OnChanges { ticks: { // Only return numeric part of the formatted string (exclude units) formatter: (tick: number | Date): string => { - const raw = this.formatValueForChart(tick, labels, divisor); + const raw = this.formatValueForChart(tick, labels, divisor, this.axisDecimals); const num = parseFloat(raw); - return num.toString(); + return Number.isNaN(num) ? '' : num.toString(); } } } @@ -161,7 +162,7 @@ export class AreaChartComponent implements OnChanges { enabled: true, showTotal: false, valueFormatter: (value: number): string => - (this.formatValueForChart(value, labels, divisor) || value).toString(), + (this.formatValueForChart(value, labels, divisor, this.decimals) || value).toString(), customHTML: (data, defaultHTML) => this.formatChartTooltip(defaultHTML, data) }, points: { @@ -204,7 +205,12 @@ export class AreaChartComponent implements OnChanges { } // Uses number formatter service to convert chart value based on unit and divisor. - private formatValueForChart(input: number | Date, labels: string[], divisor: number): string { + private formatValueForChart( + input: number | Date, + labels: string[], + divisor: number, + decimals: number + ): string { if (typeof input !== 'number') return ''; return this.numberFormatter.formatFromTo( input, @@ -212,7 +218,7 @@ export class AreaChartComponent implements OnChanges { this.chartDisplayUnit, divisor, labels, - this.decimals + decimals ); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/performance-card/performance-card.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/performance-card/performance-card.component.html index 1b62c8a0c306..64fd7c5bcc06 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/performance-card/performance-card.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/performance-card/performance-card.component.html @@ -42,7 +42,8 @@ chartTitle="Latency" [chartKey]="performanceTypes?.Latency" [dataUnit]="metricUnitMap?.latency" - [rawData]="chartDataSignal()?.latency"> + [rawData]="chartDataSignal()?.latency" + [decimals]="2">
+ [rawData]="chartDataSignal()?.throughput" + [decimals]="2">