How to change the text displayed in axis labels .NET MVC Chart?
The text displayed in axis labels can be customized using the client-side AxesLabelRendering event. Refer Chart Events for more information about the events available in Chart. Refer AxesLabelRendering Event for more information about the options available in AxesLabelRendering event.
The Event Handler is provided an object containing properties cancel, data, model and type as parameter. The property data in parameter object has options to customize the text of axis labels. The following code snippet adds â$â as prefix and âKâ as suffix to the labels in vertical axis.
CSHTML
@(Html.EJ().Chart("container") .AxesLabelRendering("LabelsRendering") ) <script type="text/javascript"> //Client-side event handler to handle labels rendering event function LabelsRendering(sender) { if (sender.data.axis.orientation == 'vertical') //Adding prefix and suffix to axis labels sender.data.label.Text = '$'+sender.data.label.Text+' K'; } </script>
Screenshot:
The following screenshot displays Chart with the prefix and suffix for the primary Y axis labels added in AxesLabelRendering event.
Figure 1: Chart with the prefix and suffix
Conclusion
I hope you enjoyed learning about how to change the text displayed in axis labels .NET MVC Chart.
You can refer to our ASP.NET MVC Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC Chart example to understand how to create and manipulate data.
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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!