View source: R/djpr_shiny_plot.R
djpr_plot_ui | R Documentation |
Function creates a plot environment containing (optional) title and subtitle, chart, notes, and download buttons Takes as input a function to create a ggplot2 or ggirafe object
djpr_plot_ui(id, height = "400px", width = "100%", interactive = TRUE)
id |
a Shiny |
height |
Height of container |
width |
Width of container; default is "100%" |
interactive |
Logical; |
To be used in conjunction with djpr_plot_server()
Shiny module,
which provides the server-side outputs that djpr_plot_ui()
expects. See
example.
A shiny.tag
object creating a plot environment, with
labels (title, subtitle, caption) as HTML text, a download button,
and optional input controls.
## Not run:
library(shiny)
library(ggplot2)
ui <- djpr_page(
title = "My dashboard",
djpr_tab_panel(
title = "First tab",
djpr_plot_ui("plot")
)
)
plot_function <- function(data = economics,
title = "This is a title",
subtitle = "This is a subtitle",
caption = "This data comes from the ggplot2 package") {
data %>%
ggplot(aes(x = date, y = unemploy)) +
geom_line() +
labs(
title = title,
subtitle = subtitle,
caption = caption
) +
theme_minimal(base_size = 14)
}
server <- function(input, output, session) {
djpr_plot_server("plot",
plot_function,
date_slider = TRUE,
data = ggplot2::economics,
plt_change = reactive(input$plt_change)
)
}
shinyApp(ui, server)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.