predominantCategories

AMD: require(["esri/smartMapping/statistics/predominantCategories"], (predominantCategories) => { /* code goes here */ });
ESM: import predominantCategories from "@arcgis/core/smartMapping/statistics/predominantCategories.js";
Function: esri/smartMapping/statistics/predominantCategories
Since: ArcGIS Maps SDK for JavaScript 4.13

Function for generating category statistics for a predominance renderer.

Method Overview

Name Return Type Summary Function

Determines predominant categories for a layer based on a given set of competing numeric fields and returns the number of features belonging to each category.

predominantCategories

Method Details

predominantCategories

Method
predominantCategories(params){Promise<PredominantCategoriesResult>}

Determines predominant categories for a layer based on a given set of competing numeric fields and returns the number of features belonging to each category.

Parameters
Specification
params Object

See the table below for details of each parameter.

Specification

The layer from which to generate predominant categories for the given set of fields.

fields String[]

An array of numeric fields from which to determine predominant categories. The fields must all be number fields and they must be competing or complementary (e.g. population totals by language spoken at home, or harvested acres by crop type, or the results of an election by candidate or party).

forBinning Boolean
optional

Indicates whether the generated statistics are for a binning or clustering visualization. If true, then the input field(s) in this method should refer to aggregate fields defined in the featureReduction property of the layer.

optional

The view in which features will be rendered.

signal AbortSignal
optional

Allows for cancelable requests. If canceled, the promise will be rejected with an error named AbortError. See also AbortController.

Returns
Type Description
Promise<PredominantCategoriesResult> Returns a promise that resolves to PredominantCategoriesResult.
Example
predominantCategories({
  layer: featureLayer,
  fields: [ "corn_acres", "cotton_acres", "wheat_acres", "soybeans_acres", "vegetables_acres" ],
  view: mapView
}).then(function(stats){
  console.log(stats.predominantCategoryInfos);
});

Type Definitions

PredominantCategoriesResult

Type Definition
PredominantCategoriesResult

The statistics returned from the predominantCategories() function.

Properties
predominantCategoryInfos Object[]

An array of objects describing the count of each predominant category.

Specification
value String|Number

The value or category referenced in a predominance visualization. This is typically a field name.

count Number

The number of features belonging to the predominant category.

label String
optional

The label describing the predominant category, or field name.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.