Skip to content

Instantly share code, notes, and snippets.

@sfrdmn
sfrdmn / gist:1217377
Created September 14, 2011 18:35
DAI 523 - Pino vs. Godzilla
var title = document.getElementById("title");
title.parentNode.removeChild(title);
function square( x ) {
return x * x;
}
pino.buildWall = function( n ) {
var wall = document.getElementById("wall");
var i = 0;
@sfrdmn
sfrdmn / gist:1227510
Created September 19, 2011 20:25
SVG Skeleton
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1"
baseProfile="full"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events">
<!-- ENTER YER STUFF HERE. DELETE THIS LINE -->
</svg>
@sfrdmn
sfrdmn / gist:1227514
Created September 19, 2011 20:27
DAI 523 - SVG Examples
<!-- DELETE ME -->
@sfrdmn
sfrdmn / gist:1233255
Created September 21, 2011 20:48
DAI 523 - 9/21 - Modify SVG
// The following line selects all circles on the page and changes their stroke-width to 10 (px)
d3.selectAll("circle").attr("stroke-width", 10)
// Two slashes means "comment". Commented code is not run.
// It is good to comment your code so you remember what's going on.
// d3.selectAll("circle").attr("fill", "blue");
// The following lines deal with making selections and then sub selections within those selections
d3.selectAll("circle").attr("stroke-width", 10);
d3.select("#blue").selectAll("circle").attr("stroke","rgb(34,56,35)");
@sfrdmn
sfrdmn / gist:1233257
Created September 21, 2011 20:48
DAI523 - D3 - Binding data and creating graphs
d3.select("body").append("svg:svg").attr("width", 3000).attr("height",500);
var chart = d3.select("svg");
var fill = d3.scale.category20();
d3.json("data/dataset1.json", function(json) {
var size = function(d,i) {
return d.size;
}
@sfrdmn
sfrdmn / gist:1249346
Created September 28, 2011 21:46
DAI523 - Bubble Chart Skeleton
/*
Yo doods. This code creates a bubble chart. It's unfinished, so you gotta finish it.
Use the comments I left to figure things out. Comments are specified by two slashes //
Multiple line comments begin with /asterix and end with asterix/
Commented code does not run.
;\
|' \
_ ; : ;
/ `-. /: : |
@sfrdmn
sfrdmn / gist:1263780
Created October 5, 2011 06:17
DAI 523 - Bubble Chart Skeleton Round 2
/*
Hey. We're going to continue with this bubble chart we were working on last class.
Here is some motivational ASCII.
,. _~-., . YOU'RE BEAUTIFUL!
~'`_ \/,_. \_
/ ,"_>@`,__`~.) | .
| | @@@@' ",! . . '
|/ ^^@ .! \ | /
@sfrdmn
sfrdmn / gist:1282451
Created October 12, 2011 20:33
DAI 523 - Bar Chart 10/12
// If you rename your script, don't forget to change the <script> tag in the HTML file!!!
var w = 800; // width
var h = 600; // height
var marginT = 20;
var marginL = 20;
/*
First append SVG to the body
*/
@sfrdmn
sfrdmn / data.csv
Created October 17, 2011 16:44
DAI 523 - Bar Chart Cont. 10/17
label area
ca 23
ma 456
ne 567
ba 345
ya 34
na 21
@sfrdmn
sfrdmn / data.csv
Created October 19, 2011 20:14
DAI 523 - Even More Bar Chart 10/19
label area
max 23
jenny 456
lenny 567
mark 345
angel 34
aurelio 21