Articles in this section

How to format the axis label text in the Flutter Radial Gauge?

Description

This article describes how to customize or format the label text for the radial axis in Flutter Radial Gauge.

Solution

You can add the prefix or suffix to the axis labels with the labelFormat property of axis and numberFormat property allows you to customize the numeric value of labels.

labelFormat – Allows you to add the required string as a prefix or suffix to axis label values.

numberFormat – Allows you to customize the axis labels with globalized number format.

The following steps explains how to set the labelFormat and numberFormat property to the axis label.

Step 1: Create the radial gauge widget and add a radial axis.

@override
Widget build(BuildContext context) {
  return Scaffold(
    backgroundColor: Colors.white,
    body: Center(
      child: SfRadialGauge(axes: <RadialAxis>[
        RadialAxis(),
      ]),
    ),
  );
}

 

Step 2: To add the prefix or suffix to the axis labels, set the labelFormat property of axis. In the following code example, a suffix symbol “%” is added to axis labels.

axes: <RadialAxis>[
          RadialAxis(
            startAngle: 180,
            endAngle: 360,
            minimum: 0,
            maximum: 100,
            interval: 10,
            labelFormat: '{value}%',
          )
        ],

 

Output

label format

 

Step 3: To customize the numeric value of axis labesl, set the numberFormat property of the axis as shown in following code example.

axes: <RadialAxis>[
          RadialAxis(
            startAngle: 180,
            endAngle: 360,
            minimum: 1000,
            maximum: 10000,
            interval: 1000,
            numberFormat: NumberFormat.compact(),
          )
        ],

 

To use NumberFormat , import 'package:intl/intl.dart' show NumberFormat;

 

Output

number format

View the Github Sample here.

 

 Conclusion

I hope you enjoyed learning about how to format the axis label text in the Flutter Radial Gauge.

You can refer to our Flutter Radial Gauge feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied