Skip to main content
100%

Untitled

✓ Published0🌍 Public
NNICHAPA
Last edited Jul 27, 2023
Created on Jul 27, 2023
Forked from Untitled

This example displays a map of Canada using GeoJSON data, with each province rendered as an SVG path. On mouse movement over a province, a tooltip div appears and tracks the cursor, displaying the province name from the data properties. The tooltip is shown by removing its hidden class and repositioned via inline CSS, while the province’s fill color changes on hover using CSS rules. The code uses `d3.geoPath` with an Albers projection and loads data from a remote GitHub repository.

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