Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Object: esri/renderers/smartMapping

require(["esri/renderers/smartMapping"], function(smartMapping) { /* code goes here */ });

Description

(Added at v3.13)
This module contains a collection of helper functions used to create pre-configured renderers for smart feature styling.

More information on working with rendering, smart mapping, and using visual variables can be found in the Data Visualization guide topic and the multiple samples referenced within this topic.

Samples

Search for samples that use this class.

Methods

NameReturn typeSummary
createClassedColorRenderer(params)PromiseCreates a renderer for visualizing features using colors.
createClassedSizeRenderer(params)PromiseCreates a renderer for visualizing features by varying their size.
createColorInfo(params)PromiseCreates an object defining a color ramp used to render a layer.
createColorRenderer(params)PromiseCreates a renderer for visualizing features using colors.
createHeatmapRenderer(params)PromiseCreates a renderer for visualizing features using heatmap.
createOpacityInfo(params)PromiseCreates an object that describes how opacity of features is calculated.
createPredominanceRenderer(params)PromiseCreates a renderer for identifying features by their color.
createRelationshipRenderer(params)PromiseCreates a renderer for exploring the relationship between two numeric attributes.
createSizeInfo(params)PromiseDefines the size of the symbol where feature size is proportional to data value.
createSizeRenderer(params)PromiseCreates a renderer for visualizing features by varying their size based on data.
createTypeRenderer(params)PromiseCreates a renderer for visualizing features by their type.
getSuggestedField(params)PromiseSearches the fields of an input layer or array of field objects for field names commonly used in rendering based on usage (e.g., RANK, TOTAL, AVERAGE, NAME, etc).
Method Details

createClassedColorRenderer(params)

Creates a renderer for visualizing features using colors. Features are categorized into multiple classes based on a data attribute (Example: population), and each class is assigned a specific color. All features that belong to a certain class are drawn with the same color. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> classificationMethod Optional Indicates the classification method used to create class breaks. The following methods are supported: equal-interval, natural-breaks, quantile and standard-deviation. Default is equal-interval.
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Object> legendOptions Optional An object providing options for displaying the color ramp in the legend. See the object specification table for legendOptions below.
<String> normalizationField Optional Name of the attribute field used to normalize the data. Applicable only when normalizationType is field.
<String> normalizationType Optional Indicates how data values are normalized. The following types are supported: field, log, percent-of-total. When normalized using a field, you need to specify normalizationField.
<Number> numClasses Optional Number of class breaks needed. Ignored when classificationMethod is standard-deviation. Default is 5.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/choropleth.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Boolean> showOthers Optional Indicates whether the renderer should display features that don't have any value for the specified field or features that do not fall within any of the class breaks. Default is true.
<Number> standardDeviationInterval Optional Standard deviation interval. The following values are supported: 1, 0.5, 0.33 and 0.25. Applicable only when classificationMethod is standard-deviation.
<String> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding color ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Object[]> classBreakInfos An array of objects each describing a class break. Each object will have the following properties: minValue, maxValue.
<Number> maxValue Maximum value used for class breaks.
<Number> minValue Minimum value used for class breaks.
<Number> normalizationTotal Sum of all data values used to normalize data. Available only when normalizationType is percent-of-total.
<Boolean> partialData Indicates that statistics were generated for a subset, or sampling, of features on the client rather than queried against the service.
<Renderer> renderer A pre-configured ClassBreaksRenderer. Use FeatureLayer.setRenderer to apply this renderer to a layer.
<Object> statistics Field statistics (min, max, avg, stddev) used to create the renderer.
<legendOptions>
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding color ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createClassedSizeRenderer(params)

