Angular UI Components Documentation
The Angular Gauge displays an indicator within a range of values. This guide adds the Angular Gauge (jqxGauge) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxgauge 
In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxGaugeModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxGaugeModule } from 'jqwidgets-ng/jqxgauge';
@Component({
selector: 'app-root',
imports: [jqxGaugeModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Default Functionality demo.
<div style="float: left">
<jqxGauge #myGauge (onValueChanging)="onValueChanging($event)"
[ranges]="ranges" [ticksMinor]="ticksMinor" [ticksMajor]="ticksMajor"
[value]="0" [colorScheme]="'scheme05'" [animationDuration]="1200">
</jqxGauge>
<div #gaugeValue class="gaugeValue"></div>
</div>
<jqxLinearGauge #myLinearGauge style="margin-left: 60px; float: left;"
[width]="100" [height]="350" [max]="60" [orientation]="'vertical'"
[ticksMajor]="ticksMajorLinear" [ticksMinor]="ticksMinorLinear"
[pointer]="{ size: '5%' }" [colorScheme]="'scheme05'" [labels]="labels"
[ranges]="rangesLinear" [animationDuration]="1500">
</jqxLinearGauge>
import { Component, ViewEncapsulation, ElementRef, AfterViewInit, viewChild } from '@angular/core';
import { jqxGaugeComponent } from 'jqwidgets-ng/jqxgauge';
import { jqxLinearGaugeComponent } from 'jqwidgets-ng/jqxlineargauge';
import { CommonModule } from '@angular/common';
import { jqxGaugeModule } from 'jqwidgets-ng/jqxgauge';
import { jqxLinearGaugeModule } from 'jqwidgets-ng/jqxlineargauge';
@Component({
imports: [CommonModule, jqxGaugeModule, jqxLinearGaugeModule],
selector: 'app-root',
templateUrl: './app.html',
styleUrl: './app.css',
encapsulation: ViewEncapsulation.None
})
export class App implements AfterViewInit {
readonly myGauge = viewChild.required<jqxGaugeComponent>('myGauge');
readonly myLinearGauge = viewChild.required<jqxLinearGaugeComponent>('myLinearGauge');
readonly gaugeValue = viewChild.required<ElementRef>('gaugeValue');
ngAfterViewInit(): void {
this.myGauge().value(140);
this.myLinearGauge().value(40);
}
ticksMinor: any = { interval: 5, size: '5%' };
ticksMajor: any = { interval: 10, size: '9%' };
ranges: any[] = [
{
startValue: 0,
endValue: 55,
style: { fill: '#4bb648', stroke: '#4bb648' },
endWidth: 5,
startWidth: 1
},
{
startValue: 55,
endValue: 110,
style: { fill: '#fbd109', stroke: '#fbd109' },
endWidth: 10,
startWidth: 5
},
{
startValue: 110,
endValue: 165,
style: { fill: '#ff8000', stroke: '#ff8000' },
endWidth: 13,
startWidth: 10
},
{
startValue: 165,
endValue: 220,
style: { fill: '#e02629', stroke: '#e02629' },
endWidth: 16,
startWidth: 13
}
];
ticksMinorLinear: any = {
size: '5%',
interval: 2.5,
style: { 'stroke-width': 1, stroke: '#aaaaaa' }
};
ticksMajorLinear: any = { size: '10%', interval: 10 };
labels: any = {
interval: 20,
formatValue: (value: number, position: string): string => {
if (position === 'far') {
value = (9 / 5) * value + 32;
if (value === -76) {
return '°F';
}
return value + '°';
}
if (value === -60) {
return '°C';
}
return value + '°';
}
};
rangesLinear: any[] = [
{ startValue: -10, endValue: 10, style: { fill: '#FFF157', stroke: '#FFF157' } },
{ startValue: 10, endValue: 35, style: { fill: '#FFA200', stroke: '#FFA200' } },
{ startValue: 35, endValue: 60, style: { fill: '#FF4800', stroke: '#FF4800' } }
];
onValueChanging(event: any): void {
this.gaugeValue().nativeElement.innerHTML = Math.round(event.args.value) + ' kph';
}
}.gaugeValue {
background-color: #f6f6f6;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fafafa), color-stop(100%, #f3f3f3));
background-image: -webkit-linear-gradient(#fafafa, #f3f3f3);
background-image: -moz-linear-gradient(#fafafa, #f3f3f3);
background-image: -o-linear-gradient(#fafafa, #f3f3f3);
background-image: linear-gradient(#fafafa, #f3f3f3);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
padding: 10px;
position: absolute;
top: 290px;
left: 140px;
font-family: Sans-Serif;
text-align: center;
font-size: 17px;
color: #333333;
width: 70px;
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, valueChanged: The event is is triggered when the gauge's value is changed.
<jqxGauge (onValueChanged)="onValueChanged($event)"></jqxGauge>
onValueChanged(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, val: Sets or gets the value.
<jqxGauge #myGauge></jqxGauge>
import { Component, viewChild } from '@angular/core';
import { jqxGaugeModule, jqxGaugeComponent } from 'jqwidgets-ng/jqxgauge';
@Component({
selector: 'app-root',
imports: [jqxGaugeModule],
templateUrl: './app.html'
})
export class App {
readonly myGauge = viewChild.required<jqxGaugeComponent>('myGauge');
run(): void {
const value = this.myGauge().val();
console.log(value);
}
}