]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Round off y-axis value of area chart 68525/head
authorAfreen Misbah <afreen@ibm.com>
Tue, 21 Apr 2026 20:14:31 +0000 (01:44 +0530)
committerAfreen Misbah <afreen@ibm.com>
Wed, 22 Apr 2026 10:03:18 +0000 (15:33 +0530)
- 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 <afreen@ibm.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/overview/storage-card/overview-storage-card.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/components/area-chart/area-chart.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/components/performance-card/performance-card.component.html

index a2e9437cd31b013427f0c1ae1226d918b9d94d3f..b6bccde8964f8ad75e92462acfd0df1e2110b273 100644 (file)
@@ -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'">
       </cd-area-chart>
     </div>
index f6308b59d46f8fa1ba84babecce281c5b6a945a6..28b33601bef69393845d7488d1636c590e61a63a 100644 (file)
@@ -41,6 +41,7 @@ export class AreaChartComponent implements OnChanges {
   @Input() rawData!: ChartPoint[];
   @Input() chartKey = '';
   @Input() decimals = DECIMAL;
+  @Input() axisDecimals?: number = 1;
   @Input() customOptions?: Partial<AreaChartOptions>;
   @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
     );
   }
 }
index 1b62c8a0c306424bcca235c7479b02eb1dfe5a96..64fd7c5bcc0619ce015bf7fd365d1ccbc8fc6c61 100644 (file)
@@ -42,7 +42,8 @@
             chartTitle="Latency"
             [chartKey]="performanceTypes?.Latency"
             [dataUnit]="metricUnitMap?.latency"
-            [rawData]="chartDataSignal()?.latency">
+            [rawData]="chartDataSignal()?.latency"
+            [decimals]="2">
           </cd-area-chart>
         </div>
         <div cdsCol
@@ -52,7 +53,8 @@
             chartTitle="Throughput"
             [chartKey]="performanceTypes?.Throughput"
             [dataUnit]="metricUnitMap?.throughput"
-            [rawData]="chartDataSignal()?.throughput">
+            [rawData]="chartDataSignal()?.throughput"
+            [decimals]="2">
           </cd-area-chart>
         </div>
       </div>