Skip to content
An htmlwidget bringing D3 drip to R 💦 📊
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
inst updated DESCRIPTION, adjusted margins, cran-comments May 17, 2019
man changed API to drip_settings and chart_settings May 11, 2019
.Rbuildignore updated DESCRIPTION, adjusted margins, cran-comments May 17, 2019
.gitignore removed DS_Store May 6, 2019
.travis.yml added travis May 7, 2019
CRAN-RELEASE
DESCRIPTION updated DESCRIPTION, adjusted margins, cran-comments May 17, 2019
LICENSE second working commit May 6, 2019
LICENSE.md second working commit May 6, 2019
NAMESPACE changed API to drip_settings and chart_settings May 11, 2019
NEWS.md updated NEWS.md May 11, 2019
README.Rmd
README.md
cran-comments.md updated DESCRIPTION, adjusted margins, cran-comments May 17, 2019
d3rain.Rproj

README.md

d3rain

Travis build status

According to the authorities at Urban Dictionary, ‘drip’ is synonymous with ‘immense swag.’ This package brings some D3 drip to R.

Installation

You can install d3rain from GitHub via:

remotes::install_github("daranzolin/d3rain")

Examples

‘Rain’ visualizations are useful aids to observe the relationship between a ranked, numeric variable (e.g. percentile, rank, etc.) and any factored, categorical variable.

library(d3rain)
library(dplyr)

armed_levels <- c('No', 'Knife', 'Non-lethal firearm', 'Firearm')
pk <- fivethirtyeight::police_killings %>% 
  filter(armed %in% armed_levels,
         !is.na(age)) %>% 
  mutate(armed = factor(armed, levels = armed_levels)) 

pk %>% 
  d3rain(age, armed, toolTip = raceethnicity, title = "2015 Police Killings by Age, Armed Status") %>% 
  drip_settings(dripSequence = 'iterate',
                ease = 'bounce',
                jitterWidth = 20,
                dripSpeed = 1000,
                dripFill = 'firebrick') %>% 
  chart_settings(fontFamily = 'times',
                 yAxisTickLocation = 'left')

Alt Text

drip_settings adjusts the drip sequence, easing animation, jitter width, drip speed, and color. chart_settings controls the axes displays, font size, font family, and background color.

You can adjust the drip iteration by reordering the data frame:

pk %>% 
  arrange(age) %>% 
  d3rain(age, armed, toolTip = raceethnicity, title = "2015 Police Killings by Age, Armed Status") %>% 
  drip_settings(dripSequence = 'iterate',
                ease = 'linear',
                jitterWidth = 25,
                dripSpeed = 500,
                dripFill = 'steelblue') %>% 
  chart_settings(fontFamily = 'times',
                 yAxisTickLocation = 'left')

Alt Text

Future Work

  • Additional drip behaviors (e.g. by group)
  • Conditional fill colors
You can’t perform that action at this time.