houseDwg = {
const width = 800,
height = 800;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
var p = svg.selectAll("polyline")
p.enter().append("polyline")
.data(redBase)
.enter()
.append("polyline")
.attr('points',function(d){return d})
.style('fill','brown')
.style('stroke','rgb(0,0,0)')
.style('stroke-width','2')
p.enter().append("polyline")
.data(roofBase)
.enter()
.append("polyline")
.attr('points',function(d){return d})
.style('fill','darkred')
.style('stroke','rgb(0,0,0)')
.style('stroke-width','2')
p.enter().append("polyline")
.data(groundColor)
.enter()
.append("polyline")
.attr('points',function(d){return d})
.style('fill','dimgray')
//.style('fill-opacity','.5')
.style('stroke','rgb(0,0,0)')
.style('stroke-width','.5')
//.style('stroke-dasharray','6,3')
p.enter().append("polyline")//add svg to variable p
.data(colorDetails2)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points',function(d){return d})
.style('fill','sienna')
//.style('fill-opacity','.5')
.style('stroke','rgb(0,0,0)')
.style('stroke-width','.5')
//.style('stroke-dasharray','6,3')
p.enter().append("polyline")//add svg to variable p
.data(details02)
.enter() //there are more data than elements, this selects them
.append("polyline")
.attr('points',function(d){return d})
.style('fill','none')
//.style('fill-opacity','.5')
.style('stroke','rgb(0,0,0)')
.style('stroke-width','.5')
//.style('stroke-dasharray','6,3')
svg.insert('rect', ':first-child')
.attr('x', 45)
.attr('y', 250)
.attr('width', 180)
.attr('height', 100)
.style('fill', 'none')
.style('stroke', 'lightgrey')
.style('stroke-width', 1);
//////////////////////////////////add windows below///////////////////////////////
if (stonebutton === "Off") {
//timberCheck = " ";
}
if (stonebutton === "On") {
p.enter().append("polyline")
.data(bluestonecombined)
.enter()
.append("polyline")
.attr('points', function (d) { return d.geo })
.attr('class', 'stoneText')
.style('fill', 'darkred')
.style('fill-opacity', '1')
.style('stroke', 'black')
.style('stroke-width', '.5')
.on('mouseover', stoneData)
.on('mouseout', stoneDataOut);
}
function stoneData(event, d) {
svg.selectAll('polyline.stoneText').style('fill', 'lightslategrey')
svg.append('image')
.attr('xlink:href','https://i.postimg.cc/tJpdsJjn/Screenshot-2024-02-28-232220.png')
.attr('class','spotImage')
.attr('x', '97')
.attr('y','450')
.attr('width', 120)
.attr('height', 120)
svg
.append("text")
.attr('x', '100')
.attr('y', '260')
.attr('class', 'stoneText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Material);
svg
.append("text")
.attr('x', '105')
.attr('y', '280')
.attr('class', 'stoneText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Location);
svg
.append("text")
.attr('x', '80')
.attr('y', '300')
.attr('class', 'stoneText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Use);
svg
.append("text")
.attr('x', '115')
.attr('y', '320')
.attr('class', 'stoneText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Fabricator);
svg
.append("text")
.attr('x', '80')
.attr('y', '340')
.attr('class', 'stoneText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Age);
}
function stoneDataOut() {
d3.selectAll('text.stoneText').remove();;
svg.selectAll('polyline.stoneText').style('fill', 'darkred')
svg.selectAll('image.spotImage').remove();
}
svg
.append("text")
.attr('x','50')
.attr('y','260')
//.attr('class','chimneyText')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','800')
.style("fill", "rgb(0,0,0)")
.text('Material: ')
svg
.append("text")
.attr('x','50')
.attr('y','280')
//.attr('class','chimneyText')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','800')
.style("fill", "rgb(0,0,0)")
.text('Location: ')
svg
.append("text")
.attr('x','50')
.attr('y','300')
//.attr('class','chimneyText')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','800')
.style("fill", "rgb(0,0,0)")
.text('Use: ')
svg
.append("text")
.attr('x','50')
.attr('y','320')
//.attr('class','chimneyText')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','800')
.style("fill", "rgb(0,0,0)")
.text('Fabricator: ')
svg
.append("text")
.attr('x','50')
.attr('y','340')
//.attr('class','chimneyText')
.style('font-family','helvetica')
.style('font-size','10px')
.style('font-weight','800')
.style("fill", "rgb(0,0,0)")
.text('Age: ')
///////////////////////
if (windowbutton === "Off") {
// windowsCheck = " ";
}
if (windowbutton === "On") {
p.enter().append("polyline")
.data(glasscombined)
.enter()
.append("polyline")
.attr('points', function (d) { return d.geo })
.attr('class', 'windowColor')
.style('fill', 'lightblue')
//.style('fill-opacity', '.5')
.style('stroke', 'rgb(0,0,0)')
.style('stroke-width', '.5')
//.style('stroke-dasharray', '6,3')
.on('mouseover', windowData)
.on('mouseout', windowDataOut)
//.style('fill', 'lightblue')
}
function windowData(event, d) {
svg.selectAll('polyline.windowColor').style('fill', 'white ')
svg.append('image')
.attr('xlink:href','https://i.postimg.cc/pdSX9FYp/Screenshot-2024-02-28-231957.png')
.attr('class','spotImage3')
.attr('x', '97')
.attr('y','450')
.attr('width', 120)
.attr('height', 120)
svg
.append("text")
.attr('x', '100')
.attr('y', '260')
.attr('class', 'windowText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Material);
svg
.append("text")
.attr('x', '105')
.attr('y', '280')
.attr('class', 'windowText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Location);
svg
.append("text")
.attr('x', '80')
.attr('y', '300')
.attr('class', 'windowText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Use);
svg
.append("text")
.attr('x', '115')
.attr('y', '320')
.attr('class', 'windowText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Fabricator);
svg
.append("text")
.attr('x', '80')
.attr('y', '340')
.attr('class', 'windowText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Age);
}
function windowDataOut() {
d3.selectAll('text.windowText').remove();
//d3.select(this).style('fill','white')
svg.selectAll('polyline.windowColor').style('fill', 'lightblue')
svg.selectAll('image.spotImage3').remove();
}
///////////////////////////////////////////////
if (timberbutton === "Off") {
//timberCheck = " ";
}
if (timberbutton === "On") {
p.enter().append("polyline")
.data(timbercombined)
.enter()
.append("polyline")
.attr('points', function (d) { return d.geo })
.attr('class', 'timberText')
.style('fill', 'white')
.style('fill-opacity', '1')
.style('stroke', 'black')
.style('stroke-width', '.5')
.on('mouseover', timberData)
.on('mouseout', timberDataOut);
}
function timberData(event, d) {
svg.selectAll('polyline.timberText').style('fill', 'black')
svg.append('image')
.attr('xlink:href','https://i.postimg.cc/gcTqYSZW/Screenshot-2024-02-28-232028.png')
.attr('class','spotImage2')
.attr('x', '97')
.attr('y','450')
.attr('width', 120)
.attr('height', 120)
svg
.append("text")
.attr('x', '100')
.attr('y', '260')
.attr('class', 'timberText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Material);
svg
.append("text")
.attr('x', '105')
.attr('y', '280')
.attr('class', 'timberText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Location);
svg
.append("text")
.attr('x', '80')
.attr('y', '300')
.attr('class', 'timberText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Use);
svg
.append("text")
.attr('x', '115')
.attr('y', '320')
.attr('class', 'timberText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Fabricator);
svg
.append("text")
.attr('x', '80')
.attr('y', '340')
.attr('class', 'timberText')
.style('font-family', 'helvetica')
.style('font-size', '10px')
.style('font-weight', '100')
.style("fill", "rgb(0,0,0)")
.text(d.data.Age);
}
function timberDataOut() {
d3.selectAll('text.timberText').remove();;
svg.selectAll('image.spotImage2').remove();
}
//////////////////////////
return svg.node();
}