Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dataArray.forEach(element => {
d3.select(`.population-map #${element.county}`)
.style('fill', color(element.total / (element.population / 10000)))
.on('mouseover', () =>
tooltip.style('display', 'block').html(
`<p><strong>${element.county} County</strong></p>
<p>${(element.total / (element.population / 10000)).toFixed(2)} Crime(s) </p>`,
))
.on('mousemove', () => tooltip.style('top', `${d3.event.pageY + 10}px`)
.style('left', `${d3.event.pageX + 20}px`))
.on('mouseout', () => tooltip.style('display', 'none'));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment