% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom-stacked-column.R
\name{hd_geom_stacked_column}
\alias{hd_geom_stacked_column}
\title{Stacked Column Geometry Layer}
\usage{
hd_geom_stacked_column(stack, stacking = c("normal", "percent"), ...)
}
\arguments{
\item{stack}{Character. Column name for the stack variable.  Each unique value
in this column creates a separate stack (facet) containing all series with that
stack value.  Required.}

\item{stacking}{Character. Stacking mode for the column geometry.  One of
\code{"normal"} (default) or \code{"percent"}.  See Highcharts documentation for
details: https://api.highcharts.com/highcharts/plotOptions.column.stacking}

\item{...}{Additional optional arguments forwarded to the geom function
(e.g. \code{show_line = FALSE}, \code{single_colour = "#025169"}).
Run \code{geom_args("arearange")} for the full list.}
}
\value{
An S3 object of class \code{"hd_geom"} for use with \code{+.hd}.
}
\description{
Create a stacked column geometry layer for \code{hd} objects.  Each stack is a facet
(sub-panel) containing one or more series.  The \code{stack} argument specifies
the column in the data that defines the stacks.  The \code{group} aesthetic in
\code{hd_spec()} defines the series within each stack.  The \code{stacking}
argument controls how the stacks are rendered: \code{"normal"} (default) stacks values
on top of each other, while \code{"percent"} stacks values as percentages of the total
stack height.
}
\examples{

# Example data: medal counts for four countries across three medal types
olympics <- data.frame(
    Country   = rep(c("Norway", "Germany", "United States", "Canada"), each = 3),
    Continent = rep(c("Europe", "Europe", "North America", "North America"), each = 3),
    Medal     = rep(c("Gold", "Silver", "Bronze"), times = 4),
    Count     = c(148, 133, 124, 102, 98, 65, 113, 122, 95, 77, 72, 80)
)

# Define Specification and Options
spec_st <- hd_spec(olympics,
    x     = "Medal",
    y     = "Count",
    group = "Country"
)

opts_st <- hd_opts(
    title    = "Olympic Games all-time medal table, grouped by continent",
    subtitle = "Source: Olympics",
    ylab     = "Count medals"
)

# Interactive - stacks are separated by continent
hd_make(spec_st, "stacked_column", opts_st, stack = "Continent")

# Static ggplot2 - stacks are separated by continent
hd(spec_st, backend = "ggplot2") +
  hd_geom_stacked_column(stack = "Continent") +
  hd_opts(title = "Olympic Games all-time medal table, grouped by continent", ylab = "Count medals")

}
