Your search did not match any results.
Range Selector

Discrete scale

Documentation

In this demo, a discrete scale is used to select a range within a set of categories.

Backend API
Copy to CodePen
Apply
Reset
window.onload = function () { const totalResult = ko.observable('12,809,000'); const viewModel = { totalResult, rangeSelectorOptions: { dataSource, chart: { commonSeriesSettings: { argumentField: 'country', type: 'bar', }, series: [ { valueField: 'copper', name: 'Copper' }, ], }, title: 'Copper Production in 2013', onValueChanged(e) { const data = e.component.option('dataSource'); let total = 0; let startIndex; let endIndex; data.forEach((item, i) => { if (item.country === e.value[0]) { startIndex = i; } else if (item.country === e.value[1]) { endIndex = i; } }); if (endIndex) { data .slice(startIndex, endIndex + 1) .forEach((item) => { total += item.copper; }); } else { total = data[startIndex].copper; } totalResult(formatNumber(total)); }, }, }; const formatNumber = new Intl.NumberFormat('en-US', { minimumFractionDigits: 0 }).format; ko.applyBindings(viewModel, $('#range-selector-demo').get(0)); };
<!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> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/22.1.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/22.1.3/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="range-selector-demo"> <div id="range-selector" data-bind="dxRangeSelector: rangeSelectorOptions"></div> <h2>Total: <span data-bind="text: totalResult"></span> tons</h2> </div> </div> </body> </html>
#range-selector-demo { text-align: center; } #range-selector { margin-bottom: 20px; height: 200px; }
const dataSource = [ { country: 'Chile', copper: 5700000 }, { country: 'United States', copper: 1220000 }, { country: 'Peru', copper: 1300000 }, { country: 'China', copper: 1650000 }, { country: 'Australia', copper: 990000 }, { country: 'Russia', copper: 930000 }, { country: 'DR Congo', copper: 900000 }, { country: 'Finland', copper: 119000 }, ];