apexcharter/examples/facet-wrap-shiny.R

36 lines
634 B
R
Raw Permalink Normal View History

2020-12-08 14:49:16 +01:00
library(shiny)
library(apexcharter)
data("unhcr_ts")
refugees <- unhcr_ts %>%
2021-11-17 12:13:25 +01:00
subset(
population_type == "Refugees (incl. refugee-like situations)"
) %>%
2020-12-08 14:49:16 +01:00
transform(date = as.Date(paste0(year, "-01-01")))
ui <- fluidPage(
tags$h2("Apexcharts Facets Example"),
apexfacetOutput("myfacet")
)
server <- function(input, output, session) {
output$myfacet <- renderApexfacet({
2021-01-05 15:08:13 +01:00
apex(refugees, aes(date, n), type = "column") %>%
2020-12-08 14:49:16 +01:00
ax_yaxis(tickAmount = 5) %>%
2021-11-17 12:13:25 +01:00
ax_facet_wrap(
vars(continent_origin),
scales = "free"
)
2020-12-08 14:49:16 +01:00
})
}
2020-12-08 16:22:24 +01:00
if (interactive())
shinyApp(ui, server)