Skip to content
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

[Feature Request]: Nicer table formatting in PPT outputs #185

Closed
Tracked by #4
lcd2yyz opened this issue Apr 22, 2023 · 14 comments · Fixed by #211
Closed
Tracked by #4

[Feature Request]: Nicer table formatting in PPT outputs #185

lcd2yyz opened this issue Apr 22, 2023 · 14 comments · Fixed by #211

Comments

@lcd2yyz
Copy link

lcd2yyz commented Apr 22, 2023

Users report that slides generated from Teal apps at the moment are not really ready-to-use.
Examples attached input_20230317191236450.pptx

Table from ppt generated by teal app at default
image

Table from ppt generated by teal app after dramatically reducing for font size
image

Notable issues include

  • Weird default fontsize
  • Table formatting is not as nice as shown in teal app
  • Table is in the printed text format, difficult to make any additional manipulation or formatting

User wants to see

  • Expecting to see table in slides formatted similarly to how it's displayed in teal app
  • Table contents in slides should be easily editable (eg. adjust column width, change styling of content, removing selective contents)
  • Ideally enable reasonable pagination

Suggestion - should look towards Roche internal package called autoslideR for inspiration and potential solutions

@chlebowa
Copy link
Contributor

chlebowa commented Aug 3, 2023

Acceptance criteria:

Research the autoslideR package (Roche internal),m it can probably solve the complicated requirements like exporting a table (not text) etc..
Explore other solutions if necessary.

Ensure font sizes in reports are more suitable.

@chlebowa
Copy link
Contributor

chlebowa commented Aug 3, 2023

NOTE: Feel free to separate into 2 issues if research and implementation are too much.

@puzeng
Copy link

puzeng commented Aug 25, 2023

Is there a consideration about converting into flextable object and work from there for nicer formats?

@kartikeyakirar
Copy link
Contributor

I'm having difficulty finding the autoslideR package. Could someone please provide assistance in locating this package?

@lcd2yyz
Copy link
Author

lcd2yyz commented Aug 28, 2023

I'm having difficulty finding the autoslideR package. Could someone please provide assistance in locating this package?

@kartikeyakirar Package is located in internal repos and not yet published externally. I will share link privately.

@kartikeyakirar
Copy link
Contributor

Hey @donyunardi and @lcd2yyz

In autoslideR there custom color-based theme for flextable, which isn't exactly the same as what's displayed on the dashboard but does enhance the overall look for reporting purposes. We'd like your input on whether we should include this theme or stick with the simpler format shown on the dashboard.

Dashboard
Screenshot 2023-09-07 at 7 22 17 PM

Report after flextable addition
Screenshot 2023-09-07 at 7 23 27 PM

Blue Theme from autoslideR:
Screenshot 2023-09-07 at 7 24 26 PM

OrangeTheme from autoslideR:
Screenshot 2023-09-07 at 7 25 07 PM

@donyunardi
Copy link
Contributor

Personally, I would like to keep the format as simple as possible. I believe that coloring is a matter of personal preference, and users can change it themselves later if they wish.

On the simple format shown in the dashboard, can we add an outer border and a horizontal line in the inner output? I was reading about flextable, and it looks like we can do something like this:
https://ardata-fr.github.io/flextable-book/define-visual-properties.html#add-lines

If we can, then I think it will further improve the looks when we keep it simple.

@lcd2yyz
Copy link
Author

lcd2yyz commented Sep 8, 2023

Agree with @donyunardi to keep it simple.
And from above website, my preference is to use the theme_booktabs() as default. This has the closest resemblance to the formal reporting we deliver from clinical data analysis.

@kartikeyakirar
Copy link
Contributor

kartikeyakirar commented Sep 8, 2023

@lcd2yyz and @donyunardi, I appreciate your valuable feedback. I have implemented some changes using theme_booktabs(), including the addition of borders and horizontal lines. You can see the updated format in this image:
image

