Skip to content

Commit

Permalink
refact(data-viz): rearrange UI
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendiot42 committed Sep 24, 2024
1 parent 0674255 commit 6abdd34
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
54 changes: 32 additions & 22 deletions src/fun/func_data-viz.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,30 @@ none_value <- "-- None --"
data_viz_ui <- function(id) {
ns <- NS(id)
div(
div(
selectInput(ns("x_var"),
"X variable",
choices = list(none_value),
multiple = FALSE
),
selectInput(ns("y_var"),
"Y variable",
choices = list(none_value),
multiple = FALSE
div(style = "display: flex;",
div(style = "flex: 0;",
selectInput(ns("x_var"),
"X variable",
choices = list(none_value),
multiple = FALSE
),

selectInput(ns("y_var"),
"Y variable",
choices = list(none_value),
multiple = FALSE
),
selectInput(ns("col_var"),
"Color variable",
choices = list(none_value),
multiple = FALSE
)
),
selectInput(ns("col_var"),
"Color variable",
choices = list(none_value),
multiple = FALSE
div(style = "flex: 1;",
plotlyOutput(ns("plot"))
)
),
div(
plotlyOutput(ns("plot"))
),
hr(),
div(style = "margin-top: 30px;",
dataTableOutput(ns("dataTable"))
)
Expand Down Expand Up @@ -91,13 +95,19 @@ data_viz_server <- function(id, plot_data) {
})

output$dataTable <- renderDataTable({
DT::datatable(plot_data(),
filter = "top",
data <- plot_data()
filter <- "top"
if (is.null(data)) {
data <- data.frame(`Variable` = numeric())
filter <- "none"
}
DT::datatable(data,
filter = filter,
style = "bootstrap4",
options = list(
pageLength = 20,
lengthMenu = c(10, 20, 50, 100),
sDom = '<"top"f>rt<"bottom"lp><"clear">'
language = list(emptyTable = 'Empty'),
pageLength = 10,
lengthMenu = c(10, 25, 50, 100)
)
)
})
Expand Down
28 changes: 17 additions & 11 deletions src/ui/ui_data-viz_loggedIn.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,30 @@ list(
width = 12, title = "Data Visualisation", id = "data-viz", side = "left", selected = "From file",
tabPanel(
"From file",
div(
div(style = "",
h4("Import file"),
fileInput(
inputId = "file_data_viz",
label = NULL,
multiple = FALSE,
accept = c(".txt", ".tsv", ".txt.gz")
accept = c(".txt", ".tsv", ".txt.gz"),
width = "100%"
),
div(style = "display: inline-block; vertical-align: top; margin-right: 10px;",
selectInput("categ_variables",
"Categorical variables",
choices = list("var 1", "var 2", "var 3"),
multiple = TRUE
)
),
selectInput("quant_variables",
"Quantitative variables",
choices = list("None","var 1", "var 2", "var 3"),
multiple = TRUE
div(style = "display: inline-block; vertical-align: top;",
selectInput("quant_variables",
"Quantitative variables",
choices = list("None","var 1", "var 2", "var 3"),
multiple = TRUE
)
),
selectInput("categ_variables",
"Categorical variables",
choices = list("var 1", "var 2", "var 3"),
multiple = TRUE
)
hr()
),
div(
data_viz_ui("data-viz_file")
Expand Down

0 comments on commit 6abdd34

Please sign in to comment.