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

theme_animint(rowspan, colspan, last_in_row) #153

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tdhock
Copy link
Collaborator

@tdhock tdhock commented Oct 8, 2024

closes #115

this proposal supersedes #139 which should be closed if this PR is sufficient.

The idea is to define three new plot attributes, to be specified inside theme_animint

  • rowspan=2 means plot takes up two rows (default=1)
  • colspan=2 means plot takes up two columns (default=1)
  • last_in_row=TRUE means this plot ends a row, HTML <tr> element. (default=FALSE)

the R code compiler needs to save these as attributes of the corresponding plot list.

For example

animint(
  ggplot()+theme_animint(rowspan=2)+ggtitle("first td in first tr, rowspan=2"),
  ggplot()+theme_animint(last_in_row=TRUE)+ggtitle("second td in first tr"),
  ggplot()+ggtitle("first td in second tr")
)

should make HTML like below
image

if any of these three attributes are specified in any of the ggplots, then the renderer JavaScript code puts the plot in the corresponding tr and td of the "outer table," according to the following rules:

  • we create a new <tr> before the first plot, and after every plot with last_in_row=TRUE
  • for every plot, we create a new <td> inside the current <tr>

There is no need for computing the total/max number of rows/columns.

@siddhesh195 please consider this PR and if you agree, close the other PR, and move any relevant code to this branch (compiler R code, tests, etc).

@tdhock tdhock mentioned this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

layout ggplots in a table
2 participants