<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Apply featureEffect to a FeatureLayer | Sample | ArcGIS Maps SDK for JavaScript</title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
padding: var(--calcite-spacing-sm);
background-color: var(--calcite-color-background);
color: var(--calcite-color-text-1);
font-size: var(--calcite-font-size-lg);
<body class="calcite-mode-dark">
<arcgis-map item-id="f3551252973c41fa868c08edceb504e6">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-left">
<arcgis-legend></arcgis-legend>
<div id="controls" slot="bottom-left">
<div id="description">Phoenix Average Age (2015-2020)</div>
<div>by block groups</div>
<arcgis-slider range-labels-placement="end" show-range-labels>
style="flex: 1"></arcgis-histogram>
const histogram = await $arcgis.import("@arcgis/core/smartMapping/statistics/histogram.js");
// get references to the map, histogram, and slider components
const viewElement = document.querySelector("arcgis-map");
const histogramElement = document.querySelector("arcgis-histogram");
const sliderElement = document.querySelector("arcgis-slider");
// define the min, max, field, and starting values for the histogram and slider
const field = "MEDAGE_CY";
const startingValues = [25, 35];
// wait for the map to be ready
await viewElement.viewOnReady();
// get the phoenix featurelayer from the webmap
const layer = viewElement.map.layers.getItemAt(0);
// generate the histogram for the median age field
// within the specified min and max values
applyFeatureEffect(layer, `MEDAGE_CY BETWEEN ${startingValues[0]} AND ${startingValues[1]}`);
// generate the histogram values for the median age field
const histogramResponse = await histogram({
// set the histogram properties
histogramElement.bins = histogramResponse.bins;
histogramElement.min = min;
histogramElement.max = max;
histogramElement.colorStops = [
minValue: startingValues[0],
maxValue: startingValues[1],
// set the slider properties
sliderElement.values = startingValues;
// this function is called when the map is loaded
// and when user changes the histogram range slider thumbs
function applyFeatureEffect(layer, where) {
includedEffect: "bloom(0.9 0.6pt 0)",
excludedEffect: "blur(2.25pt) opacity(0.5)",
// apply a feature effect to highlight the block groups that
// fall within the slider range
sliderElement.addEventListener("arcgisInput", (event) => {
const where = `MEDAGE_CY BETWEEN ${sliderElement.values[0]} AND ${sliderElement.values[1]}`;
histogramElement.colorStops = [
minValue: sliderElement.values[0],
maxValue: sliderElement.values[1],
applyFeatureEffect(layer, where);