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
// add jquery: | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'; | |
document.head.appendChild(script); | |
// add underscore: | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js'; |
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
d3.csv("https://raw.githubusercontent.com/philrenaud/smu-lesson-2/master/SeriesPost.csv", function(data) { | |
console.log('data acquired from .csv online:'); | |
console.log(data); | |
bigData = data; | |
}); //d3.csv | |
myCustomArray = []; |
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
lowVal = _.min( | |
$('tr:last-child td'), function(obj,iter){ | |
return $(obj).text().replace(/,/g,'') | |
} | |
) | |
$(lowVal).css('background-color','yellow') |
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]) |
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(19)') | |
max = _.max(column.map(function(){ return parseFloat($(this).text()) })) | |
min = _.min(column.map(function(){ return parseFloat($(this).text()) })) | |
var color = d3.scale.linear() | |
.domain([min, max]) | |
.range(["#c33", "#0fc"]); | |
column.map(function(iter,cell){ | |
return $(cell).css('background-color', color(parseFloat($(cell).text()))) |
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
$('tr').map(function(iter,row){ | |
var max = _.max($(row).children('td').map(function(iter,cell){ return $(cell).text().replace(/,/g,'') })) | |
var min = _.min($(row).children('td').map(function(iter,cell){ return $(cell).text().replace(/,/g,'') })) | |
var color = d3.scale.linear() | |
.domain([min, max]) | |
.range(["#c33", "#0fc"]); | |
$(this).children('td').map(function(iter,cell){ | |
$(cell).css('background-color', color($(cell).text().replace(/,/g,''))) | |
}) | |
}) |
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
/*===================== | |
phil@affin.io | |
November 2014 | |
=====================*/ | |
$(document).ready(function(){ | |
console.log('document ready'); | |
$('body').addClass('mobile'); //assume mobile! mobile first, yo. |
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
from bs4 import BeautifulSoup | |
import urllib2 | |
import json | |
import logging | |
logger = logging.getLogger() | |
logger.setLevel(logging.DEBUG) | |
with open('folks.json', 'r') as f: | |
folks = json.load(f) |