Select to view content in your preferred language

Dynamic legend based on filter

749
4
08-22-2023 05:19 AM
cat206
by
Occasional Contributor II

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

4 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
0 Kudos
BlakeMorrison
New Contributor III

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
Occasional 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. 

0 Kudos
NicoleStephan
New Contributor II

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.