Creating a Temp Feature Set for Stacked Serial Chart

253
0
01-04-2022 02:38 PM
JohnnyHarley232
New Contributor III

I want to stack three different layers and group them by their own date field. For some reason, my Arcade code is working but no data is showing in the data table below. I am assuming this is a small tweak to the code but wasnt sure.

JohnnyHarley232_0-1641336271726.png

 

 

I currently have the following arcade code, modeling as a template from this presentation https://www.esri.com/arcgis-blog/products/ops-dashboard/analytics/enhancing-dashboard-elements-using... 

var portal = Portal("https://planetscapeai.maps.arcgis.com/"); 
var alerts = GroupBy( 
  FeatureSetByPortalItem(portal,"9b11dda1c0804f13a72136a8bf71b93c",0,["*"],false), 
  ["Date"], 
  [ 
    { name: "Alerts1" ,expression: "FID", statistic:"COUNT" } 
  ] 
); 

var imagery = GroupBy( 
  FeatureSetByPortalItem(portal,"d70d948dd59c451bb56cc12a8f7aeb96",0,["*"],false), 
  ["Date"], 
  [ 
    { name: "Alerts2" ,expression: "FID", statistic:"COUNT" } 
  ] 
);

var survey = GroupBy( 
  FeatureSetByPortalItem(portal,"f18f6b7a0447412083228d6ce554f042",0,["*"],false), 
  ["CreationDate"], 
  [{ name: "Alerts3", expression: "objectid", statistic: "COUNT" }] 
);

var combinedDict = { 
  fields: [ 
    { name: "Type", type: "esriFieldTypeString" }, 
    { name: "CompletedDate", type: "esriFieldTypeDate" }, 
    { name: "NumberOfAlerts", type: "esriFieldTypeInteger" }, 
  ], 
  geometryType: "", 
  features: [], 
}; 

var i = 0; 
// Loop through each FeatureSet and store its attributes 
for (var m in alerts) { 
  combinedDict.features[i++] = { 
    attributes: { 
      Type: "Alerts", 
      CompletedDate: m["Date"], 
      NumberOfAlerts: m["Alerts1"], 
    }, 
  }; 
} 

for (var p in imagery) { 
  combinedDict.features[i++] = { 
    attributes: { 
      Type: "Imagery", 
      CompletedDate: p["Date"], 
      NumberOfAlerts: p["Alerts2"], 
    }, 
  }; 
}

for (var j in survey) { 
  combinedDict.features[i++] = { 
    attributes: { 
      Type: "Survey", 
      CompletedDate: j["CreationDate"], 
      NumberOfAlerts: j["Alerts3"], 
    }, 
  }; 
} 

// Return dictionary cast as a FeatureSet  
return FeatureSet(Text(combinedDict));   

 

0 Kudos
0 Replies