pier package (pronounced pie-r) is a wrapper, or
htmlwidget, for the
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.
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 guesssed this bit.
pier package is intended to be as simple and lightweight as
possible. As a starting point the data input must be a
three required columns:
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) htmlwidgets::onRender(simple.pie, 'document.getElementsByTagName("svg").setAttribute("viewBox", "")')
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()