DictionaryRenderer

AMD: require(["esri/renderers/DictionaryRenderer"], (DictionaryRenderer) => { /* code goes here */ });
ESM: import DictionaryRenderer from "@arcgis/core/renderers/DictionaryRenderer.js";
Class: esri/renderers/DictionaryRenderer
Inheritance: DictionaryRenderer Renderer Accessor
Since: ArcGIS Maps SDK for JavaScript 4.13

Dictionary Renderer is used to symbolize layers using a dictionary of CIMSymbols configured with multiple attributes. This renderer should be used when individual features need to be visualized based on multiple data attributes. This may lead to many symbol permutations that would be inappropriate for using a UniqueValueRenderer.

A dictionary renderer applies symbols to features through an associated dictionary symbol web style. The web style contains all the symbol components as well as rules for displaying the symbol.

dictionary-renderer

Known Limitations

Best Practices

  • Dictionary symbol styles can be created manually or from ArcGIS Pro (since ArcGIS Pro 2.5). It is recommended to use ArcGIS Pro to create and publish your styles. See Share a web style for details. Instructions on creating dictionary symbol style manually are available at: Creating Dictionary Symbol Style.
  • DictionaryRenderer works best when visualizing data at large scales (zoomed in closer to the ground). Because theses symbols can be complex, containing multiple icons and varied text per feature, layers rendered with DictionaryRenderer can be illegible when many features overlap one another and clutter the view. We suggest setting minScale and maxScale on layers rendered with DictionaryRenderer to avoid displaying too much information at small scales.
See also
Example
let renderer = new DictionaryRenderer({
  url: "./alternative-fuel-stations",
  fieldMap: {
    fuel_type: "Fuel_Type_Code",
    name: "Station_Name"
  },
  config: {
    show_label: "false"
  }
});

let layer = new FeatureLayer({
  url: "http://url.to.service",
  renderer: renderer
});

Constructors

DictionaryRenderer

Constructor
new DictionaryRenderer(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Example
// Typical usage
let renderer = new DictionaryRenderer({
  url: "./alternative-fuel-stations",
  fieldMap: {
    fuel_type: "Fuel_Type_Code",
    name: "Station_Name"
  },
  config: {
    show_label: "false"
  }
});

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
AuthoringInfo

Authoring metadata only included in renderers generated from one of the Smart Mapping creator methods, such as sizeRendererCreator.createContinuousRenderer() or colorRendererCreator.createContinuousRenderer().

Renderer
Object

This property allows you to set display options that can be configured on the dictionary symbol style.

DictionaryRenderer
String

The name of the class.

Accessor
HashMap<String>

Defines a field mapping that maps input fields from the feature to the dictionary symbol style's expected fields for symbols and text.

DictionaryRenderer
String

A scaling expression can be set to increase or decrease the size of the dictionary symbols.

DictionaryRenderer
String

The title identifying and describing the associated Arcade expression as defined in the scaleExpression property.

DictionaryRenderer
String

The type of renderer.

DictionaryRenderer
String

The URL to the dictionary style.

DictionaryRenderer
VisualVariable[]

An array of VisualVariable objects.

DictionaryRenderer

Property Details

authoringInfo

Inherited
Property
authoringInfo AuthoringInfoautocast
Inherited from Renderer

Authoring metadata only included in renderers generated from one of the Smart Mapping creator methods, such as sizeRendererCreator.createContinuousRenderer() or colorRendererCreator.createContinuousRenderer(). This includes information from UI elements such as sliders and selected classification methods and themes. This allows the authoring clients to save specific overridable settings so that next time it is accessed via the UI, their selections can be remembered.

config

Property
config Object

This property allows you to set display options that can be configured on the dictionary symbol style. For example, if the dictionary symbol style provides a display option to turn on/off a symbol/text, you could set it here.

Example
renderer.config = {
 show_label: "true"
}

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

fieldMap

Property
fieldMap HashMap<String>

Defines a field mapping that maps input fields from the feature to the dictionary symbol style's expected fields for symbols and text. Each key identifies an expected field (defined in the dictionary's symbol and text properties). The value identifies the corresponding mapped field from the dataset. Field names are case sensitive.

Example
renderer.fieldMap = {
  fuel_type: "Fuel_Type_Code",
  connector_types: "EV_Connector_Types",
  network: "EV_Network",
  name: "Station_Name"
};

scaleExpression

Property
scaleExpression String

