Binning - basic configuration

493
5
Jump to solution
04-13-2023 01:12 AM
GIS_test
New Contributor II

Hello everyone,

I was working on the following example while adding some additional features:

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

My question: Is there a way to retrieve via the API the minimum and maximum of all the aggregations found on the map?

Thank you in advance for your answer.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
KristianEkenes
Esri Regular Contributor

Yes. You can use those values in your stops. You first have to initialize binning then query the bins before creating the stops for the renderer. You can do this on your own using the summaryStatistics method, or you can use the smart mapping renderer creators to generate the stops for you based on the statistics.

https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-renderers-color.html

It's the same parameters, but instead of outputting stats, it outputs a renderer.

View solution in original post

5 Replies
KristianEkenes
Esri Regular Contributor

Yes. You can do this with the smartMapping statistic functions. In this case you need summaryStatistics. You can also get a histogram and unique values with count if needed. You just need to be sure to set the forBinning parameter to true.

 

 

const stats = await summaryStatistics({
  layer,
  view,
  field: "aggregateCount",
  forBinning: true
});

 

 

Here's a codepen that demonstrates how to do it for the basic configuration sample you posted: https://codepen.io/kekenes/pen/bGmEvWj?editors=1000 Let me know if you run into issues.

GIS_test
New Contributor II

@KristianEkenes Thank you Kristian, it works, I am able to retrieve these values. However, the initial idea was to be able to put them in the Stops as values.

0 Kudos
KristianEkenes
Esri Regular Contributor

Yes. You can use those values in your stops. You first have to initialize binning then query the bins before creating the stops for the renderer. You can do this on your own using the summaryStatistics method, or you can use the smart mapping renderer creators to generate the stops for you based on the statistics.

https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-renderers-color.html

It's the same parameters, but instead of outputting stats, it outputs a renderer.

GIS_test
New Contributor II

It worked well. Thank you Kristian.

0 Kudos
GIS_test
New Contributor II

@KristianEkenes  Can we apply the function that allows us to browse the entities, which is present in the following example :


https://developers.arcgis.com/javascript/latest/visualization/high-density-data/aggregation/

I tried, but the issue is that the number of aggregations is not consistent with what can be browsed in the POPUP.

Thank you for your help.

0 Kudos