bar_chart_grouped: Generates grouped horizontal barchart with scenario...

Description Usage Arguments Value Examples

View source: R/bar_chart_grouped.R

Description

Generates grouped horizontal barchart with scenario triangles.

Usage

1
2
3
4
5
6
7
8
9
bar_chart_grouped(
  data,
  cat,
  foreground,
  background,
  markers = NULL,
  series_labels,
  styles = NULL
)

Arguments

data

data frame in wide format containing data to be plotted

cat

vector containing category names of values

foreground

vector or name of column in data representing heights of bars visible in the foreground

background

vector or name of column in data representing heights of bars visible in the background

markers

optional vector representing position of triangles

series_labels

vector of series titles. Consists of 2 or 3 elements

styles

optional dataframe of styles. First column contains styles for foreground series, second for background, third for triangles. dim(styles) must be length(x), length(titles)

Value

object of class tidychart with a character vector containing SVG elements

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#preparing data frames
data <- data.frame(
city = c("Berlin", "Paris", "London", "Munich", "Vienna"),
AC = c(592, 1166, 618, 795, 538),
PL = c(570, 950, 800, 780, 460),
triangles = c(545, 800, 900, 600, 538) #AC toten bardziej na wierzchu
)

#preparing the styles data frame
df_styles <- data.frame(
 AC = c("actual","actual","actual","actual","actual"),
 PL = c("plan","plan","plan","plan","plan"),
 triangles = c("previous", "previous","previous","previous","previous"))

#creating the svg string
barchart_grouped <- bar_chart_grouped(data,
 data$city,  "AC", "PL","triangles", c("triangles", "AC", "PL"), df_styles)

#showing the plot
barchart_grouped

tidycharts documentation built on Jan. 18, 2022, 5:07 p.m.