Skip to content

Instantly share code, notes, and snippets.

@ashaw
Created January 14, 2011 17:17
Show Gist options
  • Save ashaw/779904 to your computer and use it in GitHub Desktop.
Save ashaw/779904 to your computer and use it in GitHub Desktop.
makePctGraphs : function(stat) {
var el,stat_ary,max,pct_ary;
el = "tr." + stat + "_row td .county_stat_fig";
stat_ary = _(this.$(el)).map(function(q) {
return Number($(q).attr("data-stat-val").replace(/[\$,]/g,'').replace(/(\.(.+)?)?$/,''));
});
max = _(stat_ary).max();
pct_ary = _(stat_ary).map(function(q) {
return Number(((q / max) * 100).toFixed(2));
});
var i;
for (i = 0; i < pct_ary.length; i++) {
$($("tr." + stat + "_row td .county_stat_graf_inner")[i])
.css("height", pct_ary[i] + "%")
.css("top", 100 - pct_ary[i] + "%");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment