Open zmeers opened 1 week ago
100%, this is coming up loads with Flourish customers too!
Thinking about this some more for writing from R/Python -> Microsoft products.
If there is the ability to take screenshots via Flourish API in R & Python, you could write a wrapper function that uses those functions to save the screenshot to a temporary file, then load the temporary file back into the file so that the screenshot renders in the compiled Word/PPT document, not the interactive graph.
# create a flourish graph
scatterplot = flourish("scatter") |> bind_scatter_data(data = df, ...)
# lets say you have a function called `snapshot_graph()` that will save the snapshot to a file
# wrap that in another function and add to the package - could look something like this
print_static_graph <- function(graph, file_extension){
tmp_file <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = file_extension)
snapshot_graph(graph, file_ext = file_extension, file_path = tmp_file)
include_graphics(tmp_file)
unlink(tmp_file)
}
So for the end R/Python user it'd look like:
scatterplot = flourish("scatter") |> bind_scatter_data(data = df, ...)
print_static_graph(scatterplot, "png")
Something like that! Then when they compile the R/Python file to Word or PPT, it would render as a static snapshot/image.
For additional context as to why I'd find this useful. At my new workplace, the research function kind of works like this:
I just feel like there are quite a few ways to make this process more efficient, but it's not quite there yet.
I would love the ability to write Flourish graphs from R & Python to:
Just putting in a feature request for this. 🙏🏻