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

Problem with reactable table when knitting with chrome_print #222

Open
maibennett opened this issue Apr 14, 2021 · 2 comments
Open

Problem with reactable table when knitting with chrome_print #222

maibennett opened this issue Apr 14, 2021 · 2 comments
Labels
duplicate already another issue about this

Comments

@maibennett
Copy link

Hi,

I had an issue when trying to knit a reactable table using chrome_print. For some reason, when I don't include LaTeX code, the reactable table doesn't show up in the PDF, but if I do, then it actually shows up.

Here's a simple reproducible code, if it's useful:

  1. This is the code that works:
---
title: "Example for reactable"
author: "maibennett"
date: "April 14th, 2021"
output:
  pagedown::html_paged:
    toc: no
    number_sections: no
paged-footnotes: true 
knit: pagedown::chrome_print
---

```{r setup, warning=FALSE, message=FALSE, echo=FALSE}
library(tidyverse)
library(reactable)
library(htmltools)
```

$$\text{Including this, works}$$

```{r, echo = FALSE, message=FALSE, warning=FALSE}

data(USArrests)
   
USArrests_s <- USArrests %>% dplyr::filter(rownames(.)=="Alabama" | rownames(.)=="Alaska")

tbl <- USArrests_s %>%
  reactable(
    pagination = TRUE,
    rownames = FALSE,
    defaultColDef = colDef(
      align = "center",
      minWidth = 90)
    
  )

div(
    class = "title",
    h3("This is a table"),
  tbl
)

```
  1. This code doesn't show the reactable table:
---
title: "Example for reactable"
author: "maibennett"
date: "April 14th, 2021"
output:
  pagedown::html_paged:
    toc: no
    number_sections: no
paged-footnotes: true 
knit: pagedown::chrome_print
---

```{r setup, warning=FALSE, message=FALSE, echo=FALSE}
library(tidyverse)
library(reactable)
library(htmltools)
```

```{r, echo = FALSE, message=FALSE, warning=FALSE}

data(USArrests)
   
USArrests_s <- USArrests %>% dplyr::filter(rownames(.)=="Alabama" | rownames(.)=="Alaska")

tbl <- USArrests_s %>%
  reactable(
    pagination = TRUE,
    rownames = FALSE,
    defaultColDef = colDef(
      align = "center",
      minWidth = 90)
    
  )

div(
    class = "title",
    h3("This is a table"),
  tbl
)
```

I've included both PDFs outputs. If anyone has an idea of why this might be, I'd really appreciate it! Thanks.
reactable_example2.pdf
reactable_example1.pdf

@RLesur
Copy link
Collaborator

RLesur commented Apr 15, 2021

Hi @maibennett,

Thanks for the report!

The reactable package is not yet supported by html_paged() as any other HTML widget (see #58) but we have a candidate solution (see #87) that we will merge soon.

There are many challenges to solve with HTML widgets. One of them is the synchronization between the HTML widgets and Paged.js (Paged.js must run after the widgets are rendered). We have the same synchronisation puzzle to solve for any JavaScript library.
For instance, pagedown synchronizes well MathJax and Paged.js: equations are rendered before Paged.js starts.

Your working example is really interesting because using maths, it indirectly synchronizes the HTML widget with Paged.js (the widget is rendered before MathJax and Paged.js waits for MathJax): this is an undocumented positive side effect 😄

@maibennett
Copy link
Author

Thanks! It's great to know at least why this happened 😄 (and thanks for all the work in this great package!)

@RLesur RLesur added the duplicate already another issue about this label Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate already another issue about this
Projects
None yet
Development

No branches or pull requests

2 participants