Loading...

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to generate a relationship visualization (or bivariate choropleth) to compare two numeric fields in a SceneLayer. This is accomplished with the createRenderer() method in the relationship renderer creator helper object.

While this visualization style was originally designed for 2D choropleth maps, it is particularly useful in 3D scenes where bivariate visualizations of color and size would not otherwise be possible since the size of features is reserved for real-world sizes of objects, such as buildings. Therefore, the relationship renderer becomes ideal for creating thematic bivariate visualizations of 3d object SceneLayers.

Creating bivariate choropleth visualizations is typically tedious and time consuming because it involves creating two classifications of your data and carefully combining them into bins on a 2x2, 3x3, or 4x4 grid. Creating color schemes that work well and properly communicate the message can also be very difficult. The createRenderer method in the relationshipRendererCreator module removes a lot of the guesswork and time required to create relationship visualizations. All you have to do is provide the following information and the renderer is generated for you, including a predetermined color scheme. Other color schemes are also available to you in the relationship symbology module.

const params = {
  layer: layer,
  view: view,
  field1: {
    field: "StarScore"
  },
  field2: {
    field: "ElectricUse"
  },
  focus: "HH", // changes orientation of the legend
  numClasses: 2 // 2x2 grid (value can also be 3 or 4)
};

// That's it! Now apply the renderer to your layer

relationshipRendererCreator.createRenderer(params).then(function(response) {
  layer.renderer = response.renderer;
});

Technically, the output renderer is a UniqueValueRenderer instance. By default, the legend has generic labels for indicating which field is high and low for various regions of the legend. You can customize this text by modifying the label property of each UniqueValueInfo object.

renderer.uniqueValueInfos.forEach(function(info) {
  switch (info.value) {
    case "HH":
      info.label = "High energy score, High electric use";
      break;
    case "HL":
      info.label = "High energy score, Low electric use";
      break;
    case "LH":
      info.label = "Low energy score, High electric use";
      break;
    case "LL":
      info.label = "Low energy score, Low electric use";
      break;
  }
});

Note that even if you observe a positive relationship between the two variables of interest, it doesn't mean they are statistically correlated. It also doesn't imply the presence of one variable influences the other. Therefore, this renderer should be used judiciously with some prior knowledge that two variables may likely be related.

Relationship renderers are most easily authored and configured in ArcGIS Online. Read this blog to learn more about how to do this.

A word of caution

Keep in mind that generating renderers should be avoided in most applications because of the performance cost affecting the end user. As stated in the Visualization overview: Smart mapping API guide topic, the Smart Mapping APIs were designed for two types of applications: data exploration apps and visualization authoring apps similar to ArcGIS Online. In all other cases, renderers should be saved to the layer or manually created using any of the renderer classes.

Additional visualization samples and resources

101 results for Sample Code:

