Articles in this section
Category / Section

How to rotate the data labels?

This article explains how to rotate the data labels in React Chart.

Customize the rotation of the data labels

You can rotate the data labels by setting the angle property with the specified angle.

In the following code example, the data labels are rotated by setting the angle to 45 degrees.

Index.js

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

const Line = () => {
const marker = {
 visible: true,
 dataLabel: {
   visible: true,
   border: { width: 1, color: 'red' },
   angle: 45,
   enableRotation: true,
   margin: {
     left: 5,
     right: 5,
     top: 7,
     bottom: 5
   },
 },
};
return (
     <chartcomponent id="charts" primaryxaxis="{{" valuetype:="" 'category',="" interval:="" 1="" }}="" primaryyaxis="{{" labelformat:="" '{value}°c',="" minimum:="" 5,="" maximum:="" 40="" title="Weather Report">
       <inject services="{[LineSeries," category,="" datalabel]}="">
       <seriescollectiondirective>
         <seriesdirective datasource="{data}" xname="x" yname="y" width="{2}" name="Max Temp" type="Line" marker="{marker}">
       </seriesdirective></seriescollectiondirective>
     </inject></chartcomponent>
);
};
export default Line;

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

The screenshot below depict the results of the aforementioned code snippet.

Screenshot:

React chart datalabel rotation

Refer to the working sample for additional details and implementation: View Sample in Stackblitz

Conclusion

We hope you enjoyed learning how to rotate the data labels in React Chart Component.

You can refer to our React Chart feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our React Chart 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, BoldDesk Support, 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)
Access denied
Access denied