▾
Average air quality index (AQI) in L.A. County with two guides: one for healthy AQI values and another for unhealthy AQI values.
What is a gauge?
Gauges are used to display a single metric in a quantitative context defined by a range of values. The metric can be derived from a summary statistic or one of a feature’s numeric fields.
Data configurations
This section covers a few data configuration examples for gauges, each configured using the gauge model. See the gauge model reference for the full list of available properties and methods.
Statistic gauge
A statistic gauge applies an aggregation method to a numeric field to calculate a single value that is then visualized on the gauge. This type of gauge is useful for displaying overall performance metrics or key indicators based on aggregated data.
- Set the
fieldproperty to"MeasuredValue"to specify the numeric field. - Set the
aggregationTypeproperty to"avg"to calculate the average value. - Set the
innerLabelContentproperty to display the aggregated value inside the gauge.
32 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Statistic Gauge</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "9f209b07551e4af89477ba4c454058b7", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", }); gaugeModel.field = "MeasuredValue"; gaugeModel.aggregationType = "avg"; gaugeModel.innerLabelContent = { type: "esriTS" };8 collapsed lines
gaugeModel.innerRadius = 50; gaugeModel.startAngle = -200; gaugeModel.endAngle = 20; gaugeModel.titleText = "Average Air Quality Index (AQI) in L.A. County"; chartElement.model = gaugeModel; </script> </body></html>Feature gauge
A feature gauge visualizes individual features from a dataset, allowing you to see how specific data points contribute to the overall metric.
- Set the
fieldproperty to"MeasuredValue"to specify the numeric field. - Set the
featureIndexproperty to"0"to specify the feature to visualize.
32 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Feature Gauge</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "9f209b07551e4af89477ba4c454058b7", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", }); gaugeModel.field = "MeasuredValue"; gaugeModel.featureIndex = 0;9 collapsed lines
gaugeModel.innerLabelContent = { type: "esriTS" }; gaugeModel.innerRadius = 50; gaugeModel.startAngle = -200; gaugeModel.endAngle = 20; gaugeModel.titleText = "Air Quality Index (AQI) for Specific Location (index 0) in L.A. County"; chartElement.model = gaugeModel; </script> </body></html>Customization options
Start and end angles
Gauges can be customized to display a full circle, half circle, or any other arc by adjusting the start and end angles from the startAngle and endAngle properties of the gauge model.
The angles are specified in degrees, with 0 degrees pointing to the right (3 o’clock position) and increasing counterclockwise.
| Default (full circle) | startAngle: -200endAngle: 20 | startAngle: -180endAngle: -90 | startAngle: 0endAngle: 180 |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
Inner radius
The inner radius of a gauge can be adjusted using the innerRadius property of the gauge model.
This property controls the size of the inner circle, allowing you to create a donut-like appearance or adjust the width of the gauge. The inner label size will adjust accordingly to fit within the inner radius.
Default (innerRadius: 80) | innerRadius: 50 | innerRadius: 20 |
|---|---|---|
![]() | ![]() | ![]() |
Inner label
The inner label of a gauge can be customized using the innerLabelContent and innerLabelVisible properties of the gauge model.
- Use the
innerLabelContentmethod to customize the inner label to be red and increase the font size and weight.
39 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Gauge Inner Label</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "9f209b07551e4af89477ba4c454058b7", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", });
gaugeModel.field = "MeasuredValue"; gaugeModel.aggregationType = "avg"; gaugeModel.innerLabelContent = { type: "esriTS" }; gaugeModel.innerRadius = 50; gaugeModel.startAngle = -200; gaugeModel.endAngle = 20; gaugeModel.innerLabelContent = { type: "esriTS", color: [255, 0, 0, 255], font: { size: 35, weight: "bold", }, };5 collapsed lines
gaugeModel.titleText = "Average Air Quality Index (AQI) in L.A. County"; chartElement.model = gaugeModel; </script> </body></html>Axis
There are a couple of axis elements that can be customized in a gauge: labels, lines, and the visibility of ticks. First and last labels are always displayed, other labels can be hidden when onlyShowFirstAndLastLabels is set to true.
- Use the
axisLabelsSymbolproperty to customize the axis labels to be red and increase the font size and weight. - Use the
axisLinesSymbolproperty to customize the axis lines to be dotted and increase the line width. - Optionally, use the
axisTickVisibilityproperty to hide the axis ticks if they are not needed.
39 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Gauge Axis</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "9f209b07551e4af89477ba4c454058b7", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", });
gaugeModel.field = "MeasuredValue"; gaugeModel.aggregationType = "avg"; gaugeModel.innerLabelContent = { type: "esriTS" }; gaugeModel.innerRadius = 50; gaugeModel.startAngle = -200; gaugeModel.endAngle = 20; gaugeModel.axisLabelsSymbol = { type: "esriTS", color: [255, 0, 0, 255], font: { size: 30, weight: "bold", }, }; gaugeModel.axisLinesSymbol = { type: "esriSLS", style: "esriSLSDash", color: [170, 170, 170, 255], width: 5, };5 collapsed lines
gaugeModel.titleText = "Average Air Quality Index (AQI) in L.A. County"; chartElement.model = gaugeModel; </script> </body></html>Needle
The needle of a gauge is used to indicate the current value and there are a number of properties that can be used to customize its appearance.
- Set the
needleSymbolproperty to customize the needle to be red and change the style toesriSFSBackwardDiagonal. - Set the
needleStartWidthandneedleEndWidthproperties to adjust the width of the needle at the base and tip, respectively. - Set the
needleInnerRadiusproperty to adjust the inner radius of the needle, which controls how far the needle extends into the center of the gauge. - Set the
needleDisplayPinproperty totrueto show the needle pin in the center of the gauge.
39 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Gauge Needle</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "9f209b07551e4af89477ba4c454058b7", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", });
gaugeModel.field = "MeasuredValue"; gaugeModel.aggregationType = "avg"; gaugeModel.innerLabelVisible = false; gaugeModel.innerRadius = 50; gaugeModel.startAngle = -200; gaugeModel.endAngle = 20; gaugeModel.needleSymbol = { type: "esriSFS", style: "esriSFSBackwardDiagonal", color: [255, 0, 0, 255], }; gaugeModel.needleStartWidth = 25; gaugeModel.needleEndWidth = 2; gaugeModel.needleInnerRadius = 30; gaugeModel.needleDisplayPin = true;5 collapsed lines
gaugeModel.titleText = "Average Air Quality Index (AQI) in L.A. County"; chartElement.model = gaugeModel; </script> </body></html>Guides
Guides are used to indicate specific values or ranges on the gauge, providing context for interpreting the metric being visualized. They can be used to highlight thresholds, targets, or performance levels.
- Use the
addXAxisGuidemethod to add guides to the gauge. - Use the
setGuideStartandsetGuideEndmethods to specify the start and end values for each guide. - Use the
setGuideStylemethod to customize the appearance of each guide, such as setting the color and opacity. - Repeat the above steps to add multiple guides to the gauge as needed.
42 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Gauge with Guides</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "9f209b07551e4af89477ba4c454058b7", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", }); gaugeModel.field = "MeasuredValue"; gaugeModel.aggregationType = "avg"; gaugeModel.innerRadius = 50; gaugeModel.startAngle = -200; gaugeModel.endAngle = 20; gaugeModel.needleSymbol = { type: "esriSFS", color: [255, 0, 0, 255], }; gaugeModel.innerLabelContent = { type: "esriTS" }; // 0 - 50 guide gaugeModel.addXAxisGuide("Guide 1", 0); gaugeModel.setGuideStart(0, 0, "x"); gaugeModel.setGuideEnd(50, 0, "x"); gaugeModel.setGuideStyle( { type: "esriSFS", color: [0, 228, 0, 100], }, 0, ); // 50 - 100 guide gaugeModel.addXAxisGuide("Guide 2", 1); gaugeModel.setGuideStart(50, 1, "x"); gaugeModel.setGuideEnd(100, 1, "x"); gaugeModel.setGuideStyle( { type: "esriSFS", color: [255, 255, 0, 100], }, 1, );5 collapsed lines
gaugeModel.titleText = "Average Air Quality Index (AQI) in L.A. County"; chartElement.model = gaugeModel; </script> </body></html>Progress bands
Progress bands are similar to guides but are used to visually represent the progress of a metric towards a target or threshold.
- Set the
progressBandsproperty to add progress bands to the gauge. - Set the
typeproperty ofprogressBandsto"fixed"to specify that the bands represent fixed ranges of values. - Set the
visibleproperty ofprogressBandstotrueto make the bands visible on the gauge. - Define the
bandsproperty ofprogressBandsto specify the appearance of the target and base bands.
36 collapsed lines
<html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Gauge with Progress Bands</title> <style> html, body, arcgis-chart { height: 100%; margin: 0; } </style> <!-- Load the ArcGIS Maps SDK for JavaScript from CDN --> <script type="module" src="https://js.arcgis.com/5.2/"></script> </head>
<body> <arcgis-chart></arcgis-chart> <script type="module"> const { createModel } = await $arcgis.import("@arcgis/charts-components/model/shared/setup-utils.js"); const FeatureLayer = await $arcgis.import("@arcgis/core/layers/FeatureLayer.js"); const featureLayer = new FeatureLayer({ portalItem: { id: "e3bb6dbf5e0e44baad8391c74161198c", }, }); const chartElement = document.querySelector("arcgis-chart"); const gaugeModel = await createModel({ layer: featureLayer, chartType: "gauge", }); gaugeModel.field = "PctFull"; gaugeModel.featureIndex = 0; gaugeModel.innerLabelContent = { type: "esriTS" }; gaugeModel.needleVisibility = false; gaugeModel.progressBands = { type: "fixed", visible: true, bands: { target: { type: "esriSFS", color: [33, 150, 243, 255], }, base: { type: "esriSFS", color: [224, 224, 224, 255], }, }, };10 collapsed lines
gaugeModel.startAngle = -180; gaugeModel.endAngle = 0; gaugeModel.minXBound = 0; gaugeModel.maxXBound = 1; gaugeModel.labelsIncrement = 0.1; gaugeModel.titleText = "Upper Klamath Lake Capacity (%)"; chartElement.model = gaugeModel; </script> </body></html>





