logo

G2

  • Chart Gallery
  • Docs
  • Examples
  • Theme
  • Ecosystem
  • Productsantv logo arrow
  • 5.3.3
  • Get Started
  • Introduction
    • What is G2
    • Using in Frontend Frameworks
    • Experimental Spec API
  • Chart API
  • Core Concepts
    • Chart
      • Components of G2 Charts
      • How to Use Charts
    • Mark
      • Overview
      • area
      • box
      • boxplot
      • cell
      • chord
      • density
      • gauge
      • heatmap
      • image
      • interval
      • line
      • lineX
      • lineY
      • link
      • liquid
      • sunburst
      • point
      • polygon
      • range
      • rangeX
      • rangeY
      • rect
      • shape
      • text
      • vector
      • connector
      • wordCloud
    • View
    • Data
      • Overview
      • custom
      • ema
      • fetch
      • filter
      • fold
      • inline
      • join
      • kde
      • log
      • map
      • pick
      • rename
      • slice
      • sort
      • sortBy
    • Encode
    • Scale
      • Overview
      • band
      • linear
      • log
      • ordinal
      • point
      • quantile
      • quantize
      • sqrt
      • threshold
      • time
      • pow
    • Transform
      • Overview
      • bin
      • binX
      • diffY
      • dodgeX
      • flexX
      • group
      • groupColor
      • groupX
      • groupY
      • jitter
      • jitterX
      • jitterY
      • normalizeY
      • pack
      • sample
      • select
      • selectX
      • selectY
      • sortColor
      • sortX
      • sortY
      • stackEnter
      • stackY
      • symmetryY
    • Coordinate
      • Overview
      • fisheye
      • parallel
      • polar
      • theta
      • transpose
      • radial
      • cartesian3D
      • helix
    • Style
    • Animate
      • Overview
      • fadeIn
      • fadeOut
      • growInX
      • growInY
      • morphing
      • pathIn
      • scaleInX
      • scaleInY
      • scaleOutX
      • scaleOutY
      • waveIn
      • zoomIn
      • zoomOut
    • State
    • Interaction
      • Overview
      • brushAxisHighlight
      • brushHighlight
      • brushXHighlight
      • brushYHighlight
      • brushFilter
      • brushXFilter
      • brushYFilter
      • chartIndex
      • elementHighlight
      • elementHighlightByColor
      • elementHighlightByX
      • elementSelect
      • elementSelectByColor
      • elementSelectByX
      • legendFilter
      • legendHighlight
      • poptip
      • scrollbarFilter
      • sliderFilter
      • fisheye
    • Composition
      • Overview
      • facetCircle
      • facetRect
      • repeatMatrix
      • spaceFlex
      • spaceLayer
      • timingKeyframe
    • Theme
      • Overview
      • academy
      • classic
      • classicDark
    • Events
    • Color Mapping
  • Chart Component
    • Title
    • Axis
    • Legend
    • Scrollbar
    • Slider
    • Tooltip
    • Data Label
  • Extra Topics
    • Graph
      • forceGraph
      • pack
      • sankey
      • tree
      • treemap
    • Geo
      • geoPath
      • geoView
    • 3D
      • Draw 3D Chart
      • point3D
      • line3D
      • interval3D
      • surface3D
    • Plugin
      • renderer
      • rough
      • lottie
      • a11y
    • Package on demand
    • Set pattern
    • Server-Side Rendering (SSR)
    • Spec Function Expression Support (Available in 5.3.0)
  • Whats New
    • New Version Features
    • Migration from v4 to v5
  • Frequently Asked Questions (FAQ)

gauge

Previous
density
Next
heatmap

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Overview

gauge is used to create gauge charts, which are common visualization charts used to display data progress, proportions, or comparisons.

Typical use cases:

  • Business metrics: sales achievement rate, user growth progress;
  • System monitoring: CPU/memory usage, disk capacity warnings;
  • Device gauges: vehicle speedometer, temperature gauge simulation.

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'gauge', // Set the chart type to gauge
data: {
value: {
target: 120, // Target value of the gauge
total: 400, // Total value of the gauge
name: 'score', // Name of the gauge data
},
},
});
chart.render();

Options

PropertyDescriptionTypeDefaultRequired
dataDefine the gauge values, target values and category information, driving pointer position, color mapping and multi-gauge facet display through data bindingdata-✓
encodeConfigure visual channels for gauge marks, including x, y, color, etc., to specify the relationship between visual element properties and dataencode-
scaleConfigure scales for gauge marks, including y, size, etc.scale-
styleConfigure graphic styles and label stylesstyle-

data

data defines the gauge values, target values and category information, driving pointer position, color mapping and multi-gauge facet display through data binding.

