Geocortex Web offers a functionality that leverages workflows to dynamically update KPI cards. This simplifies the process of counting key assets and allows users to display important counts in a visually appealing dashboard. By using workflows to update KPI cards, users can create dynamic applications that show customizable counts based on changing map extents!
This Geocortex Tech Tip demonstrates how to use workflows to update and configure KPI cards in Geocortex Web. Additionally, it explains how to configure performant queries in your workflows to ensure that KPI cards are dynamically and accurately updating counts as map extents are changed.
Video Transcription:
Hey everyone, my name is Patrick Fingler. In this Tech Tip video, we’re going to look at some advanced KPI card configuration. We’ll also demonstrate how you can leverage workflows to update KPI cards dynamically to create dashboard like apps for your Geocortex Web applications. Let’s dive in!
All right, we’re going to kick things off here inside of a customer application. This is the City of Portland’s “Permit Metric Map App” application that they’ve built with Geocortex Web. Immediately you’ll see here that they’ve added some KPI cards at the top. What’s really interesting is as the user zooms in and out or pans the map, you’ll notice that these KPI cards are being updated on the fly.
Now, what’s happening in the background is they’ve essentially configured a workflow that fires every time the user pans the map or zooms in and out – essentially every time the extent of the map changes. What that does is it queries all these different layers, there’s a couple different layers inside of the app, and it will query and identify how many features for that layer are within the given extent and then update the KPI cards accordingly.
In this application here we see the different permits and they’ve been symbolized accordingly. But in another application, you could have different assets that you might want to display counts of and so on.
So how does someone actually build this? Let’s navigate to Geocortex Web. Here you can see that I’ve added some KPI cards. And I’ve purposely made this building’s KPI card not fully functioning so we can walk through how to put it together.
Here you can see that if we zoom in and out, we’re going to be updating these KPI cards for the “Fire Hydrants” and the “Water Lines”. It’s essentially querying all the assets within the given extent and giving us a count. And again, if we zoom out really far, it’s going to give us a total count for all of the “Fire Hydrants” and “Water Lines” within the given extent.
So, to build this what you’ll first need to do is navigate to the “Map” tab here in the “Desktop Landscape Components” panel. We’ll scroll down. And here there’s an “Events” section. We’ll scroll down and you’ll see here there’s this “Map Viewpoint Changed” event. Here what I’ve done is I’ve configured a workflow to fire every time the maps viewpoint changes.
So, what you’ll want to do is click the edit icon. Then click on the “Workflows” tab. Then you could either click “Create a new workflow” to start from scratch or select an existing workflow, which is what I have done.
Let’s walk through this process. If we go into the workflow itself, there’s three main sections here. The first section, the “Set Up” section, is just to set up your workflow and define what layers you want to generate some KPI cards on. The second section, the “Query Layers” section, is to query those layers. And the third section, the “Update KPI” section, is to update and run some commands to update those KPI cards.
So, in this “Set Up” container it’s not too long of a workflow. What we’re doing is using the “Get Workflow Inputs” command which is going to give us the current map extent.
And here in “Assign Map Extent Variable” I’m just assigning this to a variable. I’m using “getWorkflowInputs.inputs.context.maps.extent”. We’re getting the context, then we’re going into the maps object and then we’re getting the extent. Now this is one way to do it. You could also just use the get map extent activity and that would also work just fine.
The next thing that we’re doing is we’re creating this features array variable in “Create Features Variable”, which is going to hold the results of our queries that we perform. This is a key step here. We’ve just created an empty object, which is an empty array.
And then next we’re getting the layers that we want to include in our KPI cards. So, I’m using the get layer activity and I’m getting the “Fire Hydrants” Layer, I’m getting the “Water Lines Layer” and I’m also getting the “Buildings Layer”.
Once you have those layers, we can then query them. I’ll press “Start” and open up our “Query Layers” container and here you can see I’m using the “Query Layer” activity.
I’m supplying my fire hydrants layer here in the “Layer” section.
In “Geometry” we’re essentially wanting to identify all of the fire hydrants within the current map extent.
In “Where” we’re just doing a 1 = 1.
In “Return Geometry” we’ll want to specify “false” because you do want this to be a very performant query because it’s running every time the user pans the map.
One way to make that very performant is to use what are called “Out Statistics”. This is a capability within ArcGIS Server. Here in the “statisticType” we can say that we want to do a “count”. This is the statistic type property. You can find documentation about this in Esri’s ArcGIS Server documentation. Essentially, we’re doing a count. We’re doing a count on the “OBJECTID”. Which is our “onStatisticField”. Then you can specify an “outStatisticFieldName” name. We’re going to set this also to “OBJECTID”. You could assign this to another attribute, but it’s worth mentioning that you’d probably want it to be an integer or a double.
So, to summarize, in the Out Statistics we’re doing a count and we’re outputting a single attribute called Object ID, which is going to have the count of the features within the current extent. And this same process will be done for all the other queries as well.
So again, for the “Water Lines” we’re passing the water lines layer or querying it based on the map extent. And then we’re also using that same Out Statistics object on our Object ID.
In between the query layers of our workflow, you can see that we’re just adding the results of these queries to our features collection or features array. So, here in the “Collection” field we’re adding an item to our features collection. This is just going to be the output feature from our query which will be a single feature that has that Object ID attribute which is going to be the count of the features.
So, we’re doing that for each of our three layers – “Fire Hydrants”, “Water Lines”, and “Buildings”.
Then we’ll click “Start” to go to the “Update KPI” container. Let’s double click that. This next step is important – we’re going to use this “Convert Esri to VertiGIS” to convert that features array which contains Esri features into what’s called a VertiGIS feature.
We do have other Tech Tip videos that I’d recommend watching if this is new to you, so definitely check those out.
Essentially what this process does is it uses this “Operation Name” – “results.from-graphics” – to convert these Esri features, which is our features array object, which are called graphics, and that will output a VertiGIS feature which we can then use for other native Geocortex Web commands and operations. Here we’re going to run a “Command Name” called “kpi.display” and this is where we’re going to supply the VertiGIS features again.
For more information on this check out our other Tech Tips. There’s also lots of documentation on our Geocortex Developer Center to learn more on how to use those commands.
Now, let’s save that. That’s essentially the workflow. Let us know if you want to get access to this workflow and we can always upload this to the Community. But that’s the general workflow.
Now, in regard to the KPI card configuration, let’s go to our “Buildings KPI” card because it’s not working properly. Here I’ve added a KPI card, and I’ve connected it to our buildings layer.
I’ve adjusted the coloring of it in the “Background Color” field, so it is now purple. And in “Top” I’ve added some “Text” here to say “Buildings”. If we look in the “Middle” section, under “Text” this is where this “value” property is going to be the value of a count or attribute that we want to include in the KPI card.
Really the key step here is we’re going to want to click on “Statistic” in the “Value” field and we’re going to click “Sum”. You’ll notice here the Object ID field isn’t being listed in here under “Field”, and that’s the output field that we’ve configured in the Out Statistics. So, let’s go to “Advanced Mode” and then just update it to say “OBJECTID”.
So, we’re now doing a sum and we’re getting the Object ID. Now if we zoom in and out, we now have some KPI cards that are nicely configured that are very fast. It’s not really taxing our ArcGIS server too hard and they’re including some counts based on the features within the given extent.
I hope you found that valuable and be sure to reach out if you have any questions. Bye for now!
Want to learn more about the capabilities of Geocortex Web? Click the button below for more information on what is possible with Geocortex Web.