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,
direction = 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
orcolumn
- negative
negative
- display_empty_cells_as
Either
gap
,span
orzero
- 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
displayHidden
- min_axis_type
minAxisType
- max_axis_type
maxAxisType
- right_to_left
rightToLeft
- direction
Either
NULL
,row
(or1
) orcol
(or2
). Should sparklines be created in the row or column direction? Defaults toNULL
. WhenNULL
the direction is inferred fromdims
in cases wheredims
spans a single row or column and defaults torow
otherwise.- ...
additional arguments
Examples
# create multiple sparklines
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"),
create_sparklines("Sheet 1", "A5:L5;A7:L7", "M5;M7", markers = "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)
# create sparkline groups
sparklines <- c(
create_sparklines("Sheet 2", "A2:L6;", "M2:M6", markers = "1"),
create_sparklines(
"Sheet 2", "A7:L7;A9:L9", "M7;M9", type = "stacked", negative = "1"
),
create_sparklines(
"Sheet 2", "A8:L8;A10:L13", "M8;M10:M13",
type = "column", first = "1"
),
create_sparklines(
"Sheet 2", "A2:L13", "A14:L14", type = "column", first = "1",
direction = "col"
)
)
wb <- wb$
add_worksheet("Sheet 2")$
add_data(x = t2)$
add_sparklines(sparklines = sparklines)