require(["esri/smartMapping/statistics/classBreaks"], (classBreaks) => { /* code goes here */ });
import classBreaks from "@arcgis/core/smartMapping/statistics/classBreaks.js";
esri/smartMapping/statistics/classBreaks
Function for generating class breaks for an input field in a FeatureLayer based on a given classification method and normalization type.
Known Limitations
- SceneLayers must have the
supportsRenderer
andsupportsLayerQuery
capabilities enabled unless a predefined statistics object is provided to thestatistics
parameter of the method. To check a SceneLayer's capabilities, use the getFieldInfoUsage() method. - You cannot generate statistics using SQL expressions for client-side FeatureLayers in a SceneView.
Method Overview
Name | Return Type | Summary | Function |
---|---|---|---|
Promise<ClassBreaksResult> | Generates class breaks for an input field (or expression) of a FeatureLayer based on a given classification method and normalization type. | classBreaks |
Method Details
-
classBreaks
classBreaks(params){Promise<ClassBreaksResult>}
-
Generates class breaks for an input field (or expression) of a FeatureLayer based on a given classification method and normalization type.
ParametersSpecificationparams ObjectSee the table below for details about parameters that may be passed to this function.
Specificationlayer FeatureLayer|SceneLayer|CSVLayer|PointCloudLayer|GeoJSONLayer|WFSLayer|OGCFeatureLayer|StreamLayer|OrientedImageryLayer|CatalogFootprintLayer|KnowledgeGraphSublayer|SubtypeGroupLayer|SubtypeSublayerThe layer from which to generate class breaks.
field StringoptionalThe class breaks will be generated based on values of this field. If a field is provided, the values from the given field from all features will be queried in the service.
normalizationField StringoptionalThe field by which to normalize the values returned from the given
field
.classificationMethod StringoptionalThe method for classifying the data. See the table below for a list of possible values.
Possible Value Description natural-breaks Data values that cluster are placed into a single class. Class breaks occur where gaps exist between clusters. You should use this method if your data is unevenly distributed; that is, many features have the same or similar values and there are gaps between groups of values. equal-interval Each class has an equal range of values; in other words, the difference between the high and low value is equal for each class. You should use this method if your data is evenly distributed and you want to emphasize the difference in values between the features. quantile Each class has roughly the same number of features. If your data is evenly distributed and you want to emphasize the difference in relative position between features, you should use the quantile classification method. If, for example, the point values are divided into five classes, points in the highest class would fall into the top fifth of all points. standard-deviation Class breaks are placed above and below the mean value at intervals of 1
,0.5
, or0.25
standard deviations until all the data values are included in a class.Possible Values:"equal-interval"|"natural-breaks"|"quantile"|"standard-deviation"
standardDeviationInterval NumberoptionalWhen
classificationMethod = "standard-deviation"
, this sets the interval at which each class break should be set (e.g.0.25
,0.33
,0.5
,1
). See the table below for a list of possible values.Possible Value Description field Divides the data value using the attribute value of the field specified in the normalizationField property. A normalizationField
must be provided if This value is used.log Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. percent-of-total Divides the data value by the sum of all data values then multiplies by 100. Use normalizationTotal to define the total value by which to normalize. then set the total amount with which to normalize field values. minValue NumberoptionalThe minimum bounding value for the class breaks definition. Use this in conjunction with
maxValue
to generate class breaks between lower and upper bounds.maxValue NumberoptionalThe maximum bounding value for the class breaks definition. Use this in conjunction with
minValue
to generate class breaks between lower and upper bounds.numClasses NumberoptionalIndicates the number of classes to generate for the class breaks definition.
valueExpression StringoptionalAn Arcade expression following the specification defined by the Arcade Visualization Profile. Expressions may reference field values using the
$feature
profile variable and must return a number. This property overrides thefield
property and therefore is used instead of an inputfield
value.sqlExpression StringoptionalA SQL expression evaluating to a number.
sqlWhere StringoptionalA 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.
view ViewoptionalA SceneView or MapView instance is required when a
valueExpression
is specified.filter FeatureFilteroptionalA feature filter used to filter statistic queries by geometry. This parameter is only used for filtering statistics by geometry. Any attribute filters set on the
FeatureFilter.where
property are ignored. Currently, only theintersects
spatial relationship is supported. This is useful if you already define a feature filter by geometry on your layer and want to calculate statistics for the included features. Since version 4.25.Deprecated since version 4.23. UseuseFeaturesInView
instead.A subset of features for which to generate the class breaks.
useFeaturesInView BooleanoptionalOnly applicable when the input
layer
is a service-backed FeatureLayer. Whentrue
, statistics will be calculated on the client from features visible in the view. Iffalse
, statistics will be requested from the service. Since version 4.23.forBinning BooleanoptionalIndicates 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 thefeatureReduction
property of the layer.signal AbortSignaloptionalAllows for cancelable requests. If canceled, the promise will be rejected with an error named
AbortError
. See also AbortController.ReturnsType Description Promise<ClassBreaksResult> Resolves to an instance of ClassBreaksResult. ExampleclassBreaks({ layer: featureLayer, field: "COL_DEG", normalizationField: "TOT_POP", classificationMethod: "quantile", numClasses: 5 }).then(function(response){ // class break infos that may be passed to the // constructor of a ClassBreaksRenderer let breakInfos = response.classBreakInfos; });
Type Definitions
-
An object describing a single class break generated from the classBreaks() method.
-
Object returned from the classBreaks() method. This object describes classes generated from data in a FeatureLayer for a given field with a specified classification method.
- Properties
-
classBreakInfos ClassBreak[]
An array of objects describing the class breaks generated from the classBreaks() method.
minValue NumberThe minimum value of features in the dataset. This will be the lower bound of the lowest class break.
maxValue NumberThe maximum value of features in the dataset. This will be the upper bound of the highest class break.
normalizationTotal NumberThe normalization total if
normalizationType
is set topercent-of-total
when generating class breaks with createClassBreaksRenderer().