create_sparklines {openxlsx2}R Documentation

Create sparklines object

Description

Create a sparkline to be added a workbook with wb_add_sparklines()

Usage

create_sparklines(
  sheet = current_sheet(),
  dims,
  sqref,
  type = NULL,
  negative = NULL,
  display_empty_cells_as = "gap",
  markers = NULL,
  high = NULL,
  low = NULL,
  first = NULL,
  last = NULL,
  color_series = wb_color(hex = "FF376092"),
  color_negative = wb_color(hex = "FFD00000"),
  color_axis = wb_color(hex = "FFD00000"),
  color_markers = wb_color(hex = "FFD00000"),
  color_first = wb_color(hex = "FFD00000"),
  color_last = wb_color(hex = "FFD00000"),
  color_high = wb_color(hex = "FFD00000"),
  color_low = wb_color(hex = "FFD00000"),
  manual_max = NULL,
  manual_min = NULL,
  line_weight = NULL,
  date_axis = NULL,
  display_x_axis = NULL,
  display_hidden = NULL,
  min_axis_type = NULL,
  max_axis_type = NULL,
  right_to_left = NULL,
  ...
)

Arguments

sheet

sheet

dims

Cell range of cells used to create the sparklines

sqref

Cell range of the destination of the sparklines.

type

Either NULL, stacked or column

negative

negative

display_empty_cells_as

Either gap, span or zero

markers

markers add marker to line

high

highlight highest value

low

highlight lowest value

first

highlight first value

last

highlight last value

color_series

colorSeries

color_negative

colorNegative

color_axis

colorAxis

color_markers

colorMarkers

color_first

colorFirst

color_last

colorLast

color_high

colorHigh

color_low

colorLow

manual_max

manualMax

manual_min

manualMin

line_weight

lineWeight

date_axis

dateAxis

display_x_axis

displayXAxis

display_hidden

displayHidden

min_axis_type

minAxisType

max_axis_type

maxAxisType

right_to_left

rightToLeft

...

additional arguments

Details

Colors are all predefined to be rgb. Maybe theme colors can be used too.

Value

A string containing XML code

Examples

# create sparklineGroup
sparklines <- c(
  create_sparklines("Sheet 1", "A3:L3", "M3", type = "column", first = "1"),
  create_sparklines("Sheet 1", "A2:L2", "M2", markers = "1"),
  create_sparklines("Sheet 1", "A4:L4", "M4", type = "stacked", negative = "1")
)

t1 <- AirPassengers
t2 <- do.call(cbind, split(t1, cycle(t1)))
dimnames(t2) <- dimnames(.preformat.ts(t1))

wb <- wb_workbook()$
  add_worksheet("Sheet 1")$
  add_data(x = t2)$
  add_sparklines(sparklines = sparklines)


[Package openxlsx2 version 1.8 Index]