-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.R
executable file
·98 lines (81 loc) · 3.14 KB
/
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
## UI for BoardGameGeek Data Explorer
## from https://github.com/rasmusgreve/BoardGameGeek
## see also http://fivethirtyeight.com/features/designing-the-best-board-game-on-the-planet/
## Required library; use install.packages() if necessary
library(ggvis)
## Javascript for the dropdown menu
actionLink <- function(inputId, ...) {
tags$a(href='javascript:void',
id=inputId,
class='action-button',
...)
}
## UI, with 'Yeti' theme from Bootswatch http://bootswatch.com/yeti/
shinyUI(fluidPage(theme = "bootstrap.css",
## prevent grey-out on loss of connection
tags$head(tags$style(type="text/css",
"body.disconnected {
background-color: inherit;
opacity: 1;
}"
)),
## TITLE
titlePanel("BoardGameGeek Data Explorer"),
## NEW ROW
fluidRow(
## LH COLUMN
column(3,
## AXIS CHOICES
wellPanel(
h4("Axes"),
selectInput("xvar", "X-axis variable", axis_vars, selected = "year_published"),
selectInput("yvar", "Y-axis variable", axis_vars, selected = "average_rating")
),
## FILTERS PANEL
wellPanel(
h4("Filters"),
sliderInput("reviews", "Minimum number of ratings on BoardGameGeek (>99)",
100, 45000, 3000, step = 100),
textInput("minyear", label = "Earliest year of publication (>=-3500 [yes, 3500 B.C.!])", value = "1977"),
textInput("maxyear", label = "Latest year of publication (<= 2014)", value = "2014"),
sliderInput("owned", label = "Number of copies owned", 1, 60000, value = c(1, 60000), step = 1000),
sliderInput("timed", label = "Duration of game (mins)", 1, 720, value = c(1, 720), step = 10),
sliderInput("maxplyrs", label = "Maximum number of players", 1, 21, value = c(1, 10), step = 1),
selectInput("best", label = "Best number of players", choices = seq(0, 20), selected = 0)
)
),
## RH COLUMN
column(9,
## INFO PANEL
wellPanel(
span("Number of boardgames selected:", textOutput("n_games"),
tags$small(paste0(
"There are a total of 4948 games in this dataset."))
)
),
## PLOTS PANEL
ggvisOutput("plot1"),
wellPanel(
textInput("bgname", "Name contains (e.g. Monopoly)")
),
## MECHANICS
wellPanel(
h4("Mechanics (select from list)"),
selectInput("mech", "", mech_vars, multiple = TRUE, selectize = TRUE),
radioButtons("mechLogic", label = "logical operator", choices = list("disjunctive OR" = "disj", "conjunctive AND" = "conj"), selected = "disj", inline = TRUE)
),
## SOURCES / LINKS
wellPanel(
span(
"inspiration: ", tags$a(href="http://fivethirtyeight.com/features/designing-the-best-board-game-on-the-planet/", "@ollie on FiveThirtyEight"),
" | ",
"data source: ", tags$a(href="https://github.com/rasmusgreve/BoardGameGeek", "@rasmusgreve on GitHub"),
" | ",
"code: ", tags$a(href="https://github.com/cainesap/boardgamegeek", "@cainesap on GitHub"),
" | ",
"original design: ", tags$a(href="http://shiny.rstudio.com/gallery/movie-explorer.html", "@garrettgman's Shiny Movie Explorer")
)
)
)
)
))