vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
210 stars 18 forks source link

`plot_tt()` and self-contained HTML #340

Closed J-Moravec closed 1 month ago

J-Moravec commented 1 month ago

User story

I made a nice overview table in a HTML format for my data with one column being a column of images, that is amazing!

I wanted to share the HTML. Well I can't, since I need to also send the folder with all the images.

This makes sharing the table quite a bit more complicated.

Problem

Currently, when HTML output is produced (tt(x) |> save_tt("file.html")), the images are linked in the HTML file. Ideally, save_tt() would have option for a self-contained HTML, a HTML where the images are included directly within the HTML file in a base64 encoding.

vincentarelbundock commented 1 month ago

You can save the table to PNG already. Does that not meet the requirements?

J-Moravec commented 1 month ago

No. PNG is not really format I would consider. Normally I would go for PDF, but tinytable requires quite a lot of fiddling with additional LaTeX dependencies, so I chose a self-contained HTML as an alternative, since HTML is nowadays used for this purpose anyway.

I assume that if I added the table as part of rmarkdown document, knitr or quarto would be able to create a self-contained document. But really, all I have is (a rather nice looking) table, currently I don't need any additional information.

I solved this with regexp anyway, but I would consider self-containing (or what is the correct term) a standard for shareable documents and sadly tinytable is lacking this feature at this moment.

I noticed that there are some stumps left in the code using base64encode, which I used as part of my solution.

vincentarelbundock commented 1 month ago

Got it, thanks.

I'm not sure how to embed plot_tt() images in a Quarto self contained HTML, and I don't currently have the time to investigate.

That said, I think this sounds like a good feature request, and I would be happy to review a code contribution if someone wants to make one.

If that doesn't happen, I may circle back to this eventually.

J-Moravec commented 1 month ago

Note, I am not using quarto in this case, all I do is tt(...) |> save_tt("test.html") within a simple Rscript. So the renamed title is misnomer.

vincentarelbundock commented 1 month ago

Ah yeah, sorry. I edited the title.

J-Moravec commented 1 month ago

Solved by #341