Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

veda_piechart7

Public visualization

Viewing a saved revision (read-only)

9875d727d9e24bacadbe0f366477e074

veda_piechart7

0 stars1🌍 Public
Bbhavyapokuri123@gmail.com
Last edited Mar 28, 2024
Created on Mar 28, 2024

This example shows a pie chart of GDP per capita across countries from the 2019 World Happiness Report, with each slice labeled by country name and accompanied by a color-coded legend. The visualization first computes the pie arcs using `d3.pie()` and renders them as SVG paths via `d3.arc()`, coloring each slice with a categorical scale (`d3.scaleOrdinal`). Country labels are positioned at the centroid of each arc using `d3.arc().centroid()`, and a legend is built from the color domain with appended rectangles and text. The code loads CSV data from a GitHub raw URL and uses D3 v6 within a React-compatible HTML page.

AI-generated description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.