require(["esri/renderers/smartMapping/creators/type"], function(typeRendererCreator) { /* code goes here */ });
Object: esri/renderers/smartMapping/creators/type
Since: ArcGIS API for JavaScript 4.4

This object contains helper methods for generating data-driven visualizations with unique types (or categories) based on a field value from features in a Layer. The createRenderer() method generates a Renderer object that may be applied directly to the layer used to generate it. This renderer contains unique values with colors best suited to the given basemap.

Known Limitations

  • Currently, 3D symbols cannot be generated for layers with a polyline or polygon geometry type.
  • Only FeatureLayer, SceneLayer, CSVLayer, and PointCloudLayer layer types are currently supported, except in the following scenarios:
    • SceneLayers without the supportsRenderer and supportsLayerQuery capabilities enabled, unless a predefined statistics object is passed to the statistics parameter of the method in conjunction with the layer. To check a SceneLayer's capabilities, use the getFieldInfoUsage() method.
  • Generating renderers and visual variables using SQL expressions is currently restricted to feature services hosted on ArcGIS Online.

Method Overview

NameReturn TypeSummaryObject
Promise<PCClassRendererResult>

Generates a PointCloudUniqueValueRenderer based on a given field of a PointCloudLayer.

more details
more detailstype
Promise<RendererResult>

Generates a Renderer that may be applied directly to a Layer that supports renderers.

more details
more detailstype

Method Details

createPCClassRenderer(params){Promise<PCClassRendererResult>}
Since: ArcGIS API for JavaScript 4.5

Generates a PointCloudUniqueValueRenderer based on a given field of a PointCloudLayer. This renderer visualizes points of the same type, usually from the CLASS_CODE field or an equivalent field that stores information related to the classification of the data (e.g. low vegetation, high vegetation, ground, etc.). The generated renderer visualizes each point with a standard predefined color matching the class code of the point.

All that's required is a layer instance and field name. You can optionally set the size and density of the points to suit the needs of the desired visualization.

Parameters:
params Object

Input parameters for generating a renderer based on the given field of the input layer. See the table below for details of each parameter.

Specification:

The layer for which the visualization is generated.

field String

The name of the field containing classification data for the given layer. A common field name used for this renderer type is CLASS_CODE, though other fields can be used.

size String
optional
Default Value: 100%

The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given density of points. When the value is 100%, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above 100% will allow for points to overlap neighboring points scaled to the given value. Values below 100% scale point sizes smaller so there appear to be more gaps between points.

density Number
optional
Default Value: 25

The number of points per inch in the view.

optional

In authoring apps, the user may select a pre-defined type scheme. Pass the scheme object to this property to avoid getting one based on the basemap.

optional

A statistics object generated from the uniqueValues function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server.

Returns:
TypeDescription
Promise<PCClassRendererResult>Resolves to an object containing the renderer to set on the input layer. See PCClassRendererResult for more details.
Example:
var layer = new PointCloudLayer({
  url: "https://tiles.arcgis.com/tiles/V6ZHFr6zdgNZuVG0/arcgis/rest/services/BARNEGAT_BAY_LiDAR_UTM/SceneServer"
});

var params = {
  layer: layer,
  field: "CLASS_CODE"
};

// when the promise resolves, apply the renderer to the layer
typeRendererCreator.createPCClassRenderer(params)
  .then(function(response){
    layer.renderer = response.renderer;
  });
createRenderer(params){Promise<RendererResult>}

Generates a Renderer that may be applied directly to a Layer that supports renderers. The renderer contains unique symbols representing a string or a numeric value returned from the indicated field.

In most cases you will provide a layer, basemap, and field to generate this renderer. This is a scenario in which the values of the field aren't well known and the user doesn't know which colors to use in the visualization. You can also use a valueExpression instead of a field to visualize features based on a value returned from a script executed at runtime.

Parameters:
params Object

Input parameters for generating symbols to represent unique types based on data returned from a given field. See the table below for details of each parameter.

Specification:

The layer for which the renderer is generated.

field String
optional

The name of the field from which to extract unique values that will be used for the basis of the data-driven visualization. This property is ignored if a valueExpression is used.

basemap String|Basemap
optional
Default Value: gray

The named string or basemap object of the Esri basemap that will be paired with the output visualization.

numTypes Number
optional
Default Value: 10

The number of types (or categories) displayed by the renderer. Use -1 to display all returned types.

sortBy String
optional
Default Value: count

Indicates how values should be sorted in the Legend. See the table below for information about values that may be passed to this parameter.

Possible ValueDescription
countUnique values/types will be sorted from highest to lowest based on the count of features that fall in each category.
valueUnique values/types will be sorted in alphabetical order.

Possible Values: count | value

typeScheme TypeScheme
optional

