chart = {
const width = 1250,
height = 1250;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const originalValues = {};
var g = svg.append("g").attr("id", "paths");
var p = svg.selectAll("polyline")
.data(outlines)
.enter()
.append("polyline")
.attr("points", function(d) {return d.pts})
.style("stroke","black")
.style("stroke-width","2px")
.style("fill","gray")
.on("mouseover",polyHover)
.on("mouseout",polyHoverOut)
function polyHover(event,d){
if (d.E_M2 === 0) {
d3.select(this).style("fill","blue");
} else {
d3.select(this).style("fill","yellow")
}
let multiplied;
var value = d.E_M2
var Boil_Fac= 0.20;
//if (Boiler = 'true'){
//Boil_Fac =0.20;
//} else {
//Boil_Fac = 1
//}
var Ins_Fac= 0.15;
//if (Insulation = 'true'){
//Ins_Fac = 0.15;} } else {
//Ins_Fac = 1
//}
var HVAC_Fac= 0.715;
//if (HVAC = 'true') {
// HVAC_Fac = 0.715; } else {
//Boil_Fac = 1
//}
//boolean multiply
if (Boiler) {
value *= Boil_Fac
}
if (Insulation) {
value *= Ins_Fac
}
if (HVAC) {
value *= HVAC_Fac
}
//return
p.each(function(d) {
originalValues[d.id] = d.E_M2;
});
svg
.append("text")
.attr("x","100")
.attr("y","100")
.attr("class","hoverText")
.text("Square Feet " + d.sf)
svg
.append("text")
.attr("x","100")
.attr("y","115")
.attr("class","hoverText")
.text("Meters Squared M2 " + d.M2)
svg
.append("text")
.attr("x","100")
.attr("y","130")
.attr("class","hoverText")
.text("Energy per M2 " + value)
svg
.append("text")
.attr("x","100")
.attr("y","145")
.attr("class","hoverText")
.text()
svg
.append("text")
.attr("x","50")
.attr("y","50")
.attr("class","hoverText")
.text('Calculated Room Energy Need (kWh * M2): '+(d.E_M2) * Pop)
svg
.append("text")
.attr("x","50")
.attr("y","75")
.attr("class","hoverText")
.text('Addess: ' + d.id)
}
function polyHoverOut(event, d){
d3.select(this).style("fill","gray")
svg.selectAll("text.hoverText").remove()
d.E_M2 = originalValues[d.id];
}
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")
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")
return svg.node();
}