I have seen this question and have tried the code suggested: Adapting ESRI ArcGIS API for JavaScript Feature Layer With Selection sample for use in Configurable Map Viewer (CMV)
But I have been unable to get it to work. I also want to change the result from the sum to the average.
Here is my error report from chrome development tools
Answer
For your first issue: it appears that the template file for your widget is missing, inaccessible or corrupt. Based on the code posted in the linked example, the template file is './Select/templates/Select.html'
. Check that file to ensure it is valid.
For your second issue: to do a simple average, you would take the sum calculated in the example code this.productionSum
and divide by the number of features event.features.length
. Something like:
this.productionAVG = (this.productionSum / event.features.length)
Be sure to handle a possible divide by zero error in the cases where no features are returned by the selection.
No comments:
Post a Comment