chart = {
const width = 960,
height = 900;
const svg = d3.create("svg")
.attr("viewBox", [-60, 0, width, height]);
var projection = d3
.geoMercator()
.fitSize([width - 50, height - 50], Arizona);
var path = d3.geoPath().projection(projection);
var path2 = d3.geoPath().projection(projection);
var g = svg.append("g").attr("id", "paths");
g.selectAll("path")
.data(Arizona.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", "white")
.style('fill-opacity','.8')
.style("stroke-width", ".35")
.style("stroke", "#ccc")
g.selectAll("path")
.data(Score.features)
.enter()
.append("path")
.attr('class','outlines')
.attr("d", path)
.style("fill", d => color(d.properties.Base_Base))
.style('fill-opacity','.5')
.style("stroke-width", ".1")
.style("stroke", "rgb(255,0,0)")
.on('mouseover', addFill)
.on('mouseleave', removeFill)
function addFill(event,d) {
d3.select(this).style("fill", "red")
d3.select(this).style('fill-opacity','.8')
svg
.append('text')
.attr("class","labels")
.attr('x','10')
.attr('y','70')
.attr('font-size','.85em')
.text(d.properties.Name_Name)
svg
.append('text')
.attr("class","labels")
.attr('x','10')
.attr('y','90')
.attr('font-size','.85em')
.text(d.properties.Base_Base)
}
function removeFill(event,d) {
d3.selectAll("text.labels").remove()
d3.select(this).style("fill", d => color(d.properties.Base_Base))
d3.select(this).style('fill-opacity','.5')
}
return svg.node();
}