Featured image of post pier


2 min read

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.


You probably already guessed this bit.



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.


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

pier(data) %>% pie.size(height = 350)

Advanced Usage

data %>%
    pier() %>%
    pie.size(inner=70, outer=100, width = 500, height = 350) %>%
    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') %>%
Built with Hugo
Theme Stack designed by Jimmy