% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ms_chart.R
\name{ms_piechart}
\alias{ms_piechart}
\title{Piechart object}
\usage{
ms_piechart(data, x, y, labels = NULL)
}
\arguments{
\item{data}{a data.frame}

\item{x}{column name for categories (slices).}

\item{y}{column name for values (slice sizes).}

\item{labels}{column names of columns to be used as custom data labels
displayed next to data points (not axis labels). Optional.
If more than one name is provided, only the first one will be used as a label, but all
labels (transposed if a group is used) will be available in the Excel file
associated with the chart.}
}
\value{
An \code{ms_chart} object.
}
\description{
Creation of a piechart object that can be
inserted in a 'Microsoft' document.

Pie charts show the proportion of each category as a slice
of a circle. Doughnut charts are similar but have a hole
in the centre. Use \code{chart_settings(x, hole_size = ...)} to
control the hole size: 0 produces a pie chart, values
above 0 produce a doughnut chart.

Data must be pre-aggregated: one row per slice, no grouping
column.
}
\examples{
library(officer)
library(mschart)

dat <- data.frame(
  browser = c("Chrome", "Firefox", "Safari", "Edge", "Other"),
  value = c(64, 12, 8, 5, 11)
)

# Pie chart
pie <- ms_piechart(data = dat, x = "browser", y = "value")
pie <- chart_labels(pie, title = "Browser share")

# Doughnut chart
donut <- ms_piechart(data = dat, x = "browser", y = "value")
donut <- chart_settings(donut, hole_size = 50)
donut <- chart_labels(donut, title = "Browser share (donut)")
}
\seealso{
\code{\link[=chart_settings]{chart_settings()}}, \code{\link[=chart_data_labels]{chart_data_labels()}}, \code{\link[=chart_theme]{chart_theme()}}, \code{\link[=chart_labels]{chart_labels()}}

Other 'Office' chart objects: 
\code{\link{ms_areachart}()},
\code{\link{ms_barchart}()},
\code{\link{ms_bubblechart}()},
\code{\link{ms_chart_combine}()},
\code{\link{ms_linechart}()},
\code{\link{ms_radarchart}()},
\code{\link{ms_scatterchart}()},
\code{\link{ms_stockchart}()}
}
\concept{'Office' chart objects}
