DevExtreme v26.1 is now available.

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

Your search did not match any results.

Vue Range Selector - Discrete scale

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

Backend API
<template> <div id="range-selector-demo"> <DxRangeSelector id="range-selector" :data-source="dataSource" v-model:value="range" title="Copper Production in 2013" > <DxChart> <DxSeries argument-field="country" type="bar" value-field="copper" /> </DxChart> </DxRangeSelector> <h2>Total: {{ format(totalProduction) }} tons</h2> </div> </template> <script setup lang="ts"> import { computed, ref } from 'vue'; import { DxRangeSelector, DxChart, DxSeries, } from 'devextreme-vue/range-selector'; import { dataSource } from './data.ts'; const range = ref([]); const totalProduction = computed(() => { let startIndex = 0; let endIndex = dataSource.length; dataSource.forEach((item, index) => { if (item.country === range.value[0]) { startIndex = index; } if (item.country === range.value[1]) { endIndex = index + 1; } }); return dataSource .slice(startIndex, endIndex) .reduce((total, item) => total + item.copper, 0); }); const format = new Intl.NumberFormat('en-US', { minimumFractionDigits: 0, }).format; </script> <style> #range-selector-demo { text-align: center; } #range-selector { margin-bottom: 20px; height: 200px; } </style>
export 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 }, ];
import { createApp } from 'vue'; import App from './App.vue'; createApp(App).mount('#app');
<!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/vue.vendor.js"></script> <script src="./bundle.js"></script> </body> </html>