bb_export {billboarder}R Documentation

Export a Billboard to PNG

Description

Export a Billboard to PNG

Usage

bb_export(bb, filename = NULL, download_label = "Export (.png)", ...)

Arguments

bb

A billboarder htmlwidget object or a billboarderProxy 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).

Value

A billboard htmlwidget object.

Note

This function has two uses:

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)
}

[Package billboarder version 0.4.1 Index]