Select to view content in your preferred language

Arcade in ArcGIS Online cluster symbology pop-up using aggregated features not populating.

1146
4
02-22-2022 12:00 PM
Labels (1)
EmmaHatcher
Frequent Contributor

I recently came across the blog post on using Arcade to summarize data in cluster symbology pop-ups using information from aggregated features (https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/summarize-and-explore-point-clusters...). Using the solution in the example that's demonstrating a table of custom attributes (section 4 in the post), I essentially copied and pasted the example Arcade into the Arcade set up in my web map for clusters, and swapped in the relevant field names. I'm getting empty elements in the table at every level... checked four times for typos. 

In this dataset, there are a bunch of points representing port surveys of fisherman. The points each have a bunch of info about day and location where they fished, what species they were targeting, and how much they caught and harvested of that target species. I'm trying to get the cluster pop-up to provide harvests and catches by target species of the aggregated features (for use in a dashboard where folks can filter on attributes like port and date). Here's the code I'm working with to try and get a table of Harvest by TargetSpecies from each aggregated cluster:

 

 

Expects($aggregatedFeatures, "TargetSpecies", "Harvest")
var attributes = {};
var fieldInfos = [];

var statsFS = GroupBy($aggregatedFeatures,
  [
    { name: 'species', expression: 'TargetSpecies'},
  ],
  [  // statistics to return for each unique category
    { name: 'harvest', expression: 'Harvest', statistic: 'SUM' },
//    { name: 'num_features', expression: '1', statistic: 'COUNT' }
  ]
);
var ordered = OrderBy(statsFS, 'harvest DESC');

for(var f in ordered){
  var type = f.species;
  attributes[type] = Text(f.harvest, "#,### harvested");
  Push(fieldInfos, {
    fieldName: type
  });
}

return {
  type: "fields",
  title: "Total harvested by species",
  attributes: attributes,
  fieldInfos: fieldInfos,
}

 

 

 

And the result:

EmmaHatcher_1-1645559920431.png

And the view in the pop-up:

EmmaHatcher_2-1645559970371.png

Does anyone have thoughts on why this may not be working based on the info I shared? 

 

0 Kudos
4 Replies
KimGarbade
Frequent Contributor

At first glance not sure you need the "," after line 10, since line 11 is commented out.

KimGarbade_0-1645566993384.png

 

0 Kudos
EmmaHatcher
Frequent Contributor

I was going back and forth on that comma, too. It's there in the example web map from the blog post where there is only one statistic (example 3) even... but I just removed it again in my expression with your suggestion, and it appears not to make a difference. Darn, thanks for the idea, though!

From the blog post (example 3), for reference:

EmmaHatcher_0-1645569348068.png

 

0 Kudos
KimGarbade
Frequent Contributor

Dang... now I'm going to have to look at it closer.... I found the sample map viewer project the original code you borrowed from was based on (I don't have good cluster data to test against).  

Power Plants around the Globe (arcgis.com)

I then copied your code in a custom clustered popup in that project and just changed the attribute names back to the names from the original code your borrowed from (I.E. your code with just field names changed). And.... it worked :-(.

KimGarbade_0-1645572366034.png

I would have preferred if it didn't because then I would have something to solve for.

Here's the code I used if it helps.  Maybe I changed something small like a comma or capitalization without realizing it.  Hope this helps.  If nothing else, the fact that it works might provide a clue.

KimGarbade_1-1645572635863.png

 

0 Kudos
EmmaHatcher
Frequent Contributor

Hey thank you for the troubleshooting support!! So this is really funny... the pop-up completely works as expected in the dashboard, just not in the web map. Maybe a bug? 

Here's the dashboard view:

EmmaHatcher_0-1645572767027.png

I guess that's really where that counts here. And who knows, could be the weather where I am for the inconsistency over web tools, ha!

0 Kudos