cfinst / cfinst.github.io

Campaign Finance Institute data exploration and download tool.
https://cfinst.github.io
GNU General Public License v3.0
12 stars 0 forks source link
campaign-finance campaign-finance-institute visualization

CFI WebTool

An interactive visualization of the Campaign Finance Institute database of campaign finance law, spanning all US States and every other year since 1996. Crafted and engineered by Seemant Kulleen and Curran Kelleher.

Try it out!

image

Table of Contents

Development Environment

This section describes how to get your development environment set up and run this site on your own computer.

This site is organized using Jekyll. Jekyll runs automatically on GitHub Pages, which is the main deployment strategy at the moment.

To run this site on your own machine, you'll need a working Ruby environment. (For windows, you can download and run RubyInstaller for Windows. For Linux or Mac you can use rvm). Then use the following commands:

# Install Jekyll on your machine (only required once).
gem install jekyll

# Use Jekyll to serve this site.
cd cfinst.github.io
jekyll serve --watch

Now the site should be available at http://localhost:4000/.

Configuration

This section is about how to configure various aspects of the visualization and user interface.

This project uses Jekyll to build the static site, which resides under _site. The content there is generated automatically by Jekyll based on source code files and configuration files in YAML and Markdown formats. These configuration files define many aspects of the visualization and user interface.

The following files are configuration files:

_config.yml
_data
├── buttons.yml
├── colors.yml
├── sections
│   ├── contribution-limits
│   │   ├── controls.yml
│   │   └── legends.yml
│   ├── disclosure
│   │   ├── controls.yml
│   │   └── legends.yml
│   ├── other-restrictions
│   │   ├── controls.yml
│   │   └── legends.yml
│   └── public-financing
│       ├── controls.yml
│       └── legends.yml
└── tabs.yml
index.md
_modals
├── intro.md
├── contribution-limits
│   ├── about.md
│   └── howto.md
├── disclosure
│   ├── about.md
│   └── howto.md
├── other-restrictions
│   ├── about.md
│   └── howto.md
└── public-financing
    ├── about.md
    └── howto.md
_sass
├── _tips.scss
└── _vis.scss

Configuration Parameters

_config.yml

This file configures the top-level Jekyll site. The following parameters are relevant to the visualization:

_data/buttons.yml

This file configures the text shown in the buttons along the right side. Each button has the following configuration options:

_data/colors.yml

This file defines the color palette hex values. Each color entry has the following parameters:

_data/tabs.yml

This file describes the visualization tabs. Each entry corresponds to a tab, and has the following parameters:

_data/sections
 ├── contribution-limits
 │   ├── controls.yml
 │   └── legends.yml
 ├── disclosure
 │   ├── controls.yml
 │   └── legends.yml
 ├── other-restrictions
 │   ├── controls.yml
 │   └── legends.yml
 └── public-financing
     ├── controls.yml
     └── legends.yml

This directory contains the configurations for controls and legend for each section.

_data/sections/:section/controls.yml

Within each section, the controls.yml file defines the content of the dropdown menu(s) available.

For sections other than Contribution Limits, each entry corresponds to an option in the dropdown menu of questions. Each entry has the following parameters:

_data/sections/contribution-limits/controls.yml

For the contribution-limits section, dropdown configuration is structured differently from the others. Here, there are two groups of dropdowns, donor and recipient. Within those groups, dropdown entries are configured with the following parameters:

_data/sections/:section/legends.yml

Within each section, the legends.yml file defines the set of color scales available. Each question maps onto one of these entries. Each entry defines a color scale that drives the color legend, with the following parameters:

index.md

This file contains two parameters:

_modals
├── intro.md
├── contribution-limits
│   ├── about.md
│   └── howto.md
├── disclosure
│   ├── about.md
│   └── howto.md
├── other-restrictions
│   ├── about.md
│   └── howto.md
└── public-financing
    ├── about.md
    └── howto.md

The _modals directory contains configuration files that define what gets shown within the modal dialogs that pop up when the page loads, and when you click on the "About this topic" and "Using this page" buttons.

_modals/intro.md

This file specifies the content of the introduction popup that appears the first time a user loads the page.

_modals/:section/about.md

This file specifies the content of the "About this topic" modal dialog for each section. Its Markdown body text is used as the content of the dialog, passed through a Markdown parser. Its YAML frontmatter defines the following parameters:

_modals/:section/howto.md

This file specifies the content of the "Using this page" modal dialog for each section. Its Markdown body text is used as the content of the dialog, passed through a Markdown parser. Its YAML frontmatter defines the same parameters as in about.md.

_sass/_tips.scss

This CSS defines a custom appearance of the tooltips that appear when you hover over the map or the grid. Draws from examples of d3-tip.

_sass/_vis.scss

This CSS defines styles applied to the visualization. This is where details such as stroke color, cursors, font styles, margins, and transition durations are defined.

_includes/footer.html

This file contains the footer content.

Updating Data

