-
Notifications
You must be signed in to change notification settings - Fork 14
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
Save output animation to file #99
Comments
Thanks @joelostblom! We don't have an option to output to a To output to library(dplyr)
library(datamations)
library(htmltools)
"small_salary %>%
group_by(Degree) %>%
summarize(mean = mean(Salary))" %>%
datamation_sanddance() %>%
save_html("small_salary.html") will output the datamation into a file called Hope that helps for now! Saving to |
@giorgi-ghviniashvili will follow up with gemini to ask if there's a way to do this without having to manually screenshot videos. if it's not supported in any way, one idea would be to monitor the part of the DOM that contains the datamation for changes and grab a snapshot of each rendered frame to a png or jpeg, then stitch to a gif. |
Just thinking, it would probably be helpful to even be able to export each of the frames individually, so that they can e.g. be laid out all together on a page or gif'd together really slowly, even without considering the animations! |
@sharlagelfand yes, that would be useful, but for the gif we will need intermediate screenshots I think. |
Yes definitely @giorgi-ghviniashvili - but leaving the GIF out of it, each "step" is a valid vega lite spec that we could output |
neat idea on grabbing each frame as a vegalite spec. if possible that would be pretty neat / cool. if not, then maybe an approach like these? https://observablehq.com/@mbostock/canvas-to-gif or one of the alternatives here? https://github.com/veltman/gifs |
Sounds like we might be headed towards 3 different ways of outputting things:
|
@jhofman btw, vega-lite has this details popup which is able to export visualization as png or svg. I hid it because it will not work properly when we hack facets. But it just works when there is |
I made a solution that will just download all frames as pngs. This will also work for hacked facets. export.mov |
Awesome! Note: the gemini editor has an export as GIF button, perhaps we can learn something about how it works? |
Is there a way to render and save the GIF within an R script by "hiding" the viewer window or something like that? |
this might be trickier than we thought. @giorgi-ghviniashvili will check if there's a way to generate the gif from a node command line script or equivalent (could require a headless browser, which would be complicated.) if it's really tricky we put this on the back burner. |
it's great that this is working. now we have to decide the interface to exporting a GIF. it relies on having a running page somewhere that puppeteer connects to and runs the it seems there are two basic use cases. one where you're in R or Python and want to save what you're doing, and another where you're at the command line, potentially. thinking about the first use case, it could be that the use runs datamations in R and gets a result in the Viewer window, and then puppeteer connects to that local server to grab the GIF. let's push this decision off a week or two once we're back into R development. p.s. also, the GIFs are rendering a bit fast so we need to adjust the number of frames. |
@giorgi-ghviniashvili, let's try this: a command line node tool that has the following interface:
then we can call this from the R side with a |
@giorgi-ghviniashvili, once the big PR is done, can you see if you can get the "export gif" button into the web version? |
@jhofman I made this work. PR is not merged yet, and I think I will have this as part of PR as well. This animation.gif is exported. |
done as of #146 |
Thanks for the work on this library, it looks really cool and I am looking forward to incorporating it in my data viz teaching!
I am wondering if there are any options to redirect the output to a file programatically, either
.html
or.gif
would work great for my purposes.The text was updated successfully, but these errors were encountered: