Styling Ranges

The color and position of the ranges is primarily defined by the value of the 'showRanges' and 'ranges' properties.

In this example, we also used the ':hover' pseudo-class to change the opacity of the ranges when the mouse hovers over the gauges:

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import * as gauge from '@grapecity/wijmo.gauge'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // create the gauges let linear = new gauge.LinearGauge('#linear', { isReadOnly: false, hasShadow: false, value: 50, showRanges: true, ranges: [ { min: 0, max: 33, color: 'red' }, { min: 33, max: 66, color: 'yellow' }, { min: 66, max: 100, color: 'green' } ], pointer: { thickness: 0.5 } }); // let radial = new gauge.RadialGauge('#radial', { isReadOnly: false, hasShadow: false, value: 50, showRanges: true, showText: 'Value', ranges: [ { min: 0, max: 33, color: 'red' }, { min: 33, max: 66, color: 'yellow' }, { min: 66, max: 100, color: 'green' } ], pointer: { thickness: 0.5 } }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Styling Ranges</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <div id="linear"></div> <div id="radial"></div> </div> </body> </html> .wj-gauge { width: 50%; margin: 20px auto; } .wj-gauge .wj-face path { fill: #fefefe; stroke: #e0e0e0; } .wj-radialgauge { height: 120px; } .wj-gauge .wj-pointer { fill: black; } .wj-gauge .wj-ranges { opacity: .25; } .wj-gauge:hover .wj-ranges { opacity: 1; transition: opacity 600ms; } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGaugeModule } from '@grapecity/wijmo.angular2.gauge'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { } // @NgModule({ imports: [WjGaugeModule, BrowserModule], declarations: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Styling Ranges</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <wj-linear-gauge [isReadOnly]="false" [hasShadow]="false" [value]="50" [showRanges]="true"> <wj-range [wjProperty]="'pointer'" [thickness]="0.5"></wj-range> <wj-range [min]="0" [max]="33" [color]="'red'"></wj-range> <wj-range [min]="33" [max]="66" [color]="'yellow'"></wj-range> <wj-range [min]="66" [max]="100" [color]="'green'"></wj-range> </wj-linear-gauge> <wj-radial-gauge [isReadOnly]="false" [hasShadow]="false" [value]="50" [showRanges]="true" [showText]="'Value'"> <wj-range [wjProperty]="'pointer'" [thickness]="0.5"></wj-range> <wj-range [min]="0" [max]="33" [color]="'red'"></wj-range> <wj-range [min]="33" [max]="66" [color]="'yellow'"></wj-range> <wj-range [min]="66" [max]="100" [color]="'green'"></wj-range> </wj-radial-gauge> </div> .wj-gauge { width: 50%; margin: 20px auto; } .wj-gauge .wj-face path { fill: #fefefe; stroke: #e0e0e0; } .wj-radialgauge { height: 120px; } .wj-gauge .wj-pointer { fill: black; } .wj-gauge .wj-ranges { opacity: .25; } .wj-gauge:hover .wj-ranges { opacity: 1; transition: opacity 600ms; } <template> <div class="container-fluid"> <wj-linear-gauge :isReadOnly=false :hasShadow=false :value=50 :showRanges=true> <wj-range wjProperty="pointer" :thickness=0.5></wj-range> <wj-range :min=0 :max=33 color="red"></wj-range> <wj-range :min=33 :max=66 color="yellow"></wj-range> <wj-range :min=66 :max=100 color="green"></wj-range> </wj-linear-gauge> <wj-radial-gauge :isReadOnly=false :hasShadow=false :value=50 :showRanges=true showText="Value"> <wj-range wjProperty="pointer" :thickness=0.5></wj-range> <wj-range :min=0 :max=33 color="red"></wj-range> <wj-range :min=33 :max=66 color="yellow"></wj-range> <wj-range :min=66 :max=100 color="green"></wj-range> </wj-radial-gauge> </div> </template> <script> import 'bootstrap.css'; import "@grapecity/wijmo.styles/wijmo.css"; import "src/app.css"; import Vue from 'vue'; import '@grapecity/wijmo.vue2.gauge'; let App = Vue.extend({ name: 'app' }) new Vue({ render: h => h(App) }).$mount('#app'); </script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Styling Ranges</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> import './app.css'; import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; // import * as wjGauge from '@grapecity/wijmo.react.gauge'; class App extends React.Component { render() { return (<div className="container-fluid"> <wjGauge.LinearGauge isReadOnly={false} hasShadow={false} value={50} showRanges={true}> <wjGauge.Range wjProperty="pointer" thickness={0.5}></wjGauge.Range> <wjGauge.Range min={0} max={33} color="red"></wjGauge.Range> <wjGauge.Range min={33} max={66} color="yellow"></wjGauge.Range> <wjGauge.Range min={66} max={100} color="green"></wjGauge.Range> </wjGauge.LinearGauge> <wjGauge.RadialGauge isReadOnly={false} hasShadow={false} value={50} showRanges={true} showText="Value"> <wjGauge.Range wjProperty="pointer" thickness={0.5}></wjGauge.Range> <wjGauge.Range min={0} max={33} color="red"></wjGauge.Range> <wjGauge.Range min={33} max={66} color="yellow"></wjGauge.Range> <wjGauge.Range min={66} max={100} color="green"></wjGauge.Range> </wjGauge.RadialGauge> </div>); } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Styling Ranges</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> .container-fluid .wj-gauge { width: 50%; margin: 20px auto; } .container-fluid .wj-gauge .wj-face path { fill: #fefefe; stroke: #e0e0e0; } .container-fluid .wj-radialgauge { height: 120px; } .container-fluid .wj-gauge .wj-pointer { fill: black; } .container-fluid .wj-gauge .wj-ranges { opacity: .25; } .container-fluid .wj-gauge:hover .wj-ranges { opacity: 1; transition: opacity 600ms; }