Skip to main content

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.
NameTypeDescription
centerLabel?boolean | {
  formatter:(value:number) => string,
  subtitle:string,
  suffix:string
}
Optional hero value and subtitle rendered inside the center of the gauge arc.
colorGenerator?ColorGeneratorOptional 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?DataSourceOptional data source (of type DataSource, meaning both VisuallyJsModel and Selection are supported) from which to retrieve data to load into the chart.
dataSourceFilter?ChartModelFilterWhen you provide dataSource, you can also provide a filter which accepts or rejects specific nodes/groups in the data source.
defaultColor?stringOptional color to use for every series. Overrides any colorGenerator.
emptyMessage?stringMessage to display when the chart has no data. Defaults to "No data".
endAngle?numberThe end angle of the gauge in degrees.
Typically 135 for a speedometer style.
height?numberHeight for the chart. If omitted, height is computed from the width of the chart's container
innerRadius?numberInner 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 | LegendSpecEither a boolean true/false, indicating the legend should be shown/hidden, or a spec for a legend.
max?numberThe maximum value on the scale. Defaults to 100.
min?numberThe minimum value on the scale. Defaults to 0.
outerRadius?numberOuter radius ratio (0 to 1). Defaults to 1.
resizeObserver?booleanDefaults to true, meaning the chart will redraw when its container element resizes.
showNeedle?booleanWhether to show a needle/pointer. Defaults to true. When false, the zones are painted up to the value.
startAngle?numberThe start angle of the gauge in degrees. 0 is the top.
Typically -135 for a speedometer style.
style?ChartStyleOptionsStyles for legend and grid.
subtitle?SubtitleSpecSubtitle 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?ChartTitleSpecTitle for the chart.
titlePadding?numberPadding to leave underneath the title
tooltip?TooltipOptionsOptions for a tooltip for the chart.
url?stringOptional URL from which to retrieve data to load into the chart
value?numberCurrent value. If not provided, the gauge will use the computed min (which you may have provided, but if not, will be set to 0)
width?numberWidth 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​

ClassDescription
vjs-gauge-chartAssigned to the container for a gauge chart
vjs-gauge-center-subtitleAssigned to the center subtitle text in a GaugeChart.
vjs-gauge-center-valueAssigned to the primary center value text in a GaugeChart.
vjs-gauge-labelAssigned to each label element in a GaugeChart.
vjs-gauge-label-dotAssigned to each anchor dot on the outer rim for pill labels in a GaugeChart.
vjs-gauge-label-pillAssigned to each pill background rect around a label in a GaugeChart.
vjs-gauge-needleAssigned to the needle element in a GaugeChart.
vjs-gauge-needle-pivotAssigned to the needle pivot element in a GaugeChart.
vjs-gauge-tickAssigned to each tick element in a GaugeChart.
vjs-gauge-tick-minorAssigned to each minor tick element in a GaugeChart.
vjs-gauge-trackAssigned to the track element in a GaugeChart.
vjs-gauge-zoneAssigned to each zone element in a GaugeChart.