In addition to the "face" and "pointer" ranges, gauges may contain additional ranges that show zones within the gauge (like 'bad', 'average', and 'good').
To add colorful ranges to the gauge follow these steps:
Example:
import * as gauge from '@grapecity/wijmo.gauge';
// create the gauge with ranges
var myGauge = new gauge.RadialGauge('#myGauge', {
value: 50,
showRanges: true,
ranges: [
{ min: 0, max: 30, color: 'red', thickness: .5 },
{ min: 30, max: 50, color: 'orange', thickness: .5 },
{ min: 50, max: 70, color: 'gold', thickness: .5 },
{ min: 70, max: 100, color: 'green', thickness: .5 },
]
});
If you set the gauge's showRanges property to false, the additional ranges are not shown. Instead, they are used to automatically set the color of the "pointer" based on the current value.
For example:
myGauge.showRanges = false;
Set the stackRanges property to true to show all ranges in the gauge side-by-side. This technique allows a single gauge to show multiple values.
Change the max property on the range objects to update them independently.
import * as gauge from '@grapecity/wijmo.gauge';
// create the gauges
var myRadialGauge = new gauge.RadialGauge('#myRadialGauge', {
value: 25,
stackRanges: true,
ranges: [
{ max: 25, color: 'red' },
{ max: 50, color: 'purple' },
{ max: 75, color: 'orange' }
]
});
The color and position of the ranges is primarily defined by the value of the 'showRanges' and 'ranges' properties. But you can also control the overall style attributes of the ranges to apply a hover style.
.wj-gauge .wj-ranges {
opacity: .25;
}
.wj-gauge:hover .wj-ranges {
opacity: 1;
transition: opacity 600ms;
}