require(["esri/tasks/StatisticDefinition"], function(StatisticDefinition) { /* code goes here */ });
Description
(Added at v2.6)
The StatisticDefinition class defines the type of statistics, the field used to calculate the statistics and the resulting output field name. Used to specify an array of statistic definitions for a query's outStatistics property.
Requires ArcGIS Server service version 10.1 or greater
Samples
Search for
samples that use this class.
Constructors
Properties
Constructor Details
Creates a new StatisticDefinition object.
Sample:
require([
"esri/tasks/StatisticDefinition", ...
], function(StatisticDefinition, ... ) {
var statisticDefinition = new StatisticDefinition();
...
});
Property Details
The field name or standard SQL expression on which statistics will be calculated. Standard SQL expressions are only supported on services where advancedQueryCapabilities.supportsSqlExpression is true. As of version 3.16, this capability is only available in ArcGIS Online hosted feature services.
Sample:
// Using a field name
statisticDefinition.onStatisticField = "POP2000";
// Using a SQL expression to calculate population density stats
statisticDefinition.onStatisticField = "POP2000 / AREA";
Specify the output field name. Output field names can only contain alpha-numeric characters and an underscore. If no output field name is specified the map server assigns a field name to the returned statistic field.
Sample:
statisticDefinition.outStatisticFieldName = "TotalPop";
Define the type of statistic.
Known values: 'count'|'sum'|'min'|'max'|'avg'|'stddev'
Sample:
statisticDefinition.statisticType = "sum";