-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
echarts4r and shiny downloadHandler #528
Comments
Have you tried webshot? |
I tried webshot myself (since I had a use case as well) but no luck. So if we find a way to export echarts4r plots as an image (e.g. png), this would be most welcome @munoztd0! ,🙂 |
Echarts has a functionality for this, we can integrate. |
Export as images programmatically? (I am aware of the save image feature). This would be brillant! |
Ah programmatically, missed that. Rmarkdown does it, when you use an htmlwidget in a document rendered to PDF. Maybe something to look at. |
Thanks for the replies! @rdatasculptor : Using Unfortunately, my 'stakeholders' need a Shiny solution. So, an Btw.: The |
You probably get a white image because of the animation. Set |
This works. library(shiny)
library(echarts4r)
ui <- fluidPage(
tags$head(
tags$script(
HTML("$(() => {
$('#img').on('click', (e) => {
let el = get_e_charts('plot');
let img = el.getDataURL({pixelRatio: 2, backgroundColor: '#fff'});
Shiny.setInputValue('imgstr', img)
})
});")
)
),
tags$a("Save image", id = "img", class = "btn btn-info"),
echarts4rOutput("plot")
)
server <- function(input, output, session) {
output$plot <- renderEcharts4r({
mtcars |>
e_charts(mpg) |>
e_scatter(wt, qsec)
})
observeEvent(input$imgstr, {
str <- input$imgstr
raw <- base64enc::base64decode(what = substr(str, 23, nchar(str)))
png::writePNG(png::readPNG(raw), "plot.png")
})
}
shinyApp(ui, server) |
and this doesn't work,:
Again the result is a white image. Or do I miss something here? (@JohnCoene was this what you meant by e_animation(show = FALSE))? |
webshot2 works! At least for me it does. if it works for you as well @svenb78, then we can close this issue. |
@rdatasculptor : I will check and talk to my admin. |
John's suggestion works and fits my needs. Many thanks for the help! I will close the issue. |
We should probably document that somewhere, or even provide a wrapper around that download functionality |
Hi,
some time ago, I made a shiny app which allows users to export plots -- made with ggplot2 -- into a Word document. I would like to use echarts graphs instead of ggplot, but I don't find a way to export them using a downloadHandler (--> check boxes). I found the
e_toolbox_feature
andsaveAsImage
argument, but that is not what I'm looking for.Can someone help, e.g. with a minimal example for an echarts4r_to_PPTX export function. :-)
The text was updated successfully, but these errors were encountered: