canva-public / flourishcharts

Interactive data visualization Python and R packages for data scientists.
20 stars 1 forks source link

Feature request: exporting Flourish graphs to Canva/Flourish/Office #8

Open zmeers opened 1 week ago

zmeers commented 1 week ago

I would love the ability to write Flourish graphs from R & Python to:

Just putting in a feature request for this. 🙏🏻

luptilu commented 1 week ago

100%, this is coming up loads with Flourish customers too!

zmeers commented 1 week ago

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.

zmeers commented 1 week ago

For additional context as to why I'd find this useful. At my new workplace, the research function kind of works like this:

  1. We do our analyses in R, Python, Julia, Observable etc.
  2. Then write a data-driven report with lots of tables & graphs in (R or Quarto) Markdown which is rendered to Word & Powerpoint.
  3. Additional non-data people add suggestions in Word & PPT; we then make final edits to written content there.
  4. The marketing team takes PPT content (graphs etc), recreating them in Canva charts (transcribing the data into the Canva data panel etc).

I just feel like there are quite a few ways to make this process more efficient, but it's not quite there yet.