From 4c818898e0b50e03e853776278ee720dc8aed7ef Mon Sep 17 00:00:00 2001 From: "ana.espejo" Date: Thu, 21 Nov 2024 11:38:29 -0300 Subject: [PATCH] =?UTF-8?q?fix(chart):=20corrige=20espa=C3=A7o=20em=20bran?= =?UTF-8?q?co?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige espaço em branco gerado ao atribuir números quebrados nas séries dentro de um po-widget. Fixes DTHFUI-10263 --- .../src/lib/components/po-chart/po-chart.component.spec.ts | 6 ++++++ .../ui/src/lib/components/po-chart/po-chart.component.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/projects/ui/src/lib/components/po-chart/po-chart.component.spec.ts b/projects/ui/src/lib/components/po-chart/po-chart.component.spec.ts index d143faefe..5f90a32d4 100644 --- a/projects/ui/src/lib/components/po-chart/po-chart.component.spec.ts +++ b/projects/ui/src/lib/components/po-chart/po-chart.component.spec.ts @@ -378,6 +378,12 @@ describe('PoChartComponent:', () => { expect(component['getAxisXLabelArea'](axisXLabel)).toBe(56); }); + + it('getAxisXLabelArea: should calculate and return width for a decimal number', () => { + const axisXLabel = 12.111111111111; + + expect(component['getAxisXLabelArea'](axisXLabel)).toBe(56); + }); }); describe('Template', () => { diff --git a/projects/ui/src/lib/components/po-chart/po-chart.component.ts b/projects/ui/src/lib/components/po-chart/po-chart.component.ts index 95286ab8c..2637b06e4 100644 --- a/projects/ui/src/lib/components/po-chart/po-chart.component.ts +++ b/projects/ui/src/lib/components/po-chart/po-chart.component.ts @@ -181,7 +181,9 @@ export class PoChartComponent extends PoChartBaseComponent implements AfterViewI const spanElement = this.renderer.createElement('span'); this.renderer.addClass(spanElement, 'po-chart-axis-x-label'); - spanElement.innerHTML = axisXLabel; + + const formattedLabel = typeof axisXLabel === 'number' ? axisXLabel.toFixed(2) : axisXLabel; + spanElement.innerHTML = formattedLabel; this.renderer.appendChild(this.elementRef.nativeElement, spanElement); const axisXLabelWidth = Math.ceil(spanElement.offsetWidth) + labelPoChartPadding;