DateBinParameters

AMD: require(["esri/rest/support/DateBinParameters"], (DateBinParameters) => { /* code goes here */ });
ESM: import DateBinParameters from "@arcgis/core/rest/support/DateBinParameters.js";
Class: esri/rest/support/DateBinParameters
Inheritance: DateBinParametersAccessor
Since: ArcGIS Maps SDK for JavaScript 4.32

DateBinParameters specifies binParameters on AttributeBinsQuery object. For date bins, the intervals are based on calendar units. For example, with monthly intervals, each bin corresponds to the full month. Date bins always start at the beginning of the calendar unit, not at the first item in the dataset.

When dates are binned, they start at the beginning of the temporal unit as follows:

  • An hour starts at minute 00.
  • A day starts at 12 a.m.
  • A week starts on Sunday
  • A month starts on the first day of the month
  • A quarter starts on the first month of the quarter (January, April, July, or October).
  • A year starts on January 1st.

For example, if you want to get the total number of accidents in the USA by month for the year 2021, you can use the following bin parameters:

// Query total accidents in the USA by month for the year 2021.
// TSODate field values are used to bin the data into monthly intervals.
// Request the binning results in pacific time zone.
const binQuery = new AttributeBinsQuery({
  binParameters: new DateBinParameters({
    field: "TSODate", // timestamp-offset field containing the date of each accident
    start: "2021-01-01T00:00:00+00:00", // the lower boundary of the first bin
    end: "2021-12-31T00:00:00+00:00", // the upper boundary of the last bin
    interval: { // the interval size for each bin. One month
      value: 1,
      units: "months"
    }
  }),
  outTimeZone: "America/Los_Angeles", // Get the binning results in pacific time zone
});
color-blend
Total accidents in the USA by month for the year 2021. Each bin represents the number of accidents that occurred during each month. The results are presented in Pacific time zone. The chart is based on the results of the binQuery shown above.
See also

Constructors

DateBinParameters

