Articles in this section
Category / Section

How to change the text displayed in axis labels in JS Chart ?

1 min read

The text displayed in axis labels can be customized by using the 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 the axesLabelRendering 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.

JS

<div id="container"></div>
<script type="text/javascript"> 
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';
}
$(function () {
    $("#container").ejChart({
        axesLabelRendering: 'LabelsRendering',
    });
});
</script>

Screenshot:

The following screenshot displays Chart with the prefix and suffix for the primary Y axis labels, added in the axesLabelRendering event.

Changing the text in axis labels

Figure 1: Chart with the prefix and suffix

JS Playground sample link: Label text

 

Conclusion

I hope you enjoyed learning how to change the text displayed in axis labels in JS Chart.

You can refer to our JavaScript 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 JavaScript Charts 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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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