Articles in this section
Category / Section

How to change the text displayed in axis labels

2 mins read

 

Description

This article describes how to customize the axis labels using axisLabelRender event.

 

Solution

The text displayed in axis labels can be customized by using the axesLabelRender event. Refer Chart Events for more information about the events available in Chart. Refer AxesLabelRender event for more information about the options available in the axesLabelRender event.

 

The Event handler argument containing properties like cancelname, axis, text, value and labelStyle to customize the rendered axis label. Use text property in the argument to change the rendered axis label.

 

Code Snippet 

The following code example adds “$” as prefix and “K” as suffix to the labels in the Vertical axis.

 

axisLabelRender : (args : IAxisLabelRenderEventArgs ) => {

    if (args.axis.orientation === 'Vertical')

   //Adding prefix and suffix to axis labels

   args.text = '$'+ args.text +' K';

}

 

 

Screenshot:

Customize the axis labels

 

Stackblitz Sample: https://stackblitz.com/edit/3dyeba-sszxwv?file=index.ts

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