Hi! I am trying to create a serial chart in Dashboards using data from a feature layer and its related table. I have one field in the feature layer that is basically the status (or "install") of a trap and then each of those individual records can have multiple related records with "actions." Basically, I need to be able to make a field with every trap "install" and every "action" without the actions overwriting the "install" status. I am trying to create a chart that shows the number of "installs" and the number of "actions" as different bars on a graph.
My assumption is that I can do this somehow using Groupby or a dictionary in the data expression function, but I have not been able to figure it out. At the moment I have the script below, but it doesn't recognize "monitoraction" which is the field in the related table. I am sure there are also a host of other issues. Any input would be great; I have very little experience with Arcade!
var portal = Portal('https://www.arcgis.com');
// Layer
var fs = FeatureSetByPortalItem(
portal,
'452bb162c4e84671be55c31b02d2211e',
0,
[
'status',
'monitoraction'
],
false
);
// List of installs/monitors per field per feature;
var out_dict = {
fields: [{name: 'status', type: 'esriFieldTypeString'}],
geometryType: '',
features: []
}
// Iterate over each feature in the layer
for (var f in fs){
Push(
out_dict['features'],
{attributes: {status: f['status']}}
)
Push (
out_dict['features'],
{attributes: {status: f['monitoraction']}}
)
}
// Return populated out_dict as FeatureSet
return FeatureSet(Text(out_dict))