Giter VIP home page Giter VIP logo

minnpost-pvi-map-2014's Introduction

MinnPost PVI Map 2014

Looking at new PVI analysis through cartogram map.

You can see this project in action at Minnesota's most competitive House districts.

Unless otherwise noted, MinnPost projects on Github are story-driven and meant for transparency sake and not focused on re-use. For a list of our more reusable projects, go to code.minnpost.com.

Data

Data created manually and stored at original/pvi-cartogram-data.csv. For an explanation on how the PVI was calculated, read the MinnPost PVI explainer. Layout of cartogram was created with aRanger.

Development and running locally

Prerequisites

All commands are assumed to be on the command line, often called the Terminal, unless otherwise noted. The following will install technologies needed for the other steps and will only needed to be run once on your computer so there is a good chance you already have these technologies on your computer.

  1. Install Git.
    • On a Mac, install Homebrew, then do: brew install git
  2. Install NodeJS.
    • On a Mac, do: brew install node
  3. Optionally, for development, install Grunt: npm install -g grunt-cli
  4. Install Bower: npm install -g bower
  5. Install Sass: gem install sass
    • On a Mac do: sudo gem install sass
  6. Install Compass: gem install compass
    • On a Mac do: sudo gem install compass
  7. For data processing:
    1. Install jq
      • On Mac, do: brew install jq
    2. Install csvkit: pip install csvkit

Get code and install packages

Get the code for this project and install the necessary dependency libraries and packages.

  1. Check out this code with Git: git clone https://github.com/MinnPost/minnpost-pvi-map-2014.git
  2. Go into the template directory: cd minnpost-pvi-map-2014
  3. Install NodeJS packages: npm install
  4. Install Bower components: bower install

Data processing

The Makefile runs tasks such as downloading sources and converting data.

  1. Run: make
  2. Rearrange district cartogram with aRanger using the JSON created at build/districts.json. Save as data/district-arrangement.json.

Running locally

  1. Run: grunt server
    • This will run a local webserver for development and you can view the application in your web browser at http://localhost:8867.
  2. By default, running a local server will show you the local development version. But there are other builds that you can view by changing the query parameters. Do note that you may have to run the build and deploy things for things to work normally.

Developing

Development will depend on what libraries are used. But here are a few common parts.

  • js/app.js is the main application and will contain the top logic.

Adding libraries is not difficult, but there are a few steps.

  1. User bower to install the appropriate library: bower install library --save
  2. Add the appropriate reference in js/config.js so that RequireJS knows about it.
  3. Add an entry in the dependencyMap object in bower.json. This is used to automatically collect resources in the build process. It is possible, like with minnpost-styles that multiple entries will need to be made, one ber .js file. Here is an example:
// Should be bower identifier.  Order matters for build, meaning that any dependencies should come first.
"library": {
  // Name used for reference in RequireJS (some modules expect dependencies with specific case, otherwise its arbitrary and you can just use the library name from above).
  // If this is not a JS library, do not include.
  "rname": "library",
  // (optional) Path to un-minified JS files within bower_components excluding .js suffix.
  "js": ["library/dist/library"],
  // (optional) Path to un-minified CSS files within bower_components excluding .css suffix.
  "css": ["library/dist/css/library"],
  // (optional) Path to un-minified IE-specific CSS files within bower_components excluding .css suffix.
  "ie": ["library/dist/css/library.ie"],
  // What is expected to be returned when using as a RequireJS dependency.  Some specific libraries, like jQuery use $, or backbone returns the Backbone class.
  // If this is not a JS library, do not include.
  "returns": "Library"
}

Testing

Unfortunately there are no tests at the moment.

Build

To build or compile all the assets together for easy and efficient deployment, do the following. It will create all the files in the dist/ folder.

  1. Run: grunt

Deploy

Deploying will push the relevant files up to Amazon's AWS S3 so that they can be easily referenced on the MinnPost site. This is specific to MinnPost, and your deployment might be different.

  1. Run: grunt deploy
    • This will output a bit of HTML to if you want to use the project as an embed.

There are to main ways to include the necessary HTML in a page in order to run the project.

  1. Copy the relevant parts from index.html.
    • This has the benefit of showing messages to users that have older browsers or have Javascript turned off. This also uses the build that separates out the third-party libraries that are used and are less likely to change; this gains a bit of performance for users.
  2. Copy the embed output from grunt deploy (still in development).

Hacks

List any hacks used in this project, such as forked repos. Link to pull request or repo and issue.

About Us

MinnData, the MinnPost data team, is Alan, Tom, and Kaeti and all the awesome contributors to open source projects we utilize. See our work at minnpost.com/data.


                                                   .--.
                                                   `.  \
                                                     \  \
                                                      .  \
                                                      :   .
                                                      |    .
                                                      |    :
                                                      |    |
      ..._  ___                                       |    |
     `."".`''''""--..___                              |    |
     ,-\  \             ""-...__         _____________/    |
     / ` " '                    `""""""""                  .
     \                                                      L
     (>                                                      \
    /                                                         \
    \_    ___..---.                                            L
      `--'         '.                                           \
                     .                                           \_
                    _/`.                                           `.._
                 .'     -.                                             `.
                /     __.-Y     /''''''-...___,...--------.._            |
               /   _."    |    /                ' .      \   '---..._    |
              /   /      /    /                _,. '    ,/           |   |
              \_,'     _.'   /              /''     _,-'            _|   |
                      '     /               `-----''               /     |
                      `...-'                                       `...-'

minnpost-pvi-map-2014's People

Contributors

zzolo avatar

Watchers

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