How to set size of pie/doughnut in React Chart?
This article explains how to set the size of a pie or doughnut in React Chart.
Customize the pie or doughnut size
You can customize pie or doughnut chart size by using radius property of the series. By default, radius of the pie series will be 80% of the size i.e. minimum of chart width and height.
In the following code example, the pie chart radius is set to 50% for the series.
Index.js
import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { Browser } from '@syncfusion/ej2-base';
import { AccumulationChartComponent, AccumulationSeriesCollectionDirective, AccumulationSeriesDirective, Inject,
AccumulationLegend, PieSeries, AccumulationTooltip, AccumulationDataLabel } from '@syncfusion/ej2-react-charts';
const Pie = () => {
return (
<AccumulationChartComponent id="pie-chart" legendSettings={{ visible: true, position: 'Top' }}>
<Inject
services={[ AccumulationLegend, PieSeries, AccumulationTooltip, AccumulationDataLabel ]}
/>
<AccumulationSeriesCollectionDirective>
<AccumulationSeriesDirective
dataSource={data1}
xName="x"
yName="y"
startAngle={Browser.isDevice ? 55 : 25}
dataLabel={{
visible: true,
position: 'Inside',
name: 'text',
font: { fontWeight: '600' }
}}
radius={Browser.isDevice ? '40%' : '50%'}
/>
</AccumulationSeriesCollectionDirective>
</AccumulationChartComponent>
);
};
export default Pie;
const root = createRoot(document.getElementById('sample'));
root.render(<Pie />);
The following screenshot illustrate the output of the above code snippet.
Screenshot:
Conclusion
I hope you enjoyed learning how to set size of pie or doughnut in 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!