DevExtreme v23.2 is now available.

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

Your search did not match any results.

Selection

Documentation

This demo illustrates the use of the pointClick callback function to implement selection in the Chart component. The selectionMode of the series is set to «allArgumentPoints», which means that when a user selects a point, other points with the same argument also become selected.

Backend API
$(() => { $('#chart').dxChart({ rotated: true, dataSource, commonSeriesSettings: { argumentField: 'country', type: 'bar', hoverMode: 'allArgumentPoints', selectionMode: 'allArgumentPoints', label: { visible: true, format: { type: 'percent', precision: 1, }, }, }, valueAxis: { label: { format: { type: 'percent', precision: 1, }, }, }, series: [ { valueField: 'year2007', name: '2007 - 2008' }, { valueField: 'year2008', name: '2008 - 2009' }, ], title: { text: 'Economy - Export Change', }, legend: { verticalAlignment: 'bottom', horizontalAlignment: 'center', }, export: { enabled: true, }, onPointClick(e) { e.target.select(); }, onLegendClick(e) { const series = e.target; if (series.isVisible()) { series.hide(); } else { series.show(); } }, }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/23.2.5/css/dx.light.css" /> <script src="js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="chart"></div> </div> </body> </html>
#chart { height: 440px; }
const dataSource = [{ country: 'China', year2007: 0.18265, year2008: -0.16682, }, { country: 'Germany', year2007: 0.10467, year2008: -0.20165, }, { country: 'United States', year2007: 0.1232, year2008: -0.17994, }, { country: 'Japan', year2007: 0.10868, year2008: -0.25622, }, { country: 'France', year2007: 0.09526, year2008: -0.23631, }, { country: 'Netherlands', year2007: 0.14402, year2008: -0.21923, }];