Skip to contents

Adds a footer - a small line of text such as a data source or caption - to the bottom of a chart. Footers are a common request for report charts (for example "Source: internal data, 2024").

A chart footer is not a native chart element, so it is rendered the way 'Microsoft Office' itself stores drawn chart text: as a text box in the chart's user-shapes drawing part (c:userShapes). The footer therefore travels with the chart, opens without repair, and stays editable in PowerPoint, Word and Excel.

Pair it with chart_title() (title + subtitle) to reproduce the classic title / subtitle / footer layout.

Usage

chart_footer(
  x,
  text,
  align = c("left", "center", "right"),
  footer_fp = NULL,
  top = NULL
)

Arguments

x

an ms_chart object created with a classical constructor (ms_barchart(), ms_linechart(), ms_scatterchart(), ms_areachart(), ms_piechart(), ...). ChartEx charts (box plot, histogram, pareto, ...) are not supported.

text

the footer text, a single character string. Use NULL to remove a previously set footer.

align

horizontal alignment of the footer text, one of "left" (default), "center" or "right".

an officer::fp_text() controlling the footer font. When NULL (default), a small grey style is used.

top

optional vertical position of the top of the footer box as a fraction of the chart height (0-1). Larger values push the footer lower. Defaults to 0.93 (a thin strip along the bottom edge).

Value

An updated ms_chart object.

Examples

library(officer)

dat <- data.frame(
  name = c("A", "B", "C", "D"),
  value = c(3, 8, 5, 9),
  stringsAsFactors = FALSE
)

bc <- ms_barchart(data = dat, x = "name", y = "value")
bc <- chart_title(bc, title = "Quarterly revenue", subtitle = "EUR m")
bc <- chart_footer(bc, text = "Source: internal data, 2024")