Articles in this section
Category / Section

How to change the data label connector type of pie and doughnut series to Curve?

4 mins read

This article explains how to change the data label connector type of pie and doughnut series to curve in the React Chart.

Customize the data label connector type

When the data label is placed outside the chart, the connector line becomes visible. You can easily customize the data label connector line type for pie and doughnut series to Curve by using the connectorStyle property. By default, the connector line type is set to Line.

In the following code example, the connect line type is set to Curve.

Index.js

import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject,
 AccumulationLegend, PieSeries, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';

const Pie = () => {
 const textRender = (args) => {
   if (args.point.y === parseFloat(args.text)) {
     args.color = args.point.color;
   }
 };
 return (
       <AccumulationChartComponent
         id="pie-chart"
         legendSettings={{ visible: true, position: 'Top' }}
         center={{ x: '50%', y: '50%' }}
         enableBorderOnMouseMove={false}
         textRender={textRender.bind(this)}
       >
         <Inject
           services={[AccumulationLegend, PieSeries, AccumulationDataLabel]}
         />
         <AccumulationSeriesCollectionDirective>
           <AccumulationSeriesDirective
             dataSource={data}
             xName="x"
             yName="y"
             startAngle={Browser.isDevice ? 55 : 35}
             dataLabel={{
               visible: true,
               position: 'Outside',
               font: { fontWeight: '600', color: '#ffffff' },
               connectorStyle: { length: '20px', type: 'Curve' },
               border: { width: 2 },
               rx: 0,
               ry: 0
             }}
             radius={Browser.isDevice ? '40%' : '70%'}
             legendShape="Circle"
           />
         </AccumulationSeriesCollectionDirective>
       </AccumulationChartComponent>
   );
};
export default Pie;

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

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

Screenshot:

React chart connector type curve

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to change the data label connector type of pie and doughnut series to curve 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, 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, 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