Select to view content in your preferred language

Display a line chart in the popup window for aggregated representation ( Binning )

516
3
05-23-2023 02:53 AM
GIS_test
New Contributor II

Hello everyone, In the following example, we will discuss aggregated representation :

https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-binning/

Suppose we have a Date field in our initial layer. Is it possible to have a histogram displayed when we click on a rectangle, showing the monthly evolution?

Thanks for your help.

Tags (3)
0 Kudos
3 Replies
KristianEkenes
Esri Regular Contributor

Yes. This is possible. You need to query the features within the bin and create a column chart representing however you partition the data. This sample demonstrates how to query features inside a bin using Arcade: https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-binning-arcade-summary/ 

In the popup, click one of the arrows next to the pie chart to see a similar visualization using a line chart. This chart displays the number of crimes that occurred in each month within the bin.

KristianEkenes_0-1684860678478.png

This blog also steps you through the process: https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/how-to-summarize-aggregate-data-usin... 

0 Kudos
GIS_test
New Contributor II

Hello @KristianEkenes ,
Thank you for your response. I tried to follow the same methodology, particularly to retrieve the data reported in January with the code below, but it gives me an error. Do you have any idea where the problem might come from?

 

 {
                  type: "expression",
                  // lists the top 5 most common fuel types in the bin
                  expressionInfo: {
                  expression: `
                    Expects($aggregatedFeatures, "DATE_HEURE")
                    var monthStats = Count(Filter($aggregatedFeatures, "DATE_HEURE > Date(2023-05-01)" ))
                    return {
                    type: "text",
                    text : monthStats
                  }
                  `
                  }},
0 Kudos
KristianEkenes
Esri Regular Contributor

Yeah, I see the issue, but it's a bit of a confusing one... It's in the where clause of the Filter function. That where statement is a SQL where, and doesn't allow Arcade functions. So this bit: 

"DATE_HEURE > Date(2023-05-01)"

Needs to change to:

"DATE_HEURE > '2023-05-01'"

 

Then it should work...

Here's an example: https://codepen.io/kekenes/pen/NWOJapJ?editors=100 

 

0 Kudos