DevExtreme v26.1 is now available.

Explore our newest features/capabilities and share your thoughts with us.

Your search did not match any results.

React Charts - Doughnut Selection

This demo illustrates how a user can select slices on the PieChart component with the doughnut series type.

www.wikipedia.org
Backend API
import React from 'react'; import PieChart, { type PieChartTypes, Legend, Series, Export, HoverStyle, } from 'devextreme-react/pie-chart'; import { olympicMedals } from './data.ts'; function pointClickHandler(arg: PieChartTypes.PointClickEvent) { arg.target.select(); } function App() { return ( <PieChart id="pie" type="doughnut" title="Olympic Medals in 2008" palette="Soft Pastel" dataSource={olympicMedals} onPointClick={pointClickHandler} > <Series argumentField="country" valueField="medals"> <HoverStyle color="#ffd700" /> </Series> <Export enabled={true} /> <Legend margin={0} horizontalAlignment="right" verticalAlignment="top" /> </PieChart> ); } export default App;
import React from 'react'; import PieChart, { Legend, Series, Export, HoverStyle, } from 'devextreme-react/pie-chart'; import { olympicMedals } from './data.js'; function pointClickHandler(arg) { arg.target.select(); } function App() { return ( <PieChart id="pie" type="doughnut" title="Olympic Medals in 2008" palette="Soft Pastel" dataSource={olympicMedals} onPointClick={pointClickHandler} > <Series argumentField="country" valueField="medals" > <HoverStyle color="#ffd700" /> </Series> <Export enabled={true} /> <Legend margin={0} horizontalAlignment="right" verticalAlignment="top" /> </PieChart> ); } export default App;
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.tsx'; ReactDOM.render( <App />, document.getElementById('app'), );
export const olympicMedals = [{ country: 'USA', medals: 110, }, { country: 'China', medals: 100, }, { country: 'Russia', medals: 72, }, { country: 'Britain', medals: 47, }, { country: 'Australia', medals: 46, }, { country: 'Germany', medals: 41, }, { country: 'France', medals: 40, }, { country: 'South Korea', medals: 31, }];
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.js'; ReactDOM.render(<App />, document.getElementById('app'));
export const olympicMedals = [ { country: 'USA', medals: 110, }, { country: 'China', medals: 100, }, { country: 'Russia', medals: 72, }, { country: 'Britain', medals: 47, }, { country: 'Australia', medals: 46, }, { country: 'Germany', medals: 41, }, { country: 'France', medals: 40, }, { country: 'South Korea', medals: 31, }, ];
<!DOCTYPE html> <html lang="en"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" /> <link rel="stylesheet" type="text/css" href="./bundle.css" /> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"></div> </div> <script src="bundles/vendor/react.vendor.js"></script> <script src="./bundle.js"></script> </body> </html>
#pie { height: 440px; }