summaryStatisticsForAge

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

Function for generating statistics for the age of features in a layer based on a given start time and end time.

Method Overview

Name Return Type Summary Function

Returns an object containing various statistics describing an age value (e.g.

summaryStatisticsForAge

Method Details

summaryStatisticsForAge

Method
summaryStatisticsForAge(params){Promise<SummaryStatisticsResult>}

Returns an object containing various statistics describing an age value (e.g. the difference between a given end time from a start time) in a Layer.

Parameters
Specification
params Object

See the table below for details of each parameter.

Specification

The layer from which to generate age statistics for the given startTime and endTime.

startTime Date|String|Number

The start time for the age calculation. This can be a field name or a date value, such as Date.now(). If a Date is provided, then the endTime parameter must be a field name.

endTime Date|String|Number

The end time for the age calculation. This can be a field name or a date value, such as Date.now(). If a Date is provided, then the startTime parameter must be a field name.

unit String

The desired units of the age result.

Possible Values:"years"|"months"|"days"|"hours"|"minutes"|"seconds"

optional

The view in which features will be rendered.

outStatisticTypes Object
optional

Since 4.31 Indicates the statistics to calculate. If not defined, all statistics are calculated by default. The object should have the following properties.

Specification
optional

The statistics to include in the calculation.

optional

The statistics to exclude from the calculation. Some statistics, such as median, are computationally expensive to calculate and may be excluded to improve performance.

filter FeatureFilter
optional

Since 4.31 When defined, only features included in the filter are considered in the attribute and spatial statistics calculations when determining the final renderer. This is useful when a lot of variation exists in the data that could result in undesired data ranges. A common use case would be to set a filter that only includes features in the current extent of the view where the data is most likely to be viewed. Currently, only geometry filters with an intersects spatial relationship are supported. All other filter types (including where) are ignored.

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<SummaryStatisticsResult> Returns a promise that resolves to SummaryStatisticsResult.
Example
summaryStatisticsForAge({
  layer: featureLayer,
  startTime: "Created_Date",
  endTime: Date.now(),
  unit: "days",
  view: mapView
}).then(function(stats){
  console.log(`Average age of open incidents in days: ${stats.avg}`);
});

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