trafficonese / widgetframe

Embed htmlwidgets in Responsive iframe.
https://bhaskarvk.github.io/widgetframe/
Other
69 stars 11 forks source link

Unable to save html file using widgetframe::saveWidgetframe #22

Closed elukjan closed 4 years ago

elukjan commented 4 years ago

I want to use LaTeX to parse descriptions in my plotly plots. I used the example from plotly website:

p <- plot_ly(
    x = c(1, 2, 3, 4),
    y = c(1, 4, 9, 16),
    name = TeX("\\alpha_{1c} = 352 \\pm 11 \\text{ km s}^{-1}")) %>%
  add_trace(
    x = c(1, 2, 3, 4),
    y = c(0.5, 2, 4.5, 8),
    name = TeX("\\beta_{1c} = 25 \\pm 11 \\text{ km s}^{-1}")) %>%
  layout(
    xaxis = list(
      title = TeX("\\sqrt{(n_\\text{c}(t|{T_\\text{early}}))}")),
    yaxis = list(
      title = TeX("d, r \\text{ (solar radius)}"))) %>%
  config(mathjax = 'cdn')

widget <- widgetframe::frameableWidget(p)
widgetframe::saveWidgetframe(widget, paste0("p", ".html"), selfcontained = TRUE)

problem is that both "p" and "widget" display correctly, but I can't get it to save it to a file. I don't mind whether the file is large. I'd also like ot be able to do this in a Shiny app with downloadable plots. Is that doable at all?

elukjan commented 4 years ago

So, the files are generated exactly as they should. The issue was... web browser. I've tried viewing the files in Firefox, which displayed LaTeX code in monospace font instead of actual labels. Probably some overzealous security feature working without any indication. Files are displayed correctly in both Internet Explorer and Chrome