DevExtreme v26.1 is now available.

✨ Developing with AI? Leverage the DevExpress MCP Server and our AI Agent Skills.

Your search did not match any results.

Vue Gauges - Subvalue Indicators Runtime Customization

This demo shows how to use the API of the LinearGauge to change its value and subvalue indicators at runtime. To get and set values of the indicators, the value and subvalues methods are utilized.

Backend API
<template> <div> <div id="gauge-demo"> <DxLinearGauge id="gauge" :value="value?.primary" :subvalues="value?.secondary" > <DxScale :start-value="0" :end-value="10" :tick-interval="2" > <DxLabel :customize-text="customizeText" /> </DxScale> <DxTooltip :enabled="true" :customize-tooltip="customizeTooltip" /> <DxExport :enabled="true" /> <DxTitle text="Power of Air Conditioners in Store Departments (kW)" > <DxFont :size="28" /> </DxTitle> </DxLinearGauge> <DxSelectBox id="selectbox" :data-source="dataSource" v-model:value="selected" :input-attr="{ 'aria-label': 'Department' }" :width="200" display-expr="name" value-expr="name" /> </div> </div> </template> <script setup lang="ts"> import { computed, ref } from 'vue'; import { DxLinearGauge, DxScale, DxLabel, DxTooltip, DxExport, DxTitle, DxFont, } from 'devextreme-vue/linear-gauge'; import { DxSelectBox } from 'devextreme-vue/select-box'; import { dataSource } from './data.ts'; const selected = ref(dataSource[0].name); const value = computed(() => dataSource.find((item) => item.name === selected.value)); const customizeText = ({ valueText }: Record<string, any>) => `${valueText} kW`; function customizeTooltip(scaleValue: Record<string, any>) { let result = `${scaleValue.valueText} kW`; if (scaleValue.index >= 0) { result = `Secondary ${scaleValue.index + 1}: ${result}`; } else { result = `Primary: ${result}`; } return { text: result, }; } </script> <style> #gauge-demo { height: 440px; width: 100%; } #gauge { height: 400px; } </style>
export const dataSource = [{ name: 'Meat', primary: 8, secondary: [7, 3], }, { name: 'Fish', primary: 7, secondary: [7, 5, 1], }, { name: 'Grocery', primary: 5, secondary: [1, 3], }, { name: 'Greengrocery', primary: 3, secondary: [1], }, { name: 'Stationery', primary: 2, secondary: [], }];
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>