% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/percent_bar.R
\name{pie_chart}
\alias{pie_chart}
\title{Create Pie or Donut Charts}
\usage{
pie_chart(
  input,
  var,
  var2 = NULL,
  type = 2,
  show_freq = FALSE,
  color = NULL,
  palette = "jama",
  title = NULL,
  text_size = 10,
  title_size = 20,
  add_sum = FALSE
)
}
\arguments{
\item{input}{Input dataframe.}

\item{var}{Variable for the chart.}

\item{var2}{Secondary variable for donut chart (type = 3).}

\item{type}{Chart type: 1 (pie), 2 (donut), 3 (PieDonut via webr).}

\item{show_freq}{Logical to show frequencies. Default is FALSE.}

\item{color}{Optional color palette.}

\item{palette}{Color palette name. Default is "jama".}

\item{title}{Plot title. Default is NULL.}

\item{text_size}{Text size. Default is 10.}

\item{title_size}{Title size. Default is 20.}

\item{add_sum}{Logical to add sum to labels. Default is FALSE.}
}
\value{
A ggplot object.
}
\description{
Generates a pie chart or donut chart from input data.
}
\examples{
# Simulate data
set.seed(123)
sim_data <- data.frame(
  Subtype = sample(c("EBV", "GS", "MSI", "CIN"), 100, replace = TRUE)
)

# Create pie chart
p1 <- pie_chart(input = sim_data, var = "Subtype", palette = "jama")
if (!is.null(p1)) print(p1)

# Create donut chart
p2 <- pie_chart(input = sim_data, var = "Subtype", type = 2)
if (!is.null(p2)) print(p2)
}
\author{
Dongqiang Zeng
}
