Skip to contents

`xl_chart_series()` names the values a chart plots, and optionally the categories to plot them against and a name for the legend.

Each range may live on a different sheet from the chart, so it takes an optional `sheet`:

* `"Data!B2:B10"` — an A1 range, sheet-qualified; * `list(cols = "revenue")` — resolved against the chart's own sheet; * `list(sheet = "Data", cols = "revenue")` — against another sheet.

A range that selects no data is an error rather than an empty chart.

Usage

xl_chart_series(
  values,
  categories = NULL,
  name = NULL,
  format = NULL,
  smooth = NA,
  invert_if_negative = NA
)

Arguments

values

The range holding the numbers to plot.

categories

The range holding the labels to plot them against. Omit for a chart that numbers its points.

name

The series name, shown in the legend. A string is always taken literally — a series may legitimately be called `"Q1!"` — so to take the name from a cell, give a range spec: `name = list(sheet = "Data", rows = 1, cols = 1)`.

format

An [xl_format] styling the series — its line and fill. See [xl_chart()] for which format properties a chart can express.

smooth

Draw the line smoothed. Line and scatter charts only.

invert_if_negative

Fill negative values with the inverse colour.

Value

An `xl_chart_series` object.

See also

[xl_chart]

Other images and charts: xl_chart(), xl_image()

Examples

xl_chart_series(values = list(cols = "revenue"))
#> <xl_chart_series>
xl_chart_series(values = "Data!B2:B10", categories = "Data!A2:A10",
                name = "2024")
#> <xl_chart_series: 2024>