v_bar | R Documentation |
Create a Bar Chart
v_bar(
vc,
mapping = NULL,
data = NULL,
name = NULL,
stack = FALSE,
percent = FALSE,
direction = c("vertical", "horizontal"),
...,
serie_id = NULL,
data_id = NULL,
data_specs = list()
)
vc |
A chart initialized with |
mapping |
Default list of aesthetic mappings to use for chart. |
data |
Default dataset to use for chart. If not already
a |
name |
Name for the serie, only used for single serie (no |
stack |
Whether to stack the data or not (if |
percent |
Whether to display the data as a percentage. |
direction |
The direction configuration of the chart: |
... |
Additional parameters for the serie. |
data_id , serie_id |
ID for the data/serie, can be used to further customize the chart with |
data_specs |
Additional options for the data, see online documentation. |
A vchart()
htmlwidget
object.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.