% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/xl_chart_parts.R
\name{xl_chart_trendline}
\alias{xl_chart_trendline}
\title{A trendline on a chart series}
\usage{
xl_chart_trendline(
  type,
  order = NA,
  period = NA,
  forward = NA,
  backward = NA,
  intercept = NA,
  equation = NA,
  r_squared = NA,
  name = NULL,
  format = NULL
)
}
\arguments{
\item{type}{`"linear"`, `"log"`, `"poly"`, `"power"`, `"exp"` or
`"average"` for a moving average.}

\item{order}{The order of a polynomial fit, 2 or more.  `"poly"` only.}

\item{period}{The number of points a moving average covers, 2 or more.
`"average"` only.}

\item{forward, backward}{How far to project the line beyond the data, in
categories.}

\item{intercept}{Force the line through this value on the y axis.
Exponential, linear and polynomial fits only.}

\item{equation}{Print the fitted equation on the chart.}

\item{r_squared}{Print the R-squared value on the chart.}

\item{name}{The trendline's name in the legend.  Excel generates one
otherwise.}

\item{format}{An [xl_format()] styling the line --- [xl_border()] only,
since a trendline is a line.}
}
\value{
An `xl_chart_trendline` object.
}
\description{
`xl_chart_trendline()` fits a line through a series.

Two of Excel's own restrictions are enforced, because it discards these
rather than complain: a **moving average** has no forecast, no equation and
no R-squared, and an **intercept** applies only to exponential, linear and
polynomial fits.
}
\examples{
xl_chart_trendline("linear", equation = TRUE, r_squared = TRUE)
xl_chart_trendline("poly", order = 3)
xl_chart_trendline("average", period = 2)
}
\seealso{
[xl_chart_series]

Other images and charts:
\code{\link[=xl_chart]{xl_chart()}},
\code{\link[=xl_chart_axis]{xl_chart_axis()}},
\code{\link[=xl_chart_error_bars]{xl_chart_error_bars()}},
\code{\link[=xl_chart_labels]{xl_chart_labels()}},
\code{\link[=xl_chart_legend]{xl_chart_legend()}},
\code{\link[=xl_chart_marker]{xl_chart_marker()}},
\code{\link[=xl_chart_series]{xl_chart_series()}},
\code{\link[=xl_chart_table]{xl_chart_table()}},
\code{\link[=xl_chartsheet]{xl_chartsheet()}},
\code{\link[=xl_image]{xl_image()}}
}
\concept{images and charts}
