Demo - Linear Gauges
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.gauge.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<div class="container">
<h1>
Linear Gauges</h1>
<p>
Linear gauges display a metric as a percentage of the length
of a linear scale.
They can be horizontal or vertical, depending on the setting
of the "direction" property.</p>
<p>
Use the controls below to see the effect of the main
LinearGauge properties:</p>
<div class="row">
<div class="col-xs-6">
<label for="value">value</label>
<div id="value"></div><br>
<label for="direction">direction</label>
<div id="direction"></div><br>
</div>
<div class="col-xs-6">
<div class="gauge-holder">
<div id="theGauge"></div>
</div>
</div>
</div>
</div>
CSS
.gauge-holder {
width: 80%;
height: 200px;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
padding: 12px;
}
.wj-gauge {
width: 100%;
height: 100%;
margin: auto auto;
}
.wj-combobox, .wj-inputnumber {
width: 120px;
}
label {
width: 100px;
text-align: right;
}
body {
margin-bottom: 24pt;
}
JavaScript
onload = function() {
// create the gauge
var theGauge = new wijmo.gauge.LinearGauge('#theGauge', {
isReadOnly: false,
min: 0,
max: 100,
step: 5,
value: 75,
valueChanged: function(s, e) {
value.value = s.value;
},
showRanges: false,
ranges: [
{ min: 0, max: 33, color: 'red' },
{ min: 33, max: 66, color: 'yellow' },
{ min: 66, max: 100, color: 'green' },
]
});
setDirection('Right');
// change properties
var value = new wijmo.input.InputNumber('#value', {
min: theGauge.min,
max: theGauge.max,
step: theGauge.step,
value: theGauge.value,
valueChanged: function(s, e) {
theGauge.value = s.value;
}
});
var direction = new wijmo.input.ComboBox('#direction', {
itemsSource: 'Left,Right,Up,Down'.split(','),
text: 'Right',
textChanged: function(s, e) {
setDirection(s.text);
}
});
function setDirection(dir) {
theGauge.direction = dir;
var g = theGauge.hostElement.style;
switch (dir) {
case 'Left':
case 'Right':
g.height = '2em';
g.width = '100%';
break;
case 'Up':
case 'Down':
g.height = '100%';
g.width = '2em';
break;
}
}
}