TitleSample
Import glTF 3D Models Explore in the sandboxSandbox CodePen View live
SceneView - hitTest Explore in the sandboxSandbox CodePen View live
Intro to SceneView - Create a 3D map Explore in the sandboxSandbox CodePen View live
IntegratedMeshLayer Explore in the sandboxSandbox CodePen View live
WebTileLayer Explore in the sandboxSandbox CodePen View live
Satellites in 3D view Explore in the sandboxSandbox CodePen View live
Detect WebGL support Explore in the sandboxSandbox CodePen View live
Add Graphics to a SceneView Explore in the sandboxSandbox CodePen View live
Custom background for SceneView Explore in the sandboxSandbox CodePen View live
Take a screenshot of a SceneView Explore in the sandboxSandbox CodePen View live
Synchronize MapView and SceneView Explore in the sandboxSandbox CodePen View live
Chaining Promises Explore in the sandboxSandbox CodePen View live
OpenStreetMapLayer Explore in the sandboxSandbox CodePen View live
Update the camera in a 3D view Explore in the sandboxSandbox CodePen View live
Toggle ground elevation Explore in the sandboxSandbox CodePen View live
Load a basic web scene Explore in the sandboxSandbox CodePen View live
Web scene - slides Explore in the sandboxSandbox CodePen View live
Home button Explore in the sandboxSandbox CodePen View live
Search Widget Explore in the sandboxSandbox CodePen View live
SceneView - goTo() Explore in the sandboxSandbox CodePen View live
Query Elevation (points) Explore in the sandboxSandbox CodePen View live
Low poly terrain using mesh geometry Explore in the sandboxSandbox CodePen View live
Working with 3D mesh primitives Explore in the sandboxSandbox CodePen View live
Highlight point features Explore in the sandboxSandbox CodePen View live
Intro to MapImageLayer Explore in the sandboxSandbox CodePen View live
Intro to PointCloudLayer Explore in the sandboxSandbox CodePen View live
Intro to SceneLayer Explore in the sandboxSandbox CodePen View live
WMSLayer Explore in the sandboxSandbox CodePen View live
Overview map Explore in the sandboxSandbox CodePen View live
ElevationLayer Explore in the sandboxSandbox CodePen View live
Using the view's UI Explore in the sandboxSandbox CodePen View live
Switch view from 2D to 3D Explore in the sandboxSandbox CodePen View live
Visualize features with realistic WebStyleSymbols Explore in the sandboxSandbox CodePen View live
Save a web scene Explore in the sandboxSandbox CodePen View live
BasemapGallery widget Explore in the sandboxSandbox CodePen View live
CoordinateConversion widget - Custom Formats Explore in the sandboxSandbox CodePen View live
Locate button Explore in the sandboxSandbox CodePen View live
Extend the SceneView WebGL engine Explore in the sandboxSandbox CodePen View live
Custom Basemap Explore in the sandboxSandbox CodePen View live
Create a layer from a portal item Explore in the sandboxSandbox CodePen View live
Symbol playground Explore in the sandboxSandbox CodePen View live
Generate a relationship visualization Explore in the sandboxSandbox CodePen View live
Expand widget Explore in the sandboxSandbox CodePen View live
Custom widgets with Vue Explore in the sandboxSandbox CodePen View live
Histogram widget Explore in the sandboxSandbox CodePen View live
HistogramRangeSlider Explore in the sandboxSandbox CodePen View live
LayerList widget Explore in the sandboxSandbox CodePen View live
Measurement in 3D Explore in the sandboxSandbox CodePen View live
SceneView - shadow and lighting settings Explore in the sandboxSandbox CodePen View live
Event explorer / watch properties Explore in the sandboxSandbox CodePen View live
Intro to layers Explore in the sandboxSandbox CodePen View live
Label features using Arcade expressions Explore in the sandboxSandbox CodePen View live
MapImageLayer - Set definition expressions on sublayers Explore in the sandboxSandbox CodePen View live
SceneLayer filter and query Explore in the sandboxSandbox CodePen View live
Scene Layer with point geometries Explore in the sandboxSandbox CodePen View live
Underground navigation in global mode Explore in the sandboxSandbox CodePen View live
Responsive widgets Explore in the sandboxSandbox CodePen View live
Line of sight widget Explore in the sandboxSandbox CodePen View live
Intro to CSVLayer Explore in the sandboxSandbox CodePen View live
Custom TileLayer Explore in the sandboxSandbox CodePen View live
Filter points in a PointCloudLayer Explore in the sandboxSandbox CodePen View live
PointCloudLayer - change point size and density Explore in the sandboxSandbox CodePen View live
Elevation options Explore in the sandboxSandbox CodePen View live
Use three.js from an external renderer Explore in the sandboxSandbox CodePen View live
QueryTask Explore in the sandboxSandbox CodePen View live
Thematic multivariate visualization (2D) Explore in the sandboxSandbox CodePen View live
Realistic water visualization in 3D Explore in the sandboxSandbox CodePen View live
Data-driven extrusion Explore in the sandboxSandbox CodePen View live
Web scene - slide tour Explore in the sandboxSandbox CodePen View live
Track widget simulation Explore in the sandboxSandbox CodePen View live
Query Elevation (lines) Explore in the sandboxSandbox CodePen View live
Zoom to extent of all features Explore in the sandboxSandbox CodePen View live
Custom ElevationLayer - Exaggerating elevation Explore in the sandboxSandbox CodePen View live
Filter features by geometry with SceneLayer Explore in the sandboxSandbox CodePen View live
Realistic buildings with SceneLayer Explore in the sandboxSandbox CodePen View live
Query client-side 3D extents Explore in the sandboxSandbox CodePen View live
SceneLayerView - query statistics by geometry Explore in the sandboxSandbox CodePen View live
Create a local scene Explore in the sandboxSandbox CodePen View live
Extrude building footprints based on real world heights Explore in the sandboxSandbox CodePen View live
Geoprocessing - viewshed analysis Explore in the sandboxSandbox CodePen View live
Highlight SceneLayer Explore in the sandboxSandbox CodePen View live
MapImageLayer - create dynamic map layers Explore in the sandboxSandbox CodePen View live
PointCloudLayer - toggle renderers Explore in the sandboxSandbox CodePen View live
PointCloudLayer - intensity color modulation Explore in the sandboxSandbox CodePen View live
Sketch in 3D Explore in the sandboxSandbox CodePen View live
Measurement widget Explore in the sandboxSandbox CodePen View live
Custom ElevationLayer - Thematic data as elevation Explore in the sandboxSandbox CodePen View live
Flat vs. volumetric 3D symbol layers Explore in the sandboxSandbox CodePen View live
Path visualization in 3D Explore in the sandboxSandbox CodePen View live
Generate continuous color visualization for 3D buildings Explore in the sandboxSandbox CodePen View live
Daylight widget Explore in the sandboxSandbox CodePen View live
GeometryEngine - geodesic buffers Explore in the sandboxSandbox CodePen View live
Thematic multivariate visualization (3D) Explore in the sandboxSandbox CodePen View live
Thematic visualization with realistic 3D symbols Explore in the sandboxSandbox CodePen View live
Generate univariate continuous size and color visualization in 3D Explore in the sandboxSandbox CodePen View live
MapImageLayer - dynamic data layer with table join Explore in the sandboxSandbox CodePen View live
Calcite Maps and Bootstrap Explore in the sandboxSandbox CodePen View live
Add edges to a SceneLayer Explore in the sandboxSandbox CodePen View live
Coloring options for textured buildings Explore in the sandboxSandbox CodePen View live
Using callout lines with labels Explore in the sandboxSandbox CodePen View live
Point styles for cities Explore in the sandboxSandbox CodePen View live
Loading...