Furthermore, I've introduced an additional issue/feature request as an extension to the one we discussed earlier. You can find more details here: #212

@lcd2yyz
Copy link
Author

lcd2yyz commented Sep 8, 2023

Looking very nice!
Are you able to test if outputted in .ppt or .docx, is the table fully editable? eg. able to adjust columns, add/delete rows/columns easily, etc.

@kartikeyakirar
Copy link
Contributor

Are you able to test if outputted in .ppt or .docx, is the table fully editable?

Flextables can be fully edited in both PowerPoint and document formats.

Screen.Recording.2023-09-09.at.12.15.23.AM.mov

@puzeng
Copy link

puzeng commented Sep 9, 2023

Are you able to test if outputted in .ppt or .docx, is the table fully editable?

Flextables can be fully edited in both PowerPoint and document formats.

Screen.Recording.2023-09-09.at.12.15.23.AM.mov

It's wonderful to see this change as user from study team who wants to use this feature for future slides preparation! I did a similar way to allow the tables as shown as flextable by only altering in Renderer.R:
tableBlock2md = function(block) { basename_table <- basename(block$get_content()) file.copy(block$get_content(), file.path(private$output_dir, basename_table)) sprintf("```{r echo = FALSE, message = FALSE, ft.left = 0.3, ft.top = 1} \n flextable::autofit(flextable::fontsize(flextable::fontsize(rtables::tt_to_flextable(readRDS('%s')), size = 6, part = 'body'), size = 8, part = 'header')) \n```", basename_table) }
@kartikeyakirar Your codes seemed to provide more flexibility in terms of fitting. Just a tiny curiosity here, did you also test in table with long length? Typically, table of adverse events by preferred terms could be very long. Primarily here, I'm trying to image how zooming-out works on the long tables. I guess pagination could be the next feature to consider.

@kartikeyakirar
Copy link
Contributor

kartikeyakirar commented Sep 11, 2023

did you also test in table with long length? Typically, table of adverse events by preferred terms could be very long.

@puzeng Accommodating a very lengthy table within a single slide is extremely challenging , and it's nearly impossible to adjust such a substantial amount of content in a single slide. Manual editing may be helpful in certain scenarios.

Here is the table: table_20230911_114923.pdf. This is a demonstration of how this content is displayed in a slide

Screen.Recording.2023-09-11.at.11.55.27.AM.mov

@lcd2yyz
Copy link
Author

lcd2yyz commented Sep 11, 2023

Hi @puzeng, I agree with @kartikeyakirar that enabling pagination will be quite challenging at this point, given that teal.reporter needs to accommodate more than just .ppt, but also various other output format including html (which should not need pagination), word/pdf (which probably will need different rules for pagination) compared to ppt.
Also I imagine how user want to split the pages may be quite different. For example, maybe for some sections, only want to display 10 rows per this page, and use the rest of the space to add annotation/explanation text, but for other sections, want to display as many rows as possible, to simply display the statistics. In such scenario it might be easier to split the tables rather than merge/combine two already split tables, if it will involve manual work anyways.

If you still feel strongly about this feature, please open an new issue, with your suggested approach and/or example code, if you already have it. Then we'll consider for future development.

kartikeyakirar added a commit that referenced this issue Sep 19, 2023
this PR fixes
#185

Inspired by autoslidR, I have integrated flextable functionality to
convert "data.frame," "rtables," "TableTree," and "ElementaryTable" into
flextable, which offers a more accurate representation. In this context,
I have enhanced the TableBlock to facilitate the conversion of tables
into flextable.


Output screenshot
<img width="1358" alt="Screenshot 2023-09-08 at 7 20 48 PM"
src="https://github.com/insightsengineering/teal.reporter/assets/6700955/cde22fa1-3081-4ce9-84d5-d700a30b7749">

---------

Signed-off-by: kartikeya kirar <kirar.kartikeya1@gmail.com>
Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
Co-authored-by: kartikeya <kartikeya.kirar@unicle.life>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants