Skip to main content
100%

Map hover

✓ Published3🌍 Public
AAurélien
Last edited Dec 1, 2021
Created on Dec 1, 2021
Forked from Hello VizHub

This example demonstrates interactive hover behavior on a map of Canada, where moving the mouse over a province highlights it by changing its fill color and triggers a tooltip displaying the province name. The tooltip, a positioned HTML div, appears near the cursor, shows the region’s name, and hides on mouseout. Built with D3 v7, it uses `d3.geoAlbers` for projection, `d3.geoPath` for rendering GeoJSON features, and CSS classes to manage visibility and styling.

AI-generated description

An example showing hovering on a map:

  • Loads d3v7 via UNPKG.
  • Loads map of Canada
  • On mouse move :
    • shows a div by modifying its css properties
    • modifies the content and position of a div (the tooltip)
    • changes the css class of the state to change its color
  • On mouse out :
    • hides the tooltip div
MIT Licensed

Similar vizzes