Creates a renderer for visualizing features by varying their size. Features are categorized into multiple classes based on a data attribute (Example: population), and each class is assigned a specific symbol size. All features that belong to a certain class are drawn with the same size. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> classificationMethod Optional Indicates the classification method used to create class breaks. The following methods are supported: equal-interval, natural-breaks, quantile and standard-deviation. Default is equal-interval.
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Object> legendOptions Optional An object providing options for displaying the size ramp in the legend. See the object specification table for legendOptions below.
<String> normalizationField Optional Name of the attribute field used to normalize the data. Applicable only when normalizationType is field.
<String> normalizationType Optional Indicates how data values are normalized. The following types are supported: field, log, percent-of-total. When normalized using a field, you need to specify normalizationField.
<Number> numClasses Optional Number of class breaks needed. Ignored when classificationMethod is standard-deviation. Default is 5.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/size.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Boolean> showOthers Optional Indicates whether the renderer should display features that don't have any value for the specified field or features that do not fall within any of the class breaks. Default is true.
<Number> standardDeviationInterval Optional Standard deviation interval. The following values are supported: 1, 0.5, 0.33 and 0.25. Applicable only when classificationMethod is standard-deviation.
<String> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding size ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Object[]> classBreakInfos An array of objects each describing a class break. Each object will have the following properties: minValue, maxValue.
<Number> maxValue Maximum value used for class breaks.
<Number> minValue Minimum value used for class breaks.
<Number> normalizationTotal Sum of all data values used to normalize data. Available only when normalizationType is percent-of-total.
<Boolean> partialData Indicates that statistics were generated for a subset, or sampling, of features on the client rather than queried against the service.
<Renderer> renderer A pre-configured ClassBreaksRenderer. Use FeatureLayer.setRenderer to apply this renderer to a layer.
<Object> statistics Field statistics (min, max, avg, stddev) used to create the renderer.
<legendOptions>
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding size ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createColorInfo(params)

Creates an object defining a color ramp used to render a layer. See the Object Specifications table below for the structure of the params object and Promise. (Added at v3.15)
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which the colorInfo is created.
<Object> legendOptions Optional An object providing options for displaying the color ramp in the legend. See the object specification table for legendOptions below.
<String> normalizationField Optional Name of the feature attribute field by which the data value will be normalized.
<Object> scheme Optional An object describing the style scheme used for the colorInfo. A style scheme can be obtained by calling esri/styles/choropleth.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<String> sqlExpression Optional A SQL expression evaluating to a number. When a sqlExpression is provided, an equivalent valueExpression is required. The logic of the valueExpression must match the logic of the sqlExpression.
<String> sqlWhere Optional A SQL where clause used to filter features for the statistics query. For example, this is useful in situations where you want to avoid dividing by zero as is the case with creating a predominance visualization.
<String> theme Optional Theme to be used. The following themes are supported: high-to-low, above-and-below, centered-on, or extremes. Default is high-to-low.
<String> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding color ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Object> colorInfo An object defining a color ramp used to render the layer. See Renderer.colorInfo for additional information on the object properties.
<Object> scheme An object describing the style scheme used for the colorInfo. This is the same scheme returned from esri/styles/choropleth.getSchemes.
<Object> statistics See return value from FeatureLayerStatistics.getFieldStatistics for additional information on the object properties.
<legendOptions>
<Boolean> showLegend Optional Indicates whether to show the color ramp in the legend.
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding color ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createColorRenderer(params)

Creates a renderer for visualizing features using colors. Colors are picked from a color gradient by mapping a feature's data attribute (Example: population) to a specific color in the gradient. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Object> legendOptions Optional An object providing options for displaying the color ramp in the legend. See the object specification table for legendOptions below.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/choropleth.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Boolean> showOthers Optional Indicates whether the renderer should display features that don't have any value for the specified field. Default is true.
<String> sqlExpression Optional A SQL expression evaluating to a number. When a sqlExpression is provided, an equivalent valueExpression is required. The logic of the valueExpression must match the logic of the sqlExpression.
<String> sqlWhere Optional A SQL where clause used to filter features for the statistics query. For example, this is useful in situations where you want to avoid dividing by zero as is the case with creating a predominance visualization.
<Object> statistics Optional Field statistics (min, max, avg, stddev) used to create the renderer. If not provided, FeatureLayerStatistics.getFieldStatistics will be used to calculate the statistics.
<String> theme Optional Theme to be used. The following themes are supported: high-to-low, above-and-below, centered-on, and extremes. Default is high-to-low.
<String> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding color ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Renderer> renderer A pre-configured ClassBreaksRenderer with a visual variable for colorInfo. Use FeatureLayer.setRenderer to apply this renderer to a layer.
<Object> statistics Field statistics (min, max, avg, stddev) used to create the renderer.
<legendOptions>
<Boolean> showLegend Optional Indicates whether to show the color ramp in the legend.
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding color ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createHeatmapRenderer(params)

