How to download highchart through download button

library(shiny)
library(shinydashboard)
library(highcharter)
library(shinyWidgets)

RecruitmentFunneldb_struct <-
  structure(list(
    yyyy = c(2019L, 2019L, 2019L, 2019L, 2019L, 2019L),
    stages = c(
      "Phone Scrining",
      "Interview",
      "Offer",
      "Pre-Onboarding",
      "Post-Joining",
      "Joined"
    ),
    pop = c(8L, 25L, 23L, 32L, 8L, 4L)
  ),
  row.names = c(NA,
                6L),
  class = "data.frame")


ui <-
  dashboardPage(
    dashboardHeader(
      title = HTML("Analytic view - Recruitment"),
      titleWidth = 280
    ),
    dashboardSidebar(disable = T),
    dashboardBody(fluidPage(fluidRow(
      box(
        title = fluidRow(
          column(10, "Recruitment Funnel"),
          column(
            2,
            align = "right",
            downloadButton("download", label = NULL, class = "butt1"),
            tags$head(
              tags$style(
                ".butt1{display: inline-block;}  .butt1{font-size: 20px;} .butt1{border: none;} .butt1{padding-top: 1px} .butt1{background-color: transperent .butt1{padding-right: 50px}}"
              )
            )
            
          )
        ),
        solidHeader = T,
        width = 4,
        collapsible = F,
        highchartOutput("Recruitment_Funnel", height = "240px")
      )
      
    )))
  )

server <- function(input, output, session) {
  output$Recruitment_Funnel <- renderHighchart({
    Reserve_Data <- RecruitmentFunneldb_struct %>% arrange(-pop)
    Reserve_Data %>%
      hchart("funnel", hcaes(x = stages, y = pop))
  })
  
  output$download <- downloadHandler(
    filename = function() {
      paste("Funnel", ".", "pdf")
    },
    content = function(file) {
      pdf(file)
      output$Recruitment_Funnel()
      dev.off()
    }
  )
  
}
shinyApp(ui, server)

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.