PropertyDescriptionTypeDefaultRequired
targetSet the target value of the gauge pointernumber-
totalSet the maximum range value of the gauge scalenumber-
percentSet the percentage pointed by the gauge pointer (when percent is configured, target and total values will be invalid, please set thresholds in a reasonable range, otherwise it will cause rendering errors)number-
thresholdsSet the gauge scale threshold intervalsnumber[]-

For more data configuration, you can check the data introduction page.

encode

Configure visual channels for gauge marks, which define the mapping relationship between data fields and visual properties. This is an important configuration that determines how data is transformed into visual representation.

PropertyDescriptionTypeDefaultRequired
xBind the x property channel of gauge marks, usually a time or ordinal name field in dataencode'x'
yBind the y property channel of gauge marks, usually a numeric or array field in dataencode'y'
colorBind the color property channel of gauge marks. If data fields are mapped to color channels, data will be grouped and split into multiple regions with different colorsencode'color'

For more encode configuration, you can check the encode introduction page.

scale

scale is used to define how data maps to visual properties (such as color, size, shape, etc.).

PropertyDescriptionTypeDefaultRequired
yDefine the mapping rules from data fields to Y-axis visual positionsscale{domain: [0, percent ? 1 : total]}
colorDefine the color mapping rules for gauge scalesscale{range: ['#30BF78', '#D0D0D0']}

color

The color distribution is related to the data in data. Colors here can be set as gradients for configuring gradient gauge charts.

  • With only target or percent, the color parameter range can consist of two color parameters. On the gauge scale, these two colors will divide the gauge scale into two segments

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'gauge',
data: {
value: {
target: 120,
total: 400,
name: 'score',
},
},
scale: {
color: { range: ['#FAAD14', 'green'] },
},
});
chart.render();
  • When thresholds is set, the colors in the color parameter range should match the length of thresholds. The gauge scale will be segmented by the values in thresholds and filled with colors from the corresponding positions in the scale parameter color

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'gauge',
data: {
value: {
target: 120,
total: 400,
name: 'score',
thresholds: [100, 200, 400],
},
},
scale: {
color: { range: ['#F4664A', '#FAAD14', 'green'] },
},
});
chart.render();

For more scale configuration, you can check the scale introduction page.

style

style is used to set the appearance of chart elements, including fill colors, border styles, shadow effects, etc.

PropertyDescriptionTypeDefaultRequired
arcConfigure the style of gauge arcarcSee arc
pinConfigure the style of gauge pointer axispinSee pin
pointerConfigure the style of gauge pointerpointerSee pointer
textConfigure the style of gauge center texttextSee text

Composite graphic marks need to be distinguished by different prefixes to configure graphics.

arc

Configure gauge arc styles through the arc prefix.

PropertyDescriptionTypeDefaultRequired
arcShapeGauge arc shape'rect' |'hollow'|'round''rect'
arcFillGauge arc fill colorstring | (datum, index, data) => string-
arcFillOpacityGauge arc fill opacitynumber | (datum, index, data) => number-
arcStrokeGauge arc stroke colorstring | (datum, index, data) => string-
arcStrokeOpacityGauge arc stroke opacitynumber | (datum, index, data) => number-
arcLineHeightGauge arc line heightnumber | (datum, index, data) => number-
arcLineWidthGauge arc stroke widthnumber | (datum, index, data) => number-
arcLineDashGauge arc dash configuration[number,number] | (datum, index, data) => [number , number]-
arcOpacityGauge arc overall opacitynumber | (datum, index, data) => number-
arcShadowColorGauge arc shadow colorstring | (datum, index, data) => string-
arcShadowBlurGauge arc shadow blur factornumber | (datum, index, data) => number-
arcShadowOffsetXGauge arc shadow horizontal offsetnumber | (datum, index, data) => number-
arcShadowOffsetYGauge arc shadow vertical offsetnumber | (datum, index, data) => number-
arcCursorGauge arc mouse cursor stylestring | (datum, index, data) => stringdefault

pin

Configure gauge pointer axis styles through the pin prefix.

PropertyDescriptionTypeDefaultRequired
pinRGauge pointer axis radius sizenumber | (datum, index, data) => number10
pinFillGauge pointer axis fill colorstring | (datum, index, data) => string'#fff'
pinFillOpacityGauge pointer axis fill opacitynumber | (datum, index, data) => number-
pinStrokeGauge pointer axis stroke colorstring | (datum, index, data) => string-
pinStrokeOpacityGauge pointer axis stroke opacitynumber | (datum, index, data) => number-
pinLineHeightGauge pointer axis line heightnumber | (datum, index, data) => number-
pinLineWidthGauge pointer axis stroke widthnumber | (datum, index, data) => number-
pinLineDashGauge pointer axis dash configuration[number,number] | (datum, index, data) => [number , number]-
pinOpacityGauge pointer axis overall opacitynumber | (datum, index, data) => number-
pinShadowColorGauge pointer axis shadow colorstring | (datum, index, data) => string-
pinShadowBlurGauge pointer axis shadow blur factornumber | (datum, index, data) => number-
pinShadowOffsetXGauge pointer axis shadow horizontal offsetnumber | (datum, index, data) => number-
pinShadowOffsetYGauge pointer axis shadow vertical offsetnumber | (datum, index, data) => number-
pinCursorGauge pointer axis mouse cursor stylestring | (datum, index, data) => stringdefault

