Create a Bar Chart
v_bar.RdCreate a Bar Chart
Arguments
- vc
A chart initialized with
vchart().- mapping
Default list of aesthetic mappings to use for chart.
- data
Default dataset to use for chart. If not already a
data.frame, it will be coerced to withas.data.frame.- name
Name for the serie, only used for single serie (no
color/fillaesthetic supplied).- stack
Whether to stack the data or not (if
fillaesthetic is provided).- percent
Whether to display the data as a percentage.
- direction
The direction configuration of the chart:
"vertical"(default) or"horizontal".- ...
Additional parameters for the serie.
- data_id, serie_id
ID for the data/serie, can be used to further customize the chart with
v_specs().- data_specs
Additional options for the data, see online documentation.
Value
A vchart() htmlwidget object.
Examples
library(vchartr)
# Classic Bar Chart
vchart(top_generation) %>%
v_bar(aes(country, electricity_generation))
# Horizontal Bar Chart
vchart(top_generation) %>%
v_bar(aes(country, electricity_generation), direction = "horizontal")
# Grouped Bar Chart
vchart(subset(world_electricity, type == "total")) %>%
v_bar(aes(year, generation, fill = source))
# Horizontal Grouped Bar Chart
vchart(subset(world_electricity, type == "total")) %>%
v_bar(aes(year, generation, fill = source), direction = "horizontal")
# Stacked Bar Chart
vchart(subset(world_electricity, type == "total")) %>%
v_bar(aes(year, generation, fill = source), stack = TRUE)
# Percentage Stacked Bar Chart
vchart(subset(world_electricity, type == "total")) %>%
v_bar(aes(year, generation, fill = source), stack = TRUE, percent = TRUE)