Your search did not match any results.
Charts

Discrete Axis Zooming and Panning

Documentation

Discrete data support is one of many strengths of the Chart component. In this example, you can zoom data in the Chart using another DevExtreme JavaScript UI component, the RangeSelector.

Backend API
Copy to CodePen
Apply
Reset
$(() => { const chart = $('#zoomedChart').dxChart({ palette: 'soft', title: 'The Chemical Composition of the Earth Layers', valueAxis: { label: { customizeText() { return `${this.valueText}%`; }, }, }, dataSource, series, commonSeriesSettings: { type: 'bar', ignoreEmptyPoints: true, }, legend: { border: { visible: true, }, visible: true, verticalAlignment: 'top', horizontalAlignment: 'right', orientation: 'horizontal', }, }).dxChart('instance'); $('#range-selector').dxRangeSelector({ size: { height: 120, }, margin: { left: 10, }, scale: { minorTickCount: 1, }, dataSource, chart: { palette: 'soft', commonSeriesSettings: { type: 'bar', ignoreEmptyPoints: true, }, series, }, behavior: { callValueChanged: 'onMoving', }, onValueChanged(e) { chart.getArgumentAxis().visualRange(e.value); }, }); });
<!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/21.2.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.2.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/21.2.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="chart-demo"> <div id="zoomedChart"></div> <div id="range-selector"></div> </div> </div> </body> </html>
#zoomedChart { margin-bottom: 20px; }
const series = [{ name: 'Si', valueField: 'Si', }, { name: 'Fe', valueField: 'Fe', }, { name: 'Ni', valueField: 'Ni', }, { name: 'S', valueField: 'S', }, { name: 'O', valueField: 'O', }, { name: 'Mg', valueField: 'Mg', }, { name: 'Al', valueField: 'Al', }, { name: 'K', valueField: 'K', }, { name: 'Na', valueField: 'Na', }]; const dataSource = [{ arg: 'Inner Core', Si: 7.35, Fe: 79.39, Ni: 5.2, S: 2.3, O: 4.1, }, { arg: 'Outer Core', Si: 7.33, Fe: 78.56, Ni: 5.2, S: 2.7, O: 4.2, }, { arg: 'Lower Mantle', Si: 21.5, Fe: 5.8, O: 44.8, Mg: 22.8, Al: 2.2, Ca: 2.3, Na: 0.3, K: 0.03, }, { arg: 'Upper Mantle', Si: 28.1, Mg: 23.2, Fe: 4.3, Al: 1.2, Ca: 2.2, O: 40.3, Na: 0.2, }, { arg: 'Lower Crust', O: 46.6, Si: 27.7, Al: 8.1, Fe: 5, Ca: 3.6, Na: 2.8, K: 2.6, Mg: 1.5, }, { arg: 'Upper Crust', O: 47, Si: 29.5, Al: 8.05, Fe: 4.66, Ca: 2.96, Na: 2.5, K: 2.5, Mg: 1.87, }];