Select to view content in your preferred language

Label support for Predominant Category symbology style

747
2
Jump to solution
07-20-2022 10:08 AM
Labels (2)
BrittanyBurson
Frequent Contributor

Hi there, I'm enjoying the Predominant Category symbology style available in ArcGIS Online, however I am  finding it difficult to label the results I am showing. I want to show the predominant category + value as labels in the map. It would be great if the result automatically became available as a label when using this style.

BrittanyBurson_0-1658336814834.png

But since it's not...

When I bring the map into ArcGIS Pro, I can see the Arcade snippet driving the symbology, but I am not good enough with Arcade to adapt it to show me the predominant category + value as a label. Using maxValueField only gives me the predominant field... anyone have suggestions to return the value as well?

var dec_var_P_Phone=$feature.P_Phone;var dec_var_P_Mobile=$feature.P_Mobile;var dec_var_P_Other=$feature.P_Other;var dec_var_P_Web=$feature.P_Web;
  $feature["P_Phone"];
$feature["P_Mobile"];
$feature["P_Other"];
$feature["P_Web"];

  
  var fieldNames = [ "P_Phone", "P_Mobile", "P_Other", "P_Web" ];
  var numFields = 4;
  var maxValueField = null;
  var maxValue = -Infinity;
  var value, i, totalValue = null;

  for(i = 0; i < numFields; i++) {
    value = $feature[fieldNames[i]];

    if(value > 0) {
      if(value > maxValue) {
        maxValue = value;
        maxValueField = fieldNames[i];
      }
      else if (value == maxValue) {
        maxValueField = null;
      }
    }
    
  }
  
  return maxValueField;
  

 

Thank you!

0 Kudos
1 Solution

Accepted Solutions
BrittanyBurson
Frequent Contributor

I was able to do this and am posting the (very simple...) solution to return the predominant label and value in case it helps someone else.

BrittanyBurson_0-1658354843041.png

It's a simple return of the maxValueField and the maxValue. In my example above I am using

return Mid(maxValueField, 2) + TextFormatting.NewLine + maxValue + '%';

Cheers!

View solution in original post

0 Kudos
2 Replies
BrittanyBurson
Frequent Contributor

I was able to do this and am posting the (very simple...) solution to return the predominant label and value in case it helps someone else.

BrittanyBurson_0-1658354843041.png

It's a simple return of the maxValueField and the maxValue. In my example above I am using

return Mid(maxValueField, 2) + TextFormatting.NewLine + maxValue + '%';

Cheers!

0 Kudos
kmsmikrud
Frequent Contributor

Hi Brittany,

I was also looking up on predominance mapping in AGOL and had followed this blog post creating the arcade syntax.  A couple of questions for you, is the map above with the pie charts symbols in AGOL or Pro? I really like being able to easily see the breakdown you are showing with all the slices. When I looked up I think pie chart symbology is not yet supported in AGOL?

Another question, I had transposed the data I have to new fields for each category. For instance I'm working with fish species and catch in a certain area. I consolidated catch records and moved species (5 of them) and counts to each have their own fields for the predominance mapping to work. The map is used in a dashboard and while the predominant species is mapped accordingly, I can no longer filter the dashboard map by species. I'm trying to figure out a way to have both (predominant species caught for a time period) but also be able to filter by species. Prior to transposing there was a species field and count, so many records for one period of time, but I could filter by species. 

In short to relate to your map above, how would you filter the map for one the categories such as all areas with 'Mobile' in a dashboard"?

I would appreciate any ideas!

Thanks,

Kathy

Thanks,

Kathy

0 Kudos