Export a Billboard to PNG
Arguments
- bb
A
billboarder
htmlwidget
object or abillboarderProxy
htmlwidget
object.- filename
A string of the filename, excluding extension (will be
".png"
).- download_label
Label to appear on the link to download PNG.
- ...
Additional arguments (not used).
Note
This function has two uses:
in shiny: you can export to PNG with an
observeEvent
by usingbillboarderProxy
.in markdown and in shiny: add a button to download chart as PNG.
Examples
# Add a button to download as PNG:
data("equilibre_mensuel")
billboarder() %>%
bb_linechart(
data = equilibre_mensuel,
mapping = bbaes(date, solde),
type = "spline"
) %>%
bb_x_axis(
tick = list(format = "%Y-%m", fit = FALSE)
) %>%
bb_export(
filename = "my-awesome-chart",
download_label = "Click to download"
)
# In shiny, you can use proxy :
if (interactive()) {
library(shiny)
library(billboarder)
ui <- fluidPage(
fluidRow(
column(
width = 8, offset = 2,
tags$h1("Export billboard as PNG via Proxy"),
billboarderOutput(outputId = "mybb"),
actionButton(
inputId = "export",
label = "Export",
icon = icon("download")
)
)
)
)
server <- function(input, output, session) {
output$mybb <- renderBillboarder({
data("prod_par_filiere")
billboarder() %>%
bb_barchart(
data = prod_par_filiere[, c("annee", "prod_hydraulique")],
color = "#102246"
) %>%
bb_y_grid(show = TRUE)
})
observeEvent(input$export, {
billboarderProxy(shinyId = "mybb") %>%
bb_export(filename = "my-billboard-chart")
})
}
shinyApp(ui, server)
}