Method Overview
Name | Return Type | Summary | |
---|---|---|---|
Promise | Returns an object containing an array of unique values queried from a given field in a Layer along with the total count of features that contain the pertinent value or belong to the given category. more details | more details |
Method Details
uniqueValues(params){Promise}
Returns an object containing an array of unique values queried from a given field in a Layer along with the total count of features that contain the pertinent value or belong to the given category.
Parameters:params ObjectSee the table below for details of each parameter.
Specification:layer FeatureLayer | SceneLayerThe layer from which to query for unique values.
field StringThe name of the numeric or string field from which the unique values will be obtained.
optionalfeatures Graphic[]If the FeatureLayer is constructed with client-side graphics or you would like to calculate statistics based on a subset of features, then pass the features in this parameter.
optionalreturnAllCodedValues BooleanIndicates that all domain codes should be returned if the given field has domain values.
Returns:Type Description Promise Returns a promise that resolves to UniqueValuesResult. Example:var layer = new FeatureLayer({ portalItem: { id: "5ce5374a461e45bab714b43ffedf151d" } }); uniqueValues({ layer: layer, field: "Candidate" }).then(function(response){ // prints each unique value and the count of features containing that value var infos = response.uniqueValueInfos; infos.forEach(function(info){ console.log("CANDIDATE: ", info.value, " # OF CAMPAIGN STOPS: ", info.count); }); });
Type Definitions
UniqueValuesResult
An object that contains the unique values returned from the uniqueValues() query of a layer's field.
Properties:uniqueValueInfos Object[]An array of objects, each containing a unique value/type/category present in the field specifed in the uniqueValues() query. See table below for the specification of each object.
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).