Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
whitehouse/choropleth:WhiteHouse#2: Add an option to set the desired …
Browse files Browse the repository at this point in the history
…behaviour whan a search returns multiple rows
  • Loading branch information
teosibileau committed May 26, 2014
1 parent 71ff37b commit 26128b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions static/recline.view.ChoroplethMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ this.recline.View = this.recline.View || {};
// Property to hold Geographic bounds (if given).
this.bounds = options.bounds ? options.bounds : null;

// Property to set how to handle multiple row instances.
this.avg = options.avg ? options.avg : true;

// Breakpoints and color scale.
this.breakpoints = options.breakpoints ? options.breakpoints : [];
this.breakpoints = this.breakpoints.length > 0 ? this._validateBreakpoints(this.breakpoints) : [];
Expand Down Expand Up @@ -397,7 +400,9 @@ this.recline.View = this.recline.View || {};
n++;
}
});

if (n) {
n = self.avg ? n : 1;
d = sum/n;
}

Expand Down Expand Up @@ -524,6 +529,7 @@ this.recline.View = this.recline.View || {};
v += self._preparePercentage(value[field_index]);
});
if (n > 0) {
n = self.avg ? n : 1;
v = parseInt(v / n, 10);
}

Expand Down

0 comments on commit 26128b8

Please sign in to comment.