Creates a renderer for visualizing features using heatmap. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<Number> blurRadius Optional Radius (in pixels) around each point over which the majority of the intensity value calculated for that point is spread out. Default is 10.
<Boolean> fadeToTransparent Optional Indicates whether heat boundaries smooth out. Default is true.
<String> field Optional Name of the attribute field used to calculate the weighted intensity of each point. When an attribute field is not specified, each point will have the same intensity value.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Number> maxRatio Optional Pixel intensity ratio to which the last color in the scheme is associated with. All pixels with intensity greater than maxRatio will be displayed with the last color. It is a number between 0 and 1. Default is 1.
<Number> minRatio Optional Pixel intensity ratio to which the first color in the scheme is associated with. If fadeToTransparent is true, all pixels with intensity less than minRatio will fade away smoothly. Else, they will be displayed with the first color. It is a number between 0 and 1. Default is 0.01.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/heatmap.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Object> statistics Optional Statistics (min, max, avg, stddev) used to create the renderer. If not provided, FeatureLayerStatistics.getHeatmapStatistics will be used to calculate the statistics.
<Promise>
<Renderer> renderer A pre-configured HeatmapRenderer. Use FeatureLayer.setRenderer to apply this renderer to your layer.
<Object> statistics Field statistics (min, max, avg, stddev) used to create the renderer.

createOpacityInfo(params)

Creates an object that describes how opacity of features is calculated. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which the opacityInfo is created.
<Object> legendOptions Optional An object providing options for displaying the opacity ramp in the legend. See the object specification table for legendOptions below.
<String> normalizationField Optional Indicates how data values are normalized. The following types are supported: field, log, percent-of-total. When normalized using a field, you need to specify normalizationField.
<Boolean> useStdDev Optional Indicates whether to use standard deviation classification when creating the opacityInfo.
<String> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding opacity ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Object> statistics Field statistics (min, max, avg, stddev) used to create the renderer.
<legendOptions>
<Boolean> showLegend Optional Indicates whether to show the opacity ramp in the legend.
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding opacity ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createPredominanceRenderer(params)

Creates a renderer for identifying features by their color. A feature's color is calculated based on its predominant numeric attribute.

As of version 3.16, this method only works on hosted feature services. (Added at v3.15)
Return type: Promise
Parameters:
<Object> params Required See the Object Specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap. This is required unless scheme is used.
<Object[]> fields Required A list of up to 10 numeric attribute fields to include in the predominance calculation. The field with the highest value will be designated as the predominant field for that feature.

This is an array of objects with two properties: name and label. label is optional. A maximum of 10 fields may be used for creating predominance renderers.
<Boolean> includeOpacityInfo Optional Indicates whether the renderer should calculate opacity of features based on the ratio of the predominant field to the sum of all fields. The higher the ratio, the more opaque the features. Default value is false.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/type.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Boolean> showOthers Optional Indicates whether the renderer should display features that do not have a value for any of the specified fields, or for features that have one or more fields with the same highest value. Default value is true.
<String> theme Optional Theme to be used. The following themes are supported: default. Default is default.
<Promise>
<Renderer> renderer A pre-configured UniqueValueRenderer. Use FeatureLayer.setRenderer to apply this renderer to a layer.
<Object> scheme This is the same as a scheme object returned by esri/styles/type.getSchemes method.

createRelationshipRenderer(params)

Creates a renderer for exploring the relationship between two numeric attributes. This is commonly known as a bivariate choropleth visualization, which classifies each variable in either 2, 3, or 4 classes along separate color ramps. One of those ramps is rotated 90 degrees and overlaid on the other to create a 2x2, 3x3, or 4x4 square grid. The x-axis indicates the range of values for one variable, and the y-axis indicates the range for the second variable. The squares running diagonal from the lower left corner to the upper right corner indicate features where the two variables may be related or in agreement with one another.

The lower right and upper left corners indicate features where one field has high values and the other field low values and vice versa.

Keep in mind 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.

(Added at v3.25)
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used in the map. This is used to select an optimal color scheme based on the colors of the basemap. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles the basemap.
<String> classificationMethod Optional Indicates the classification method used to create class breaks for each field. The following methods are supported: equal-interval, natural-breaks, quantile. The default is quantile.
<Object> field1 Required Object describing the first attribute field. See the field object specification table below for the structure of this object.
<Object> field2 Required Object describing the second attribute field. See the field object specification table below for the structure of this object.
<String> focus Optional

Indicates the focus of the visualization (i.e. the break range, or corner of the legend, in which the user is most interested). It affects the order of unique value infos in the renderer, and therefore, the presentation and layout of the legend. Given a color ramp, the color assigned to a given feature does NOT change based on focus. The following values are supported: HH (high-high), HL (high-low), LH (low-high) or LL (low-low). The default is null.

If the value is null, then the legend renders as a square. If the value is any other of the supported values, the legend is rendered as a diamond with the corresponding corner indicated by this value rotated to the top of the legend.

