Item page
CodePen
Sandbox Download

Weather stations styled with a simple renderer and visual variables to show air temperature.

What are visual variables?

Visual variables Visual variables are a set of parameters that define one or more properties of a renderer's symbols based on the numeric data value returned from a field or expression. Learn more are objects that allow you to override one or more properties of a renderer’s symbols based on a numeric data value returned from a field or an expression. This is an alternative to visualizing numeric data with a class breaks style. Rather than separate values into discrete ranges of data, visual variables linearly interpolate between data stops to create a smooth, continuous (unclassed) visualization.

There are four visual variables that can be overridden with data values.

  1. Color
  2. Size
  3. Opacity
  4. Rotation

How visual variables work

All visual variables are added to a renderer’s visualVariables property. A renderer can contain more than one visual variable, but adding more than one at a time may cause confusion.

Multivariate visualizations

Learn how to style layers with a simple renderer using 2D and 3D symbols.

Color

A color variable A color variable is a visual variable that defines the color of a symbol based on a numeric data value returned from a field or expression. If an expression is used, the color can be defined from a color ramp with a set of pre-defined color ranges. Learn more overrides the color of a symbol based on a numeric data value returned from a field or expression along a continuous color ramp. Numeric data should be normalized before visualizing it with color, especially for polygon layers.

Color visual variables require the following:

  1. A reference to a data value either from a field name, or an Arcade expression.
  2. At least two color stops that match data values to colors. The colors of symbols with data values between the designated stops are linearly interpolated.
Map Viewer provides predefined color ramps that may include intermediate stops, but only two or three control values are adjustable, depending on the theme. For continuous styles, use JavaScript to create custom ramps with full control over every color stop.
Item page
CodePen
Sandbox Download
Weather stations are colored by the current air temperature along a continuous color ramp.
Visual variables - color
20 collapsed lines
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Visual variables - color</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.2/"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<arcgis-map item-id="b0cd29bd5eaf46d9aa4de29dd86ca0e6">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-right">
<arcgis-legend></arcgis-legend>
</arcgis-expand>
</arcgis-map>
2 collapsed lines
</body>
</html>

Size

A size variable A size variable is a visual variable that defines the size of a symbol based on a numeric data value returned from a field or expression. Learn more overrides the size of a symbol based on a numeric data value returned from a field or expression. This does not apply to renderers with fill symbols. To visualize a polygon layer by size, you should use a marker symbol, which will be rendered at the centroid of the polygon.

The size visual variable can be defined in two different ways:

  1. With size stops, or
  2. Matching a maxDataValue with a maxSize, and a minDataValue with a minSize.

Size visual variables require the following:

  1. A reference to a data value either from a field name, or an Arcade expression.
  2. At least two size stops that match data values to sizes. The sizes of symbols with data values between the designated stops are linearly interpolated.
Item page
CodePen
Sandbox Download
Weather station symbols vary in size with current wind speed along a continuous size ramp.
Visual variables - size
20 collapsed lines
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Visual variables - size</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.2/"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<arcgis-map item-id="9d0cf573da4c43b0ada459150011f52c">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-right">
<arcgis-legend></arcgis-legend>
</arcgis-expand>
</arcgis-map>
2 collapsed lines
</body>
</html>

Rotation

A rotation variable A rotation variable is a visual variable that defines the rotation of a symbol based on a numeric data value returned from a field or expression. This value is typically used to rotate symbols that indicate directionality. Learn more sets the rotation of a symbol based on a numeric data value returned from a field or expression. This is typically done to rotate symbols that indicate directionality, such as:

  • wind direction
  • traffic flow
  • aspect

Rotation visual variables are different from other visual variables in that they only require a data value without the need for stops.

  1. A reference to a data value either from a field name, or an Arcade expression.
  2. An optional rotation type indicating a geometry or arithmetic rotation.
Item page
CodePen
Sandbox Download
Weather station arrow markers rotate to show wind direction.
Visual variables - rotation
20 collapsed lines
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Visual variables - rotation</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.2/"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<arcgis-map item-id="1d64cf8c1804422faa6526346c407867">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-right">
<arcgis-legend></arcgis-legend>
</arcgis-expand>
</arcgis-map>
2 collapsed lines
</body>
</html>

Opacity

An opacity variable An opacity variable defines the opacity of a symbol based on a numeric data value returned from a field or expression. It is typically used to make features more or less prominent than others. Learn more overrides the opacity of a symbol based on a numeric data value returned from a field or expression. This variable is typically used to subdue features or make some more prominent than others.

Opacity visual variables require the following:

  1. A reference to a data value either from a field name or an Arcade expression.
  2. At least two opacity stops that match data values to opacity values between 0 and 1. The opacity of symbols with data values between the designated stops are linearly interpolated.
Map Viewer only supports minimum and maximum transparency values. Intermediate opacity stops must be configured in JavaScript.
Item page
CodePen
Sandbox Download
U.S. counties show their predominant crop and are faded or emphasized by the share of farmland they contain.
Visual variables - opacity
20 collapsed lines
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Visual variables - opacity</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.2/"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<arcgis-map item-id="9d605ee515e54abc9008955d166a08d8">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-right">
<arcgis-legend></arcgis-legend>
</arcgis-expand>
</arcgis-map>
2 collapsed lines
</body>
</html>

API support

  1. Color only
  2. Size variable creators only supported for points
  3. Size variable creators not supported in 3D