inst/easyPlot/ui.R

# ============================= User Interface: ================================

shinyUI(
  tagList(
    shinyjs::useShinyjs(),
    includeCSS("css/easyPlot.css"),
    div(
      id = "loader",
      h2("Loading..."),
      tags$style(type="text/css",
                 ".recalculating {opacity: 1.0;}" ) # No blinking
    ),
    tags$head(
      tags$link(rel = "icon",
                type = "image/png",
                sizes = "32x32",
                href = "/chart_line_solid.png")
    ),
    # navbarPage(title = easy_plot_header_name_, id = "navbar", fluid = TRUE, theme = shinytheme("flatly"),
    # navbarPage(title = easy_plot_header_name_, id = "navbar", fluid = TRUE, theme = bslib::bs_theme("5"),
    navbarPage(title = easy_plot_header_name_,
               windowTitle = "easyPlot",
               id = "navbar",
               fluid = TRUE,
               tabPanel(title = "Data", icon = icon("table"),
                        sidebarLayout(
                          sidebarPanel(

                            checkboxInput(inputId = "my_data",
                                          label = "My data",
                                          value = show_my_data_bool_),

                            conditionalPanel(
                              condition = "input.my_data",
                              br(),
                              recode_class_render_UI("my_data"),
                              recode_class_render_UI2("my_data"),
                              recode_class_render_UI3("my_data"),
                              recode_class_render_UI4("my_data"),
                              recode_class_render_UI5("my_data"),

                            ),

                            shiny::tags$hr(id = "my_data_hr"),

                            checkboxInput(inputId = "exampleData",
                                          label = "Use example data",
                                          value = FALSE
                            ),

                            conditionalPanel(
                              condition = "input.exampleData",
                              selectInput(inputId = "Data", label = "Example Datasets:",
                                          choices = c("iris", "mtcars", "faithful", "attitude", "diamonds")),

                              recode_class_render_UI("example_data"),
                              recode_class_render_UI2("example_data"),
                              recode_class_render_UI3("example_data"),
                              recode_class_render_UI4("example_data"),
                              recode_class_render_UI5("example_data"),
                              verbatimTextOutput(outputId = "description")
                            ),


                            tags$hr(),

                            checkboxInput(inputId = "upload_data",
                                          label = "Upload a file",
                                          value = FALSE
                            ),
                            conditionalPanel(
                              condition = "input.upload_data",
                              fileInput(inputId = "uploaded",
                                        label = "Upload file (.csv/.xlsx/.txt)",
                                        accept = c("text/csv",
                                                   ".csv",
                                                   "text/comma-separated-values",
                                                   "text/plain",
                                                   ".xlsx",
                                                   ".xls")),

                              bsTooltip(id = "upload_data",
                                        title = "If your data is uploaded and ready to visualize - press the red button \"ready\". No data is stored. For privacy policy see the tab \"Info\"",
                                        placement = "right",
                                        options = list(container = "body")),

                              bsTooltip(id = "readyButton",
                                        title = "If your data is uploaded and ready to visualize then press me",
                                        placement = "right",
                                        options = list(container = "body")),

                              # tags$hr(),

                              # Dynamic UI for CSV datasets
                              conditionalPanel(
                                  condition = "input.upload_data == true && output.data_format == 'csvtxt'",
                                  source("widgets_csvtxt_UI.R", local = TRUE)$value
                              ),


                              # Dynamic UI for XLSX datasets
                              conditionalPanel(
                                condition = "input.upload_data == true && output.data_format == 'xlsx'",
                                source("widgets_xlsx_UI.R", local = TRUE)$value
                              ),

                              # Recoding of variables
                              # conditionalPanel(
                              #   condition = "output.data_format == 'csvtxt' || output.data_format == 'xlsx'",
                              #   uiOutput("recode_class_dynamic"),

                              recode_class_render_UI("uploaded"),
                              recode_class_render_UI2("uploaded"),
                              recode_class_render_UI3("uploaded"),
                              recode_class_render_UI4("uploaded"),
                              recode_class_render_UI5("uploaded"),

                              # Data Ready button
                              conditionalPanel(
                                condition = "input.upload_data == true && (output.data_format == 'csvtxt' || output.data_format == 'xlsx')",
                                tags$hr(),
                                bsButton(inputId = "readyButton",
                                         label = "   Ready",
                                         type = "toggle",
                                         value = FALSE)
                              )
                            ), # end conditionalPanel("uploaded")

                            # br(),
                            # hr(),
                            # h4("Contact:"),
                            # HTML("<a target=\"_blank\" href='https://twitter.com/majkamichal' <i class='fa fa-twitter fa-2x' aria-hidden='true'></i></a>"),
                            # br(),
                            # a("michalmajka@hotmail.com", href="mailto:michalmajka@hotmail.com"),
                            # br()
                            # # Writte in the RMarkdown document how to also install the package
                            # # with install.packages("easyPlot")

                          ), # end sidebarPanel
                          mainPanel(
                            bsAlert("dataAlert1"),
                            DT::DTOutput(outputId = "table")
                          )
                        ),
                        br(),
                        br(),
                        br(),
                        br(),
                        br(),
                        br()
               ),
# ----------------------------- SCATTERPLOT SECTION ----------------------------

     tabPanel(title = "Scatterplot", icon = icon("spinner"),

        bsAlert("dataAlert2"),
        bsAlert("dataAlert2_upload"),
        fluidRow(
          column(2,
               br(),
               br(),
               br(),
               uiOutput(outputId = "brush_info_sc"),
               br(),
               uiOutput(outputId = "click_info_sc")

            ),
        column(6,
               uiOutput(outputId = "scatter_ui")
        )
    ),
    tabsetPanel(
      tabPanel("MAIN",
               fluidRow(
                 # widgets for X-axis -------------------------------------------------
                 column(2,
                        selectInput(inputId = "x_input_sc", label = "X-axis",
                                    choices = ""),
                        checkboxInput(inputId = "show_range_sc", label = "Modify ranges:",
                                      value = FALSE),
                        conditionalPanel(condition = "input.show_range_sc",
                                         uiOutput(outputId = "dynamic_range_x")
                        ),

                        checkboxInput(inputId = "x_log_sc", label = "X-log:",
                                      value = FALSE),
                        textInput(inputId = "label_x_sc", label = "X-label",
                                  value = ""),
                        # COORD FLIP
                        checkboxInput(inputId = "coord_flip_sc", label = "Coord flip",
                                      value = FALSE)

                 ),
                 # widgets for Y-axis -------------------------------------------------
                 column(2,
                        selectInput(inputId = "y_input_sc", label = "Y-axis",
                                    choices = ""),
                        br(),

                        conditionalPanel(condition = "input.show_range_sc",

                                         uiOutput(outputId = "dynamic_range_y")
                        ),
                        checkboxInput(inputId = "y_log_sc", label = "Y-Log:",
                                      value = FALSE),
                        textInput(inputId = "label_y_sc", label = "Y-label",
                                  value = "")

                 ),
                 column(2,
                        #LOESS DYNAMIC SECTION
                        uiOutput(outputId = "loess_out_sc"),

                        conditionalPanel(
                          condition = "input.loess_sc !== 'none'",
                          checkboxInput(inputId = "customize_l_sc",label = "Customize:",
                                        value = FALSE)
                        ),

                        conditionalPanel(
                          condition = "input.customize_l_sc  && input.loess_sc === 'Loess'",

                          colourpicker::colourInput(inputId = "loess_col1_sc",
                                      label = "Colour:",
                                      showColour = "both",
                                      value = "#3366FF",
                                      returnName = TRUE,
                                      allowTransparent = FALSE),

                          sliderInput(inputId = "loess_size1_sc", label = "Linewidth:",
                                      min = 0, max = 5, value = 1, step = 0.05),
                          sliderInput(inputId = "loess_span1_sc", label = "Span:",
                                      min = 0, max = 1, value = 0.75, step = 0.05)


                        ),

                        conditionalPanel(
                          condition = "input.customize_l_sc && input.loess_sc === 'Loess + SE'",

                          colourpicker::colourInput(
                            inputId = "loess_col2_sc",
                            label = "Colour:",
                            showColour = "both",
                            returnName = TRUE,
                            value = "#3366FF",
                            allowTransparent = FALSE
                          ),

                          colourpicker::colourInput(
                            inputId = "loess_fill2_sc",
                            label = "Colour:",
                            showColour = "both",
                            returnName = TRUE,
                            value = "grey60",
                            allowTransparent = FALSE
                          ),

                          sliderInput(inputId = "loess_size2_sc", label = "Linewidth:",
                                      min = 0, max = 5, value = 1, step = 0.05),
                          sliderInput(inputId = "loess_span2_sc", label = "Span:",
                                      min = 0, max = 1, value = 0.75, step = 0.05)

                        ),

                        uiOutput(outputId = "errbar_out_sc"),

                        conditionalPanel(condition = "input.errbar_sc !== 'none'",
                          checkboxInput(inputId = "customize_err_sc",
                                        label = "Customize:",
                                        value = FALSE)
                        ),

                        conditionalPanel(condition = "input.customize_err_sc && input.errbar_sc !== 'none'",

                                         sliderInput(inputId = "err_width_sc", label = "Width:",
                                                     min = 0, max = 1, value = 0.1),

                                         colourpicker::colourInput(
                                           inputId = "err_col_sc",
                                           label = "Colour:",
                                           showColour = "both",
                                           returnName = TRUE,
                                           value = "red",
                                           allowTransparent = FALSE
                                         ),

                                         sliderInput(inputId = "err_size_sc", label = "Size:",
                                                     min = 0.5, max = 5, value = 2)
                        )),
                 column(2,
                        # FACETS:
                        radioButtons(inputId = "faceting_sc", label = "Facet Type:",
                                     choices = c("none", "Grid", "Wrap"),
                                     selected = "none"),

                        # Grid
                        conditionalPanel(condition = "input.faceting_sc === 'Grid'",

                                         selectInput(inputId = "x_facet_sc", label = "Row split:",
                                                     choices = ""),

                                         selectInput(inputId = "y_facet_sc", label = "Column split:",
                                                     choices = "")
                        ),

                        # Wrap
                        conditionalPanel(condition = "input.faceting_sc === 'Wrap'",

                                         selectInput(inputId = "wrap_sc", label = "Split by:",
                                                     choices = "")
                        ),
                        conditionalPanel(condition = "input.wrap_sc !== '.'",

                                         selectInput(inputId = "wrap_sc2", label = "and",
                                                     choices = "")
                        ),
                        conditionalPanel(condition = "input.faceting_sc !== 'none'",
                                         hr(),
                                         selectInput(inputId = "scales_sc", label = "Scales:",
                                                     choices = c("Default" = "fixed", "Free" = "free",
                                                                 "Free x" = "free_x", "Free y" = "free_y"))
                        )
                 ),
                 column(2,

                        radioButtons(inputId = "point_app_sc", label = "Reduce overplotting",
                                     choices = c("none", "Jitter", "Remove duplicates"))

                 ),
                 column(2,
                        # ADD TITLE
                        checkboxInput(inputId = "add_title_sc", label = "Add the title",
                                      value = FALSE),

                        div(id = "show_title_widgets_sc",

                            textInput(inputId = "title_sc", label = "Title",
                                      value = ""),

                            numericInput(inputId = "title_size_sc", label = "Size",
                                         value = 30, min = 1, max = 50, step = 0.5),

                            colourpicker::colourInput(
                              inputId = "title_color_sc",
                              label = "Title colour:",
                              showColour = "both",
                              returnName = TRUE,
                              value = "black",
                              allowTransparent = FALSE
                            )
                        ),
                        # CHANGE THEME
                        checkboxInput(inputId = "change_theme_sc",
                                      label = "Change the theme",
                                      value = FALSE),

                        div(id = "show_theme_widgets_sc",

                            radioButtons(inputId = "theme_sc", label = "Theme:",
                                         choices = c("Grey", "White", "Linedraw", "Light",
                                                     "Minimal", "Classic", "Dark", "Void")),

                            radioButtons(inputId = "legend_sc", label = "Legend",
                                         choices = c("right", "bottom", "left", "none"),
                                         selected = "right"),

                            numericInput(inputId = "theme_size_sc", label = "Font size",
                                         value = 11, min = 2, max = 50, step = 0.5),

                            selectInput(inputId = "theme_font_sc", label = "Font",
                                        choices = c("sans", "Times", "Courier"))
                        ),
                        # CHANGE SIZE
                        checkboxInput(inputId = "ch_size_sc",label = "Size of the plot:",
                                      value = FALSE),
                        div(id = "show_size_sc",

                            sliderInput("width_sc" , "Plot Width (px)",
                                        min = 100, max = 1500, value = 700,
                                        step = 10),

                            sliderInput("height_sc", "Plot Height (px)",
                                        min = 100, max = 1500, value = 500,
                                        step = 10),

                            actionButton(inputId = "reset_sc", "Reset")
                        ),
                        br(),
                        downloadGraphButtonUI("scatterplot")
                      )
                 )),
      tabPanel("POINTS",
               fluidRow(
                 column(2
                 ),
                 column(2,
                        radioButtons(inputId = "change_point_size_sc", label = "Point size:",
                                     choices = c("Size", "Size by"),
                                     selected = "Size", inline = TRUE),

                        conditionalPanel(condition = "input.change_point_size_sc === 'Size'",

                                         sliderInput(inputId = "point_size_sc", label = "Size:",
                                                     min = 0.5, max = 10, value = 2, step = 0.01)),

                        conditionalPanel(condition = "input.change_point_size_sc === 'Size by'",

                                         selectInput(inputId = "point_size_by_sc", label = "Size by:",
                                                     choices = ""))
                 ),
                 column(2,
                        radioButtons(inputId = "change_color_sc", label = "Colour:",
                                     choices = c("Colour", "Colour by"),
                                     selected = "Colour", inline = TRUE),

                        conditionalPanel(condition = "input.change_color_sc === 'Colour'",
                                         colourpicker::colourInput(
                                           inputId = "color_sc",
                                           label = "Colour:",
                                           showColour = "both",
                                           returnName = TRUE,
                                           value = "black",
                                           allowTransparent = FALSE
                                         )
                        ),
                        conditionalPanel(condition = "input.change_color_sc === 'Colour by'",

                                         selectInput(inputId = "color_by_sc", label = "Colour by:",
                                                     choices = "")
                        ),

                        uiOutput(outputId = "dyn_palette_sc"),

                        uiOutput(outputId = "dyn_palette_sc2")
                 ),


                 column(2,
                        selectInput(inputId = "shape_sc", label = "Shape by:",
                                    choices = "")
                 ),
                 column(2,
                        sliderInput(inputId = "opacity_sc", label = "Opacity:",
                                    min = 0, max = 1, value = 1,
                                    step = 0.01)
                 ),
                 column(2
                 )
               ),
               br(),
               br(),
               br(),
               br(),
               br()

      )),

    br(),
    aceEditor(outputId = "print_code_sc", value = "", mode = "r", theme = "texmate", readOnly = FALSE),
    br(),
    br(),
    br(),
    br(),
    br(),
    br()

    ),

    # ----------------------------- HISTOGRAM SECTION --------------------------

    tabPanel(title = "Histogram", icon = icon("chart-column"),

             bsAlert(anchorId = "dataAlert3"),
             bsAlert(anchorId = "dataAlert3_upload"),
             bsAlert(anchorId = "alert_hi"),
             fluidRow(
               column(2),

               column(6,
                      uiOutput(outputId = "Histogram_ui")
               )
             ),

             br(),
             br(),

             fluidRow(
               column(2,
                      selectInput(inputId = "x_input_hi", label = "Variable:",
                                  choices = ""),
                      checkboxInput(inputId = "show_range_hi", label = "Modify ranges:",
                                    value = FALSE),
                      conditionalPanel(condition = "input.show_range_hi",
                                       uiOutput(outputId = "dynamic_range_x_hi")
                      ),

                      checkboxInput(inputId = "x_log_hi", label = "Log10-Transformation:",
                                    value = FALSE),

                      selectInput(inputId = "weight_hi", label = "Weight by:",
                                  choices = "none"),

                      textInput(inputId = "label_x_hi", label = "X-label:",
                                value = ""),

                      checkboxInput(inputId = "set_label_y_hi", "Y-Label", value = FALSE),

                      conditionalPanel(condition = "input.set_label_y_hi",
                          textInput(inputId = "label_y_hi", label = "", value = "")
                      )
               ),
               column(2,
                      # NUMBER OF BREAKS
                      sliderInput(inputId = "breaks_hi", label = "Number of bins:",
                                  min = 2, max = 100, step = 1, value = 30),

                      # OPACITY
                      sliderInput(inputId = "opacity_hi", label = "Opacity:",
                                  min = 0, max = 1, value = 1)
               ),

               column(2,
                      # FILL
                      radioButtons(inputId = "change_fill_hi", label = "Fill:",
                                   choices = c("none", "Count", "Fill by"),
                                   selected = "none"),

                      conditionalPanel(condition = "input.change_fill_hi === 'none' &&
                                       input.change_density_hi !== 'Density'",
                                       colourpicker::colourInput(
                                         inputId = "color_hi",
                                         label = "Colour:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = '#000000',
                                         allowTransparent = FALSE
                                       ),
                                       colourpicker::colourInput(
                                         inputId = "fill_hi",
                                         label = "Fill:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "black",
                                         allowTransparent = FALSE
                                       ),
                                       actionButton(inputId = "reset_colours_hi", label = "Reset:")
                      ),

                      conditionalPanel(condition = "input.change_fill_hi === 'Fill by'",

                                       selectInput(inputId = "fill_by_hi", label = "Fill by:",
                                                   choices = ""),
                                       radioButtons(inputId = "position_hi", label = "Position:",
                                                    choices = c("Identity" = "identity","Stack" = "stack",
                                                                "Dodge" = "dodge", "Fill" = "fill"),
                                                    selected = "stack")


                      ),
                      conditionalPanel(condition = "input.change_fill_hi === 'Count'",

                                       colourpicker::colourInput(
                                         inputId = "high_hi",
                                         label = "Gradient high:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "#56B1F7",
                                         allowTransparent = FALSE
                                       ),
                                       colourpicker::colourInput(
                                         inputId = "low_hi",
                                         label = "Gradient low:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "#132B43",
                                         allowTransparent = FALSE
                                       ),

                                       actionButton(inputId = "reset_count_hi", "Reset:")

                      )
             ),
             column(2,
                    # FACETS:
                    radioButtons(inputId = "faceting_hi", label = "Facet Type:",
                                 choices = c("none", "Grid", "Wrap"),
                                 selected = "none"),

                    # Grid
                    conditionalPanel(condition = "input.faceting_hi === 'Grid'",

                                     selectInput(inputId = "x_facet_hi", label = "Row split:",
                                                 choices = ""),

                                     selectInput(inputId = "y_facet_hi", label = "Column split:",
                                                 choices = "")
                    ),

                    # Wrap
                    conditionalPanel(condition = "input.faceting_hi === 'Wrap'",

                                     selectInput(inputId = "wrap_hi", label = "Split by:",
                                                 choices = "")
                    ),
                    conditionalPanel(condition = "input.wrap_hi !== '.'",

                                     selectInput(inputId = "wrap_hi2", label = "and:",
                                                 choices = "")
                    ),
                    conditionalPanel(condition = "input.faceting_hi !== 'none'",
                                     hr(),
                                     selectInput(inputId = "scales_hi", label = "Scales:",
                                                 choices = c("Default" = "fixed", "Free" = "free",
                                                             "Free x" = "free_x", "Free y" = "free_y"))
                    )
             ),
             column(2,
                    # DENSITY
                    radioButtons(inputId = "change_density_hi", label = "Density:",
                                 choices = c("no", "Both", "Density"),
                                 selected = "no"),

                    conditionalPanel(condition = "input.change_density_hi !== 'no'",
                                     radioButtons(inputId = "change_density_hi2", label = "Density colour type:",
                                                  choices = c("Colour", "Colour by"),
                                                  selected = "Colour")
                    ),

                    conditionalPanel(condition = "input.change_density_hi !== 'no' &&
                                     input.change_density_hi2 === 'Colour'",

                                     colourpicker::colourInput(
                                       inputId = "dens_color_hi",
                                       label = "Density colour:",
                                       showColour = "both",
                                       returnName = TRUE,
                                       value = "#BD1515"
                                     ),

                                     colourpicker::colourInput(
                                       inputId = "dens_fill_hi",
                                       label = "Density fill:",
                                       showColour = "both",
                                       returnName = TRUE,
                                       value = "#BD1515"
                                     ),

                                     sliderInput(inputId = "dens_opacity_hi", label = "Density opacity:",
                                                 min = 0, max = 1, value = 0.2),
                                     actionButton(inputId = "reset_dens_hi", label = "Density reset:")
                    ),

                    conditionalPanel(condition = "input.change_density_hi !== 'no' &&
                                     input.change_density_hi2 === 'Colour by'",
                                     selectInput(inputId = "dens_fill_by_hi", label = "Density colour by:",
                                                 choices = ""),
                                     sliderInput(inputId = "dens_fill_by_opacity_hi", label = "Density opacity",
                                                 min = 0, max = 1, value = 0.2),

                                     radioButtons(inputId = "dens_position_hi", label = "Density position:",
                                                  choices = c("Identity" = "identity", "Stack" = "stack", "Dodge" = "dodge",
                                                              "Fill" = "fill"),
                                                  selected = "identity")
                    )
             ),
             column(2,
                    # ADD TITLE
                    checkboxInput(inputId = "add_title_hi", label = "Add the title:",
                                  value = FALSE),
                    div(id = "show_title_widgets_hi",

                        textInput(inputId = "title_hi", label = "Title:",
                                  value = ""),

                        numericInput(inputId = "title_size_hi", label = "Size:",
                                     value = 30, min = 1, max = 50, step = 0.5),

                        colourpicker::colourInput(
                          inputId = "title_color_hi",
                          label = "Title colour:",
                          showColour = "both",
                          returnName = TRUE,
                          value = "black",
                          allowTransparent = FALSE
                        )
                    ),
                    # CHANGE THE THEME
                    checkboxInput(inputId = "change_theme_hi", label = "Change the theme:",
                                  value = FALSE),

                    div(id = "show_theme_widgets_hi",

                        radioButtons(inputId = "theme_hi", label = "Theme:",
                                     choices = c("Grey", "White","Linedraw", "Light",
                                                 "Minimal", "Classic", "Dark", "Void")),

                        radioButtons(inputId = "legend_hi", label = "Legend:",
                                     choices = c("right", "bottom", "left"),
                                     selected = "right"),
                        numericInput(inputId = "theme_size_hi", label = "Font size:",
                                     value = 11, min = 2, max = 50, step = 0.5),

                        selectInput(inputId = "theme_font_hi", label = "Font:",
                                    choices = c("sans", "Times", "Courier"))
                    ),
                    # CHANGE THE SIZE OF THE PLOT
                    checkboxInput(inputId = "ch_size_hi",label = "Size of the plot:",
                                  value = FALSE),

                    div(id = "show_size_hi",

                        sliderInput("width_hi" , "Plot Width (px):",
                                    min = 100, max = 1500, value = 700,
                                    step = 10),

                        sliderInput("height_hi", "Plot Height (px):",
                                    min = 100, max = 1500, value = 500,
                                    step = 10),
                        actionButton(inputId = "reset_hi", "Reset:")
                    ),
                    br(),
                    downloadGraphButtonUI("histogram")
             )

             ),
             br(),
             aceEditor(outputId = "print_code_hi", value = "", mode = "r", theme = "texmate", readOnly = TRUE),
             br(),
             br(),
             br(),
             br(),
             br(),
             br()

    ),
    # ----------------------------- BOXPLOT SECTION -------------------------------
    tabPanel(title = "Boxplot", icon = icon("sliders", class = "fa-rotate-90"),
             bsAlert("dataAlert4"),
             bsAlert("dataAlert4_upload"),
             bsAlert("alert_box1"),
             bsAlert("alert_box2"),
             fluidRow(
               column(2),
               column(6,
                      uiOutput(outputId = "box_plot")
               )
             ),
             br(),
             fluidRow(
               column(2,
                      selectInput(inputId = "x_input_box", label = "X-Axis:",
                                  choices = ""),

                      checkboxInput(inputId = "show_range_box", label = "Modify ranges:",
                                    value = FALSE),
                      conditionalPanel(condition = "input.show_range_box",

                                       uiOutput(outputId = "dynamic_factors_box")
                      ),

                      textInput(inputId = "label_x_box", label = "X-label:",
                                value = ""),

                      checkboxInput(inputId = "coord_flip_box", label = "Coord flip:",
                                    value = FALSE)

               ),
               column(2,
                      selectInput(inputId = "y_input_box", label = "Y-Axis:",
                                  choices = ""),

                      conditionalPanel(condition = "input.show_range_box",
                                       uiOutput(outputId = "dynamic_range_y_box")
                      ),
                      br(),
                      br(),

                      textInput(inputId = "label_y_box", label = "Y-label:",
                                value = ""),
                      checkboxInput(inputId = "y_log_box", label = "Y-Log:",
                                    value = FALSE)

               ),
               column(2,
                      radioButtons(inputId = "change_fill_box", label = "Colours:",
                                   choices = c("Colours", "Colour by", "Fill by"),
                                   selected = "Colours", inline = FALSE),

                      conditionalPanel(condition = "input.change_fill_box === 'Colours'",

                                       colourpicker::colourInput(
                                         inputId = "fill_box",
                                         label = "Fill:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "white",
                                         allowTransparent = FALSE
                                       ),

                                       colourpicker::colourInput(
                                         inputId = "color_box",
                                         label = "Colour:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "black",
                                         allowTransparent = FALSE
                                       )
                      ),

                      conditionalPanel(condition = "input.change_fill_box === 'Colour by' || input.change_fill_box === 'Fill by'",

                                       selectInput(inputId = "fill_by_box", label = "Colour by:",
                                                   choices = ""),

                                       selectInput(inputId = "fill_by_col_box", label = "Type:",
                                                   choices = c("Default" = "default", "Qualitative" = "qual",
                                                               "Sequential" = "seq", "Diverging" = "div"))
                      ),
                      conditionalPanel(condition = "(input.change_fill_box === 'Colour by' ||
                                                     input.change_fill_box === 'Fill by') &&
                                       input.fill_by_col_box !== 'default'",
                                       sliderInput(inputId = "palette_box", label = "Palette:",
                                                   min = 1, max = 8, value = 1, step = 1)
                      )
             ),
             column(2,
                    # FACETS:
                    radioButtons(inputId = "faceting_box", label = "Facet Type:",
                                 choices = c("none", "Grid", "Wrap"),
                                 selected = "none"),

                    # Grid
                    conditionalPanel(condition = "input.faceting_box === 'Grid'",

                                     selectInput(inputId = "x_facet_box", label = "Row split:",
                                                 choices = ""),

                                     selectInput(inputId = "y_facet_box", label = "Column split:",
                                                 choices = "")
                    ),

                    # Wrap
                    conditionalPanel(condition = "input.faceting_box === 'Wrap'",

                                     selectInput(inputId = "wrap_box", label = "Split by:",
                                                 choices = "")
                    ),
                    conditionalPanel(condition = "input.wrap_box !== '.'",

                                     selectInput(inputId = "wrap_box2", label = "and:",
                                                 choices = "")
                    ),

                    conditionalPanel(condition = "input.faceting_box !== 'none'",
                                     hr(),
                                     selectInput(inputId = "scales_box", label = "Scale:",
                                                 choices = c("Default" = "fixed", "Free" = "free",
                                                             "Free x" = "free_x", "Free y" = "free_y"))
                    ),
                    checkboxInput("box_jitter", label = "Add jitter", value = FALSE),
                    conditionalPanel(condition = "input.box_jitter == true",
                                     sliderInput(inputId = "box_jitter_opacity",
                                                 label = "Jitter opacity:",
                                                 min = 0, max = 1, value = 1,
                                                 step = 0.01),
                                     ),

                    hr(),
                    sliderInput(inputId = "out_size", label = "Outlier size:",
                                min = 0, max = 5, value = 1.5, step = 0.1),

                    selectInput(inputId = "out_shape", label = "Outlier shape",
                                choices = c("Dot" = 19,
                                            "No outlier" = -1,
                                            "Solid square" = 15,
                                            "Solid triangle" = 17,
                                            "Solid rhombus" = 18,
                                            "Circle" = 1,
                                            "Square" = 0,
                                            "Triangle" = 2,
                                            "Rhombus" = 5)),

                    colourpicker::colourInput(
                      inputId = "out_color",
                      label = "Outlier Colour:",
                      showColour = "both",
                      returnName = TRUE,
                      value = "black",
                      allowTransparent = FALSE
                    )
             ),
             column(2,

                    sliderInput(inputId = "box_width", label = "Box width:",
                                min = 0, max = 1, value = 0.75),

                    sliderInput(inputId = "colour_size_box", "Box size:",
                                min = 0, max = 2.5,
                                value = 0.5, step = 0.1),

                    sliderInput(inputId = "opacity_box", label = "Opacity:",
                                min = 0, max = 1, value = 1,
                                step = 0.01)
             ),


             column(2,

                    # ADD TITLE
                    checkboxInput(inputId = "add_title_box", label = "Add the title:",
                                  value = FALSE),

                    div(id = "show_title_widgets_box",

                        textInput(inputId = "title_box", label = "Title:",
                                  value = ""),

                        numericInput(inputId = "title_size_box", label = "Size:",
                                     value = 30, min = 1, max = 50, step = 0.5),

                        colourpicker::colourInput(
                          inputId = "title_color_box",
                          label = "Title colour:",
                          showColour = "both",
                          returnName = TRUE,
                          value = "black",
                          allowTransparent = FALSE
                        )
                    ),
                    # CHANGE THEME
                    checkboxInput(inputId = "change_theme_box",
                                  label = "Change the theme:",
                                  value = FALSE),

                    div(id = "show_theme_widgets_box",

                        radioButtons(inputId = "theme_box", label = "Theme:",
                                     choices = c("Grey", "White","Linedraw", "Light",
                                                 "Minimal", "Classic", "Dark", "Void")),

                        radioButtons(inputId = "legend_box", label = "Legend:",
                                     choices = c("right", "bottom", "left", "none"),
                                     selected = "right"),

                        numericInput(inputId = "theme_size_box", label = "Font size:",
                                     value = 11, min = 2, max = 50, step = 0.5),

                        selectInput(inputId = "theme_font_box", label = "Font:",
                                    choices = c("sans", "Times", "Courier"))
                    ),
                    # CHANGE SIZE
                    checkboxInput(inputId = "ch_size_box",label = "Size of the plot:",
                                  value = FALSE),
                    div(id = "show_size_box",

                        sliderInput("width_box" , "Plot Width (px):",
                                    min = 100, max = 1500, value = 700,
                                    step = 10),

                        sliderInput("height_box", "Plot Height (px):",
                                    min = 100, max = 1500, value = 500,
                                    step = 10),

                        actionButton(inputId = "reset_box", "Reset")
                    ),
                    br(),
                    downloadGraphButtonUI("boxplot"),
                    hr(),
                    actionButton(inputId = "reset_colours_box", label = "Reset colours")
             )
               ),
             br(),
             aceEditor(outputId = "print_code_box", value = "", mode = "r", theme = "texmate", readOnly = TRUE),
             br(),
             br(),
             br(),
             br(),
             br(),
             br()
             ),
    # ----------------------------- BAR GRAPH SECTION ------------------------------
    tabPanel(title = "Bar graph", icon = icon("align-left", class = "fa-rotate-270"),
             bsAlert(anchorId = "dataAlert5"),
             bsAlert(anchorId = "dataAlert5_upload"),
             bsAlert(anchorId = "alert_ba"),
             fluidRow(
               column(2),
               column(6,
                      uiOutput(outputId = "bar_plot")
               )
             ),
             br(),
             fluidRow(
               column(2,
                      selectInput(inputId = "x_input_ba", label = "Variable:",
                                  choices = ""),

                      uiOutput(outputId = "dynamic_factors_ba"),

                      selectInput(inputId = "weight_ba", label = "Weight by:",
                                  choices = ""),

                      textInput(inputId = "label_x_ba", label = "X-label:",
                                value = ""),

                      checkboxInput(inputId = "set_label_y_ba", "Y-Label", value = FALSE),

                      conditionalPanel(condition = "input.set_label_y_ba",
                                       textInput(inputId = "label_y_ba", label = "", value = "")
                      ),
                      checkboxInput(inputId = "coord_flip_ba", label = "Coord flip:",
                                    value = FALSE)

               ),
               column(2,

                      radioButtons(inputId = "change_fill_ba", label = "Colours:",
                                   choices = c("Colours", "Colour by"),
                                   selected = "Colours"),

                      conditionalPanel(condition = "input.change_fill_ba === 'Colours'",

                                       colourpicker::colourInput(
                                         inputId = "fill_ba",
                                         label = "Fill:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "black",
                                         allowTransparent = FALSE
                                       ),
                                       colourpicker::colourInput(
                                         inputId = "color_ba",
                                         label = "Colour:",
                                         showColour = "both",
                                         returnName = TRUE,
                                         value = "black",
                                         allowTransparent = FALSE
                                       ),
                                       sliderInput(inputId = "colour_size_ba", "Box Linewidth:",
                                                   min = 0.1, max = 5, value = 0.5),
                                       actionButton(inputId = "reset_colours_ba", label = "Reset")
                      ),

                      conditionalPanel(condition = "input.change_fill_ba === 'Colour by'",

                                       selectInput(inputId = "fill_by_ba", label = "Colour by:",
                                                   choices = ""),

                                       selectInput(inputId = "fill_by_col_ba", label = "Type:",
                                                   choices = c("Default" = "default", "Qualitative" = "qual",
                                                               "Sequential" = "seq", "Diverging" = "div"))
                      ),
                      conditionalPanel(condition = "input.change_fill_ba === 'Colour by' &&
                                       input.fill_by_col_ba !== 'default'",
                                       sliderInput(inputId = "palette_ba", label = "Palette:",
                                                   min = 1, max = 8, value = 1, step = 1)
                      )
             ),
             column(2,
                    sliderInput(inputId = "bar_width", label = "Bar width:",
                                min = 0.01, max = 1, value = 0.9),

                    sliderInput(inputId = "opacity_ba", label = "Opacity:",
                                min = 0, max = 1, value = 1,
                                step = 0.01)
             ),
             column(2,
                    # FACETS:
                    radioButtons(inputId = "faceting_ba", label = "Facet Type:",
                                 choices = c("none", "Grid", "Wrap"),
                                 selected = "none"),

                    # Grid
                    conditionalPanel(condition = "input.faceting_ba === 'Grid'",

                                     selectInput(inputId = "x_facet_ba", label = "Row split:",
                                                 choices = ""),

                                     selectInput(inputId = "y_facet_ba", label = "Column split:",
                                                 choices = "")
                    ),

                    # Wrap
                    conditionalPanel(condition = "input.faceting_ba === 'Wrap'",

                                     selectInput(inputId = "wrap_ba", label = "Split by:",
                                                 choices = "")
                    ),
                    conditionalPanel(condition = "input.wrap_ba !== '.'",

                                     selectInput(inputId = "wrap_ba2", label = "and:",
                                                 choices = "")
                    ),

                    conditionalPanel(condition = "input.faceting_ba !== 'none'",
                                     hr(),
                                     selectInput(inputId = "scales_ba", label = "Scale:",
                                                 choices = c("Default" = "fixed", "Free" = "free",
                                                             "Free x" = "free_x", "Free y" = "free_y"))
                    )
             ),
             column(2,
                    radioButtons(inputId = "position_ba", label = "Position:",
                                 choices = c("Stack" = "stack", "Dodge" = "dodge",
                                             "Fill" = "fill"),
                                 selected = "stack")
             ),


             column(2,

                    # ADD TITLE
                    checkboxInput(inputId = "add_title_ba", label = "Add the title:",
                                  value = FALSE),

                    div(id = "show_title_widgets_ba",

                        textInput(inputId = "title_ba", label = "Title:",
                                  value = ""),

                        numericInput(inputId = "title_size_ba", label = "Size:",
                                     value = 30, min = 1, max = 50, step = 0.5),

                        colourpicker::colourInput(
                          inputId = "title_color_ba",
                          label = "Title colour:",
                          showColour = "both",
                          returnName = TRUE,
                          value = "black",
                          allowTransparent = FALSE
                        )
                    ),
                    # CHANGE THEME
                    checkboxInput(inputId = "change_theme_ba",
                                  label = "Change the theme:",
                                  value = FALSE),

                    div(id = "show_theme_widgets_ba",

                        radioButtons(inputId = "theme_ba", label = "Theme:",
                                     choices = c("Grey", "White","Linedraw", "Light",
                                                 "Minimal", "Classic", "Dark", "Void")),

                        radioButtons(inputId = "legend_ba", label = "Legend:",
                                     choices = c("right", "bottom", "left", "none"),
                                     selected = "right"),

                        numericInput(inputId = "theme_size_ba", label = "Font size:",
                                     value = 11, min = 2, max = 50, step = 0.5),

                        selectInput(inputId = "theme_font_ba", label = "Font:",
                                    choices = c("sans", "Times", "Courier"))
                    ),
                    # CHANGE SIZE
                    checkboxInput(inputId = "ch_size_ba",label = "Size of the plot:",
                                  value = FALSE),
                    div(id = "show_size_ba",

                        sliderInput("width_ba" , "Plot Width (px):",
                                    min = 100, max = 1500, value = 700,
                                    step = 10),

                        sliderInput("height_ba", "Plot Height (px):",
                                    min = 100, max = 1500, value = 500,
                                    step = 10),

                        actionButton(inputId = "reset_ba", "Reset")
                    ),
                    br(),
                    downloadGraphButtonUI("bargraph")
               )
             ),
             br(),
             aceEditor(outputId = "print_code_ba", value = "", mode = "r", theme = "chrome", readOnly = TRUE),
             br(),
             br(),
             br(),
             br(),
             br(),
             br()

             ),

    tabPanel(title = "Info",
             icon = icon("circle-info"),
             htmltools::HTML(
               '<h1>easyPlot</h1>

<p><strong>Effortless Data Visualization with ggplot2</strong></p>

<p><code>easyPlot</code> is a Shiny app crafted for ggplot2, simplifying the creation of scatterplots, histograms, boxplots, and bar charts.</p>

<hr/>

<h1>Key features</h1>

<ul>
<li><p><strong>Seamless Data Upload:</strong> Easily import data in various formats (csv, xlsx, txt) for a smooth start to your visualization journey.</p></li>
<li><p><strong>Swift Visualization:</strong> Swiftly explore patterns and relationships within your dataset, providing quick insights.</p></li>
<li><p><strong>Multivariate Visualizations:</strong> Visualize multiple variables simultaneously, enhancing the depth of data exploration in a single graph.</p></li>
<li><p><strong>Flexible Styling:</strong> Customize the appearance of your graphs by adjusting colors, themes, and other visual elements to suit your preferences.</p></li>
<li><p><strong>Interactive Scatterplot:</strong> Identify outliers, calculate summary statistics for marked points, and efficiently zoom into specific areas for enhanced data exploration.</p></li>
<li><p><strong>Reproducibility:</strong> Benefit from automatic generation of R code corresponding to your plots, ensuring easy reproduction and integration into your scripts and reports.</p></li>
</ul>

<hr/>

<h1>Privacy policy</h1>

<p>We want to assure our users that no data is stored or processed on our server after it is uploaded to the easyPlot app. Your data remains private and secure throughout the usage of the application. We prioritize the confidentiality and privacy of your information.</p>

<p><strong>Data Handling:</strong></p>

<ol>
<li><p><strong>No Storage:</strong> The <code>easyPlot</code> app does not store any data uploaded by users on our server. Once you upload your data, it is processed in real-time for visualization purposes only.</p></li>
<li><p><strong>Real-time Processing:</strong> Data uploaded to the app is processed in real-time exclusively for generating plots and visualizations within the application interface.</p></li>
<li><p><strong>No Tracking:</strong> We do not track or store any personal information related to your data. Your usage of the app is anonymous, and we do not collect any identifiable information.</p></li>
</ol>

<p><strong>User Responsibility:</strong></p>

<ol>
<li><p><strong>Secure Data Transmission:</strong> While we take measures to ensure the security of your data within the app, please ensure that you do not upload sensitive or confidential information.</p></li>
<li><p><strong>Session-based Processing:</strong> The app processes your data on a session-by-session basis. Once you close or leave the app, there is no retention of the data from your previous sessions.</p></li>
<li><p><strong>External Links:</strong> The app may provide links to external sources for additional information or resources. Please be aware that our privacy policy applies only to data processed within the <code>easyPlot</code> app.</p></li>
</ol>

<p>By using the <code>easyPlot</code> app, you acknowledge and agree to the terms outlined in this privacy disclaimer. If you have any concerns or questions regarding privacy, please contact us. Your privacy and trust are of utmost importance to us.</p>

<hr/>

<h1>Connect</h1>

<ul>
<li><p>For feedback, feature requests, and bug reports, please visit my <a href="https://github.com/majkamichal/easyPlot">GitHub repository</a>.</p></li>
<li><p>Contact me at <a href="mailto:michalmajka@hotmail.com">michalmajka@hotmail.com</a>.</p></li>
<li><p>Follow me on <a href="https://twitter.com/majkamichal">Twitter</a> and <a href="https://www.linkedin.com/in/michal-majka/">LinkedIn</a> for updates.</p></li>
<li><p>If you find easyPlot valuable and would like to support my work, consider <a href="https://www.buymeacoffee.com/michalmajka">buy me a coffee</a>.</p></li>
</ul>

<hr/>

<p><strong>Thank you for using easyPlot!</strong></p>

<hr/>'
             )
   ),
    if (package_mode_bool_) {
        tabPanel(title = "", value = "quit", icon = icon("power-off"),
                 br(),
                 br(),
                 br(),
                 br(),
                 br(),
                 br(),
                 fluidRow(
                   column(3),
                   column(6,
                          h2("Thank you for using easyPlot!")
                   )
                 )
       )
   }
  )
 )
)
majkamichal/easyPlot documentation built on March 8, 2024, 1:01 a.m.