🌍 Public
Viewing a saved revision (read-only)
0f839f70d71c417eac65392397531607
Untitled
This example shows an interactive map of Canada with SVG paths representing provinces, initially colored dark green. When the mouse hovers over a province, the CSS class changes to turn it red and a tooltip div appears, displaying information about the province. The tooltip is positioned and shown by modifying its CSS properties on mouse move, and hidden on mouse out. Built with D3.v7, it loads GeoJSON data from GitHub and renders paths using `d3.geoPath` with an Albers projection, while D3's `select` and `join` methods handle the interactive state changes.
AI-generated descriptionAn 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