Skip to content

Commit

Permalink
choropleth: Update the undetermined counting mechanism
Browse files Browse the repository at this point in the history
Now that there is a location value called "undetermined" we need to use
that rather than calculating it from the total grants vs the total
grants on the map.
  • Loading branch information
michaelwood committed Jul 3, 2024
1 parent 8b12fa1 commit adcfa86
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions insights/static/js/components/choropleth.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,22 @@ export const choropleth = {
return layerData;
},
updateTotalNotOnMap(field) {
/* Total not on map = those aggregated under the key 'undertermined' note this is not the norm */
for (let bucket of this.dataAll.aggregations[field].buckets){
if (bucket.key === 'Undetermined'){
this.totalNotOnMap = bucket.doc_count;
break;
}
}

/* selection has happened only count selected */
if (this.currentApiUrl.searchParams.getAll(field).length){
this.totalOnMap = this.dataAll.aggregations[field].buckets.filter((item) => item.selected).reduce((total, item) => total + item.doc_count, 0);
this.totalOnMap = this.dataAll.aggregations[field].buckets.filter((item) => item.selected).reduce((total, item) => total + item.doc_count, 0) - this.totalNotOnMap;
} else {
this.totalOnMap = this.dataAll.aggregations[field].buckets.reduce((total, item) => total + item.doc_count, 0);
this.totalOnMap = this.dataAll.aggregations[field].buckets.reduce((total, item) => total + item.doc_count, 0) - this.totalNotOnMap;
}
this.totalNotOnMap = this.dataAll.hits.total.value - this.totalOnMap;


},
updateMap() {

Expand Down

0 comments on commit adcfa86

Please sign in to comment.