Articles in this section
Category / Section

How to explode a pie chart slice on touch in React Chart?

3 mins read

This article explains how to explode a pie chart slice on touch in the React Chart.

Customize to explode a pie chart slice on touch

A Pie chart in React Chart with an explosion can be considered as an exploded pie chart. You can change the pie explosion settings manually by enabling the explode property.

In the following code example, the explode property is set to true, which causes the pie chart slice to explode on a mouse click or touch.

Index.js

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

const Pie = () => {
return (
   <accumulationchartcomponent id="pie-chart" center="{{" x:="" '50%',="" y:="" '50%'="" }}="" enableborderonmousemove="{false}">
     <inject services="{[PieSeries," accumulationdatalabel]}="">
     <accumulationseriescollectiondirective>
       <accumulationseriesdirective datasource="{data1}" xname="x" yname="y" explode="{true}" explodeoffset="10%" startangle="{Browser.isDevice" ?="" 55="" :="" 90}="" datalabel="{{" visible:="" true,="" position:="" 'inside',="" name:="" 'text',="" font:="" {="" fontweight:="" '600'="" },="" connectorstyle:="" length:="" '20px',="" type:="" 'curve'="" }="" }}="" radius="{Browser.isDevice" '40%'="" '70%'}="">
     </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:

React chart pie explode

View Sample in Stackblitz

Conclusion

I hope you enjoyed learning how to explode a pie chart slice on touch 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