jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
719 stars 148 forks source link

Shiny + Highcharter: download pdf works in edge, firefox but not chrome #293

Closed klopianoRTA closed 7 years ago

klopianoRTA commented 7 years ago

First, thank you for developing and maintaining such an incredible R package.

The R program below builds upon the example here http://jkunst.com/highcharter/shiny.html Note I changed hc_demo to highcharts_demo and added an hc_exporting line.

I'm able to download the chart as a pdf file when I open the application in Microsoft Edge and Mozilla Firefox but not Google Chrome. Any thoughts?

library("shiny")
library("highcharter")

data(citytemp)

ui <- fluidPage(
  h1("Highcharter Demo"),
  fluidRow(
    column(width = 4, class = "panel",
           selectInput("type", label = "Type", width = "100%",
                       choices = c("line", "column", "bar", "spline")),
           selectInput("stacked", label = "Stacked",  width = "100%",
                       choices = c(FALSE, "normal", "percent")),
           selectInput("theme", label = "Theme",  width = "100%",
                       choices = c(FALSE, "fivethirtyeight", "economist",
                                   "darkunica", "gridlight", "sandsignika",
                                   "null", "handdrwran", "chalk")
           )
    ),
    column(width = 8,
           highchartOutput("hcontainer",height = "500px")
    )
  )
)

server = function(input, output) {

  output$hcontainer <- renderHighchart({

    hc <- highcharts_demo() %>%
      hc_rm_series("Berlin") %>%
      hc_chart(type = input$type)

    if (input$stacked != FALSE) {
      hc <- hc %>%
        hc_plotOptions(series = list(stacking = input$stacked))
    }

    if (input$theme != FALSE) {
      theme <- switch(input$theme,
                      null = hc_theme_null(),
                      darkunica = hc_theme_darkunica(),
                      gridlight = hc_theme_gridlight(),
                      sandsignika = hc_theme_sandsignika(),
                      fivethirtyeight = hc_theme_538(),
                      economist = hc_theme_economist(),
                      chalk = hc_theme_chalk(),
                      handdrwran = hc_theme_handdrawn()
      )

      hc <- hc %>% hc_add_theme(theme)

    }

    hc %>%
      hc_exporting(enabled = TRUE,
                   filename = "thanks-joshua-kunst")

  })

}

shinyApp(ui = ui, server = server)
jbkunst commented 7 years ago

Hi @klopianoRTA

I use your app without problems in chrome, do you have the lastest version (dev) of highcharter?

This can be related to https://github.com/jbkunst/highcharter/issues/131#issuecomment-231753664

image

Have you tried with other version of chrome, Or maybe other pc with chorme?

klopianoRTA commented 7 years ago

Hi Joshua, Thanks for the quick reply. Installing the dev version of highcharter solved the problem. Thanks. When you have time, I'd love to better understand what was causing the issue. Thanks again.

jbkunst commented 7 years ago

@klopianoRTA , Sadly I don't have any clue about this issue. I'll let you know if I know something.