Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created October 23, 2013 18:07
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 enjalot/7123619 to your computer and use it in GitHub Desktop.
Save enjalot/7123619 to your computer and use it in GitHub Desktop.
html5devconf starter
{"description":"html5devconf starter","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"survey.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/4R4ZMtU.png"}
//this is using data from twitter survey
//http://bit.ly/advd3presurvey
var results = tributary.survey;
results.forEach(function(d) {
d.evil = +d.evil;
d.passion = +d.passion;
d.age = +d.age || 0;
d.exp = +d.exp;
d.oj = d.oj.replace(/ /g, '-');
d.toothpaste = d.toothpaste.replace(/ /g, '-');
d.time = new Date(d.time);
})
//console.log(results);
var qmap = {
time: {q: "Timestamp"},
pb: {q: "What type of peanut butter do you prefer?", a: ["Crunchy", "Smooth"]},
toothpaste: {q:"Where do you squeeze the toothpaste from?", a: ["Top-of-the-tube", "Bottom-of-the-tube"]},
cv: {q:"Vanilla or Chocolate?", a: ["Chocolate", "Vanilla"]},
tp: {q:"What direction does toilet paper go on the holder thingy?", a: ["Over", "Under"]},
oj: {q:"Do you prefer pulp or no pulp in your orange juice?", a: ["Pulp", "No-pulp"]},
evil: {q:"Where do you sit on the good vs. evil scale?"},
age: {q:"How old are you?"},
passion: {q:"How passionate of a person are you?"},
exp: {q:"How many years have you been building for the web?"}
}
//time,pb,toothpaste,cv,tp,oj,evil,passion,exp,age
var questions = [
"pb", "toothpaste", "cv", "tp", "oj"
]
var field = questions[4]
results.sort(function(a,b) {
return b[field] < a[field] ? 1 : -1
})
var colorScale = d3.scale.ordinal()
.domain(qmap[field].a)
.range(["#fff", "#000"])
var display = d3.select("#display")
var ppl = display.selectAll("div.person")
.data(results)
ppl.enter()
.append("div").classed("person", true)
ppl.style({
width: "20px",
height: "20px",
float: "left",
margin: "10px 2px",
"background-color": function(d,i) {
return colorScale(d[field])
}
})
ppl.on("click", function(d,i) {
console.log("data", d, i);
})
var legend = display.append("div").classed("legend", true)
legend.append("span").text(qmap[field].q)
var answers = legend.append("div")
answers.append("div")
.style({
width: "100%",
height: "20px",
float: "left",
margin: "10px 2px",
"background-color": function(d,i) {
return colorScale(qmap[field].a[0])
}
})
.append("span").text(qmap[field].a[0])
answers.append("div")
.style({
width: "100%",
height: "20px",
float: "left",
margin: "10px 2px",
"background-color": function(d,i) {
return colorScale(qmap[field].a[1])
}
})
.append("span").text(qmap[field].a[1])
.style("color", "white")
.legend {
float:left;
clear:left;
}
time pb toothpaste cv tp oj evil passion exp age
10/22/2013 21:20:17 Smooth Top Vanilla Over Pulp 1 7 10 28
10/22/2013 21:28:01 Smooth Top Chocolate Over No pulp 4 4 5 20
10/23/2013 10:31:36 Smooth Bottom Vanilla Over No pulp 2 3 10 39
10/23/2013 10:35:52 Smooth Bottom Chocolate Over Pulp 3 2 8 29
10/23/2013 10:36:33 Crunchy Top Chocolate Over Pulp 3 6 2 31
10/23/2013 10:36:33 Crunchy Bottom Chocolate Over Pulp 1 7 15 34
10/23/2013 10:36:39 Crunchy Top Chocolate Over Pulp 4 3 1 27
10/23/2013 10:36:39 Crunchy Bottom Vanilla Over Pulp 2 6 2 36
10/23/2013 10:36:43 Smooth Bottom Vanilla Over Pulp 3 3 5 23
10/23/2013 10:36:51 Smooth Bottom Vanilla Over Pulp 9 1 0 22
10/23/2013 10:36:54 Crunchy Bottom Vanilla Over Pulp 3 3 16 36
10/23/2013 10:36:55 Crunchy Bottom Chocolate Over Pulp 7 8 10 30
10/23/2013 10:37:02 Smooth Bottom Chocolate Over Pulp 10 4 15 29
10/23/2013 10:37:16 Crunchy Bottom Vanilla Over Pulp 3 5 5 35
10/23/2013 10:37:17 Smooth Bottom Vanilla Over No pulp 1 1 15 39
10/23/2013 10:37:18 Crunchy Top Chocolate Over Pulp 3 3 13 32
10/23/2013 10:37:23 Smooth Bottom Chocolate Over Pulp 2 3 16 43
10/23/2013 10:37:23 Crunchy Top Chocolate Over Pulp 4 4 5 25
10/23/2013 10:37:28 Crunchy Bottom Vanilla Over No pulp 4 3 13 28
10/23/2013 10:37:29 Smooth Bottom Chocolate Over Pulp 3 3 3 24
10/23/2013 10:37:31 Crunchy Bottom Chocolate Over Pulp 7 5 15 38
10/23/2013 10:37:38 Smooth Bottom Chocolate Over Pulp 8 6 9 37
10/23/2013 10:37:38 Crunchy Bottom Chocolate Over Pulp 4 3 4 24
10/23/2013 10:37:38 Crunchy Bottom Vanilla Over No pulp 4 5 11 26
10/23/2013 10:37:41 Smooth Top Chocolate Over Pulp 3 1 5 26
10/23/2013 10:37:44 Crunchy Bottom Chocolate Over Pulp 5 6 10 34
10/23/2013 10:37:55 Crunchy Top Chocolate Over Pulp 3 2 10 27
10/23/2013 10:38:00 Smooth Bottom Chocolate Over No pulp 3 2 8 37
10/23/2013 10:38:13 Smooth Bottom Chocolate Over Pulp 1 2 13 27
10/23/2013 10:38:16 Crunchy Bottom Vanilla Under No pulp 3 3 12 40
10/23/2013 10:38:19 Crunchy Bottom Vanilla Over No pulp 5 3 12 29
10/23/2013 10:38:21 Crunchy Top Vanilla Over Pulp 3 3 0 32
10/23/2013 10:38:30 Smooth Bottom Vanilla Over Pulp 2 1 15 23
10/23/2013 10:38:34 Crunchy Top Chocolate Over Pulp 1 8 10 50
10/23/2013 10:38:42 Crunchy Bottom Chocolate Over Pulp 3 4 5 45
10/23/2013 10:38:55 Crunchy Bottom Vanilla Over Pulp 6 5 3 30
10/23/2013 10:39:14 Smooth Bottom Vanilla Over No pulp 6 7 6 35
10/23/2013 10:39:15 Crunchy Top Chocolate Over Pulp 3 2 20 53
10/23/2013 10:39:18 Crunchy Bottom Chocolate Over Pulp 1 1 1 22
10/23/2013 10:39:30 Crunchy Top Vanilla Over Pulp 3 6 1 22
10/23/2013 10:39:44 Crunchy Bottom Chocolate Over Pulp 2 5 18 42
10/23/2013 10:39:46 Smooth Bottom Chocolate Over No pulp 7 1 1 36
10/23/2013 10:39:51 Crunchy Bottom Vanilla Over Pulp 1 1 20 63
10/23/2013 10:39:55 Smooth Bottom Vanilla Over No pulp 3 3 2 24
10/23/2013 10:39:55 Smooth Top Chocolate Over No pulp 3 6 4 26
10/23/2013 10:39:56 Smooth Bottom Chocolate Under Pulp 8 1 15 34
10/23/2013 10:40:07 Crunchy Bottom Chocolate Over Pulp 3 4 15 42
10/23/2013 10:40:23 Crunchy Bottom Vanilla Over No pulp 8 3 6 32
10/23/2013 10:40:24 Crunchy Bottom Chocolate Over Pulp 1 5 10
10/23/2013 10:40:24 Smooth Top Chocolate Over No pulp 3 3 10
10/23/2013 10:40:25 Crunchy Top Chocolate Over Pulp 5 1 12 35
10/23/2013 10:40:25 Crunchy Top Chocolate Under No pulp 5 1 10 40
10/23/2013 10:40:28 Smooth Top Vanilla Over No pulp 7 2 9 27
10/23/2013 10:40:41 Smooth Top Vanilla Over Pulp 3 4 7 22
10/23/2013 10:41:30 Smooth Bottom Vanilla Over Pulp 4 6 4 43
10/23/2013 10:42:58 Smooth Bottom Vanilla Over No pulp 2 6 13
10/23/2013 10:43:30 Smooth Top Chocolate Over Pulp 7 2 5 47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment