`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.
Usage
xl_chart_trendline(
type,
order = NA,
period = NA,
forward = NA,
backward = NA,
intercept = NA,
equation = NA,
r_squared = NA,
name = NULL,
format = NULL
)
Value
An `xl_chart_trendline` object.
Arguments
type
`"linear"`, `"log"`, `"poly"`, `"power"`, `"exp"` or
`"average"` for a moving average.
order
The order of a polynomial fit, 2 or more. `"poly"` only.
period
The number of points a moving average covers, 2 or more.
`"average"` only.
forward, backward
How far to project the line beyond the data, in
categories.
intercept
Force the line through this value on the y axis.
Exponential, linear and polynomial fits only.
equation
Print the fitted equation on the chart.
r_squared
Print the R-squared value on the chart.
name
The trendline's name in the legend. Excel generates one
otherwise.
format
An [xl_format()] styling the line --- [xl_border()] only,
since a trendline is a line.
See Also
[xl_chart_series]
Other images and charts:
xl_chart(),
xl_chart_axis(),
xl_chart_error_bars(),
xl_chart_labels(),
xl_chart_legend(),
xl_chart_marker(),
xl_chart_series(),
xl_chart_table(),
xl_chartsheet(),
xl_image()