CodePen
Sandbox Download

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.

CodePen
Sandbox Download
This chart visualizes the average air quality index (AQI) in L.A. County.
  1. Set the field property to "MeasuredValue" to specify the numeric field.
  2. Set the aggregationType property to "avg" to calculate the average value.
  3. Set the innerLabelContent property to display the aggregated value inside the gauge.
Statistic 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.

CodePen
Sandbox Download
This chart visualizes the air quality index (AQI) for a specific feature (at index `0`) in L.A. County.
  1. Set the field property to "MeasuredValue" to specify the numeric field.
  2. Set the featureIndex property to "0" to specify the feature to visualize.
Feature 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>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: -200
endAngle: 20
startAngle: -180
endAngle: -90
startAngle: 0
endAngle: 180
Default start and end anglesStart angle -200, end angle 20Start angle -180, end angle -90Start angle 0, end angle 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: 50innerRadius: 20
Default inner radiusInner radius 50Inner radius 20

Inner label

The inner label of a gauge can be customized using the innerLabelContent and innerLabelVisible properties of the gauge model.

CodePen
Sandbox Download
Customized inner label style of the gauge.
  1. Use the innerLabelContent method to customize the inner label to be red and increase the font size and weight.
Inner label
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.

CodePen
Sandbox Download
Customized axis style of the gauge.
  1. Use the axisLabelsSymbol property to customize the axis labels to be red and increase the font size and weight.
  2. Use the axisLinesSymbol property to customize the axis lines to be dotted and increase the line width.
  3. Optionally, use the axisTickVisibility property to hide the axis ticks if they are not needed.
Axis
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.

CodePen
Sandbox Download
Customized needle style of the gauge.
  1. Set the needleSymbol property to customize the needle to be red and change the style to esriSFSBackwardDiagonal.
  2. Set the needleStartWidth and needleEndWidth properties to adjust the width of the needle at the base and tip, respectively.
  3. Set the needleInnerRadius property to adjust the inner radius of the needle, which controls how far the needle extends into the center of the gauge.
  4. Set the needleDisplayPin property to true to show the needle pin in the center of the gauge.
Needle
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.

CodePen
Sandbox Download
This chart visualizes the AQI in L.A. County with two guides: one for healthy AQI values (0-50) and another for unhealthy AQI values (50-100).
  1. Use the addXAxisGuide method to add guides to the gauge.
  2. Use the setGuideStart and setGuideEnd methods to specify the start and end values for each guide.
  3. Use the setGuideStyle method to customize the appearance of each guide, such as setting the color and opacity.
  4. Repeat the above steps to add multiple guides to the gauge as needed.
Guides
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.

CodePen
Sandbox Download
This chart visualizes the Upper Klamath Lake capacity with two progress bands: one for the current capacity (blue band) and another for the target capacity (grey band).
  1. Set the progressBands property to add progress bands to the gauge.
  2. Set the type property of progressBands to "fixed" to specify that the bands represent fixed ranges of values.
  3. Set the visible property of progressBands to true to make the bands visible on the gauge.
  4. Define the bands property of progressBands to specify the appearance of the target and base bands.
Progress 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>