diff --git a/src/fun/func_data-viz.R b/src/fun/func_data-viz.R index fb4b101..721f734 100644 --- a/src/fun/func_data-viz.R +++ b/src/fun/func_data-viz.R @@ -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")) ) @@ -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) ) ) }) diff --git a/src/ui/ui_data-viz_loggedIn.R b/src/ui/ui_data-viz_loggedIn.R index 6f3f38d..bf6ab23 100644 --- a/src/ui/ui_data-viz_loggedIn.R +++ b/src/ui/ui_data-viz_loggedIn.R @@ -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")