Skip to content

Commit

Permalink
moved optional option boxes server side
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewelamb committed Oct 7, 2020
1 parent 401789c commit c1cece2
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .Rproj.user/C84B4C12/persistent-state
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build-last-errors="[]"
build-last-errors-base-dir="~/repos/irwg/iatlas.modules/tests/testthat/test-drilldown_scatterplot_server.R/"
build-last-outputs="[{\"type\":0,\"output\":\"==> Testing R file using 'testthat'\\n\\n\"},{\"type\":1,\"output\":\"Loading iatlas.modules\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"✓ | OK \\u001B[31mF\\u001B[39m \\u001B[35mW\\u001B[39m \\u001B[34mS\\u001B[39m | Context\\n\"},{\"type\":1,\"output\":\"\\r⠏ | 0 | drilldown_scatterplot_server\"},{\"type\":1,\"output\":\"\\r⠋ | 1 | drilldown_scatterplot_server\"},{\"type\":1,\"output\":\"\\r⠹ | 3 | drilldown_scatterplot_server\"},{\"type\":1,\"output\":\"\\r⠼ | 5 | drilldown_scatterplot_server\\r\\u001B[32m✓\\u001B[39m | 6 | drilldown_scatterplot_server\\u001B[36m [0.6 s]\\u001B[39m\\n\"},{\"type\":1,\"output\":\"\\n\"},{\"type\":1,\"output\":\"══ \\u001B[1mResults\\u001B[22m ════════════════════════════════════════════════════════\\n\"},{\"type\":1,\"output\":\"\\u001B[36mDuration: 0.6 s\\u001B[39m\\n\"},{\"type\":1,\"output\":\"\\n\"},{\"type\":1,\"output\":\"OK: \\u001B[32m6\\u001B[39m\\n\"},{\"type\":1,\"output\":\"Failed: \\u001B[32m0\\u001B[39m\\n\"},{\"type\":1,\"output\":\"Warnings: \\u001B[32m0\\u001B[39m\\n\"},{\"type\":1,\"output\":\"Skipped: \\u001B[32m0\\u001B[39m\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"\\nTest complete\\n\"}]"
build-last-errors-base-dir=""
build-last-outputs="[]"
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
Expand Down
4 changes: 2 additions & 2 deletions .Rproj.user/C84B4C12/sources/prop/18867B26
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"cursorPosition": "9,10",
"scrollLine": "0"
"cursorPosition": "23,26",
"scrollLine": "15"
}
4 changes: 2 additions & 2 deletions .Rproj.user/C84B4C12/sources/prop/197A3AED
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "9,21",
"scrollLine": "0"
"cursorPosition": "14,56",
"scrollLine": "6"
}
2 changes: 1 addition & 1 deletion .Rproj.user/C84B4C12/sources/prop/65FA481C
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"cursorPosition": "2,0",
"cursorPosition": "14,59",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/C84B4C12/sources/prop/BDF46D78
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "3,22",
"scrollLine": "0"
"scrollLine": "2"
}
2 changes: 1 addition & 1 deletion .Rproj.user/C84B4C12/sources/prop/CD8C21F7
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "22,40",
"cursorPosition": "11,35",
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/C84B4C12/sources/prop/E7F42F0B
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"tempName": "Untitled1",
"cursorPosition": "6,71",
"cursorPosition": "15,2",
"scrollLine": "0"
}
1 change: 0 additions & 1 deletion .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/home/aelamb/repos/irwg/iatlas.modules/R/utils.R="A9482D6C"
/home/aelamb/repos/irwg/iatlas.modules/tests/testthat/test-barplot_server.R="C62B0741"
/home/aelamb/repos/irwg/iatlas.modules/tests/testthat/test-barplot_ui.R="CCBC5799"
/home/aelamb/repos/irwg/iatlas.modules/tests/testthat/test-data_tranformations.R="C2F5581B"
/home/aelamb/repos/irwg/iatlas.modules/tests/testthat/test-drilldown_scatterplot_server.R="7A07AC69"
/home/aelamb/repos/irwg/iatlas.modules/tests/testthat/test-drilldown_scatterplot_ui.R="B4768F5C"
/home/aelamb/repos/irwg/iatlas.modules/tests/testthat/test-plotly_bar.R="B7EA6C24"
Expand Down
18 changes: 13 additions & 5 deletions R/barplot_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param plot_data A shiny::reactive that returns a dataframe with columns
#' "sample", "x", "y", "color"
#' @param group_data A shiny::reactive that returns NULL or a dataframe with
#' columns "feature", "description"
#' columns "group", "description"
#' @param feature_data A shiny::reactive that returns NULL or a dataframe with
#' columns "feature", "class"
#' @param barplot_xlab A shiny::reactive that returns a string
Expand Down Expand Up @@ -34,13 +34,21 @@ barplot_server <- function(
ns <- session$ns

output$feature_class_selection_ui <- shiny::renderUI({

shiny::req(feature_data())
choices <- unique(feature_data()$class)
shiny::req(length(choices) > 1)
shiny::selectInput(
inputId = ns("feature_class_choice"),
label = "Select Feature Class",
choices = choices

optionsBox(
width = 12,
shiny::column(
width = 12,
shiny::selectInput(
inputId = ns("feature_class_choice"),
label = "Select Feature Class",
choices = choices
)
)
)
})

Expand Down
8 changes: 1 addition & 7 deletions R/barplot_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ barplot_ui <- function(id, title = ""){
shiny::tagList(
titleBox(title),
shiny::fluidRow(
optionsBox(
width = 12,
shiny::column(
width = 6,
shiny::uiOutput(ns("feature_class_selection_ui"))
)
),
shiny::uiOutput(ns("feature_class_selection_ui")),
plotBox(
width = 12,
"barplot" %>%
Expand Down
35 changes: 19 additions & 16 deletions R/drilldown_scatterplot_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,28 @@ drilldown_scatterplot_server <- function(
tidyr::pivot_wider(., values_from = "y", names_from = "color")
})

output$x_feature_selection_ui <- shiny::renderUI({
output$feature_selection_ui <- shiny::renderUI({
shiny::req(scatterplot_data())
choices <- colnames(scatterplot_data())[-1]
shiny::req(length(choices) > 1)
shiny::selectInput(
inputId = ns("x_feature_choice"),
label = "Select X Feature",
choices = choices
)
})

output$y_feature_selection_ui <- shiny::renderUI({
shiny::req(scatterplot_data())
choices <- colnames(scatterplot_data())[-1]
shiny::req(length(choices) > 1)
shiny::selectInput(
inputId = ns("y_feature_choice"),
label = "Select Y Feature",
choices = choices
optionsBox(
width = 12,
shiny::column(
width = 6,
shiny::selectInput(
inputId = ns("x_feature_choice"),
label = "Select X Feature",
choices = choices
)
),
shiny::column(
width = 6,
shiny::selectInput(
inputId = ns("y_feature_choice"),
label = "Select Y Feature",
choices = choices
)
)
)
})

Expand Down
12 changes: 1 addition & 11 deletions R/drilldown_scatterplot_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ drilldown_scatterplot_ui <- function(id){
ns <- shiny::NS(id)

shiny::fluidRow(
optionsBox(
width = 12,
shiny::column(
width = 6,
shiny::uiOutput(ns("x_feature_selection_ui"))
),
shiny::column(
width = 6,
shiny::uiOutput(ns("y_feature_selection_ui"))
)
),
shiny::uiOutput(ns("feature_selection_ui")),
plotBox(
width = 12,
"scatterplot" %>%
Expand Down
2 changes: 1 addition & 1 deletion man/barplot_server.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions tests/testthat/test-drilldown_scatterplot_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ test_that("drilldown_scatterplot_server", {
{
expect_equal(selected_group(), "setosa")
expect_type(scatterplot_data(), "list")
expect_type(output$x_feature_selection_ui, "list")
expect_type(output$y_feature_selection_ui, "list")
expect_type(output$feature_selection_ui, "list")
session$setInputs("x_feature_choice" = "Petal.Length")
session$setInputs("y_feature_choice" = "Petal.Width")
expect_type(formatted_scatterplot_data(), "list")
Expand Down

0 comments on commit c1cece2

Please sign in to comment.