Coder Social home page Coder Social logo

doiobchen / d3-country-bubble-chart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeffreymorganio/d3-country-bubble-chart

0.0 1.0 0.0 6.54 MB

Demonstrate positioning elements with D3 forces and animating axes on and off screen.

License: MIT License

HTML 9.85% JavaScript 86.60% CSS 3.55%

d3-country-bubble-chart's Introduction

D3 Country Bubble Chart

This project demonstrates various ways in which D3's forces simulation can lay out elements. Each element is a circle that represents a country. The area of each circle is proportional to the UN's 2015 population estimate of the country. Each circle is filled with a color or the flag of the country.

Watch the D3 Country Bubble Chart video on YouTube. Try the live demo.

Combined/Colors
Country Centers/Colors
Continents/Colors
Population/Colors
Combined/Flags
Country Centers/Flags
Continents/Flags
Population/Flags

Data

The population and country center longitude and latitude data for each country is stored in countries.csv. The continent names used to create the continent color key are stored in continent-names.json. Both files are loaded asynchronously by d3-queue, which initiates the visualization after both files have loaded.

Colors and Flags

One set of radio buttons control whether each circle is filled with a color or the flag of the country. The color represents the continent of the country and is chosen from the schemeCategory10 palette using an ordinal scale.

Each flag is rendered as an SVG image and is stored in the flags folder. The flags are from the googlei18n/region-flags package (see COPYING).

Forces

Another set of radio buttons controls the forces that determine the location of the circles.

Combine
Pushes the circles into a single group at the center.
Continents
Groups the circles by continent and pushes the groups towards the four corners and the center.
Country Centers
Uses the Equirectangular projection to push the center of the circles towards the center of the countries they represent.
Population
Groups the circles by continent and sorts them according to population on a log scale.

Axes

This project also demonstrates how to animate D3 axes on and off the screen when selecting and de-selecting the Population circle grouping. Additionally, the continent color key demonstrates how to create a color key.

d3-country-bubble-chart's People

Contributors

jeffreymorganio avatar

Watchers

zchen avatar

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.