In authoring apps, the user may select a pre-defined type scheme. Pass the scheme object to this property to avoid getting one based on the basemap.

valueExpression String
optional

An Arcade expression that returns a number or a string. This expression can reference field values using the $feature global variable. This property overrides the field property and therefore is used instead of an input field value.

valueExpressionTitle String
optional

Text describing the value returned from the valueExpression. This is used by the Legend widget.

legendOptions Object
optional

Provides options for setting a title to a field that will override the field alias defined in the service. This title will represent the field in the Legend.

Specification:
title String

The title used to represent the given field in the Legend.

defaultSymbolEnabled Boolean
optional

Enables the defaultSymbol on the renderer and assigns it to features with no value.

view View
optional

The view instance in which the visualization will be rendered. A SceneView is required if symbolType = "3d-volumetric" or 3d-volumetric-uniform. The relevant SceneView or MapView is required when a valueExpression is specified.

symbolType String
optional
Default Value: 2d

The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter can be ignored for layers with a mesh geometry type. Possible values are described below.

ValueDescription
2dGenerates a visualization using 2D symbols such as SimpleMarkerSymbol, SimpleLineSymbol, or SimpleFillSymbol. Use this option if generating a visualization for data in a MapView.
3d-flatGenerates a visualization using 3D symbols with flat symbol layers such as IconSymbol3DLayer, LineSymbol3DLayer, or FillSymbol3DLayer. Use this option if generating a 2D visualization for data in a SceneView.
3d-volumetricGenerates a visualization using 3D symbols with volumetric symbol layers such as ObjectSymbol3DLayer, PathSymbol3DLayer, or ExtrudeSymbol3DLayer. Use this option if generating a 3D visualization for data in a SceneView and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the view parameter if this option is used.
3d-volumetric-uniformGenerates a visualization using uniformly-sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a SceneView and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the view parameter if this option is used.
optional

A statistics object generated from the uniqueValues function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server.

colorMixMode String
optional
Default Value: replace

This option only applies to generating renderers for mesh SceneLayers. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in FillSymbol3DLayer.material for more context. See the table below for possible values.

ValueDescription
tintApplies the symbol color to the desaturated geometry/texture color.
replaceRemoves the geometry/texture color and applies the symbol color.
multiplyMultiplies geometry/texture color value with the symbol color value. The result is a darker color. Multiplying with white keeps the geometry color the same.
Returns:
TypeDescription
Promise<RendererResult>Resolves to an instance of RendererResult.
Examples:
var layer = new FeatureLayer({
  portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" }
});

// visualization based on categorical field
var typeParams = {
  layer: layer,
  basemap: map.basemap,  // "gray"
  field: "Party"
};

// when the promise resolves, apply the visual variables to the renderer
typeRendererCreator.createRenderer(typeParams)
  .then(function(response){
    layer.renderer = response.renderer;
  });
var layer = new FeatureLayer({
  url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/counties_politics_poverty/FeatureServer/0"
});

// visualization based off Arcade expression
var typeParams = {
  layer: layer,
  basemap: "topo",
  valueExpression: "IIF($feature.DEMOCRAT > $feature.REPUBLICAN, 'Democrat', 'Republican', 'Tied')",
  view: view,
  valueExpressionTitle: "Election Winner"
};

// when the promise resolves, apply the visual variables to the renderer
typeRendererCreator.createRenderer(typeParams)
  .then(function(response){
    layer.renderer = renderer;
  });

Type Definitions

PCClassRendererResult

The result object of the createPCClassRenderer() method. See the table below for details of each property.

Property:

The renderer object configured to represent the class codes in the point cloud. Set this object on the input layer's renderer property to update its visualization.

RendererResult

The result object of the createRenderer() method. See the table below for details of each property.

Properties:

The renderer object configured to best match the given basemap. Set this on a layer's renderer property to update its visualization.

uniqueValueInfos UniqueValueInfo[]

An array of objects describing the value, symbol, and count of each unique type or category represented in the renderer. See the table below describing each property.

excludedUniqueValueInfos Object[]

An array of objects describing the values or categories excluded from consideration in visualizing data from the given field. The specification of each object matches that of the objects specified in the uniqueValueInfos property.

typeScheme TypeScheme

The scheme used to represent each category within the uniqueValueInfos.

basemapId String

The ID of the basemap used to determine the optimal color scheme to represent the categorical variable.

UniqueValueInfo

Describes the symbol, label, and value of a unique value generated by the createRenderer() method.

Properties:
value String | Number

A unique value representing a type or category of features in a layer.

count Number

The number of features with the given value (or belonging to the given category).

label String

The label describing the value or category in the Legend.

symbol Symbol

The symbol used to represent features belonging to the given category.

API Reference search results

NameTypeModule
Loading...