Git Product home page Git Product logo

owid-grapher's Introduction

owid-grapher

Actions Status Netlify Status Test coverage Storybook

This is the project we use at the University of Oxford to create embeddable visualizations for Our World in Data. It's not currently designed for immediate reuse as a full library, but you are very welcome to adapt any of our code or to send pull requests.

An example of what this can make (click for interactive):

Life expectancy at birth

The owid-grapher visualization frontend code can run isomorphically under node to render data directly to an SVG string, which is how the above image works!

Initial development setup

macOS

  1. Install Homebrew first, follow the instructions here: https://brew.sh/

  2. Install Homebrew services:

    brew tap homebrew/services
  3. Install MySQL 5.7 and Node 12.13.1+:

    brew install [email protected] node
  4. Start the MySQL service:

    brew services start [email protected]
  5. Install yarn:

    npm install -g yarn
  6. Inside the repo folder, install all dependencies by running:

    yarn

Other platforms

You will need: MySQL 5.7, Node 12.13.1+ and Yarn. Running yarn in the repo root will grab the remaining dependencies.

Database setup

Remove the password

Remove the password for root by opening the MySQL shell with mysql and running:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY ''

We do this for convenience so we can run mysql commands without providing a password each time. You can also set a password, just make sure you include it in the .env file later.

Import the latest data extract

Daily exports from the live OWID database are published here and can be used for testing:

File Description Size (compressed)
owid_metadata.sql.gz Table structure and metadata, everything except data_values ~15 MB
owid_chartdata.sql.gz All data values used by published visualizations >200MB

This script will create a database, then download and import all OWID charts and their data (might take a while!):

./db/downloadAndCreateDatabase.sh

Since the full data_values table (including everything we haven't visualized yet) is really big (>10GB uncompressed), we don't currently have an export for it. If you'd like a copy please contact us.

Inspecting the database

On macOS, we recommend using Sequel Pro (it's free).

We also have a rough sketch of the schema as it was on November 2019 (there may be slight changes).

Development server

cp .env.example .env and populate .env with your database details.

Finally, run yarn dev and head to localhost:3030/admin. If everything is going to plan, you should see a login screen! The default user account is "[email protected]" with a password of "admin".

This development server will rebuild and live-reload the site upon changes, so you can just make changes to the code, save the file and see the result in the browser right away.

Migrations

If you need to make changes to the MySQL database structure, these are specified by typeorm migration files. Use yarn typeorm migration:create -n MigrationName and then populate the file with the SQL statements to alter the tables, using past migration files for reference if needed. Then run migrations with yarn migrate.

Architecture notes

owid-grapher is based around reactive programming using React and Mobx, allowing it to do client-side data processing efficiently. New code should be written in TypeScript. Visual Studio Code is recommended for the autocompletion and other awesome editor analysis features enabled by static typing.

The OWID tech stack has evolved over time as we've found different ways to solve our problems. We're happy with the combination of React + Mobx + TypeScript + node and expect to be using these core tools for the foreseeable future. The MySQL database and data structure however is much older and we're interested in exploring alternatives that might allow us to work with large amounts of data more quickly and with more flexibility.


Cross-browser testing provided by BrowserStack

owid-grapher's People

Contributors

danielgavrilov avatar mlbrgl avatar zdenekhynek avatar breck7 avatar marcelgerber avatar shaahmad avatar aaldaber avatar jasoncrawford avatar sherin avatar dependabot-preview[bot] avatar markledwich2 avatar dependabot[bot] avatar hannahritchie avatar zamakkat avatar aral avatar madhums avatar jazzido avatar xammamax avatar

Watchers

James Cloos avatar  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.