Skip to contents

Quick pie chart from values and labels.

Usage

draw_pie(
  values,
  labels = NULL,
  radius = "75%",
  rose_type = NULL,
  palette = NULL,
  title = NULL,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL,
  filename = NULL,
  legend_position = "top",
  legend_placement = "outside",
  label_format = "name",
  percent_digits = 1L
)

Arguments

values

Numeric or data frame: Slice values, or a two-column table containing labels followed by values. Values must be finite and nonnegative with a positive total.

labels

Optional Character: Slice labels; names(values) when omitted.

radius

Numeric or Character: Pie radius.

rose_type

Optional Character {"radius", "area"}: Nightingale chart type.

palette

Optional Character: Series color palette — a single color string or character vector that overrides the theme palette for this chart. color takes precedence over the theme palette (it sets option.color).

title

Optional Character: Chart title.

theme

Optional Theme: Theme override. The palette inside the theme can be overridden per-chart with the color argument.

width

Optional Character or Numeric: Widget width.

height

Optional Character or Numeric: Widget height.

element_id

Optional Character: Explicit DOM element ID for the widget container. NULL lets htmlwidgets generate one.

filename

Optional Character: If provided, save the widget to this file via save_drawing().

legend_position

Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.

legend_placement

Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.

label_format

Character {"name", "value", "percent", "name_value", "name_percent"}: Slice label content.

percent_digits

Integer [0, 6]: Percentage precision.

Value

htmlwidget: Widget object.

Examples

draw_pie(
  values = c(1048, 735, 580),
  labels = c("Chrome", "Firefox", "Safari")
)