import histogram from "@arcgis/core/smartMapping/statistics/histogram.js";const histogram = await $arcgis.import("@arcgis/core/smartMapping/statistics/histogram.js");- Since
- ArcGIS Maps SDK for JavaScript 4.2
Generates a histogram based on data in a Layer for a given field. The returned object can be used for displaying a histogram in the UI within visualization authoring applications and analytical apps that query and display statistics.
Known Limitations
SceneLayers must have the supportsRenderer and supportsLayerQuery capabilities enabled unless a predefined statistics object is provided to the statistics parameter of the method. To check a SceneLayer's capabilities, use the SceneLayer.getFieldUsageInfo() method.
You cannot generate statistics using SQL expressions for client-side FeatureLayers
in a SceneView.
The normalizationType parameter only normalizes data returned by a field. It does not apply to values returned from a valueExpression or sqlExpression.
Functions
| Name | Return Type | Object |
|---|---|---|
| |
histogram
Generates a histogram for data returned from a field in a given layer.
The returned object can be used for displaying
a histogram to the UI in visualization authoring applications and analytical apps that query and
display statistics.
- Signature
-
histogram (parameters: HistogramParameters): Promise<HistogramResult>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| parameters | The function parameters. | |
- Returns
- Promise<HistogramResult>
Resolves to a HistogramResult object.
Examples
histogram({ layer: featureLayer, valueExpression: "( ($feature.POP2020 - $feature.POP2010) / $feature.POP2010 ) * 100" view: mapView, numBins: 30}).then((histogramResult) => { colorSlider.histogram = histogramResult;});histogram({ layer: featureLayer, field: "Population", normalizationType: "natural-log", sqlWhere: "Population > 0", numBins: 100}).then((histogramResult) => { const histogramElement = document.createElement("arcgis-histogram"); // Set histogram properties based on the histogramResult histogramElement.min = histogramResult.minValue; histogramElement.max = histogramResult.maxValue; histogramElement.bins = histogramResult.bins;});