How can I configure the Arcade expression for Operations Dashboard to dynamically change data in widgets when map extent changes?

397
7
Jump to solution
01-04-2022 11:06 AM
Labels (1)
Norchevskyi
New Contributor II

Hi,

I have the Arcade Expression (that was described here:ArcGIS Operations Dashboard Arcade Join Table )  for the Indicator widget, that perform a join operation between a feature layer and a feature table, I applied the rule "When map extent changes" in Map actions for the Indicator widget. But the Widget doesn't display the data, that is empty.

Is it possible to customize the Arcade expression so that the widget dynamically displays data from the current extent?

Thank you,

Roman

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Notable Contributor

Your FeatureSet is being set to an empty geometry type, which is better for performance. To bring in the spatial component for map filtering, etc., you need to define the geometry type and include the geometry in your features array.

var joinedDict = {
    ...
    geometryType: "esriGeometryPoint" // or whatever geometry type applies
    ...
}

...

        joinedDict.features[i] = {
            attributes: {
                StreetID: tableID,
                Name: p["Address"],
				Depth: t["Depth"],
            },
            geometry: Geometry(p)
        }

...
- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
7 Replies
jcarlson
MVP Notable Contributor

Your FeatureSet is being set to an empty geometry type, which is better for performance. To bring in the spatial component for map filtering, etc., you need to define the geometry type and include the geometry in your features array.

var joinedDict = {
    ...
    geometryType: "esriGeometryPoint" // or whatever geometry type applies
    ...
}

...

        joinedDict.features[i] = {
            attributes: {
                StreetID: tableID,
                Name: p["Address"],
				Depth: t["Depth"],
            },
            geometry: Geometry(p)
        }

...
- Josh Carlson
Kendall County GIS
0 Kudos
Norchevskyi
New Contributor II

Josh, thank you for help. I added your your edits to the expression:

var portal = Portal("https://www.arcgis.com/");
var polyfs = FeatureSetByPortalItem(portal,"2c70f00e262a4488b266595720312617",0,["*"],true);
var tablefs = FeatureSetByPortalItem(portal,"227503e1ba6848baa7227b6311c04802",0,["*"],false);

var joinedDict = {
  fields: [
    { name: "StreetID", type: "esriFieldTypeInteger" },
    { name: "Name", type: "esriFieldTypeString" },	
    { name: "Depth", type: "esriFieldTypeDouble" },
  ],
    geometryType: "esriGeometryPoint",
'features':[]};

var i = 0;
for (var t in tablefs) {
    var tableID = t["StreetID"]
    for (var p in Filter(polyfs, "StreetID = "+tableID)){
        joinedDict.features[i] = {
            attributes: {
                StreetID: tableID,
                Name: p["Address"],
				Depth: t["Depth"],
            },
            geometry: Geometry(p)
        }
    }
i++
}

return FeatureSet(Text(joinedDict));

 

The widget is working but does not display data when map extent changes. 

Norchevskyi_0-1641326744563.png

 

Thank you,

Roman

0 Kudos
jcarlson
MVP Notable Contributor

You added the appropriate action to the map widget? I can get it to update just fine.

uosl_0-1641328809030.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
Norchevskyi
New Contributor II

Yes, see please my screen:

Norchevskyi_0-1641329007069.png

Thank you,

Roman

0 Kudos
Norchevskyi
New Contributor II

Josh, it's very strange, but when full extent we can see all counts of features, and when zooming we see 0 features

Thank you,

Roman

0 Kudos
jcarlson
MVP Notable Contributor

That is very strange indeed! I created a List widget and added a Flash action on it. It seems that the features are coming in with just two particular points in this area:

uosl_0-1641330278755.png

I noticed there are only two values that show up in the Street ID field, so that seems to correspond with this. I'm assuming these values should correspond with the points layer in your screenshots, though, right?

Should you maybe join these based on a matching address field, rather than the street id?

- Josh Carlson
Kendall County GIS
0 Kudos
Norchevskyi
New Contributor II

Josh, the dashhboard is working. It was my mistake, as is joined data had only two values for StreetID field. All is well, but it seems that this method can work with no more than a few hundred features, if there are several thousand features, then the dashboard takes a very long time to process the data.

Thank you so much for your help and time,

Roman

0 Kudos