[ Launch: tremulous OthoC1 table - tremor only ! and : ] 2762dec4105714dda6df by enjalot
[ Launch: tremulous OthoC1 counts ] 9b516c122192051be4b5 by enjalot
[ Launch: tremulous data ] 9352d58a979286955897 by enjalot
[ Launch: tremulous data ] 0823d99a670acfa3fb3e by enjalot
-
-
Save enjalot/2762dec4105714dda6df to your computer and use it in GitHub Desktop.
tremulous OthoC1 table - tremor only ! and :
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
{"description":"tremulous OthoC1 table - tremor only ! and :","endpoint":"","display":"div","public":true,"require":[{"name":"crossfilter.js","url":"http://square.github.io/crossfilter/crossfilter.v1.min.js"}],"fileconfigs":{"inlet.js":{"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,"ajax-caching":true,"thumbnail":"http://i.imgur.com/YOL6vOV.png"} |
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.json("https://s3.amazonaws.com/medieval/tremor/OthoC1/folios.json", function(err, folios) { | |
d3.json("https://s3.amazonaws.com/medieval/tremor/OthoC1/marks.json?", function(err, marks) { | |
var cwidth = 80; | |
var cheight = 120; | |
var folioArray = []; | |
for(key in folios) { | |
folioArray.push(folios[key]) | |
} | |
folioArray.sort(function(a,b) { | |
if(a.index === b.index) { | |
if(a.side === 'r') return -1; | |
return 1 | |
} | |
return a.index - b.index | |
}); | |
//console.log("folio", folioArray[0]); | |
var fxscale = d3.scale.linear() | |
.domain([0, 980]) | |
.range([0, 80]) | |
var fyscale = d3.scale.linear() | |
.domain([0, 1500]) | |
.range([0, 120]) | |
var nested = d3.nest() | |
.key(function(d) { return d.folioId }) | |
.key(function(d) { return d.author }) | |
.rollup(function(leaves) { return { count: leaves.length, marks: leaves } }) | |
.entries(marks) | |
//console.log("nested", nested[0]); | |
var display = d3.select("#display"); | |
var table = display.append("table") | |
var rows = table.selectAll("tr") | |
.data(folioArray, function(f) { return f.id}) | |
.enter().append("tr") | |
.attr("id", function(d) { return "tr-" + d.id }) | |
var desc = rows.append("td").classed("description", true) | |
var counttd = rows.append("td").classed("count", true) | |
rows.append("td").attr("id", function(d) { return "folio-" + d.id }) | |
/* | |
var fdivs = display.selectAll("div.folio") | |
.data(folioArray, function(f) { return f.id}) | |
.enter().append("div").classed("folio", true) | |
.attr("id", function(d) { return "folio-" + d.id }) | |
*/ | |
//var text = fdivs.append("div").classed("description", true) | |
var counts = {} | |
nested.forEach(function(f) { | |
var id = "#folio-" + f.key; | |
var div = display.select(id) | |
if(f.values[0].key == "original") { | |
var original = f.values[0]; | |
var tremor = f.values[1]; | |
} else { | |
var original = f.values[1]; | |
var tremor = f.values[0]; | |
} | |
counts[f.key] = {}; | |
if(tremor) { | |
var count = tremor.values.count; | |
counts[f.key].tremor = count; | |
var marks = tremor.values.marks; | |
//ctx.fillStyle = "rgba(253, 0, 0, 1)"; | |
//preprocess the marks | |
marks.forEach(function(m) { | |
if(m.certainty < 20 && m.value === "!") { | |
m.certainty = 100; | |
m.value = ":" | |
} | |
}) | |
marks.sort(function(a,b) { | |
return a.y - b.y; | |
}) | |
marks.forEach(function(m) { | |
if(!(m.value === "!" || m.value === ":")) return; | |
div.append("span").classed("mark", true).classed("tremor", true) | |
.datum(m) | |
.text(m.value) | |
.style("background-color", "rgba(255, 255, 125, " + (m.certainty/100) + ")") | |
.on("click", function(d) { console.log("d", d) }); | |
}) | |
} | |
/* | |
if(original) { | |
var count = original.values.count; | |
var marks = original.values.marks; | |
marks.forEach(function(m) { | |
div.append("span").classed("mark", true).classed("original", true) | |
.text(m.value); | |
}) | |
}*/ | |
}); | |
desc.text(function(f) { | |
return f.index + f.side; | |
/* | |
var str = "(" + f.index + f.side + " - " | |
if(counts[f.id]) | |
str += counts[f.id].tremor + ")"; | |
return str; | |
*/ | |
}) | |
counttd.text(function(f) { | |
if(counts[f.id]) | |
return counts[f.id].tremor; | |
return 0; | |
}) | |
}); | |
}); |
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
#display { | |
overflow: scroll; | |
font-family: Courier; | |
background-color: #262626; | |
} | |
.folio { | |
width: 100%; | |
overflow-x: scroll; | |
display: inline-block; | |
margin: 1px; | |
padding: 0; | |
} | |
.mark { | |
display: inline-block; | |
padding: 1px; | |
margin: 1px; | |
font-size: 10px; | |
width: 12px; | |
} | |
.tremor { | |
border-bottom: 2px solid #000; | |
} | |
.original { | |
background-color: #25736d; | |
color: white; | |
} | |
.description { | |
font-size: 14px; | |
color: white; | |
text-align: left; | |
display: inline-block; | |
padding-right: 5px; | |
padding-left: 5px; | |
} | |
.count { | |
font-size: 14px; | |
color: white; | |
text-align: left; | |
display: inline-block; | |
padding-right: 5px; | |
padding-left: 5px; | |
} | |
.folio canvas { | |
width: 80px; | |
height: 120px; | |
} | |
td { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment