Select to view content in your preferred language

Creating a legend with Arcade with data populated later

2186
4
Jump to solution
08-02-2018 09:19 AM
KenBuja
MVP Esteemed Contributor

I have a feature layer in my web map whose attributes will be edited by users. The fields to be edited have domains set up, so I know what values to expect. I want to create the legend for the expected combinations of data, but since the layer starts out with all the fields having their default attribute, I cannot do that without editing a few of the features to make sure they all the combination variants. Is there any way I can create the legend without putting dummy data in the layer?

My Arcade code looks like this

var status = 'Not Assigned';
if ($feature.FishPriority == 1){
    if ($feature.FishStatus == 1) {
        if ($feature.BenthicPriority == 1) {
            if ($feature.BenthicStatus == 1) {
                status = 'Both';
            } else {
                status = 'Partially Complete';
            }
        } else {
            status = 'Fish';
        }
    } else if ($feature.FishStatus == 0) {
        if ($feature.BenthicPriority == 1) {
            if ($feature.BenthicStatus == 0) {
                status = 'Neither';
            } else {
                status = 'Partially Complete';
            }
        } else {
            status = 'Fish Not Complete';
        }
    } else {
         if ($feature.BenthicPriority == 1) {
            status = 'Partially Complete';
        } else {
            status = 'Fish Terminated';
        }      
    }
}
return status;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

with this legend as the result:

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Ken Buja , you have hit a limitation of how the symbology works in ArcGIS in relation to Arcade. The problem is as you already detected, that (part of) the data is passed through the function and only the values resulted from that will be presented to the legend. It will not scan the code to see what possible values may result and it will not be able to take into account additional values that might result in the future. The only way I have been able to resolve this is to use ArcGIS Online Assistant  and edit the json of the map manually to add the values that I know will appear later on in the data. 

Situations in which I have done this are:

  • You want to display the classified  time between an event and the current time, the classes are defined, but there is no data yet that should appear in the higher classes
  • Implementing scale dependent symbology, but the $view.scale will only reflect the current scale of the map 

I still feel that ArcGIS Online should offer the possibility to add more than 1 element to the legend to avoid hacking the json of the map. 

CC Kelly Gerrow

View solution in original post

4 Replies
XanderBakker
Esri Esteemed Contributor

Hi Ken Buja , you have hit a limitation of how the symbology works in ArcGIS in relation to Arcade. The problem is as you already detected, that (part of) the data is passed through the function and only the values resulted from that will be presented to the legend. It will not scan the code to see what possible values may result and it will not be able to take into account additional values that might result in the future. The only way I have been able to resolve this is to use ArcGIS Online Assistant  and edit the json of the map manually to add the values that I know will appear later on in the data. 

Situations in which I have done this are:

  • You want to display the classified  time between an event and the current time, the classes are defined, but there is no data yet that should appear in the higher classes
  • Implementing scale dependent symbology, but the $view.scale will only reflect the current scale of the map 

I still feel that ArcGIS Online should offer the possibility to add more than 1 element to the legend to avoid hacking the json of the map. 

CC Kelly Gerrow

KellyGerrow
Esri Alum

Thanks for the detailed reply Xanderand question Ken,

Ken Buja‌, Can you get this logged on the ideas site or through technical support as a usability bug? We will discuss this internally, but it would be great to have a trackable request.

KenBuja
MVP Esteemed Contributor

This has been identified as a bug

[BUG-000116504 : Arcade codes are not honored in the legend unless value combination exists in the Feature Services of a web map in ArcGIS Online.]

ArmstKP
Frequent Contributor

Any Updates?