How to change the text displayed in axis labels
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 cancel, name, 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:
Stackblitz Sample: https://stackblitz.com/edit/3dyeba-sszxwv?file=index.ts