Gauge Chart
The Gauge chart displays a single value within a defined range, often represented as a needle on a circular arc.
Default Gauge
A gauge with no zones that shows the needle by default.
import { VisuallyJsModule } from "@visuallyjs/browser-ui-angular"
import { Component } from '@angular/core'
@Component({
selector: 'app-root',
imports: [VisuallyJsModule],
template: '<vjs-gauge-chart [options]="chartOptions"/>',
styleUrl: './app.css'
})
export class App {
data = ...
chartOptions = {
title: {
text: "Default Gauge"
},
value: 65
}
}
Zones and Needle
A gauge configured with multiple color zones and a needle.
import { VisuallyJsModule } from "@visuallyjs/browser-ui-angular"
import { Component } from '@angular/core'
@Component({
selector: 'app-root',
imports: [VisuallyJsModule],
template: '<vjs-gauge-chart [options]="chartOptions"/>',
styleUrl: './app.css'
})
export class App {
data = ...
chartOptions = {
title: {
text: "Gauge with Zones and Needle"
},
value: 75,
zones: [
{
from: 0,
to: 33,
color: "#ff4d4d"
},
{
from: 33,
to: 66,
color: "#ffdb4d"
},
{
from: 66,
to: 100,
color: "#4dff4d"
}
]
}
}
Zones without Needle
A gauge that has zones but doesn't show the needle. In this case, the zones are only painted up to the current value.
import { VisuallyJsModule } from "@visuallyjs/browser-ui-angular"
import { Component } from '@angular/core'
@Component({
selector: 'app-root',
imports: [VisuallyJsModule],
template: '<vjs-gauge-chart [options]="chartOptions"/>',
styleUrl: './app.css'
})
export class App {
data = ...
chartOptions = {
title: {
text: "Gauge with Zones, No Needle"
},
value: 45,
showNeedle: false,
zones: [
{
from: 0,
to: 100,
color: "#4d94ff"
}
]
}
}
Gradient Zones
A gauge with two zones that each have a gradient.
import { VisuallyJsModule } from "@visuallyjs/browser-ui-angular"
import { Component } from '@angular/core'
@Component({
selector: 'app-root',
imports: [VisuallyJsModule],
template: '<vjs-gauge-chart [options]="chartOptions"/>',
styleUrl: './app.css'
})
export class App {
data = ...
chartOptions = {
title: {
text: "Gauge with Gradient Zones"
},
value: 80,
zones: [
{
from: 0,
to: 50,
gradient: {
stops: [
{
offset: 0,
color: "#ff4d4d"
},
{
offset: 100,
color: "#ffdb4d"
}
]
}
},
{
from: 50,
to: 100,
gradient: {
stops: [
{
offset: 0,
color: "#ffdb4d"
},
{
offset: 100,
color: "#4dff4d"
}
]
}
}
]
}
}
Ticks
The ticks object allows you to configure the appearance and interval of the tick marks on the gauge.
import { VisuallyJsModule } from "@visuallyjs/browser-ui-angular"
import { Component } from '@angular/core'
@Component({
selector: 'app-root',
imports: [VisuallyJsModule],
template: '<vjs-gauge-chart [options]="chartOptions"/>',
styleUrl: './app.css'
})
export class App {
data = ...
chartOptions = {
title: {
text: "Gauge with Custom Ticks"
},
value: 65,
ticks: {
interval: 10,
show: true,
width: 2,
length: 10,
color: "#666"
}
}
}
Labels
The labels object is used to configure the numeric labels displayed around the gauge arc.
import { VisuallyJsModule } from "@visuallyjs/browser-ui-angular"
import { Component } from '@angular/core'
@Component({
selector: 'app-root',
imports: [VisuallyJsModule],
template: '<vjs-gauge-chart [options]="chartOptions"/>',
styleUrl: './app.css'
})
export class App {
data = ...
chartOptions = {
title: {
text: "Custom Labels"
},
value: 45,
labels: {
show: true,
fontSize: 18,
suffix: "%",
fontWeight: "bold",
fontColor: "#4d94ff"
}
}
}
Options
GaugeChartOptions
Options for a Gauge chart.
| Name | Type | Description |
|---|---|---|
| centerLabel? | boolean | {
formatter:(value:number) => string, subtitle:string, suffix:string } | Optional hero value and subtitle rendered inside the center of the gauge arc. |
| colorGenerator? | ColorGenerator | Optional function to call in order to establish the color to be used for each series |
| data? | Array<ObjectData> | Optional data to load into the chart. |
| dataSource? | DataSource | Optional data source (of type , meaning both and are supported) from which to retrieve data to load into the chart. |
| dataSourceFilter? | ChartModelFilter | When you provide , you can also provide a filter which accepts or rejects specific nodes/groups in the data source. |
| defaultColor? | string | Optional color to use for every series. Overrides any colorGenerator. |
| emptyMessage? | string | Message to display when the chart has no data. Defaults to "No data". |
| endAngle? | number | The end angle of the gauge in degrees. Typically 135 for a speedometer style. |
| height? | number | Height for the chart. If omitted, height is computed from the width of the chart's container |
| innerRadius? | number | Inner radius ratio (0 to 1). A higher value (e.g. 0.8) creates a thin arc. 0 creates a semi-circle. |
| labels? | {
color:string, distance:number, fontSize:number, fontWeight:string | number, formatter:(value:number) => string, interval:number, pill:boolean | GaugeChartLabelPillOptions, position:"outside" | "ends", rotate:"none" | "tangent", suffix:string, values:Array<number> } | Configuration for the scale labels. |
| legend? | boolean | LegendSpec | Either a boolean true/false, indicating the legend should be shown/hidden, or a spec for a legend. |
| max? | number | The maximum value on the scale. Defaults to 100. |
| min? | number | The minimum value on the scale. Defaults to 0. |
| outerRadius? | number | Outer radius ratio (0 to 1). Defaults to 1. |
| resizeObserver? | boolean | Defaults to true, meaning the chart will redraw when its container element resizes. |
| showNeedle? | boolean | Whether to show a needle/pointer. Defaults to true. When false, the zones are painted up to the value. |
| startAngle? | number | The start angle of the gauge in degrees. 0 is the top. Typically -135 for a speedometer style. |
| style? | ChartStyleOptions | Styles for legend and grid. |
| subtitle? | SubtitleSpec | Subtitle for the chart. |
| ticks? | {
color:string, interval:number, length:number, minorColor:string, minorInterval:number, minorLength:number, position:"inside" | "outside", values:Array<number>, width:number } | Configuration for tick marks. |
| title? | ChartTitleSpec | Title for the chart. |
| titlePadding? | number | Padding to leave underneath the title |
| tooltip? | TooltipOptions | Options for a tooltip for the chart. |
| url? | string | Optional URL from which to retrieve data to load into the chart |
| value? | number | Current value. If not provided, the gauge will use the computed (which you may have provided, but if not, will be set to 0) |
| width? | number | Width for the chart. If omitted, width is computed from the width of the chart's container |
| zones? | Array<GaugeChartZone> | Optional segments to color the background arc |
| zoom? | {
enabled:boolean, initialValue:number, range:[number, number] } | Optional zoom configuration. |
CSS Classes
| Class | Description |
|---|---|
vjs-gauge-chart | Assigned to the container for a gauge chart |
vjs-gauge-center-subtitle | Assigned to the center subtitle text in a GaugeChart. |
vjs-gauge-center-value | Assigned to the primary center value text in a GaugeChart. |
vjs-gauge-label | Assigned to each label element in a GaugeChart. |
vjs-gauge-label-dot | Assigned to each anchor dot on the outer rim for pill labels in a GaugeChart. |
vjs-gauge-label-pill | Assigned to each pill background rect around a label in a GaugeChart. |
vjs-gauge-needle | Assigned to the needle element in a GaugeChart. |
vjs-gauge-needle-pivot | Assigned to the needle pivot element in a GaugeChart. |
vjs-gauge-tick | Assigned to each tick element in a GaugeChart. |
vjs-gauge-tick-minor | Assigned to each minor tick element in a GaugeChart. |
vjs-gauge-track | Assigned to the track element in a GaugeChart. |
vjs-gauge-zone | Assigned to each zone element in a GaugeChart. |