Skip to main content
Public

Share visualization

Loading preview…

ice_7 , question 2

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

ice_7 , question 2

1
Sshailajat1998@gmail.com
Last edited Mar 28, 2024
Created on Mar 28, 2024
Forked from ice_7 , question 1

This pie chart visualizes the distribution of fuel types in a used-car dataset, with each slice encoded by a distinct color from D3's categorical scaleOrdinal scheme. The visualization is interactive: hovering over a segment displays a tooltip showing the fuel type and its exact count, while a dynamically generated legend maps colors to fuel categories for quick reference. Data is loaded from car_dataset.csv via d3.csv, and the chart is rendered with SVG in D3 v7, featuring smooth animated transitions. The tooltip and legend enhance accessibility and readability, making it easy to compare categorical proportions at a glance.

AI-generated description

Pie Chart with Tooltips and Legend

This project showcases a pie chart visualization with tooltips and a dynamic legend using D3.js library.

Features:

  1. Data Loading: Data is loaded from a CSV file (car_dataset.csv) using D3's d3.csv method.

  2. Pie Chart: A pie chart is rendered using SVG elements to visualize the distribution of fuel types present in the dataset.

  3. Interactive Tooltip: Mouseover events on each segment of the pie chart display a tooltip showing the fuel type and its count.

  4. Dynamic Legend: A legend is dynamically generated based on the unique fuel types present in the dataset, providing visual cues for the colors used in the pie chart.

  5. Color Encoding: Fuel types are encoded with distinct colors using D3's scaleOrdinal scale and a categorical color scheme.

  6. Responsive Design: The visualization adjusts to different screen sizes, maintaining its integrity and readability.

  7. External Library: D3.js library is included via CDN (https://d3js.org/d3.v7.min.js).

  8. Styling: CSS styling is applied to enhance the appearance of the tooltip, providing a clean and intuitive user experience.

  9. Modularity: The code is structured using functions and method chaining for improved readability and maintainability.

  10. Accessibility: The visualization is designed to be accessible, with tooltips providing additional information for users with disabilities.

Comments

Sign in to join the discussion.

MIT Licensed