Method Overview
Name | Return Type | Summary | |
---|---|---|---|
Promise | Generates a Renderer that may be applied directly to a Layer that supports renderers. more details | more details |
Method Details
createRenderer(params){Promise}
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
, andfield
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.Parameters:params ObjectInput 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:layer FeatureLayer | SceneLayerThe layer for which the renderer is generated.
field StringThe name of the field from which to extract unique values that will be used for the basis of the data-driven visualization.
optional The named string of the Esri basemap or basemap object that will be paired with the output visualization.
Default Value: grayoptionalnumTypes NumberThe number of types (or categories) displayed by the renderer. Use
-1
to display all returned types.
Default value: 10optionalsortBy StringIndicates how values should be sorted in the Legend. See the table below for information about values that may be passed to this parameter.
Possible Value Description count Unique values/types will be sorted from highest to lowest based on the count of features that fall in each category. value Unique values/types will be sorted in alphabetical order.
Known Values: count | value
Default Value: countoptionaltypeScheme PointTypeScheme | PolylineTypeScheme | PolygonTypeSchemeIn 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
.optionallegendOptions ObjectProvides 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 StringThe title used to represent the given field in the Legend.
optionaldefaultSymbolEnabled BooleanEnables the
defaultSymbol
on the renderer and assigns it to features with no value.optionalview SceneViewThe SceneView instance in which the visualization will be rendered. This parameter is required if
symbolType = "3d-volumetric" or "3d-volumetric-uniform"
, except for layers with amesh
geometry type.optionalsymbolType StringThe 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. Known values are described below.
Default Value: 2dValue Description 2d Generates a visualization using 2D symbols such as SimpleMarkerSymbol, SimpleLineSymbol, or SimpleFillSymbol. Use this option if generating a visualization for data in a MapView. 3d-flat Generates 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-volumetric Generates 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-uniform Generates 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.optionalstatistics UniqueValuesResultA 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.
optionalcolorMixMode StringThis 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.
Value Description tint Applies the symbol color
to the desaturated geometry/texture color.replace Removes the geometry/texture color and applies the symbol color
.multiply Multiplies geometry/texture color value with the symbol color
value. The result is a darker color. Multiplying with white keeps the geometry color the same.Default value: replace
Returns:Type Description Promise Resolves to an instance of RendererResult. Example: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; });
Type Definitions
RendererResult
The result object of the createRenderer() method. See the table below for details of each property.
Properties:renderer UniqueValueRendererThe renderer object configured to best match the given basemap. Set this on a layer's
renderer
property to update its visualization.uniqueValueInfos Object[]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.
Specification:A unique value representing a type or category of features in the layer.
count NumberThe number of features assigned the given
value
(or belonging to the given category).label StringThe label describing the value or category in the Legend.
symbol SymbolThe symbol used to represent features belonging to the given category.
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.basemapId StringThe ID of the basemap used to determine the optimal color scheme to represent the categorical variable.