AttributeBinsGraphic

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

A Graphic returned in a FeatureSet as result of running queryAttributeBins() method. It can contain stackedAttributes in addition to geometry, a symbol, and attributes.

See also

Constructors

AttributeBinsGraphic

Constructor
new AttributeBinsGraphic(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 aggregateGeometries contains spatial aggregation geometries when statistics query is executed with envelope-aggregate, centroid-aggregate and/or convex-hull-aggregate statistics type.

Graphic

Name-value pairs of fields and field values associated with the graphic.

Graphic

The name of the class.

Accessor

The geometry that defines the graphic's location.

Graphic

Indicates whether the graphic refers to an aggregate, or cluster graphic.

Graphic

If applicable, references the layer in which the graphic is stored.

Graphic

Returns information about an origin of a graphic if applicable.

Graphic

The template for displaying content in a Popup when the graphic is selected.

Graphic

The stackedAttributes contains an array of name-value pairs, where the names correspond to unique values of the specified field or expression alias.

AttributeBinsGraphic

The Symbol for the graphic.

Graphic

Indicates the visibility of the graphic.

Graphic

Property Details

aggregateGeometries

Inherited
Property
aggregateGeometries Object |null |undefined
Inherited from Graphic

The aggregateGeometries contains spatial aggregation geometries when statistics query is executed with envelope-aggregate, centroid-aggregate and/or convex-hull-aggregate statistics type. Each property on aggregateGeometries is populated with statistics field containing the aggregate geometry matching the aggregate statistics type.

Example
// average of age fields by regions
const ageStatsByRegion = new StatisticDefinition({
  onStatisticField: field,
  outStatisticFieldName: "avgAge",
  statisticType: "avg"
});

// extent encompassing all features by region
const aggregatedExtent = new StatisticDefinition({
  statisticType: "envelope-aggregate",
  outStatisticFieldName: "aggregateExtent",
});

// group the statistics by Region field
// get avg age by Regions and extent of each region
const query = layer.createQuery();
query.groupByFieldsForStatistics = ["Region"];
query.outStatistics = [consumeStatsByRegion, aggregatedExtent];
layer.queryFeatures(query).then((results) => {
  results.features.forEach((feature) => {
    if (feature.attributes.Region === "Midwest") {
       view.goTo(feature.aggregateGeometries.aggregateExtent);
    }
  });
});

attributes

Inherited
Property
attributes Object
Inherited from Graphic

Name-value pairs of fields and field values associated with the graphic.

Example
let graphic = new Graphic();
graphic.attributes = {
  "name": "Spruce",
  "family": "Pinaceae",
  "count": 126
};

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

geometry

Inherited
Property
geometry GeometryUnion |null |undefinedautocast
Inherited from Graphic

The geometry that defines the graphic's location.

Z-values defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service.

Example
// First create a point geometry
let point = {
  type: "point",  // autocasts as new Point()
  longitude: -71.2643,
  latitude: 42.0909
};

// Create a symbol for drawing the point
let markerSymbol = {
  type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
  color: [226, 119, 40]
};

// Create a graphic and add the geometry and symbol to it
let pointGraphic = new Graphic({
  geometry: point,
  symbol: markerSymbol
});

isAggregate

Inherited
Property
isAggregate Booleanreadonly
Inherited from Graphic

Indicates whether the graphic refers to an aggregate, or cluster graphic. Aggregate graphics represent clusters of features. If a graphic is an aggregate, you can use its Object ID to query the features comprising the cluster.

Inherited from Graphic

If applicable, references the layer in which the graphic is stored.

origin

Inherited
Property
origin GraphicOrigin |null |undefined
Inherited from Graphic

Returns information about an origin of a graphic if applicable. Origin information about a graphic can be returned as a result of the hitTest() or queryFeatures() method. It can include information such as a layer in which the graphic originates from. Information returned in the origin depends on the origin type.

Example
// get screen point from view's click event
view.on("click", (event) => {
  // Search for all features only on included layers at the clicked location
  view.hitTest(event, {include: vectorTileLayer}).then((response) => {
    // if graphics are returned from vector tile layer, do something with results
    if (response.results.length){
      response.results.forEach((result, i) => {
        const layerId = result.graphic?.origin?.layerId;
        const styleLayer = vectorTileLayer.getStyleLayer(layerId);
        // update layer's style
      });
    }
  })
});

popupTemplate

Inherited
Property
popupTemplate PopupTemplate |null |undefinedautocast
Inherited from Graphic

The template for displaying content in a Popup when the graphic is selected. The PopupTemplate may be used to access a graphic's attributes and display their values in the view's default popup. See the documentation for PopupTemplate for details on how to display attribute values in the popup.

As of 4.8 to get the actual popupTemplate of the graphic, see the getEffectivePopupTemplate() method that either returns this value or the popupTemplate of the graphic's layer.

Example
// The following snippet shows how to set a popupTemplate
// on the returned results (features) from identify

 idResult.feature.popupTemplate = {
 title: "{NAME}",
   content: [{
     // Pass in the fields to display
     type: "fields",
     fieldInfos: [{
       fieldName: "NAME",
       label: "Name"
     }, {
       fieldName: "REGION",
       label: "Region"
    }]
   }]
};

stackedAttributes

Property
stackedAttributes HashMap<any>[] |null |undefined

The stackedAttributes contains an array of name-value pairs, where the names correspond to unique values of the specified field or expression alias. Each name-value pair in the array represents a segment of the data, and these segments are stacked within the same bin. This allows for visualizing how different categories contribute to a total value. For example, it can be used to compare sales performance across different regions within the same time period.

symbol

Inherited
Property
symbol SymbolUnion |null |undefinedautocast
Inherited from Graphic

The Symbol for the graphic. Choosing a symbol for a graphic depends on the View type (SceneView or MapView), and the geometry type of the graphic.

Each graphic may have its own symbol specified when the parent layer is a GraphicsLayer. For a FeatureLayer the symbol of each graphic should not be set by the developer since the graphics' rendering properties are determined by the layer's renderer.

To change a graphic's symbol in the GraphicsLayer and in the view.graphics at runtime, one of the following can be done:

  1. Clone the symbol and change its properties.
  2. Assign a new symbol to the graphic.
Example
view.on("click", function(event){
  let graphic = new Graphic({
    geometry: event.mapPoint,
    symbol: {
      type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
      color: "blue",
      size: 8,
      outline: { // autocasts as new SimpleLineSymbol()
        width: 0.5,
        color: "darkblue"
      }
    }
  });
});

visible

Inherited
Property
visible Boolean
Inherited from Graphic

Indicates the visibility of the graphic.

Default Value:true

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
this

Creates a deep clone of this object.

AttributeBinsGraphic

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

AttributeBinsGraphic
*

Returns the value of the specified attribute.

Graphic

Returns the popup template applicable for the graphic.

Graphic

Returns the Object ID of the feature associated with the graphic, if it exists.

Graphic

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

Sets a new value to the specified attribute.

Graphic

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

AttributeBinsGraphic

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.

clone

Method
clone(){this}

Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.

Returns
Type Description
this A deep clone of the class instance that invoked this method.

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.

getAttribute

Inherited
Method
getAttribute(name){*}
Inherited from Graphic

Returns the value of the specified attribute.

Parameter
name String

The name of the attribute.

Returns
Type Description
* Returns the value of the attribute specified by name.

getEffectivePopupTemplate

Inherited
Method
getEffectivePopupTemplate(defaultPopupTemplateEnabled){PopupTemplate |null |undefined}
Inherited from Graphic

Returns the popup template applicable for the graphic. It's either the value of popupTemplate or the popupTemplate from the graphic's layer.

Parameter
defaultPopupTemplateEnabled Boolean
optional
Default Value: false

Whether support for default popup templates is enabled. When true, a default popup template may be created automatically if neither the graphic nor its layer have a popup template defined.

Returns
Type Description
PopupTemplate | null | undefined Returns the popup template of the graphic.

getObjectId

Inherited
Method
getObjectId(){Number |String |null |undefined}
Inherited from Graphic

Returns the Object ID of the feature associated with the graphic, if it exists.

Returns
Type Description
Number | String | null | undefined The ObjectID of the feature associated with the graphic.

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");

setAttribute

Inherited
Method
setAttribute(name, newValue)
Inherited from Graphic

Sets a new value to the specified attribute.

Parameters
name String

The name of the attribute to set.

newValue *

The new value to set on the named attribute.

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.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close