Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Pie Chart - Expenses

Public visualization

Pie Chart - Expenses

0 stars0🌍 Public
YYash Raj Mathur
Last edited Mar 30, 2026
Created on Mar 30, 2026

This example renders a simple pie chart that visualizes expense categories (Food, Travel, Shopping, Others) with their corresponding quantitative values. The chart uses d3.pie() and d3.arc() to generate the slices, with a d3.scaleOrdinal() providing the categorical color scheme. Each slice is labeled using arc.centroid() to position the category names, and a separate HTML legend is appended below the SVG to reinforce the color-coded categories. The visualization is built with d3.v7 and rendered as inline SVG.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed