How to remove a comma from the category axis labels in .NET MAUI Chart (SfCartesianChart)?
In this article, we will explore how to eliminate commas in category axis labels in .NET MAUI Charts using ArrangeByIndex. By default, the ArrangeByIndex is true. By leveraging the LabelCreated event in the CategoryAxis, you can display only the x-values of the first series individually, rather than displaying all series x-values separated by commas.
The following code snippet illustrates the process of removing the commas from axis labels in the CategoryAxis by utilizing the label created event and customizing the axis labels to suit your specific requirements.
XAML
<chart:SfCartesianChart.XAxes>
<chart:CategoryAxis LabelCreated="CategoryAxis_LabelCreated" />
</chart:SfCartesianChart.XAxes>
C#
private void CategoryAxis_LabelCreated(object sender, Syncfusion.Maui.Charts.ChartAxisLabelEventArgs e)
{
e.Label = e.Label.Split(',')[0].Trim();
}
The output of axis labels on the category axis includes commas
The output of axis labels commas removed in category axis
Conclusion
I hope you enjoyed learning how to remove commas on the axis labels in the category axis in the .NET MAUI Chart (SfCartesianChart).
Refer to our .NET MAUI Chart feature tour page to learn about its other groundbreaking feature representations. You can also explore our .NET MAUI Chart documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Chart and other .NET MAUI components.
Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!