This section is about how you can update the data shown in the visualization based on the original CFI Microsoft Access database file.

Updating from Access Database

The following instructions are for updating the data used by this software from a new database dump from the original Microsoft Access database. After following these steps, the software will use the updated data.

  1. Download database dump file, e.g. CFI State Laws Update_Merge.zip. This will likely end up in your ~/Downloads folder (on Linux / Mac).
  2. Move the file into the data directory of this repository: cd cfinst.github.io/data; mv ~/Downloads/CFI\ State\ Laws\ Update_Merge.zip .
  3. Unzip the file unzip CFI\ State\ Laws\ Update_Merge.zip
  4. Install mdbtools. In Ubuntu Linux, these can be installed with the command sudo apt-get install mdbtools.
  5. Run the shell script that generates the CSV files from the database dump: cd cfints.github.io; ./bin/parse-mdb.sh data/CFI\ State\ Laws\ Update_Merge.mdb

If successful, you should see the following output:

./bin/parse-mdb.sh data/CFI\ State\ Laws\ Update_Merge.mdb
Exporting Laws_00_IdentifierTable to CSV...
Exporting Laws_01_Defintions to CSV...
Exporting Laws_02_Contributions_1 to CSV...
Exporting Laws_02_Contributions_2 to CSV...
Exporting Laws_02_Contributions_3 to CSV...
Exporting Laws_03_Disclosure_1 to CSV...
Exporting Laws_03_Disclosure_2 to CSV...
Exporting Laws_03_Disclosure_3 to CSV...
Exporting Laws_04_PublicFinancing to CSV...
...

Updating Field Descriptions

Field descriptions live inside the Jekyll configurations, under _data/sections/<section>/controls.yml. These files are automatically converted to .CSV files when you run ./bin/package-downloads.sh.

Packaging Download Files

The database content as well as metadata (field descriptions and about button contents) is packaged into a .zip file for download. To create this .zip file, run the following script:

./bin/package-downloads.sh

You should see output similar to the following:

$ ./bin/package-downloads.sh
Configuration file: /home/curran/repos/cfi/_config.yml
            Source: /home/curran/repos/cfi
       Destination: /home/curran/repos/cfi/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.133 seconds.
 Auto-regeneration: disabled. Use --watch to enable.

Creating cfi-laws-database.zip
updating: cfi-laws-database/ (stored 0%)
updating: cfi-laws-database/LICENSE (deflated 68%)
updating: cfi-laws-database/metadata/ (stored 0%)
updating: cfi-laws-database/metadata/other-restrictions-fields.csv (deflated 61%)
updating: cfi-laws-database/metadata/disclosure-fields.csv (deflated 70%)
updating: cfi-laws-database/metadata/public-financing-fields.csv (deflated 59%)
updating: cfi-laws-database/data/ (stored 0%)
updating: cfi-laws-database/data/Laws_03_Disclosure_3.csv (deflated 94%)
updating: cfi-laws-database/data/Laws_05_Other.csv (deflated 93%)
updating: cfi-laws-database/data/Laws_03_Disclosure_1.csv (deflated 96%)
updating: cfi-laws-database/data/Laws_02_Contributions_1.csv (deflated 95%)
updating: cfi-laws-database/data/Laws_00_IdentifierTable.csv (deflated 76%)
updating: cfi-laws-database/data/Laws_03_Disclosure_2.csv (deflated 92%)
updating: cfi-laws-database/data/Laws_02_Contributions_3.csv (deflated 93%)
updating: cfi-laws-database/data/Laws_04_PublicFinancing.csv (deflated 93%)
updating: cfi-laws-database/data/Laws_01_Defintions.csv (deflated 95%)
updating: cfi-laws-database/data/Laws_02_Contributions_2.csv (deflated 96%)

This will produce the cfi-laws-database.zip file inside the downloads directory, which will contain both the database tables and the metadata (field description) tables. The .zip archive will have the following layout:

├── cfi-laws-database
    ├── LICENSE
    ├── data
    │   ├── Laws_00_IdentifierTable.csv
    │   ├── Laws_01_Defintions.csv
    │   ├── Laws_02_Contributions_1.csv
    │   ├── Laws_02_Contributions_2.csv
    │   ├── Laws_02_Contributions_3.csv
    │   ├── Laws_03_Disclosure_1.csv
    │   ├── Laws_03_Disclosure_2.csv
    │   ├── Laws_03_Disclosure_3.csv
    │   ├── Laws_04_PublicFinancing.csv
    │   └── Laws_05_Other.csv
    └── metadata
        ├── disclosure-fields.csv
        ├── other-restrictions-fields.csv
        └── public-financing-fields.csv

Licensing

The source code is released under the GPL3 license (LICENSE).

The data driving the visualizations (found under data/CSVs) is released under the Creative Commons Attribution 4.0 International license (data/CSVs/LICENSE). This means that you are free to use the data for any purpose, as long as you add attribution citing Campaign Finance Institute as the source of the data.