ageUtils

AMD: require(["esri/smartMapping/statistics/support/ageUtils"], (ageUtils) => { /* code goes here */ });
ESM: import * as ageUtils from "@arcgis/core/smartMapping/statistics/support/ageUtils";
Object: esri/smartMapping/statistics/support/ageUtils
Since: ArcGIS API for JavaScript 4.13

Provides utility functions for generating Arcade expressions intended for use in an age renderer.

Method Overview

Name Return Type Summary Object
AgeExpressionsResultmore details

Returns an Arcade expression for visualizing the age of a feature based on a given start time and end time.

more detailsageUtils

Method Details

getAgeExpressions(params){AgeExpressionsResult}

Returns an Arcade expression for visualizing the age of a feature based on a given start time and end time.

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
optional

The desired units of the age result.

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

Returns:
Type Description
AgeExpressionsResult Returns an instance of AgeExpressionsResult.
Example:
const ageExpressions = ageUtils.getAgeExpressions({
  layer: featureLayer,
  startTime: "Created_Date",
  endTime: Date.now(),
  unit: "days"
});

console.log(`value expression: ${ageExpressions.valueExpression}`);

Type Definitions

AgeExpressionsResult

The result object returned from the getAgeExpressions() method.

Properties:
valueExpression String

An Arcade expression following the specification defined by the Arcade Visualization Profile. The expression should be used to calculate the age of a feature based on the difference between the end time and the start time. It may reference field values using the $feature global variable and must return a number.

statisticsQuery Object

A SQL expression and where clause that matches the generated valueExpression used to query statistics from the layer.

histogramQuery Object

A SQL expression and where clause that matches the generated valueExpression used to query for a histogram from the layer.

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