const DemoApp = angular.module('DemoApp', ['dx']);
DemoApp.controller('DemoController', ($scope) => {
$scope.gaugeValue = dataSource[0].primary;
$scope.gaugeSubvalues = dataSource[0].secondary;
$scope.linearGaugeOptions = {
bindingOptions: {
value: 'gaugeValue',
subvalues: 'gaugeSubvalues',
},
scale: {
startValue: 0,
endValue: 10,
tickInterval: 2,
label: {
customizeText(arg) {
return `${arg.valueText} kW`;
},
},
},
tooltip: {
enabled: true,
customizeTooltip(arg) {
let 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 },
},
};
$scope.selectBoxOptions = {
dataSource,
displayExpr: 'name',
onValueChanged(e) {
const { value } = e;
$scope.gaugeValue = value.primary;
$scope.gaugeSubvalues = value.secondary;
},
value: dataSource[0],
width: 200,
};
});
<!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/22.2.6/css/dx.light.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
<script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script>
<script src="https://cdn3.devexpress.com/jslib/22.2.6/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" ng-app="DemoApp" ng-controller="DemoController">
<div id="gauge-demo">
<div id="gauge" dx-linear-gauge="linearGaugeOptions"></div>
<div dx-select-box="selectBoxOptions"></div>
</div>
</div>
</body>
</html>
#gauge-demo {
height: 440px;
width: 100%;
}
#gauge {
height: 400px;
}
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: [],
}];