<FeatureLayer> layer Required Feature layer instance for which this renderer is created.
<Number> numClasses Optional The number of classes for classifying each field. A value of 2 creates a 2x2 scheme (4 total categories). A value of 3 creates a 3x3 scheme (9 total categories). A value of 4 creates a 4x4 scheme (16 total categories). No other values are supported. The default is 3.
<Boolean> optimizeOutline Optional Indicates whether the polygon outline width should be automatically managed based on map scale. The default is true.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/relationship.getSchemes() method. Either the primary scheme or a secondary scheme can be used. In the absence of a scheme, the basemap should be specified.
<Boolean> showOthers Optional Indicates whether the layer should display features that don't have a value for any of the specified fields, or features that don't fall within the computed classes. The default value is true.
<Promise>
<Object> classBreaks Object containing the class breaks result for field1 and field2. It has two properties: field1 and field2. Both field1 and field2 are objects with properties identical to the result returned by createClassedColorRenderer().
<UniqueValueRenderer> renderer A pre-configured UniqueValueRenderer representing a relationship renderer. Use FeatureLayer.setRenderer() followed by FeatureLayer.redraw() to apply this renderer to the input layer.
<Object> scheme The color scheme used by the renderer.
<Object[]> uniqueValueInfos The list of unique value infos used by the renderer.
<field>
<String> field Required The name of the numeric field used to generate class breaks for one side of the relationship visualization.
<Number> maxValue Optional The maximum value of one side of the relationship. This is used to create an upper bound for one side of the class breaks.
<Number> minValue Optional The minimum value of one side of the relationship. This is used to create a lower bound for one side of the class breaks.
<String> normalizationField Optional The name of the numeric field used to normalize field values prior to generating class breaks for one side of the relationship visualization.
Sample:

var params = {
  field1: {
    field: "EDUC01_CY",
    normalizationField: "EDUCA_BASE",
  },
  field2: {
    field: "AVGHHSZ_CY"
  },
  layer: layer,  // feature layer instance
  basemap: map.getBasemap(),
  classificationMethod: "quantile",
  optimizeOutline: true
};
      
smartMapping.createRelationshipRenderer(params)
  .then(function(response){
     layer.setRenderer(response.renderer);
     layer.redraw();
  });

createSizeInfo(params)

Defines the size of the symbol where feature size is proportional to data value. See the Object Specifications table below for the structure of the params object and Promise. (Added at v3.15)
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which the colorInfo is created.
<Object> legendOptions Optional An object providing options for displaying the size ramp in the legend. See the object specification table for legendOptions below.
<String> normalizationField Optional Name of the feature attribute field by which the data value will be normalized.
<Boolean> optimizeForScale Optional Indicates whether to calculate the most optimal size range.
<Object> scheme Optional An object describing the style scheme used for the sizeInfo. A style scheme can be obtained by calling esri/styles/size.getSchemes method.
<string> sqlExpression Optional A SQL expression evaluating to a number. When a sqlExpression is provided, an equivalent valueExpression is required. The logic of the valueExpression must match the logic of the sqlExpression.
<string> sqlWhere Optional A SQL where clause used to filter features for the statistics query. For example, this is useful in situations where you want to avoid dividing by zero as is the case with creating a predominance visualization.
<String> theme Optional Theme to be used. The following themes are supported: high-to-low, above-and-below, centered-on, and extremes. Default is high-to-low.
<string> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding size ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Object> scheme An object describing the style scheme used for the sizeInfo. This is the same scheme returned from esri/styles/size.getSchemes.
<Object> sizeInfo An object defining the size of the symbol where feature size is proportional to data value. See Renderer.sizeInfo for additional information on the object properties.
<Object> statistics See return value from FeatureLayerStatistics.getFieldStatistics for additional information on the object properties.
<legendOptions>
<Boolean> showLegend Optional Indicates whether to show the size ramp in the legend.
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding size ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createSizeRenderer(params)

Creates a renderer for visualizing features by varying their size based on data. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> field Required Name of the attribute field that contains data values.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Object> legendOptions Optional An object providing options for displaying the size ramp in the legend. See the object specification table for legendOptions below.
<Boolean | String> optimizeForScale Required Only applicable to polygon features. This parameter supports the following values:
  • "map-scale" or true: The size range is optimized only for the current map scale.
  • "visible-scale-range": Size range is optimized for all scales in the layer's visible scale range.