pointer

Configure gauge pointer styles through the pointer prefix.

PropertyDescriptionTypeDefaultRequired
pointerShapeGauge pointer shape'line' |(points, value, coordinate, theme) => DisplayObject'line'
pointerStrokeGauge pointer stroke colorstring | (datum, index, data) => string-
pointerStrokeOpacityGauge pointer stroke opacitynumber | (datum, index, data) => number-
pointerLineWidthGauge pointer line widthnumber | (datum, index, data) => number-
pointerLineDashGauge pointer dash configuration[number,number] | (datum, index, data) => [number , number]-
pointerOpacityGauge pointer overall opacitynumber | (datum, index, data) => number-
pointerShadowColorGauge pointer shadow colorstring | (datum, index, data) => string-
pointerShadowBlurGauge pointer shadow blur factornumber | (datum, index, data) => number-
pointerShadowOffsetXGauge pointer shadow horizontal offsetnumber | (datum, index, data) => number-
pointerShadowOffsetYGauge pointer shadow vertical offsetnumber | (datum, index, data) => number-
pointerCursorGauge pointer mouse cursor stylestring | (datum, index, data) => stringdefault

text

Configure gauge indicator text styles through the text prefix.

PropertyDescriptionTypeDefaultRequired
textContentSet gauge center indicator text contentstring-
textXGauge center indicator text x-direction offset, can be set as specific value or percentagenumber | string50%
textYGauge center indicator text y-direction offset, can be set as specific value or percentagenumber | string60%
textFontSizeGauge indicator text font sizenumber | (datum, index, data) => number20
textFontFamilyGauge indicator text font familystring | (datum, index, data) => string-
textFontWeightGauge indicator text font weightnumber | (datum, index, data) => number800
textTextAlignGauge indicator text alignmentcenter | end | left | right | startcenter
textTextBaselineGauge indicator text baseline alignmenttop | middle | bottom | alphabetic | hangingmiddle
textFillGauge indicator text colorstring | (datum, index, data) => string#888
textFillOpacityGauge indicator text opacitynumber | (datum, index, data) => number-
textStrokeGauge indicator text stroke colorstring | (datum, index, data) => string-
textStrokeOpacityGauge indicator text stroke opacitynumber | (datum, index, data) => number-
textLineHeightGauge indicator text line heightnumber | (datum, index, data) => number-
textLineWidthGauge indicator text stroke widthnumber | (datum, index, data) => number-
textLineDashGauge indicator text dash configuration[number,number] | (datum, index, data) => [number , number]-
textOpacityGauge indicator text overall opacitynumber | (datum, index, data) => number-
textShadowColorGauge indicator text shadow colorstring | (datum, index, data) => string-
textShadowBlurGauge indicator text shadow blurnumber | (datum, index, data) => number-
textShadowOffsetXGauge indicator text shadow horizontal offsetnumber | (datum, index, data) => number-
textShadowOffsetYGauge indicator text shadow vertical offsetnumber | (datum, index, data) => number-
textCursorGauge indicator text mouse cursor stylestring | (datum, index, data) => stringdefault

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'gauge',
data: {
value: {
target: 159,
total: 400,
name: 'score',
// thresholds: [200, 400],
},
},
scale: {
color: {
range: ['l(0):0:#62CFF4 1:#2C67F2', 'l(0):0:#2C67F2 1:#00008B'],
},
y: {
range: [1, -0.5],
},
},
style: {
// Configure gauge indicator text style
textContent: (target, total) => `Ratio: ${(target / total) * 100}%`,
textFill: '#000',
textFontSize: 24,
textfontWeight: 300,
textX: '35%',
textY: '75%',
// Configure gauge pointer style
pointerStroke: '#c5c5c5',
pointershadowColor: '#333333',
pointershadowBlur: 10,
pointershadowOffsetX: 5,
pointershadowOffsetY: 5,
// Configure gauge pointer axis style
pinStroke: '#d5d5d5',
pinFill: '#d5d5d5',
pinlinewidth: 6,
pinshadowColor: '#333333',
pinshadowBlur: 30,
pinshadowOffsetX: 5,
pinshadowOffsetY: 5,
// Configure gauge arc style
arcLineWidth: 2,
arcStroke: '#fff',
arcshadowColor: '#333333',
arcshadowBlur: 30,
arcshadowOffsetX: 5,
arcshadowOffsetY: 5,
},
legend: false,
});
chart.render();

For more style configuration, you can check the style introduction page.

Try it out:

Examples

Custom Gauge Pointer Shape