GithubHelp home page GithubHelp logo

timelyportfolio / rcstatebin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ramnathv/rcstatebin

1.0 3.0 0.0 1.89 MB

Interactive Statebin Charts

Home Page: http://ramnathv.github.io/rcstatebin

License: MIT License

R 8.46% JavaScript 58.88% HTML 3.43% CSS 3.31% CoffeeScript 25.92%

rcstatebin's Introduction

State Bin

This is an alpha version of tool to create interactive state bin maps. It has an R API as well as a javascript API.

Installation

You can install rcstatebin from github.

install_github(c('ramnathv/htmlwidgets', 'ramnathv/rcstatebin'))

Usage

Let us start by recreating some analysis done by http://fivethirtyeight.com on where states get their taxes from. You can create an interactive statebin chart with just one line of code, using the formula interface.

library(rcstatebin)
statebin(taxdata, share ~ state | description, control = 'dropdown')

Alternately, you can also use a more traditional syntax.

library(rcstatebin)
statebin(data = taxdata,
  x = "state",
  y = "share",
  facet = "description",
  heading =  "<b>Where do your state's taxes come from?</b>",
  footer = "<small>Source: Census <a href='http://www2.census.gov/govs/statetax/14staxcd.txt'>(Data)</a>",
  colors = RColorBrewer::brewer.pal(5, 'PuRd'),
  control = 'dropdown'
)

gif

If you prefer hexagons instead of rectangles, you can pass type = "hex".

statebin(taxdata, share ~ state | description, control = 'dropdown', type = "hex")

gif2

Javascript API

I built d3statebin using a modular approach following the reusable chart guidelines outlined by Mike Bostock

mystatemap = statemap()
  .x("state")
  .y("share")
  .facet("description")
  
d3.select(el)
  .datum(x.data)
  .call(mystatemap)

References

Thanks are due to all these folks below, for building great components were used to create d3statebin

  1. [Mike Bostock] for D3.js
  2. [Elijah Meeks] for d3.svg.legend
  3. [Gregor Aisch] for d3-jetpack
  4. [Justin Palmer](Justin Palmer) for d3-tip

rcstatebin's People

Contributors

ramnathv avatar

Stargazers

 avatar

Watchers

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