Public
Edited
Mar 27, 2024
1 fork
Insert cell
# base map - UD Spring 2024 - Troy 3/27
Insert cell
d3 = require("d3@6")
Insert cell
mutable wallet = 100
Insert cell
Insert cell
historyData = {

var array = []

//add restaurants and menu items to array

array.push({name:"National State Bank Building",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"McCarthy Building",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Llium Building",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Church of the Holy Cross",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Chapel and Cultural Center",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Winslow Chemical Lab",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Theta Xi",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Troy Savings Bank and Music Hall",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Proctor's Theater",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"W. & L.E. Gurley Building",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Hart-Cluett House",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Troy Public Library",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Pumpkin House",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Public School No. 10",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"St. Paul's Episcopal Church",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"U.S Post Office",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"RSE",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
array.push({name:"Fire Alarm, Telegraph, and Police Signaling Building",clue:[{hours:"1",scare:'30'},{hours:"2",scare:'40'},{hours:"3",scare:'60'}]})
return array
}
Insert cell
bbox = FileAttachment("boxerererer.geojson").json()
Insert cell
streets = FileAttachment("Streets.geojson").json()
Insert cell
bldgs = FileAttachment("aa RensBuildingFP.geojson").json()
Insert cell
traffic = FileAttachment("traffic.geojson").json()
Insert cell
fire = FileAttachment("firre4.geojson").json()
Insert cell
mypoints = FileAttachment("troy-historic.geojson").json()
Insert cell
realhistory = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQG8HcXWHsAAw44o2BILgcxKsaDuZx5dlKGLst82ViwY1fb_3X-t6qw0OSYQhdatnHiXJ8stmqsj5ip/pub?gid=0&single=true&output=csv'
Insert cell
mypointsHistory = d3.csv(realhistory,d3.autotype)
Insert cell
haunt = "https://docs.google.com/spreadsheets/d/e/2PACX-1vQG8HcXWHsAAw44o2BILgcxKsaDuZx5dlKGLst82ViwY1fb_3X-t6qw0OSYQhdatnHiXJ8stmqsj5ip/pub?gid=2010654036&single=true&output=csv"
Insert cell
haunted = d3.csv(haunt,d3.autotype)
Insert cell
Insert cell
personal_spots = d3.csv(personal_spots_link,d3.autoType)
Insert cell
import { wrap_text, wrap_text_nchar } from "@ben-tanen/svg-text-and-tspan-word-wrapping"
Insert cell
ghostIconForMap = FileAttachment("ghost icon for map@2.txt").tsv({array:true})
Insert cell
selected = FileAttachment("whenselected@1.txt").tsv({array:true})
Insert cell
icon_list = {

////create empty list
var list = []

//// loop through google sheets list
for (let i = 0; i < haunted.length; i++) {

//function to add items to a list
list.push({data:haunted[i],pts:ghostIconForMap})
}


////return list
return list
}
Insert cell
icon_list2 = {

///create empty list
var list = []

///loop through google sheets list
for (let i = 0; i < mypointsHistory.length; i++) {
//function to add item to a list
list.push({data:mypointsHistory[i],pts:ghostIconForMap})
}
//add icon points to each google sheet item
////addd combined data to empty list


//return new list
return list
}
Insert cell
dashboard = FileAttachment("dashboard@2.txt").tsv({array:true})
Insert cell
dashboard2 = FileAttachment("dashboard 2.txt").tsv({array:true})
Insert cell
dashboard_graphics = {

const width = 1200,
height = 1200;

const svg = d3.create("svg")
.attr("viewBox",[0,500,width,height]);

var p = svg.selectAll("polyline")
.data(dashboard)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points', function(d){return d})
.attr('transform', 'translate(1000,-10000)')
.style("fill-opacity", "0.5")
.style('fill', 'dark grey')
.style('stroke','black')
.style('stroke-width','50')
.style('stroke-fill', '4,4,8,8')
.style("stroke-opacity", "50")

return svg.node();

}
Insert cell
dashboard_graphics2 = {

const width = 1200,
height = 1200;

const svg = d3.create("svg")
.attr("viewBox",[200,1500,width,height]);

var p = svg.selectAll("polyline")
.data(dashboard2)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points', function(d){return d})
.attr('transform', 'translate(1000,-11250)')
.style("fill-opacity", "0.75")
.style('fill', 'white')
.style('stroke','black')
.style('stroke-width','50')
.style('stroke-fill', '4,4,8,8')
.style("stroke-opacity", "50")

return svg.node();

}
Insert cell
dashboard1 =

html`

<div class='dashboardOuter' style='height:1010px;width:1500px'>
<div class='dashboard_graphics' style='position:absolute;width:1000px;top:0px;left:0px'>
${dashboard_graphics}
</div>
<div class='dashboardOuter' style='height:1010px;width:1250px'>
<div class='dashboard_graphics' style='position:absolute;width:1000px;top:0px;left:0px'>
${dashboard_graphics2}
</div>

<div class='dashboardOuter' style='height:1010px;width:1250px'>
<div class='dashboard_graphics' style='position:absolute;width:1000px;top:22px;left:0px'>
${chart}
<div class='inputs' style='position:absolute;width:1500px;top:810px;left:20px'>
${viewof NSBB}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:845px;left:20px'>
${viewof MCCB}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:865px;left:20px'>
${viewof IB}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:890px;left:250px'>
${viewof WLE}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:885px;left:20px'>
${viewof CHC}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:920px;left:20px'>
${viewof CCC}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:905px;left:480px'>
${viewof PO}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:955px;left:20px'>
${viewof WCL}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:810px;left:250px'>
${viewof TX}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:830px;left:250px'>
${viewof BMH}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:865px;left:480px'>
${viewof SPC}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:870px;left:250px'>
${viewof PT}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:810px;left:710px'>
${viewof FA}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:930px;left:480px'>
${viewof RSE}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:930px;left:250px'>
${viewof HCH}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:950px;left:250px'>
${viewof TPL}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:810px;left:480px'>
${viewof PH}
</div>
<div class='inputs' style='position:absolute;width:1500px;top:830px;left:480px'>
${viewof PS}
</div>
<div class='text' style='position:absolute;top:900px;left:710px;font-family:helvetica;font-size:12px'>
${md`Ghost Option 1: **${calculatedValues[0]}** `}
</div>

<div class='star' style='position:absolute;width:200px;top:880px;left:800px'>
${DrawGhostMap}
</div>

<div class='text' style='position:absolute;top:925px;left:710px;font-family:helvetica;font-size:12px'>
${md`Ghost Option 2: **${calculatedValues[1]}** `}
</div>
<div class='star' style='position:absolute;width:200px;top:880px;left:800px'>
${DrawGhostMap}
</div>

<div class='text' style='position:absolute;top:950px;left:710px;font-family:helvetica;font-size:12px'>
${md`Ghost Option 3: **${calculatedValues[2]}** `}
</div>


<div class='star' style='position:absolute;width:200px;top:880px;left:800px'>
${DrawGhostMap}
</div>
</div>
`
Insert cell
DrawGhostMap = {
var icon = ' '
if(calculatedValues[0]>=5) {icon = drawghost}
if(calculatedValues[1]>=4) {icon = drawghost2}
if(calculatedValues[2]>=6) {icon = drawghost3}


return icon
}
Insert cell
viewof NSBB = Inputs.radio(["1"], {label: "National State Bank Building?"})

Insert cell
viewof MCCB = Inputs.radio(["1"], {label: "McCarthy Building?"})
Insert cell
viewof IB = Inputs.radio(["1"], {label: "Ilium Building?"})
Insert cell
viewof WLE = Inputs.radio(["1"], {label: "W. & L.E. Gurley Building?"})
Insert cell
viewof CHC = Inputs.radio(["1"], {label: "Church of the Holy Cross?"})
Insert cell
viewof CCC = Inputs.radio(["1"], {label: "Chapel and Cultural Center?"})
Insert cell
viewof PO = Inputs.radio(["1"], {label: "U.S Post Office?"})
Insert cell
viewof WCL = Inputs.radio(["1"], {label: "Winslow Chemical Lab?"})
Insert cell
viewof TX = Inputs.radio(["1"], {label: "Theta Xi?"})
Insert cell
viewof BMH = Inputs.radio(["1"], {label: "Troy Savings Bank and Music Hall?"})
Insert cell
viewof SPC = Inputs.radio(["1"], {label: "St. Paul's Episcopal Church?"})
Insert cell
viewof PT = Inputs.radio(["1"], {label: "Proctor's Theater?"})
Insert cell
viewof FA = Inputs.radio(["1"], {label: "Fire Alarm, Telegraph, and Police Signaling Building?"})
Insert cell
viewof RSE = Inputs.radio(["1"], {label: "RSE?"})
Insert cell
viewof HCH = Inputs.radio(["1"], {label: "Hart-Cluett House?"})
Insert cell
viewof TPL = Inputs.radio(["1"], {label: "Troy Public Library?"})
Insert cell
viewof PH = Inputs.radio(["1"], {label: "Pumpkin House?"})
Insert cell
viewof PS = Inputs.radio(["1"], {label: "Public School No. 10?"})
Insert cell
HistoricDataset = [
{name:"NSBB",haunt: 1},

]
Insert cell
Haunt1Dataset = [
{name:"NSBB",haunt: 0},
{name:"MCCB",haunt: 0},
{name:"IB",haunt: 1},
{name:"WLE",haunt: 0},
{name:"CHC",haunt: 0},
{name:"CCC",haunt: 0},
{name:"PO",haunt: 0},
{name:"WCL",haunt: 1},
{name:"TX",haunt: 1},
{name:"BMH",haunt: 1},
{name:"SPC",haunt: 0},
{name:"PT",haunt: 0},
{name:"FA",haunt: 0},
{name:"RSE",haunt: 0},
{name:"HCH",haunt: 0},
{name:"TPL",haunt: 0},
{name:"PH",haunt: 1},
{name:"PS",haunt: 0},
]
Insert cell
Haunt2Dataset = [
{name:"NSBB",haunt: 0},
{name:"MCCB",haunt: 0},
{name:"IB",haunt: 0},
{name:"WLE",haunt: 0},
{name:"CHC",haunt: 0},
{name:"CCC",haunt: 0},
{name:"PO",haunt: 0},
{name:"WCL",haunt: 0},
{name:"TX",haunt: 0},
{name:"BMH",haunt: 0},
{name:"SPC",haunt: 1},
{name:"PT",haunt: 1},
{name:"FA",haunt: 0},
{name:"RSE",haunt: 0},
{name:"HCH",haunt: 1},
{name:"TPL",haunt: 0},
{name:"PH",haunt: 0},
{name:"PS",haunt: 1},
]
Insert cell
Haunt3Dataset = [
{name:"NSBB",haunt: 1},
{name:"MCCB",haunt: 0},
{name:"IB",haunt: 0},
{name:"WLE",haunt: 1},
{name:"CHC",haunt: 1},
{name:"CCC",haunt: 0},
{name:"PO",haunt: 1},
{name:"WCL",haunt: 0},
{name:"TX",haunt: 0},
{name:"BMH",haunt: 0},
{name:"SPC",haunt: 0},
{name:"PT",haunt: 0},
{name:"FA",haunt: 0},
{name:"RSE",haunt: 0},
{name:"HCH",haunt: 1},
{name:"TPL",haunt: 1},
{name:"PH",haunt: 0},
{name:"PS",haunt: 0},
]
Insert cell
calculatedValues = {


var haunt1 = 0
var haunt2 = 0
var haunt3 = 0
haunt1 = haunt1+Haunt1Dataset[0].haunt*NSBB
haunt1 = haunt1+Haunt1Dataset[1].haunt*MCCB
haunt1 = haunt1+Haunt1Dataset[2].haunt*IB
haunt1 = haunt1+Haunt1Dataset[3].haunt*WLE
haunt1 = haunt1+Haunt1Dataset[4].haunt*CHC
haunt1 = haunt1+Haunt1Dataset[5].haunt*CCC
haunt1 = haunt1+Haunt1Dataset[6].haunt*PO
haunt1 = haunt1+Haunt1Dataset[7].haunt*WCL
haunt1 = haunt1+Haunt1Dataset[8].haunt*TX
haunt1 = haunt1+Haunt1Dataset[9].haunt*BMH
haunt1 = haunt1+Haunt1Dataset[10].haunt*SPC
haunt1 = haunt1+Haunt1Dataset[11].haunt*PT
haunt1 = haunt1+Haunt1Dataset[12].haunt*FA
haunt1 = haunt1+Haunt1Dataset[13].haunt*RSE
haunt1 = haunt1+Haunt1Dataset[14].haunt*HCH
haunt1 = haunt1+Haunt1Dataset[15].haunt*TPL
haunt1 = haunt1+Haunt1Dataset[16].haunt*PH
haunt1 = haunt1+Haunt1Dataset[17].haunt*PS

haunt2 = haunt2+Haunt2Dataset[0].haunt*NSBB
haunt2 = haunt2+Haunt2Dataset[1].haunt*MCCB
haunt2 = haunt2+Haunt2Dataset[2].haunt*IB
haunt2 = haunt2+Haunt2Dataset[3].haunt*WLE
haunt2 = haunt2+Haunt2Dataset[4].haunt*CHC
haunt2 = haunt2+Haunt2Dataset[5].haunt*CCC
haunt2 = haunt2+Haunt2Dataset[6].haunt*PO
haunt2 = haunt2+Haunt2Dataset[7].haunt*WCL
haunt2 = haunt2+Haunt2Dataset[8].haunt*TX
haunt2 = haunt2+Haunt2Dataset[9].haunt*BMH
haunt2 = haunt2+Haunt2Dataset[10].haunt*SPC
haunt2 = haunt2+Haunt2Dataset[11].haunt*PT
haunt2 = haunt2+Haunt2Dataset[12].haunt*FA
haunt2 = haunt2+Haunt2Dataset[13].haunt*RSE
haunt2 = haunt2+Haunt2Dataset[14].haunt*HCH
haunt2 = haunt2+Haunt2Dataset[15].haunt*TPL
haunt2 = haunt2+Haunt2Dataset[16].haunt*PH
haunt2 = haunt2+Haunt2Dataset[17].haunt*PS

haunt3 = haunt3+Haunt3Dataset[0].haunt*NSBB
haunt3 = haunt3+Haunt3Dataset[1].haunt*MCCB
haunt3 = haunt3+Haunt3Dataset[2].haunt*IB
haunt3 = haunt3+Haunt3Dataset[3].haunt*WLE
haunt3 = haunt3+Haunt3Dataset[4].haunt*CHC
haunt3 = haunt3+Haunt3Dataset[5].haunt*CCC
haunt3 = haunt3+Haunt3Dataset[6].haunt*PO
haunt3 = haunt3+Haunt3Dataset[7].haunt*WCL
haunt3 = haunt3+Haunt3Dataset[8].haunt*TX
haunt3 = haunt3+Haunt3Dataset[9].haunt*BMH
haunt3 = haunt3+Haunt3Dataset[10].haunt*SPC
haunt3 = haunt3+Haunt3Dataset[11].haunt*PT
haunt3 = haunt3+Haunt3Dataset[12].haunt*FA
haunt3 = haunt3+Haunt3Dataset[13].haunt*RSE
haunt3 = haunt3+Haunt3Dataset[14].haunt*HCH
haunt3 = haunt3+Haunt3Dataset[15].haunt*TPL
haunt3 = haunt3+Haunt3Dataset[16].haunt*PH
haunt3 = haunt3+Haunt3Dataset[17].haunt*PS
return [haunt1, haunt2, haunt3]
}
Insert cell
calculatedValues[0,1,2]
Insert cell
drawghost = {

const width = 90,
height = 60;
const svg = d3.create("svg")
.attr("viewBox", [-40, -30, width, height]);

var p = svg.selectAll("polyline")
.data(ghostIconForMap)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points',function(d){return d})
.style('fill','cyan')
.style('stroke','black')
.style('stroke-width','0.5')

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

const width = 90,
height = 60;
const svg = d3.create("svg")
.attr("viewBox", [-40, -30, width, height]);

var p = svg.selectAll("polyline")
.data(ghostIconForMap)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points',function(d){return d})
.style('fill','white')
.style('stroke','black')
.style('stroke-width','0.5')

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

const width = 90,
height = 60;
const svg = d3.create("svg")
.attr("viewBox", [-40, -30, width, height]);

var p = svg.selectAll("polyline")
.data(ghostIconForMap)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points',function(d){return d})
.style('fill','yellow')
.style('stroke','black')
.style('stroke-width','0.5')

return svg.node();
}
Insert cell
cannonbuilding = FileAttachment("CannonBuilding.jpg").url()
Insert cell
chapelculturalcenter = FileAttachment("ChapelCulturalCenter.jpg").url()
Insert cell
firealarmtelegraphandpolicesignalingbuilding = FileAttachment("FireAlarmTelegraphAndPoliceSignalingBuilding.jpg").url()
Insert cell
churchofHolycross = FileAttachment("Churchof HolyCross.jpg").url()
Insert cell
gurleybuilding = FileAttachment("GurleyBuilding.jpg").url()
Insert cell
hartcluett = FileAttachment("HartCluett.jpg").url()
Insert cell
mccarthybuilding = FileAttachment("McCarthyBuilding.jpeg").url()
Insert cell
illiumbuilding = FileAttachment("IlliumBuilding.jpg").url()
Insert cell
proctorStheater = FileAttachment("Proctor-sTheater.jpg").url()
Insert cell
nationalstatebankbuilding = FileAttachment("NationalStateBankBuilding.jpg").url()
Insert cell
pumpkinhouse = FileAttachment("PumpkinHouse.jpg").url()
Insert cell
rse = FileAttachment("RSE.jpg").url()
Insert cell
savingsbank = FileAttachment("SavingsBank.jpg").url()
Insert cell
stpauls = FileAttachment("StPauls.jpg").url()
Insert cell
thetaxi = FileAttachment("ThetaXi.jpg").url()
Insert cell
troypostoffice = FileAttachment("TroyPostOffice.jpg").url()
Insert cell
troypubliclibrary = FileAttachment("TroyPublicLibrary.jpg").url()
Insert cell
winslowchemicallab = FileAttachment("WinslowChemicalLab.webp").url()
Insert cell
school10 = FileAttachment("school10.jpg").url()
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