Skip to content

Commit

Permalink
add check_package() and move shiny to suggests
Browse files Browse the repository at this point in the history
  • Loading branch information
gaospecial committed Dec 21, 2023
1 parent 067df9c commit 7c7dca2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ Imports:
tibble,
aplot,
forcats,
tidyr,
shiny
tidyr
URL: https://github.com/gaospecial/ggVennDiagram, https://gaospecial.github.io/ggVennDiagram/
License: GPL-3
Encoding: UTF-8
Expand All @@ -40,6 +39,7 @@ Suggests:
knitr,
rmarkdown,
venn,
RColorBrewer
RColorBrewer,
shiny
VignetteBuilder: knitr
LazyData: true
8 changes: 8 additions & 0 deletions R/check_pakage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
check_package = function(package = "ggVennDiagram"){
if (!requireNamespace(package, quietly = TRUE)){
stop(paste("The", package, "package is not found in your library paths.",
" It is required to show intersections interactively.",
" Please run `install.packages('package')` and retry.",
collapse = "\n"))
}
}
13 changes: 1 addition & 12 deletions R/ggVennDiagram.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ plot_venn = function(data,

# use plotly to show intersect
if (show_intersect){
check_plotly()
check_package("plotly")
region_label = region_label |>
dplyr::rowwise() |>
dplyr::mutate(item = str_wrap(paste0(.data$item, collapse = " "),
Expand Down Expand Up @@ -202,17 +202,6 @@ plot_venn = function(data,

}


check_plotly = function(){
if (!requireNamespace("plotly", quietly = TRUE)){
stop(paste("The plotly package is not found in your library paths.",
" It is required to show intersections interactively.",
" Please run `install.packages('plotly')` and retry.",
collapse = "\n"))
}
}


# from yulab.utils::str_wrap
str_wrap = function (string, width = getOption("width")){
result <- vapply(string, FUN = function(st) {
Expand Down
3 changes: 2 additions & 1 deletion R/launch_app.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
#' @return a shiny app
#' @export
launch_app = function(){
check_package("shiny")
app = system.file(
"shiny",
"shinyApp.R",
package = "ggVennDiagram",
mustWork = TRUE
)
shiny::runApp(app)
if(interactive()) shiny::runApp(app)
}
13 changes: 7 additions & 6 deletions inst/shiny/shinyApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ui = fluidPage(
actionButton(
inputId = "increase_btn",
label = "increase the no. of set",
icon = icon("caret-up")
icon = icon("caret-up"),
align = "right"
),

hr(),
Expand Down Expand Up @@ -90,11 +91,11 @@ server = function(input, output, session){
# initialize plot note
output$plot_note = renderUI({
tagList(
h3("Steps"),
p("1. Use the button or slider to set the no. of sets."),
p("2. Specify set members using comma-sparated strings."),
p("3. Click the <Plot Now!> button."),
p("4. Enjoy and download your publication-quality figures.")
markdown("### Steps"),
markdown("1. Use the button or slider to specify the number of sets."),
markdown("2. Specify set members using comma-sparated strings (just follow the examples)."),
markdown("3. Click the **<Plot Now!>** button."),
markdown("4. Enjoy and download your publication-quality figures.")
)
})

Expand Down

0 comments on commit 7c7dca2

Please sign in to comment.