Public
Edited
Oct 2, 2023
Insert cell
# 2023 fall studio 9/7 - fleet's version
Insert cell
Co2Capita = 16.28
Insert cell
Co2Factor = 0.01803491773
Insert cell
SF = 0
Insert cell
ResidentialSF = 0
Insert cell
NumOfHousehold = 0
Insert cell
StandardManPop = 1.86
Insert cell
GHG = SF * Co2Factor
Insert cell
{var HouseholdSF;
}
Insert cell
//Household SF base condition

{
var HouseholdSF;
if(NumOfHousehold === 0){
HouseholdSF = ResidentialSF / StandardManPop
} else{
HouseholdSF = ResidentialSF / NumOfHousehold
}
var HouseholdGHG = HouseholdSF * Co2Factor
var NewCapita = HouseholdGHG / Pop
Insert cell
//Slider Value Switch
{
var Rating;
let NewCapita = 'Neutral'
if (NewCapita > Co2Capita){
Rating = 'BAD'
} else if (NewCapita = Co2Capita){
Rating = "Neutral"
} else{
Rating = 'Good'
}
}
Insert cell
co2Calc = {

var totalCo2SF = 0
var totalOccupants = 0
//Per capita = 16.28
//Average SF = 0.01803491C773
// Pop=# of People
// Co2Capita = 16.28
// SF = SF
// Co2SF=(ocMult*16.28)/SF
// Co2SF-Factor = 0.01803491773
// HouseholdSF = TotalResidentialSF / NumOfHouseholds
// GHG = Co2SF_Factor * HouseholdSF
// NewCapita = GHG/Slider
// If New Capita > Co2Capita then ('Bad')
// If not ('Good')
//do some calc and rtrn value
for (let i = 0; i < outlines.length; ++i) {

var alteredOcc = Math.round(outlines[i].occ * Pop) // multiplying occ of each bldg by occupancy

//totalCo2 = totalCo2 + outlines[i].co2
totalCo2SF = totalCo2SF + outlines[i].sf/outlines[i].occ
var totalOccupants = totalOccupants+alteredOcc

}
return [Math.round(totalOccupants),Math.round(totalCo2SF)]
}
Insert cell
Pop
Insert cell
viewof Pop = Inputs.range([0, 10], {value: 1, step: 0.01, label: "Population"})
Insert cell
chart = {
const width = 1200,
height = 810;
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","black")//style
.style("stroke-width","1px")
.style("fill","gray")
.on("mouseover",polyHover)
.on("mouseout",polyHoverOut)

function polyHover(event,d){
//console.log("hello studious students")
d3.select(this).style("fill","purple")
svg
.append("text")
.attr("x","100")
.attr("y","100")
.attr("class","hoverText")
.text(d.sf)

svg
.append("text")
.attr("x","100")
.attr("y","115")
.attr("class","hoverText")
.text(d.occ)
.text("I love CASE 😀")

}
p.enter().append("polyline") //after we draw our first polyline, use this line
.data(cobble_hill_win)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","white")//style
.style("stroke-width",".7px")
.style("fill","gray")
p.enter().append("polyline") //after we draw our first polyline, use this line
.data(detailline)
.enter() //there are more data than elements, this selects them
.append("polyline") //appends path to data
.attr("points", function(d) {return d})//required attributes
.style("stroke","black")//style
.style("stroke-width","1px")
.style("fill","white")

function polyHoverOut(){
d3.select(this).style("fill","gray")
svg.selectAll("text.hoverText").remove()

}

return svg.node();
}
Insert cell
outlines = {

var list = cobble_hill_energy_buildings
var spreadsheet = buildingList
var cleanLines = []
for (let i = 0; i < list.length-1; i=i+2) {
var id = list[i+1][0]
var Floors
var Residental
var Units
var SF
for (let k = 0; k < spreadsheet.length; k++) {
if(id==spreadsheet[k].Address){
//console.log("match!!!!!!!")
Floors = spreadsheet[k].Floors
Residental = spreadsheet[k].Residental
Units = spreadsheet[k].Units
SF = spreadsheet[k].SF
}
}
cleanLines.push({pts:list[i],id:id, Floors:Floors, Residental:Residental, Units:Units,SF:SF})//add features to our final list of objects
}


return cleanLines
}
Insert cell
cobble_hill_energy_buildings = FileAttachment("Cobble_Hill_Energy_buildings.txt").tsv({array:true})
Insert cell
cobble_hill_map_iii = FileAttachment("cobble_hill_map_III.txt").tsv({array:true})
Insert cell
Insert cell
buildingList = d3.csv(buildingList_link,d3.autoType)
Insert cell
detailline = FileAttachment("detailline.txt").tsv({array:true})
Insert cell
cobble_hill_win = FileAttachment("cobble_hill_win.txt").tsv({array:true})
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