Constructor
new DateBinParameters(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

The name of the class.

Accessor

The end date value for bins to generate.

DateBinParameters

A standardized SQL expression used to calculate the bins, rather than referencing a field.

DateBinParameters

Specifies the expected data type of the output from the expression, based on the type of value the expression generates.

DateBinParameters

The field name used to calculate the bins.

DateBinParameters

The first day of the week.

DateBinParameters

If true, the upperBoundary and bin fields will not be included in the attributes.

DateBinParameters

Defines a length of time in one of the temporal units such as days, weeks, or years.

DateBinParameters

Defines an offset to the bin's starting position.

DateBinParameters

Indicates whether the last bin should match the specified interval size exactly.

returnFullIntervalBin

This property determines how the bins are aligned relative to the data points.

snapToData

The splitBy parameter divides data into separate bins for each unique value in the categorical field.

DateBinParameters

The stackBy parameter divides each bin into segments based on unique values from a categorical field, allowing you to compare multiple categories within the same bin while keeping the bin boundaries consistent across all categories.

DateBinParameters

The start date value for bins to generate.

DateBinParameters

The type of bin parameters.

DateBinParameters

Property Details

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

end

Property
end Date |String |Number |null |undefined

The end date value for bins to generate. ISO date strings can be passed when the bin field is timestamp-offset, date-only, and time-only field.

Default Value:null

expression

Property
expression String |null |undefined

A standardized SQL expression used to calculate the bins, rather than referencing a field. The specified SQL expression must evaluate to a numeric or date type. Both field and the expression cannot be specified for the same bin. The expressionValueType property must be set to the expected data type of the output from the expression.

Known Limitations

The expression is only supported with server-side FeatureLayers.

Example
const binQuery = new AttributeBinsQuery({
  binParameters: new AutoIntervalBinParameters({
    numBins: 5, // the interval size for each bin
    // sql expression to calculate the bins based on the product of Quantity and SalesAmount
    expression: "Quantity * SalesAmount"
    expressionValueType: "double"
  })
});

expressionValueType

Property
expressionValueType String |null |undefined

Specifies the expected data type of the output from the expression, based on the type of value the expression generates. The expression property must be set when this property is set.

Known Limitations

The expressionValueType is only supported with server-side FeatureLayers.

Possible Values:"small-integer" |"integer" |"single" |"double" |"long" |"date-only" |"time-only" |"timestamp-offset" |"date"

See also
Example
const binQuery = new AttributeBinsQuery({
  binParameters: new AutoIntervalBinParameters({
    numBins: 5, // the interval size for each bin
    // sql expression to calculate the bins based on the product of Quantity and SalesAmount
    expression: "Quantity * SalesAmount"
    expressionValueType: "double"
  })
});

field

Property
field String |null |undefined

The field name used to calculate the bins. The expression property cannot be set when this property is set.

See also

firstDayOfWeek

Property
firstDayOfWeek Number |null |undefined

The first day of the week. This property is used to determine the start of the week for date-based bins. The default value is 7, representing Sunday, if no value is specified.

Known Limitations

The firstDayOfWeek is only supported with server-side FeatureLayers.

hideUpperBound

Property
hideUpperBound Boolean |null |undefined

If true, the upperBoundary and bin fields will not be included in the attributes.

Known Limitations

The hideUpperBound is only supported with server-side FeatureLayers.

interval

Property
interval DateBinTimeIntervalautocast

Defines a length of time in one of the temporal units such as days, weeks, or years.

Default Value:null

offset

Property
offset DateBinTimeInterval |null |undefinedautocast

Defines an offset to the bin's starting position. For example, with a bin unit of day and an offset of 12 hours, bins run from noon to noon. The offset can be positive or negative.

Known Limitations

  • Only days, hours, minutes, seconds are supported for offset units.
  • The offset is only supported with server-side FeatureLayers.
Default Value:null

returnFullIntervalBin

Property
returnFullIntervalBin Boolean |null |undefinedinner

Indicates whether the last bin should match the specified interval size exactly. When set to false, the last bin may have a different interval size than the others. For example, if the bins are set to a monthly interval, the last bin could be shorter than a full month if the end date doesn’t align with the end of the month. When set to true, all bins will have the same interval size, including the first and last bins. For example, if the bins are set to a monthly interval and returnFullIntervalBin is set to true, the first and last bins will have a full month interval. This means that even if the first or last date doesn’t align perfectly with the start or end of the month, the first bin will start from the beginning of the month, and the last bin will cover the full month, potentially extending beyond the actual data range to ensure consistent bin sizes.

Known Limitations

  • The returnFullIntervalBin is only supported with server-side FeatureLayers.

snapToData

Property
snapToData String |null |undefinedinner

This property determines how the bins are aligned relative to the data points. It can be set to either the first or last data point. When set to first, the binning will start from the earliest date in your dataset and move forward in time. When set to last, the binning will start from the most recent date and move backward in time. For example, if the bins are set to a monthly interval and the data starts on January 18th:

  • When snapToData is set to first: The binning starts from the earliest date in the dataset and progresses forward in time. Each bin will cover a full month. However, the last bin may not be a full month if the end date does not align perfectly with the interval.
  • When snapToData is set to last: The binning starts from the most recent date in the dataset and moves backward in time. Each bin will cover a full month. However, the first bin may not be a full month if the start date does not align perfectly with the interval.

Known Limitations

The snapToData is only supported with server-side FeatureLayers.

Possible Values:"first" |"last"

See also

splitBy

Property
splitBy AttributeBinsGrouping |null |undefinedautocast

The splitBy parameter divides data into separate bins for each unique value in the categorical field. Each category will have different bin boundaries based on the data distribution within that category. For example, when analyzing sales by region (e.g., Central, Northeast, etc.), splitBy will create separate bin ranges for each region, allowing the boundaries to adjust to the specific data distribution of each region. The splitBy parameter is useful when the distribution of values within each category (e.g., branch or region) differs significantly, and you want each category’s binning to reflect its unique data range.

  • Field with many unique values are not appropriate for splitting bins into multiple series.
Example
// create bins based on the SalesTotal field, split by the Branch field.
const binQuery = new AttributeBinsQuery({
  binParameters: new AutoIntervalBinParameters({
    numBins: 5, // the interval size for each bin
    field: "SalesTotal",
    splitBy: { // autocasts to AttributeBinsGrouping
      type: "field",
      value: "Branch"
    }
  })
});
const result = await layer.queryAttributeBins(binQuery);

stackBy

Property
stackBy AttributeBinsGrouping |null |undefinedautocast

The stackBy parameter divides each bin into segments based on unique values from a categorical field, allowing you to compare multiple categories within the same bin while keeping the bin boundaries consistent across all categories. This enables you to visualize or analyze the distribution of categories stacked together within the same range of values. For example, with 3 bins based on total sales with ranges like $0 to $5000, $5001 to $10,000, and $10,001 to $15,000, setting stackBy = SalesRep will stack each sales rep's contribution within the same bin range. The bin boundaries remain the same, and each segment within the bin shows how individual categories contribute to the total frequency or value.

  • Field with many unique values are not appropriate for splitting bins into multiple series.
Example
// create bins based on the SalesTotal field, stacked by the Month field.
const binQuery = new AttributeBinsQuery({
  binParameters: new AutoIntervalBinParameters({
    numBins: 5, // the interval size for each bin
    field: "SalesTotal",
    stackBy: {
      value: "EXTRACT(MONTH from invoiceDate)",
      type: "expression",
      valueType: "double",
      alias: "Month"
    }
  })
});
const result = await layer.queryAttributeBins(binQuery);

start

Property
start Date |String |Number |null |undefined

The start date value for bins to generate. ISO date strings can be passed when the bin field is timestamp-offset, date-only, and time-only field.

Default Value:null

type

Property
type Stringreadonly

The type of bin parameters.

For DateBinParameters the type is always "date".

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

DateBinParameters

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

Converts an instance of this class to its ArcGIS portal JSON representation.

DateBinParameters

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

fromJSON

Method
fromJSON(json){* |null |undefined}static

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
Type Description
* | null | undefined Returns a new instance of this class.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

toJSON

Method
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

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