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

This object contains helper methods for generating data-driven visualizations with continuous size based on a field value or expression from features in a Layer. The createContinuousRenderer() method generates a Renderer object that may be applied directly to a supported layer. This renderer contains a continuous size ramp with optimal sizes based on the scale of the view that are mapped to specific break values based on the statistics of the indicated field or expression.

Alternately, you can use the createVisualVariables() method to generate size visual variables with default stops and sizes that are optimally chosen based on the statistics of the indicated field and the view scale.

Known Limitations

  • 3D symbols can only be generated for layers with a point geometry type.
  • Only FeatureLayer and SceneLayer layer types are supported, except in the following scenarios:
    • FeatureLayers created with source graphics or feature collections.
    • SceneLayers with mesh geometryType
    • 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.

Method Overview

NameReturn TypeSummaryObject
Promise<ContinuousRendererResult>

Generates a Renderer that may be applied directly to the layer used to call this method.

more details
more detailssize
Promise<VisualVariableResult>

This method generates an array of size visual variables with default stops that are optimally chosen based on the statistics queried for the indicated field or expression and mapped to appropriate sizes.

more details
more detailssize

Method Details

createContinuousRenderer(params){Promise<ContinuousRendererResult>}

Generates a Renderer that may be applied directly to the layer used to call this method. The renderer contains a continuous size visual variable that maps marker sizes to specific stop values based on queried statistics from the indicated field or expression.

In most cases you will provide a layer, basemap, and field to generate this renderer. This is a scenario in which the statistics of the data aren't well known and the user doesn't know what colors to use in the visualization.

The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the statistics object to the statistics parameter to avoid making an extra call to the server.

Parameters:
params Object

Input parameters for generating size visual variables based on data returned from a given field or expression. See the table below for details of each parameter.

Specification:

The layer for which the renderer is generated.

field String

The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization.

normalizationField String
optional

The name of the field to normalize the values of the given field. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities.

basemap String|Basemap
optional

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

Default Value: gray

optional

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

legendOptions Object
optional

Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the Legend.

Specification:
title String

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

optional

A statistics object generated from the summaryStatistics 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.

minValue Number
optional

A custom minimum value set by the user. Use this in conjunction with maxValue to generate statistics between lower and upper bounds. This will be the lowest stop in the returned size visual variable.

maxValue Number
optional

A custom maximum value set by the user. Use this in conjunction with minValue to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned size visual variable.

defaultSymbolEnabled Boolean
optional

Enables the defaultSymbol on the renderer and assigns it to features with no value and features that do not fall within the configured data range.

optional

The SceneView instance in which the visualization will be rendered. This parameter is required if symbolType = "3d-volumetric" or "3d-volumetric-uniform".

symbolType String
optional

The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below.

Default Value: 2d

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.
Returns:
TypeDescription
Promise< ContinuousRendererResult>Resolves to an instance of ContinuousRendererResult.
Example:
var layer = new FeatureLayer({
  url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/counties_politics_poverty/FeatureServer/0"
});

// visualization based on field and normalization field
var sizeParams = {
  layer: layer,
  basemap: map.basemap,  // "gray"
  field: "POP_POVERTY",
  normalizationField: "TOTPOP_CY",
};

// when the promise resolves, apply the renderer to the layer
sizeRendererCreator.createContinuousRenderer(sizeParams)
  .then(function(response){
    layer.renderer = response.renderer;
  });

createVisualVariables(params){Promise<VisualVariableResult>}

This method generates an array of size visual variables with default stops that are optimally chosen based on the statistics queried for the indicated field or expression and mapped to appropriate sizes.

There are two different ways this method may be called. The most common case is by providing a layer, basemap, and field. This is the scenario where the statistics of the data aren't well known and the user doesn't know what colors to use.

The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the object in the statistics parameter to avoid making an extra call to the server. You can also provide a colorScheme if you don't want one picked for you. In this case the basemap and theme options would be ignored.

The resulting array of visual variables will contain exactly one size visual variable unless the axis parameter is set to "height".

Parameters:
params Object

Input parameters for generating size visual variables based on data returned from a given field or expression. See the table below for details of each parameter.

Specification:

The layer for which the visual variables are generated.

field String

The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization.

normalizationField String
optional

The name of the field to normalize the values of the given field. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities.

basemap String|Basemap
optional

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

Default Value: gray

optional

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

legendOptions Object
optional

Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the Legend.

Specification:
title String

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

optional

A statistics object generated from the summaryStatistics 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.

minValue Number
optional

A custom minimum value set by the user. Use this in conjunction with maxValue to generate statistics between lower and upper bounds. This will be the lowest stop in the returned size visual variable.

maxValue Number
optional

A custom maximum value set by the user. Use this in conjunction with minValue to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned size visual variable.

optional

The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols.

worldScale Boolean
optional

Indicates if the size units of the symbols will be in meters. This should be true when generating visualizations with 3D volumetric symbology. A view must be provided if this property is set to true.

axis Boolean
optional

When set to all, a single size variable that scales uniformly in all dimensions is generated. When set to height, the result contains two size visual variables: the first one sizes the height according to the field statistics, while the second defines a constant size for width and depth.

Possible Values: all | height

Default Value: all

Returns:
TypeDescription
Promise< VisualVariableResult>Resolves to an instance of VisualVariableResult.
Example:
var layer = new FeatureLayer({
  url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/counties_politics_poverty/FeatureServer/0"
});

// visualization based on field and normalization field
var sizeParams = {
  layer: layer,
  basemap: map.basemap,  // "gray"
  field: "POP_POVERTY",
  normalizationField: "TOTPOP_CY"
};

// when the promise resolves, apply the visual variables to the renderer
sizeRendererCreator.createVisualVariables(sizeParams)
  .then(function(response){
    var renderer = layer.renderer.clone();
    renderer.visualVariables = response.visualVariables;
    layer.renderer = renderer;
  });

Type Definitions

ContinuousRendererResult

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

Properties:

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

visualVariables SizeVisualVariable[]

Size visual variables configured based on the statistics of the data and the given basemap and scheme.

The size scheme used by the visual variables.

defaultValuesUsed Boolean

Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all.

Basic statistics returned from a query to the service for data from the given field name or expression.

basemapId String

The ID of the basemap used to determine the optimal fill color of the features.

VisualVariableResult

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

Properties:
visualVariables SizeVisualVariable[]

An array of size visual variables configured based on the statistics of the data and the view scale.

The size scheme used by the main visual variable.

defaultValuesUsed Boolean

Indicates whether default values were used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all.

Basic statistics returned from a query to the service for the given field or expression.

basemapId String

The ID of the basemap used to determine the optimal fill color of the features.

authoringInfo AuthoringInfo

Authoring information related to the creation of the visual variable. This includes information related to UI inputs from sliders and selected themes.

API Reference search results

NameTypeModule

There were no match results from your search criteria.