Created
October 21, 2015 07:08
-
-
Save philrenaud/8b7ff0c5f9280ebfcd2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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