▾
Weather stations styled with a simple renderer and visual variables to show air temperature.
What are visual variables?
Visual variables
There are four visual variables that can be overridden with data values.
- Color
- Size
- Opacity
- 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
Color visual variables require the following:
- A reference to a data value either from a field name, or an Arcade expression.
- 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.
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>47 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Visual variables - color</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/light/main.css" /> <!-- 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 center="-96.702688, 41.1198" scale="36978595"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right"> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [Map, FeatureLayer] = await $arcgis.import(["@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js"]);
const viewElement = document.querySelector("arcgis-map");
const referenceScale = 9244650 * 4;
const renderer = { label: "Stations", type: "simple", symbol: { type: "simple-marker", style: "circle", color: [250, 250, 250], outline: { color: [255, 255, 255, 0.5], width: 0.5, }, size: "8px", }, visualVariables: [ { type: "color", field: "TEMP", stops: [ { value: 20, color: "#0571b0" }, { value: 35, color: "#92c5de" }, { value: 50, color: "#f7f7f7" }, { value: 65, color: "#f4a582" }, { value: 80, color: "#ca0020" }, ], }, ],27 collapsed lines
};
// Set the renderer on the feature layer const layer = new FeatureLayer({ portalItem: { id: "cb1886ff0a9d4156ba4d2fadd7e8a139", }, title: "Current weather conditions", renderer: renderer, });
const map = new Map({ basemap: { portalItem: { id: "ba223f982a3c4a0ea8c9953346e2a201", }, }, layers: [layer], });
viewElement.map = map; viewElement.constraints = { snapToZoom: false, }; </script> </body></html>Size
A size variable
The size visual variable can be defined in two different ways:
- With size stops, or
- Matching a
maxDataValuewith amaxSize, and aminDataValuewith aminSize.
Size visual variables require the following:
- A reference to a data value either from a field name, or an Arcade expression.
- 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.
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>46 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Visual variables - size</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/light/main.css" /> <!-- 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 center="-90.944135, 40.196798" scale="18489298"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right"> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [Map, FeatureLayer] = await $arcgis.import(["@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js"]);
const viewElement = document.querySelector("arcgis-map");
const referenceScale = 9244650 * 2;
const renderer = { type: "simple", symbol: { type: "simple-marker", style: "circle", color: [50, 50, 50, 0.4], outline: { color: [255, 255, 255, 0.3], width: 0.2, }, size: "8px", }, visualVariables: [ { type: "size", field: "WIND_SPEED", minDataValue: 5, maxDataValue: 60, minSize: 4, maxSize: 22, }, ],27 collapsed lines
};
// Set the renderer on the feature layer const layer = new FeatureLayer({ portalItem: { id: "cb1886ff0a9d4156ba4d2fadd7e8a139", }, title: "Current weather conditions", renderer: renderer, });
const map = new Map({ basemap: { portalItem: { id: "ba223f982a3c4a0ea8c9953346e2a201", }, }, layers: [layer], });
viewElement.map = map; viewElement.constraints = { snapToZoom: false, }; </script> </body></html>Rotation
A rotation variable
- 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.
- A reference to a data value either from a field name, or an Arcade expression.
- An optional rotation type indicating a geometry or arithmetic 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>49 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Visual variables - rotation</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/light/main.css" /> <!-- 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 center="-90.30195, 40.690002" scale="18489298"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right"> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [Map, FeatureLayer] = await $arcgis.import(["@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js"]);
const viewElement = document.querySelector("arcgis-map");
const referenceScale = 9244650 * 2;
const renderer = { label: "Stations", type: "simple", symbol: { angle: 180, type: "simple-marker", // Arrow marker defined as SVG path path: "M14.5,0 5.5,29 14.5,20 23.5,29z", color: [50, 50, 50], outline: { color: [255, 255, 255, 0.5], width: 0.5, }, size: "20px", }, visualVariables: [ { field: "WIND_DIRECT", rotationType: "geographic", type: "rotation", }, ],27 collapsed lines
};
// Set the renderer on the feature layer const layer = new FeatureLayer({ portalItem: { id: "cb1886ff0a9d4156ba4d2fadd7e8a139", }, title: "Current weather conditions", renderer: renderer, });
const map = new Map({ basemap: { portalItem: { id: "ba223f982a3c4a0ea8c9953346e2a201", }, }, layers: [layer], });
viewElement.map = map; viewElement.constraints = { snapToZoom: false, }; </script> </body></html>Opacity
An opacity variable
Opacity visual variables require the following:
- A reference to a data value either from a field name or an Arcade expression.
- At least two opacity stops that match data values to opacity values between
0and1. The opacity of symbols with data values between the designated stops are linearly interpolated.
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>71 collapsed lines
<!doctype html><html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <title>Visual variables - opacity</title>
<link rel="stylesheet" href="https://js.arcgis.com/5.2/esri/themes/dark/main.css" /> <!-- 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 center="-89.372318, 38.815995" scale="18489298"> <arcgis-zoom slot="top-left"></arcgis-zoom> <arcgis-expand slot="top-right"> <arcgis-legend></arcgis-legend> </arcgis-expand> </arcgis-map>
<script type="module"> const [Map, FeatureLayer] = await $arcgis.import(["@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js"]);
const viewElement = document.querySelector("arcgis-map");
const referenceScale = 9244650 * 2;
function createSymbol(color) { return { type: "simple-fill", outline: { color: "rgba(50,50,50,0.1)", width: 0.5, }, color, style: "solid", }; }
const renderer = { type: "unique-value", field: "DOM_CROP_ACRES", uniqueValueInfos: [ { value: "Corn", symbol: createSymbol("#e6d800"), }, { value: "Wheat", symbol: createSymbol("#9b19f5"), }, { value: "Soybeans", symbol: createSymbol("#0bb4ff"), }, { value: "Cotton", symbol: createSymbol("#50e991"), }, { value: "Vegetables", symbol: createSymbol("#e60049"), }, ], visualVariables: [ { type: "opacity", field: "TotalFarmedAcres", normalizationField: "AREA_ACRES", legendOptions: { showLegend: false, }, stops: [ { value: 0.0, opacity: 0.2 }, { value: 0.1, opacity: 0.5 }, { value: 0.5, opacity: 0.8 }, { value: 0.9, opacity: 1.0 }, ], }, ],21 collapsed lines
};
// Set the renderer on the feature layer const layer = new FeatureLayer({ url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/US_county_crops_2007_clean/FeatureServer/0", title: "U.S. county crops", renderer: renderer, });
const map = new Map({ basemap: "dark-gray-vector", layers: [layer], });
viewElement.map = map; viewElement.constraints = { snapToZoom: false, }; </script> </body></html>Related samples and resources
Data-driven continuous color
Size visual variable themes
Data-driven extrusion
Visualize data with rotation
Data-driven continuous size
Data-driven opacity
Generate data-driven continuous size visualization
Thematic visualization with realistic 3D symbols
API support
| 2D | 3D | Arcade | Points | Lines | Polygons | Mesh | |
|---|---|---|---|---|---|---|---|
| | | | | | | | |
| | | | | | | | |
| | | | | | | ||
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | |
- Color only
- Size variable creators only supported for points
- Size variable creators not supported in 3D