bar_chart: Generates basic horizontal barchart. If more than one series...

Description Usage Arguments Value Examples

View source: R/bar_chart.R

Description

Generates basic horizontal barchart. If more than one series is supplied, stacked barchart is generated.

Usage

1
bar_chart(data, cat, series, series_labels = series, styles = NULL)

Arguments

data

data frame containing data to be plotted

cat

vector containing category names of values

series

vector containing names of columns in data with values to plot

series_labels

vector containing names of series to be shown on the plot

styles

optional vector with styles of bars

Value

object of class tidychart with a character vector containing SVG elements

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#prepare the data frame
data <- data.frame(
city = c("Berlin", "Munich", "Cologne", "London", "Vienna", "Paris", "Zurich"),
Products = c(538, 250, 75, 301, 227, 100, 40),
Services = c(621, 545, 302, 44, 39, 20, 34)
)
#generate svgstring
barchart <- bar_chart(data, data$city, c("Products", "Services"), c("Products", "Services"))

#show the plot
barchart

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