-
Notifications
You must be signed in to change notification settings - Fork 1
/
layout_sidebar_ui.R
70 lines (52 loc) · 1.99 KB
/
layout_sidebar_ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
## ------------------------------------- ##
# Layout Options - Sidebar
## ------------------------------------- ##
# Call needed libraries
library(shiny); library(htmltools); library(lterpalettefinder)
# User Interface (UI) --------------
sidebar_ui <- fluidPage(
# Add a title that appears in the browser tab
title = "Shiny Sidebar",
# Title within app
headerPanel(list(title = "Layout Options - Sidebar",
htmltools::img(src = "lter_logo.png",
height = 42,
align = "right") ) ),
# Decide on sidebar layout
sidebarLayout(
# UI - Sidebar Content ----
sidebarPanel(
# Heading
htmltools::h3("Decide on Number of Histogram Bins"),
# Slider for deciding on number of historgram bins
sliderInput(inputId = "bin_num",
label = "Number of bins:",
min = 5, value = 30, max = 50),
# Heading
htmltools::h3("Pick a Plot Color"),
# Color dropdown menu
selectInput(inputId = "color",
label = "Choose a Color",
choices = palette_find(site = "LTER"),
selected = palette_find(site = "LTER")[2]),
# Heading
htmltools::h3("Enter Plot Labels"),
# X-axis label
textInput(inputId = "x_lab", label = "X-Axis Label"),
# Y-axis label
textInput(inputId = "y_lab", label = "Y-Axis Label"),
# Plot title
textInput(inputId = "title", label = "Plot Title")
), # Close `sidebarPanel(...`
# UI - Main Panel Content ----
mainPanel(
plotOutput(outputId = "histo")
)
, position = 'right') # Close `sidebarLayout(...`
) # Close `fluidPage(...`
# Server ---------------------------
# To better demonstrate that layout is *only* a UI thing, all layout options will use the same script containing the server function
source("layout_server.R")
# Assemble App ---------------------
shinyApp(ui = sidebar_ui, server = layout_server)
# End ----