Skip to content

Commit 4d501d6

Browse files
Added option to specify output resolution in PRISMA_save()
1 parent 9b9ae58 commit 4d501d6

3 files changed

Lines changed: 60 additions & 15 deletions

File tree

R/PRISMA_flowdiagram.R

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ PRISMA_flowdiagram <- function( #nolint
234234
} else {
235235
cond_citation <- ""
236236
}
237-
other_excluded_data <- PRISMA_format_reasons_(other_excluded)
237+
other_excluded_data <- PRISMA_format_reasons_(other_excluded) #nolint
238238
# labels
239239
other_identified_label <- paste0(
240240
"Records identified from:",
@@ -302,13 +302,13 @@ PRISMA_flowdiagram <- function( #nolint
302302
cond_newreports <- ""
303303
}
304304
if (detail_databases == TRUE) {
305-
db_specific_data <- PRISMA_format_reasons_(database_specific_results)
305+
db_specific_data <- PRISMA_format_reasons_(database_specific_results) #nolint
306306
} else {
307307
db_specific_data <- ""
308308
db_specific_data_nr <- ""
309309
}
310310
if (detail_registers == TRUE) {
311-
reg_specific_data <- PRISMA_format_reasons_(register_specific_results)
311+
reg_specific_data <- PRISMA_format_reasons_(register_specific_results) #nolint
312312
} else {
313313
reg_specific_data <- ""
314314
reg_specific_data_nr <- ""
@@ -329,7 +329,7 @@ PRISMA_flowdiagram <- function( #nolint
329329
} else {
330330
cond_register <- paste0("", reg_specific_data_nr)
331331
}
332-
dbr_excluded_data <- PRISMA_format_reasons_(dbr_excluded)
332+
dbr_excluded_data <- PRISMA_format_reasons_(dbr_excluded) #nolint
333333
if (is.na(duplicates) == FALSE) {
334334
cond_duplicates <- paste0(
335335
stringr::str_wrap(
@@ -1194,14 +1194,14 @@ PRISMA_data <- function(data) { #nolint
11941194
]$n
11951195
)
11961196
)
1197-
database_specific_results <- PRISMA_parse_reasons_(data[
1197+
database_specific_results <- PRISMA_parse_reasons_(data[ #nolint
11981198
grep(
11991199
"database_specific_results",
12001200
data[, 1]
12011201
),
12021202
]$n
12031203
)
1204-
register_specific_results <- PRISMA_parse_reasons_(data[
1204+
register_specific_results <- PRISMA_parse_reasons_(data[ #nolint
12051205
grep(
12061206
"register_specific_results",
12071207
data[, 1]
@@ -1338,7 +1338,7 @@ PRISMA_data <- function(data) { #nolint
13381338
]$n
13391339
)
13401340
)
1341-
dbr_excluded <- PRISMA_parse_reasons_(data[
1341+
dbr_excluded <- PRISMA_parse_reasons_(data[ #nolint
13421342
grep(
13431343
"dbr_excluded",
13441344
data[, 1]
@@ -1355,7 +1355,7 @@ PRISMA_data <- function(data) { #nolint
13551355
]$n
13561356
)
13571357
)
1358-
other_excluded <- PRISMA_parse_reasons_(data[
1358+
other_excluded <- PRISMA_parse_reasons_(data[ #nolint
13591359
grep(
13601360
"other_excluded",
13611361
data[, 1]
@@ -1555,6 +1555,12 @@ PRISMA_data <- function(data) { #nolint
15551555
#' alongside supporting javascript and css files in an adjacent folder,
15561556
#' instead of embedded base64 within the HTML file
15571557
#' @param overwrite if TRUE, will overwrite an existing file
1558+
#' @param width passed as the width argument to
1559+
#' [rsvg::rsvg()] and similar functions
1560+
#' @param height passed as the height argument to
1561+
#' [rsvg::rsvg()] and similar functions
1562+
#' @param css passed as the css argument to
1563+
#' [rsvg::rsvg()] and similar functions
15581564
#' @return the absolute filename of the saved diagram plot.
15591565
#' @examples
15601566
#' csvFile <- system.file("extdata", "PRISMA.csv", package = "PRISMA2020")
@@ -1571,7 +1577,10 @@ PRISMA_save <- function( #nolint
15711577
plotobj,
15721578
filename = "PRISMA2020_flowdiagram.html",
15731579
filetype = NA,
1574-
overwrite = FALSE
1580+
overwrite = FALSE,
1581+
width = NULL,
1582+
height = NULL,
1583+
css = NULL
15751584
) {
15761585
if (!file.exists(filename) || overwrite == TRUE) {
15771586
format_real <- PRISMA_calc_filetype_(filename, filetype) #nolint
@@ -1622,12 +1631,24 @@ PRISMA_save <- function( #nolint
16221631
},
16231632
"PDF" = {
16241633
tmp_svg <- PRISMA_gen_tmp_svg_(plotobj) #nolint
1625-
rsvg::rsvg_pdf(tmp_svg, filename)
1634+
rsvg::rsvg_pdf(
1635+
tmp_svg,
1636+
filename,
1637+
width = width,
1638+
height = height,
1639+
css = css
1640+
)
16261641
file.remove(tmp_svg)
16271642
},
16281643
"PNG" = {
16291644
tmp_svg <- PRISMA_gen_tmp_svg_(plotobj) #nolint
1630-
rsvg::rsvg_png(tmp_svg, filename)
1645+
rsvg::rsvg_png(
1646+
tmp_svg,
1647+
filename,
1648+
width = width,
1649+
height = height,
1650+
css = css
1651+
)
16311652
file.remove(tmp_svg)
16321653
},
16331654
"SVG" = {
@@ -1639,12 +1660,24 @@ PRISMA_save <- function( #nolint
16391660
},
16401661
"PS" = {
16411662
tmp_svg <- PRISMA_gen_tmp_svg_(plotobj) #nolint
1642-
rsvg::rsvg_ps(tmp_svg, filename)
1663+
rsvg::rsvg_ps(
1664+
tmp_svg,
1665+
filename,
1666+
width = width,
1667+
height = height,
1668+
css = css
1669+
)
16431670
file.remove(tmp_svg)
16441671
},
16451672
"WEBP" = {
16461673
tmp_svg <- PRISMA_gen_tmp_svg_(plotobj) #nolint
1647-
rsvg::rsvg_webp(tmp_svg, filename)
1674+
rsvg::rsvg_webp(
1675+
tmp_svg,
1676+
filename,
1677+
width = width,
1678+
height = height,
1679+
css = css
1680+
)
16481681
file.remove(tmp_svg)
16491682
},
16501683
stop("Please choose one of the supported file types")

inst/shiny-examples/PRISMA_flowdiagram/app.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ ui <- tagList( #nolint
380380
)
381381

382382
# Define server logic required to draw a histogram
383-
server <- function(input, output, session) {
383+
server <- function(input, output, session) { #nolint
384384
# Define reactive values
385385
rv <- shiny::reactiveValues()
386386
# Data Handling ----

man/PRISMA_save.Rd

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)