Skip to content

Instantly share code, notes, and snippets.

@jsrath
Last active January 5, 2019 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsrath/54efee6c03c54e3c2cb64ee3a5e8eac8 to your computer and use it in GitHub Desktop.
Save jsrath/54efee6c03c54e3c2cb64ee3a5e8eac8 to your computer and use it in GitHub Desktop.
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