Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Renaud philrenaud

View GitHub Profile
View bigDataMunging
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 = [];
View Draw custom color bars
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])
View Columnar heatmap
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())))
View Heatmap rows with d3 and map
$('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,'')))
})
})
View Find the lowest yearly-total
lowVal = _.min(
$('tr:last-child td'), function(obj,iter){
return $(obj).text().replace(/,/g,'')
}
)
$(lowVal).css('background-color','yellow')
@philrenaud
philrenaud / Insert jQuery, Underscore, and D3
Last active Nov 19, 2018
Import a few necessary packages into your browser's instance of any webpage
View Insert jQuery, Underscore, and D3
// 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';
@philrenaud
philrenaud / vis.js
Last active Aug 29, 2015
D3 Network Vis example for Acadia
View vis.js
/*=====================
phil@affin.io
November 2014
=====================*/
$(document).ready(function(){
console.log('document ready');
$('body').addClass('mobile'); //assume mobile! mobile first, yo.
View Collide - Tw Scraping
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)
You can’t perform that action at this time.