Skip to content

Instantly share code, notes, and snippets.

@philrenaud
Created October 21, 2015 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philrenaud/8b7ff0c5f9280ebfcd2b to your computer and use it in GitHub Desktop.
Save philrenaud/8b7ff0c5f9280ebfcd2b to your computer and use it in GitHub Desktop.
var column = $('#teams_standard_batting td:nth-child(13)')
max = _.max(column.map(function(){ return parseFloat($(this).text()) }))
min = _.min(column.map(function(){ return parseFloat($(this).text()) }))
barwidth = 250
column.map(function(iter,cell){
$(cell).prepend('<div class="bar"></div>');
$(cell).children('.bar').css('width', parseFloat($(cell).text()) / max * barwidth )
var color = d3.scale.linear()
.domain([min, max])
.range(["#c33", "#0fc"]);
$(cell).children('.bar').css('background-color', color(parseFloat($(cell).text())))
})
$(column).css('text-align', 'left')
$('.bar').css('height', '10px').css('float', 'left')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment