Select to view content in your preferred language

Dynamic legend based on filter

1678
5
08-22-2023 05:19 AM
cat206
by
Frequent Contributor

Hi, Is there a way to create a dynamic legend based on the filter widget in ExB? I can't seem to locate an action to link the two together, but i have a layer of work packages which can be filters to only show a few selected packages, and i would like the legend to display on those within the map extent and/or remove those that have been filtered out

5 Replies
Shen_Zhang
Esri Contributor

Hi @cat206, the legend widget displays visible layers of the map that it is connected to. When you apply a filter that results in an empty collection of features, I think it is something reasonable to keep the legend rather than remove it - as the map is actually filtered to display only those features that adhere to the applied filter.

It would be a little bit confusing to me if a legend got removed when applying a filter on it.

Shen Zhang
BlakeMorrison
Frequent Contributor

I found this thread cos I'm looking for the exact same functionality as OP.

I can think of scenarios where both options would be useful. My legend, which should naturally show the things visible in the current map, is showing a large stack of layers which are filtered in various ways to be not visible. It's rather confusing that the legend is displaying them as visible when they're clearly not.

Perhaps a legend option that offered a selection between "Visible layers" and "Visible features".

chill_gis_dude
Frequent Contributor

I agree with Blake. A better functionality is to give us the option to toggle between having the legend dynamic with the map view extent or having the legend dynamic with a back end feature service. 

NicoleStephan
Emerging Contributor

I would also love this functionality. I have a layer symbolized on lots of different unique values, but these unique values are not the same across cities. It makes sense for me to keep all the data in one layer, instead of having separate layers for each city. But it would be so nice to have an option that when I filter to a city, the legend just shows the unique values for that city, instead of having the legend cluttered with everything.

CodyPresny
New Contributor

I'm here in  March of 2025, attempting to bump this topic. For live NWS layers such as National Watches and Warnings, it would be extremely beneficial to filter the legend results by map frame extent. There are dozens of very similar color coded warnings, referencing the legend quickly is near impossible. Would be great to be able to dynamically filter out the noise at runtime.     

0 Kudos