-
Notifications
You must be signed in to change notification settings - Fork 26
theme_animint(rowspan, colspan, last_in_row) #153
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
Open
tdhock
wants to merge
21
commits into
master
Choose a base branch
from
rowspan-colspan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+121
−16
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
b427622
sketch of implementation
tdhock 4337e15
row col span from p_info
tdhock 0707c2d
making_outer_table true or false
tdhock 7f54fc3
made variable local, passed making_outer_table in add_plot
siddhesh195 898755d
Merge branch 'master' into rowspan-colspan
siddhesh195 2bb97e8
Add support for rowspan and colspan attributes in plot rendering, ad…
biplab-sutradhar 3edcaea
Refactor tests, undo file
biplab-sutradhar 4b0b033
Merge branch 'master' of https://github.com/animint/animint2 into row…
biplab-sutradhar bb00daa
Enhance rowspan and colspan handling in layout
biplab-sutradhar d6abf07
Refactor plot addition logic to simplify row and column handling
biplab-sutradhar de4a59b
refactor plot rendering
biplab-sutradhar d6945c0
undo code
biplab-sutradhar fa96c0b
Refactor plot logic and test
biplab-sutradhar 57c5559
Refactor tests for rowspan handling and add new test cases for plot l…
biplab-sutradhar 319af67
Refactor code for spaces indentation
biplab-sutradhar e2f4105
fixed spacing
biplab-sutradhar e8a23dd
Refactor theme option extraction into one reusable helper function
biplab-sutradhar 40ae9dd
Merge branch 'master' of https://github.com/animint/animint2 into row…
biplab-sutradhar 2110323
sync master
biplab-sutradhar 27f58e7
remove redundant add_legend call
biplab-sutradhar 0d15e7e
undo spaces
biplab-sutradhar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
test_that("HTML layout includes rowspan and colspan attributes", { | ||
|
||
base_data <- data.frame(x = 1:3, y = c(2, 4, 6)) | ||
|
||
plot_list <- list( | ||
LargeLeftPanel = ggplot(base_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("Left Side Large") + | ||
theme_animint(rowspan = 2, colspan = 1), | ||
TopRight = ggplot(base_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("Top Right") + | ||
theme_animint(last_in_row = TRUE), | ||
BottomRight = ggplot(base_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("Bottom Right") + | ||
theme_animint(last_in_row = TRUE), | ||
FooterLeft = ggplot(base_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("Footer Left"), | ||
FooterMiddle = ggplot(base_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("Footer Middle"), | ||
FooterRight = ggplot(base_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("Footer Right") + | ||
theme_animint( last_in_row = TRUE) + | ||
theme_animint(colspan = 2) | ||
) | ||
|
||
info <- animint2HTML(plot_list) | ||
html <- info$html | ||
|
||
all_plot_tables <- getNodeSet(html, "//table[@style='display: inline-block;']") | ||
expect_equal(length(all_plot_tables), 6) | ||
|
||
td_with_rowspan <- getNodeSet(html, "//td[@rowspan]") | ||
rowspan_values <- sapply(td_with_rowspan, xmlGetAttr, "rowspan") | ||
expect_true(any(rowspan_values == "2"), info = "Expect one or more cells with rowspan=2") | ||
|
||
td_with_colspan <- getNodeSet(html, "//td[@colspan]") | ||
colspan_values <- sapply(td_with_colspan, xmlGetAttr, "colspan") | ||
expect_true(any(colspan_values == "2"), info = "Expect one or more cells with colspan=2") | ||
|
||
html_lines <- XML::saveXML(html) | ||
expect_true(any(grepl("Left Side Large", html_lines))) | ||
expect_true(any(grepl("Footer Right", html_lines))) | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
test_that("Simple rowspan layout works", { | ||
plot_data <- data.frame(x = 1:3, y = c(2, 4, 6)) | ||
|
||
plot_collection <- list( | ||
LeftPlot = ggplot(plot_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("left_plot") + | ||
theme_animint(rowspan = 2), | ||
TopRightPlot = ggplot(plot_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("top_right_plot") + | ||
theme_animint(last_in_row = TRUE), | ||
BottomRightPlot = ggplot(plot_data, aes(x, y)) + | ||
geom_point() + | ||
ggtitle("bottom_right_plot") | ||
) | ||
|
||
html <- animint2HTML(plot_collection)$html | ||
|
||
# 3 plot tables should be rendered | ||
tables <- getNodeSet(html, "//table[@style='display: inline-block;']") | ||
expect_equal(length(tables), 3) | ||
|
||
# Check that at least one cell has rowspan=2 | ||
rowspan_cells <- getNodeSet(html, "//td[@rowspan='2']") | ||
expect_true(length(rowspan_cells) >= 1) | ||
|
||
# Check that plot titles appear in HTML | ||
html_text <- saveXML(html) | ||
expect_true(grepl("left_plot", html_text)) | ||
expect_true(grepl("top_right_plot", html_text)) | ||
expect_true(grepl("bottom_right_plot", html_text)) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be a copy of getWidthAndHeight in z_animintHelpers.R
which is used in parsePlot() in z_animint.R:
please refactor your additions to avoid duplicated logic with this existing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in getWidthAndHeight function extract c("width", "height"); in theme_attribute extract c("rowspan", "colspan", "last_in_row")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I create a single function to prevent logic duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please