Articles in this section
Category / Section

How to customize the axis labels in React Chart?

2 mins read

This article explains how to customize the axis labels in the React Chart.

Customization of axis labels

You can easily customize the size, color, and fontWeight of the of the axis label by using the labelStyle property in the axis. Additionally, you can control the label’s placement inside the axis line by using the labelPosition property. By default, the axis labels are placed outside the axis line.

In the following code example, the axis labels are customized in terms of position, format, size, font weight, and color.

Index.js

import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, ColumnSeries, Category
    } from '@syncfusion/ej2-react-charts';

const Column = () => {
return (
    <chartcomponent id="charts" primaryxaxis="{{" valuetype:="" 'category',="" interval:="" 1,="" labelplacement:="" 'onticks',="" title:="" 'month',="" labelposition:="" 'inside',="" labelstyle:="" {="" size:="" '14px',="" color:="" 'red',="" fontweight:="" '800'="" },="" rangepadding:="" 'round',="" edgelabelplacement:="" 'shift'="" }}="" primaryyaxis="{{" minimum:="" 0,="" maximum:="" 100,="" 5,="" 'temperature',="" labelformat:="" '{value}°c'="">
      <inject services="{[ColumnSeries," category]}="">
      <seriescollectiondirective>
        <seriesdirective datasource="{data}" xname="x" yname="y" type="Column" fill="#ffc803">
      </seriesdirective></seriescollectiondirective>
    </inject></chartcomponent>
  );
};
export default Column;

const root = createRoot(document.getElementById('sample'));
root.render(<column>);

The following screenshot portrays the results of the code snippet mentioned above.

Screenshot:

React chart axis label customization

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to customize the axis labels in the React Chart Component.

You can refer to our React Chart feature tour page to know about its other groundbreaking feature representations and documentation, 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, support portal, 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  to leave a comment
Access denied
Access denied