% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ms_treemapchart.R
\name{ms_treemapchart}
\alias{ms_treemapchart}
\title{Treemap chart object}
\usage{
ms_treemapchart(data, path, value, labels = NULL)
}
\arguments{
\item{data}{a data.frame.}

\item{path}{character vector of column names defining the hierarchy,
from outermost (root) to innermost (leaf).}

\item{value}{column name for the numeric leaf values.}

\item{labels}{unused for now; reserved for future custom data label
columns.}
}
\value{
An \code{ms_chart} object (subclass \code{ms_treemapchart}).
}
\description{
Creation of a treemap chart object that can be inserted
in a 'Microsoft' document. Treemap charts use the chartEx pipeline
(Office 2016+); older versions of 'Microsoft Office' will display a
fallback placeholder.

Data is hierarchical: one column per level (parent to leaf, left to
right) and one numeric column for the leaf values.
}
\section{Per-leaf coloring with \code{chart_data_fill()}}{

Per-leaf coloring via \code{\link[=chart_data_fill]{chart_data_fill()}} with a named vector works
correctly on flat treemaps (\code{length(path) == 1}). With a hierarchy
(\code{length(path) >= 2}), PowerPoint silently re-maps \verb{<cx:dataPt>}
indices in a way that drops \code{idx="0"} and applies the last specified
color to remaining leaves. This is a PowerPoint rendering limitation
(also reproducible from Excel-generated chartEx files); the mschart
XML output is conformant. For hierarchical treemaps, prefer a single
fill color via \code{chart_data_fill(x, "#HEX")}.
}

\examples{
library(officer)

dat <- data.frame(
  region  = c("EU", "EU", "EU", "AM", "AM"),
  country = c("FR", "FR", "DE", "US", "US"),
  city    = c("Paris", "Lyon", "Berlin", "NYC", "LA"),
  value   = c(10, 5, 12, 20, 8),
  stringsAsFactors = FALSE
)
tm <- ms_treemapchart(
  data = dat, path = c("region", "country", "city"), value = "value"
)
tm <- chart_labels(tm, title = "Sales by region")

doc <- read_pptx()
doc <- add_slide(doc)
doc <- ph_with(doc, tm, location = ph_location_fullsize())
print(doc, target = tempfile(fileext = ".pptx"))
}
\seealso{
\code{\link[=chart_labels]{chart_labels()}}, \code{\link[=chart_theme]{chart_theme()}}

Other 'Office' chart objects:
\code{\link[=ms_areachart]{ms_areachart()}},
\code{\link[=ms_barchart]{ms_barchart()}},
\code{\link[=ms_boxplotchart]{ms_boxplotchart()}},
\code{\link[=ms_bubblechart]{ms_bubblechart()}},
\code{\link[=ms_chart_combine]{ms_chart_combine()}},
\code{\link[=ms_funnelchart]{ms_funnelchart()}},
\code{\link[=ms_histogramchart]{ms_histogramchart()}},
\code{\link[=ms_linechart]{ms_linechart()}},
\code{\link[=ms_paretochart]{ms_paretochart()}},
\code{\link[=ms_piechart]{ms_piechart()}},
\code{\link[=ms_radarchart]{ms_radarchart()}},
\code{\link[=ms_scatterchart]{ms_scatterchart()}},
\code{\link[=ms_stockchart]{ms_stockchart()}},
\code{\link[=ms_sunburstchart]{ms_sunburstchart()}},
\code{\link[=ms_waterfallchart]{ms_waterfallchart()}}
}
\concept{'Office' chart objects}