NOTE: Version 3.13 was slightly different in behavior as it only took a boolean with a default value of 'false'.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/size.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Boolean> showOthers Optional Indicates whether the renderer should display features that don't have any value for the specified field. Default is true.
<string> sqlExpression Optional A SQL expression evaluating to a number. When a sqlExpression is provided, an equivalent valueExpression is required. The logic of the valueExpression must match the logic of the sqlExpression.
<string> sqlWhere Optional A SQL where clause used to filter features for the statistics query. For example, this is useful in situations where you want to avoid dividing by zero as is the case with creating a predominance visualization.
<Object> statistics Optional Field statistics (min, max, avg, stddev) used to create the renderer. If not provided, getFieldStatistics will be used to calculate the statistics.
<String> theme Optional Theme to be used. The following themes are supported: default. Default is default.
<string> valueExpression Optional An Arcade expression evaluating to a number. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding size ramp in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Renderer> renderer A pre-configured ClassBreaksRenderer with a visual variable for sideInfo. Use FeatureLayer.setRenderer to apply this renderer to a layer.
<Object> statistics Field statistics (min, max, avg, stddev) used to create the renderer.
<legendOptions>
<Boolean> showLegend Optional Indicates whether to show the size ramp in the legend.
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding size ramp in the Legend and takes precedence over the field alias or valueExpressionTitle.

createTypeRenderer(params)

Creates a renderer for visualizing features by their type. See the Object Specifications table below for the structure of the params object and Promise.
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for the structure of the params object.
Object Specifications:
<params>
<String> basemap Required Basemap used for your map. The following basemaps are supported: streets, gray, topo, terrain, national-geographic, oceans, osm, satellite, hybrid, dark-gray. If you're not using any of these basemaps, then pick one that closely resembles your basemap.
<String> field Required Name of the attribute field that contains uniquely identifiable type for every feature.
<FeatureLayer> layer Required Feature layer for which this renderer is created.
<Object> legendOptions Optional An object providing options for displaying the unique values table in the legend. See the object specification table for legendOptions below.
<Number> numTypes Optional Number of types displayed by the renderer. Use -1 to display all types. Default is 10.
<Object> scheme Optional An object describing the style scheme used for the renderer. A style scheme can be obtained by calling esri/styles/type.getSchemes method - either the primary scheme or a secondary scheme can be used. In the absence of scheme, both theme and basemap should be specified.
<Boolean> showOthers Optional Indicates whether the renderer should display features that don't have any value for the specified field or features that belong to types not displayed by the renderer. Default is true.
<String> theme Optional Theme to be used. The following themes are supported: default. Default is default.
<String> valueExpression Optional An Arcade expression evaluating to a number or a string. This expression can reference field values using the $feature global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. When a valueExpression is provided the field option is not needed.
<String> valueExpressionTitle Optional The title identifying and describing the associated Arcade expression as defined in the valueExpression property. This is displayed as the title of the corresponding unique values table in the Legend in the absence of a provided title in the legendOptions property.
<Promise>
<Number> othersStartIndex Index of uniqueValueInfos array that marks the beginning of types not displayed by the renderer. An index of -1 indicates that the renderer displays all types.
<Boolean> partialData Indicates that statistics were generated for a subset, or sampling, of features on the client rather than queried against the service.
<legendOptions>
<String> title Optional Text that describes the visualization. This is displayed as the title of the corresponding unique values table in the Legend and takes precedence over the field alias or valueExpressionTitle.

getSuggestedField(params)

Searches the fields of an input layer or array of field objects for field names commonly used in rendering based on usage (e.g., RANK, TOTAL, AVERAGE, NAME, etc). Numeric fields have a higher ranking than string fields. If no commonly used field name and no other useful field name can be found, then null is returned. Use this method to determine the field on which to base the renderer of a layer if the field names aren't known ahead of time. (Added at v3.16)
Return type: Promise
Parameters:
<Object> params Required See the object specifications table below for details about the params object.
Object Specifications:
<params>
<Field[]> fields Optional An array of fields from which to search and get the optimal field for rendering a layer. This property is required if the layer property is not used.
<Layer> layer Optional The layer from which to search and get the optimal field for rendering the layer. This property is required if the fields property is not used.
Sample:
require([
  "esri/layers/FeatureLayer", "esri/renderers/smartMapping", ... 
], function(FeatureLayer, smartMapping, ... ) {
  var fl = new FeatureLayer( ... );  //points to a Feature Service endpoint
  var params = { layer: fl };
  smartMapping.getSuggestedField(params).then(function(fieldName){
    var params = {
      basemap: "gray",
      field: fieldName,
      layer: fl
    };
    return params;
  }).then(function(rendererParams){
    smartMapping.createColorRenderer(rendererParams).then(function(response){
      fl.setRenderer(response.renderer);
      fl.redraw();
    });
  });
});
Show Modal