You are using a browser that is no longer supported. Please use the latest version of Google Chrome, Mozilla Firefox, Apple Safari, or Microsoft Edge. For more information please see the System Requirements.
Skip To ContentArcGIS for DevelopersSign In Dashboard

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to create a HistogramRangeSlider widget and use it to filter a layer's features based on a numeric attribute. The histogram can be generated with the histogram() statistics function.

view.whenLayerView(layer).then(function(layerView) {

  // temperature in Celsius
  const field = "temp";
  const min = 0;
  const max = 30;

  // generate 100-bin histogram
    layer: layer,
    field: field,
    numBins: 100,
    minValue: min,
    maxValue: max
  }).then(function(histogramResponse) {

    // histogram response contains the histogram bins
    // the code block shown below will be placed here


Then you can construct the slider using the output bins, and min/max values. You also must indicate a rangeType. This property serves two purposes:

  1. It determines how histogram bars are rendered, indicating which bins are included and excluded from the selected range.
  2. It determines the SQL where clause used for executing queries, highlighting, selecting, or filtering features.

In this case, the rangeType is between so two thumbs will render on the slider track and all values between the two thumbs will be included in the selection/query/filter.

const slider = new HistogramRangeSlider({
  bins: histogramResponse.bins,
  min: min,
  max: max,
  values: [min, max],
  excludedBarColor: "#524e4e",
  rangeType: "between",
  container: document.getElementById("slider-container")

slider.on(["thumb-change", "thumb-drag", "segment-drag"], function(event) {
  // field is "temp"

const filterByHistogramRange = promiseUtils.debounce(function (field) {
  layerView.filter = {
    // generates the where clause for filtering features
    where: slider.generateWhereClause(field)

Sample search results