Chart - format label

Hello,

I want to format my axis label as

'{value} l/min'

but I also want to round value to one decimal. How can I do that? The documentation gives me either/or.


4 Replies

NP Nishanthi Panner Selvam Syncfusion Team December 6, 2023 11:25 AM UTC

Ewa,


Greetings from Syncfusion.


We have analyzed your query based on that we suggest you to set labelFormat as ‘n1’. This will round values to one decimal place and using axisLabelRender event we can add ‘l/min’ to the label.


We have attached code-snippet, sample and screenshot for your reference.


Code-snippet:


public primaryYAxis: Object = {

        labelFormat: 'n1'

    };

public axisLabelRender(args): void {

        if(args.axis.name === "primaryYAxis") {

        args.text = args.text + ' l/min';

    }

};


Screenshot:



Sample: https://stackblitz.com/edit/angular-su2b64-eizhbg?file=src%2Fapp.component.ts


Documentation: https://ej2.syncfusion.com/angular/documentation/chart/data-labels#format


Kindly revert us if you have any concerns.


Regards,

Nishanthi



EB Ewa Baumgarten December 7, 2023 08:32 AM UTC

Hello Nishanti,

thank you for your reply, that does indeed sound like the solution to my problem. Would it perhaps be possible to update the documentation? It makes no mention of AxisLabelRender that I have been able to find.

Thank you!



NP Nishanthi Panner Selvam Syncfusion Team December 8, 2023 08:43 AM UTC

Ewa,


We have logged task for the request to add documentation for the axisLabelRender event. This will be available in our Volume 1 release in 2024, which is tentatively scheduled to be rolled out at the end of March 2024.


Kindly revert us if you have any concerns.


Regards,

Nishanthi



NP Nishanthi Panner Selvam Syncfusion Team April 25, 2024 07:08 AM UTC

Ewa,


Thank you for your patience,


We're pleased to inform you that we've added a Knowledge Base (KB) article covering the axisLabelRender event. For your convenience, we've attached the KB document for your reference.


KB: https://support.syncfusion.com/kb/article/15526/how-can-the-globalized-axis-label-be-further-formatted-in-angular-charts


Kindly revert us if you have any concerns.


Regards,

Nishanthi


Loader.
Up arrow icon