How to change the text displayed in axis labels in .NET WebForms Chart ?
The text displayed in axis labels can be customized by using the client-side event OnClientAxesLabelRendering. Refer Chart Events for more information about the events available in Chart. Refer AxesLabelRendering Event for more information about the options available in the OnClientAxesLabelRendering event.
The Event Handler is provided with an object containing properties like 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 example adds â$â as prefix and âKâ as suffix to the labels in the Vertical axis.
ASP
<ej:Chart ID="container" OnClientAxesLabelRendering="LabelsRendering" runat="server"> </ej:Chart> <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 OnClientAxesLabelRendering event.
Figure 1: Chart with the prefix and suffix
I hope you enjoyed learning about how to change the text displayed in axis labels in .NET WebForms Chart.
You can refer to our .NET WebForms Charts 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 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!