
Kpi card with line chart
Installation
Development version from GitHub:
GitHub: https://github.com/zpio/ggexplorer
Show/Hide code
remotes::install_github("zpio/ggexplorer")Show/Hide code
library(ggexplorer)
library(dplyr)Examples
Superstore Dataset
Show/Hide code
data <- readr::read_csv(
file = "https://raw.githubusercontent.com/zpio/datasets/main/sample_superstore.csv"
)
dataBasic Chart
Show/Hide code
card_kpi_line(
data = data,
date = order_date,
value = sales,
prior_year = 2020,
current_year = 2021,
title = "Sales 2021"
)
Colors
Show/Hide code
data %>%
filter(sub_category == "Machines") %>%
card_kpi_line(
date = order_date,
value = sales,
prior_year = 2020,
current_year = 2021,
title = "Sales 2021 | Subcategory: Machines",
title_hjust = 0.7,
line_color = "cyan4",
area_color = "cyan",
area_alpha = 0.2
)
Interactive
Show/Hide code
card_kpi_line(
data = data,
date = order_date,
value = sales,
prior_year = 2020,
current_year = 2021,
title = "Sales 2021",
show_label = FALSE,
line_width = 0.5,
line_color = "purple",
area_color = "purple",
area_alpha = 0.1,
text_top_size = 3,
value_size = 8,
yoy_size = 4,
text_bottom_size = 3,
show_axis_text = FALSE,
interactive = TRUE
)