chart = { const svg = d3.create("svg").attr("viewBox", [0, 0, 900, 610]); svg .append("g") .attr("transform", "translate(610,20)") .append(() => legend({ color: prevScale, title: 'Prev. of Obesity (%)', width: 260 }) ); svg .append("g") .selectAll("path") .data(topojson.feature(TJHD_ZCTAs, TJHD_ZCTAs.objects.TJHD_ZCTAs).features) .join("path") .attr('stroke', '#404040')+.attr('fill', 'white').attr("d", path) .attr("class", "ZCTA")-.append("title") .text( d => `${d.properties.ZCTA5CE10}: ${prev_by_ZCTA.get( d.properties.ZCTA5CE10 ) || '-'}\%` );+.append("title");return svg.node(); }
d3+.select(chart).selectAll('.ZCTA') .transition() .attr( "fill", d => prevScale(prev_by_ZCTA.get(d.properties.ZCTA5CE10)) || "white" )-.duration(2000)+.select("title") .text( d => `${d.properties.ZCTA5CE10}: ${prev_by_ZCTA.get( d.properties.ZCTA5CE10 ) || '-'}\%` )