Coder Social home page Coder Social logo

clmnth / fcc-d3-choropleth-map Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 320 KB

A simple choropleth map created with D3 for the freeCodeCamp Data Visualization certification.

HTML 15.33% JavaScript 75.01% CSS 9.66%
d3 d3js data-visualization freecodecamp graph

fcc-d3-choropleth-map's Introduction

D3.js Percentage of Adults with Bachelor's Degree Choropleth Map

This project was created as part of the freeCodeCamp Data Visualization Certification.

The objective of the project is to build a choropleth map that shows the percentage of adults age 25 and older with a bachelor's degree or higher (2010-2014) using the D3.js library.

Dependencies

This code relies on the following external libraries:

d3.js v6.7.0
• topojson v3.0.2

Both libraries are loaded using a CDN link in the HTML file.

Data Sources

The choropleth map uses two datasets from freeCodeCamp:

  • counties.json containing the county boundaries of the United States in the TopoJSON format.

- [for_user_education.json](https://cdn.freecodecamp.org/testable-projects-fcc/data/choropleth_map/counties.json) containing the educational attainment data of US counties in JSON format.

Screenshot

Here is an example of what the choropleth map looks like when you run the code:
Choropleth map screenshot

Project Structure

The project is a single HTML file (index.html) with the following JavaScript code:

  • Load the data files using d3.json.
  • Create a SVG element to display the map.
  • Create a color scale using d3.scaleThreshold.
  • Create a tooltip.
  • Create a legend using d3.selectAll.
  • Use topojson.feature method to convert the county data to GeoJSON format.
  • Use d3.selectAll and .data to bind the data to the SVG and create the path elements.
  • Set the fill color of each county based on the percentage of adults aged 25 and older with a bachelor's degree or higher.
  • Create interactivity with the tooltip on hover.

Credits

This code was developed by me and was based on the examples and instructions provided by the freeCodeCamp platform.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.