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, the radius of the pie series will be 80% of the size, i.e., the minimum of the 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%'}="">
</accumulationseriesdirective></accumulationseriescollectiondirective>
</inject></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:
Refer to the working sample for additional details and implementation: View Sample in Stackblitz
Conclusion
We hope you enjoyed learning how to set the size of a pie or doughnut in the React Chart Component.
You can refer to our React Chart feature tour page to learn about its other groundbreaking feature representations and documentation, as well as how to quickly get started with 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!