Skip to main content
100%

Gender Pay Gap Dumbbell Chart

✓ Published0🌍 Public
CCurran Kelleher
Last edited Oct 9, 2025
Created on Mar 15, 2025

This dumbbell chart displays the gender pay gap across 30 US occupations from 2016, with pink circles representing women's average salaries and blue circles representing men's, connected by horizontal lines. The visualization uses `d3.scaleLinear` and `d3.scaleBand` to map salaries and occupations, while `d3.axisBottom` and `d3.axisLeft` render the axes. The `d3.selection.join()` pattern manages the SVG elements dynamically, and `ResizeObserver` enables responsive dimensions. The chart includes interactive y-axis labels that dim non-related dumbbell groups on hover, and grid lines from `renderGridLines` improve readability.

AI-generated description

Gender Pay Gap Visualization with D3.js

This project visualizes the gender pay gap across various occupations using a dumbbell chart created with D3.js. It highlights disparities in salaries between men and women for different job categories.

What is D3?

D3 (Data-Driven Documents) is a JavaScript library that enables dynamic, interactive data visualizations in web browsers using HTML, SVG, and CSS.

About This Project

This visualization uses salary data for men and women across multiple occupations to illustrate differences in earnings. Each dumbbell represents an occupation, with endpoints showing the average salaries of men and women, and a line connecting them to depict the pay gap.

How This Works

The Code Structure

This project consists of the following key files:

  • index.js: The main entry point that loads data and orchestrates rendering.
  • data.js: Handles loading and formatting the salary dataset.
  • renderSVG.js: Creates and configures the SVG container.
  • renderDumbbellChart.js: Contains logic for rendering the dumbbell chart.
  • observeDimensions.js: Enables responsiveness by tracking container size.
  • config.js: Stores layout and appearance settings.
  • theme.js: Defines color schemes and font styles.
  • styles.css: Contains CSS styles for the visualization.

Key D3 Concepts Used

  1. Scales: Mapping data values (salary amounts) to visual properties.
  2. Axes: Creating labeled axes for better readability.
  3. Data Joins: Using selection.data().join() to dynamically update elements.
  4. Transitions & Animations: Implementing smooth updates when data changes.

Getting Started with D3

If you're new to D3, here are some helpful resources:

MIT Licensed

Similar vizzes