Public
Edited
Sep 11, 2023
Insert cell
# 2023 fall studio 9/7
Insert cell
etCurves = FileAttachment("buildings_manhattan.txt").tsv({array:true})
Insert cell
chart = {
const width = 1500,
height = 1500;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
var g = svg.append("g").attr("id", "paths");

var p = svg.selectAll("polyline") //d3 geopath
.data(outlines)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d.pts})//required attributes
.style("stroke","orange")//style
.style("stroke-width","3px")
.style("fill","yellow")
.on("mouseover",polyHover)
.on("mouseout",polyHoverout)

function polyHover(event,d){
//console.log("hello studious students")
d3.select(this).style("fill","purple")
d3.select(this).style("stroke","blue")
svg
.append("text")
.attr("x","100")
.attr("y","100")
.text("I love CASE")
}
function polyHoverout(){
d3.select(this).style("fill","yellow")
d3.select(this).style("stroke","orange")
svg.SelectAll("text.hoverText").remove()

}

return svg.node()
}
Insert cell
Insert cell
Insert cell
st3 = FileAttachment("square_test3.txt").tsv({array:true})
Insert cell
square_test = FileAttachment("square_test.txt").tsv({array:true})
Insert cell
outlines = {

var list = etCurves
var spreadsheet = buildinglist
var cleanLines = []
for (let i = 0; i < list.length-1; i=i+2) {
var id = list[i+1][0]
var idNum = Number(id)

var build
var occupancy
var materials

for (let k = 0; k < spreadsheet.length; k++) {
if(idNum==spreadsheet[k].address){
//console.log("match!")
build = spreadsheet[k].building
occupancy = spreadsheet[k].occ
materials = spreadsheet[k].material
}
}
//cleanLines.push({pts:st3[i],id:st3[i+1][0]})
cleanLines.push({pts:list[i],id:idNum,building:build,occ:occupancy,mat:materials})
}


return cleanLines
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more