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 - Multiple Point Selection

This demo illustrates the use of multi-point selection within the Chart component.

www.wikipedia.org
Backend API
import React from 'react'; import Chart, { CommonSeriesSettings, SelectionStyle, Hatching, Series, Legend, Export, } from 'devextreme-react/chart'; import type { ChartTypes } from 'devextreme-react/chart'; import { medalSources, medalStatistics } from './data.ts'; function onPointClick(e: ChartTypes.PointClickEvent): void { if (e.target.isSelected()) { e.target.clearSelection(); } else { e.target.select(); } } function App() { return ( <Chart id="chart" dataSource={medalStatistics} rotated={true} pointSelectionMode="multiple" onPointClick={onPointClick} title="Olympic Medals in 2024" > <CommonSeriesSettings argumentField="country" type="stackedbar" > <SelectionStyle> <Hatching direction="left" /> </SelectionStyle> </CommonSeriesSettings> { medalSources.map(({ value, name, color }) => <Series key={value} valueField={value} name={name} color={color} />) } <Legend verticalAlignment="bottom" horizontalAlignment="center"> </Legend> <Export enabled={true} /> </Chart> ); } export default App;
import React from 'react'; import Chart, { CommonSeriesSettings, SelectionStyle, Hatching, Series, Legend, Export, } from 'devextreme-react/chart'; import { medalSources, medalStatistics } from './data.js'; function onPointClick(e) { if (e.target.isSelected()) { e.target.clearSelection(); } else { e.target.select(); } } function App() { return ( <Chart id="chart" dataSource={medalStatistics} rotated={true} pointSelectionMode="multiple" onPointClick={onPointClick} title="Olympic Medals in 2024" > <CommonSeriesSettings argumentField="country" type="stackedbar" > <SelectionStyle> <Hatching direction="left" /> </SelectionStyle> </CommonSeriesSettings> {medalSources.map(({ value, name, color }) => ( <Series key={value} valueField={value} name={name} color={color} /> ))} <Legend verticalAlignment="bottom" horizontalAlignment="center" ></Legend> <Export enabled={true} /> </Chart> ); } 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 medalSources = [ { value: 'gold', name: 'Gold Medals', color: '#ffd700' }, { value: 'silver', name: 'Silver Medals', color: '#c0c0c0' }, { value: 'bronze', name: 'Bronze Medals', color: '#cd7f32' }, ]; export const medalStatistics = [{ country: 'USA', gold: 40, silver: 44, bronze: 42, }, { country: 'Japan', gold: 20, silver: 12, bronze: 13, }, { country: 'Australia', gold: 18, silver: 19, bronze: 16, }, { country: 'France', gold: 16, silver: 26, bronze: 22, }, { country: 'Great Britain', gold: 14, silver: 22, bronze: 29, }, { country: 'Italy', gold: 12, silver: 13, bronze: 15, }];
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App.js'; ReactDOM.render(<App />, document.getElementById('app'));
export const medalSources = [ { value: 'gold', name: 'Gold Medals', color: '#ffd700' }, { value: 'silver', name: 'Silver Medals', color: '#c0c0c0' }, { value: 'bronze', name: 'Bronze Medals', color: '#cd7f32' }, ]; export const medalStatistics = [ { country: 'USA', gold: 40, silver: 44, bronze: 42, }, { country: 'Japan', gold: 20, silver: 12, bronze: 13, }, { country: 'Australia', gold: 18, silver: 19, bronze: 16, }, { country: 'France', gold: 16, silver: 26, bronze: 22, }, { country: 'Great Britain', gold: 14, silver: 22, bronze: 29, }, { country: 'Italy', gold: 12, silver: 13, bronze: 15, }, ];
<!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>
#chart { height: 440px; }