A scaling expression can be set to increase or decrease the size of the dictionary symbols. The scaling expression can be a constant value for all symbols or an Arcade expression following the specification defined by the Arcade Visualization Profile. Expressions in DictionaryRenderer may reference field values using the $feature profile variable and must return a number.

Examples
renderer.scaleExpression = "2"; //Make the symbols two times bigger.
renderer.scaleExpression = "IIF($feature.symbolset == 10, 2, 1)"; //If the value of "symbolset" field of a feature is 10, make the symbols two times bigger.

scaleExpressionTitle

Property
scaleExpressionTitle String

The title identifying and describing the associated Arcade expression as defined in the scaleExpression property.

Example
renderer.scaleExpression = "IIF($feature.symbolset == 10, 2, 1)";
renderer.scaleExpressionTitle = "Scale by symbol set";

type

Property
type String

The type of renderer.

For DictionaryRenderer the type is always "dictionary".

url

Property
url String

The URL to the dictionary style.

Example
renderer.url = "https://www.arcgis.com/sharing/rest/content/items/30cfbf36efd64ccf92136201d9e852af/data";

visualVariables

Property
visualVariables VisualVariable[]autocast
Autocasts from Object[]

An array of VisualVariable objects. Each object must indicate the type of visual variable to apply (e.g. ColorVisualVariable, SizeVisualVariable, OpacityVisualVariable, RotationVisualVariable), the numeric field or expression from which to drive the visualization, and the visual values to map to the data. The following list identifies each visual variable type and provides a link to the specification table of each.

Type Object Specification Legend Example
color ColorVariable legend-color-vv
size SizeVisualVariable legend-color-vv
opacity OpacityVisualVariable legend-color-vv
rotation RotationVisualVariable -

Visual variables are primarily be used in two ways.

1. Thematic mapping

In most cases, visual variables are used to create visualizations based on a thematic attribute (e.g. population, education, rank, money, magnitude, etc.) in either 2D or 3D.

renderer.visualVariables = [{
  type: "size",
  field: "POP_POVERTY",
  normalizationField: "TOTPOP_CY",
  legendOptions: {
    title: "% population in poverty by county"
  },
  stops: [
    { value: 0.15, size: 4, label: "<15%" },
    { value: 0.25, size: 12, label: "25%" },
    { value: 0.35, size: 24, label: ">35%" }
  ]
}];

size-image-here

You can take the visualization a step further and use multiple visual variables in the same renderer. The sample below uses three visual variables (size, color, and opacity).

visualization-multivariate-2d

2. Mapping real-world sizes

The size visual variable can be used to visualize the true sizes of features (e.g. tree canopy, road width, building height, etc.) based on their size in the real world. This can be particularly powerful when working in a 3D SceneView. The image below shows a layer of trees that uses visual variables to size each feature to the true dimensions of each tree based on data stored in multiple attribute fields.

renderer-vv-rw

See the Thematic visualization with realistic 3D symbols for an example of using multiple visual variables to visualize your data.

Known Limitations

Color and opacity visual variables must not have more than 8 stops and size visual variables must not have more than 6 stops. This does not apply to variables driven by view scale.

For apps where users can interactively change the field or valueExpression of a visual variable, we suggest you include all potential fields referenced by visual variables in the outFields of the layer. This ensures the best user experience when switching or updating fields in renderers.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor
DictionaryRenderer

Creates a deep clone of the renderer.

DictionaryRenderer
*

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

Renderer
Promise<CIMSymbol>

This method will return the symbol for a given graphic using the dictionary renderer.

DictionaryRenderer
Boolean

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor
Object

Converts an instance of this class to its ArcGIS portal JSON representation.

Renderer

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

clone

Method
clone(){DictionaryRenderer}

Creates a deep clone of the renderer.

Returns
Type Description
DictionaryRenderer A deep clone of the object that invoked this method.
Example
// Creates a deep clone of the first layer's renderer
const renderer = view.map.layers.at(0).renderer.clone();

fromJSON

Inherited
Method
fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
Type Description
* Returns a new instance of this class.

getSymbolAsync

Method
getSymbolAsync(graphic){Promise<CIMSymbol>}

This method will return the symbol for a given graphic using the dictionary renderer.

Parameter
graphic Graphic

The graphic used to get the resulting symbol.

Returns
Type Description
Promise<CIMSymbol> When resolved, a CIMSymbol will be returned.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

toJSON

Inherited
Method
toJSON(){Object}
Inherited from Renderer

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.