Your search did not match any results.
Gauges

Variable Number of Subvalue Indicators

Documentation
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.
Copy to Codepen
Apply
Reset
window.onload = function() { var gaugeValue = ko.observable(dataSource[0].primary), gaugeSubvalues = ko.observable(dataSource[0].secondary); var viewModel = { linearGaugeOptions: { scale: { startValue: 0, endValue: 10, tickInterval: 2, label: { customizeText: function (arg) { return arg.valueText + " kW"; } } }, tooltip: { enabled: true, customizeTooltip: function (arg) { var result = arg.valueText + " kW"; if (arg.index >= 0) { result = "Secondary " + (arg.index + 1) + ": " + result; } else { result = "Primary: " + result; } return { text: result }; } }, "export": { enabled: true }, title: { text: "Power of Air Conditioners in Store Departments (kW)", font: { size: 28 } }, value: gaugeValue, subvalues: gaugeSubvalues }, selectBoxOptions: { dataSource: dataSource, displayExpr: "name", onValueChanged: function(e) { var value = e.value; gaugeValue(value.primary); gaugeSubvalues(value.secondary); }, value: dataSource[0], width: 200 } }; ko.applyBindings(viewModel, $("#gauge-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="js/jquery-3.1.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/17.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="gauge-demo"> <div id="gauge" data-bind="dxLinearGauge: linearGaugeOptions"></div> <div data-bind="dxSelectBox: selectBoxOptions"></div> </div> </div> </body> </html>
#gauge-demo { height: 440px; width: 100%; } #gauge { height: 400px; }
var 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: [] }];