HTMLWidget for d3pie javascript library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
img
inst
man
tests
vignettes
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
NAMESPACE
README.Rmd
README.md
pier.Rproj

README.md

pier

DOI Build Status codecov

The pier package (pronounced pie-r) is a wrapper, or htmlwidget, for the d3pie javascript library by Benjamin Keen. If you are just wanting to generate a pie chart the d3pie website has a fantastic generator that will create the code that you need. If you are wanting create a chart using R for embedding in a Rmarkdown document or Shiny App, then you are in the right place.

The d3pie library is very versatile and includes a lot of options. Currently this package only wraps the configuration object. Even with this current limitation a wide range of options are available.

Currently the intention is to wrap the entire d3pie api.

Installation

You probably already guesssed this bit.

devtools::install_github("mrjoh3/pier")

Usage

The pier package is intended to be as simple and lightweight as possible. As a starting point the data input must be a data.frame with three required columns: label, value and color. From this point most of the defaults from d3pie are carried over. Note that all examples here have lost their interactivity.

library(pier)

data <- data.frame(label = c('Environment','Education','Business','Community'),
                   value = c(104,119,638,1250),
                   color = RColorBrewer::brewer.pal(4, 'Spectral'))

simple.pie <- pier(data)

Advanced Usage

advanced.pie <- data %>%
    pier() %>%
    pie.size(inner=70, outer=100, width = 600, height = 450) %>%
    pie.header(text='Segments', font='Impact', location='pie-center') %>%
    pie.subtitle(text='by Type') %>%
    pie.footer(text='Economic Segments using fake data.',
               location = 'bottom-left') %>%
    pie.tooltips()