-
Notifications
You must be signed in to change notification settings - Fork 130
/
ui.R
161 lines (137 loc) · 5.83 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
library(shiny)
library(tidyverse)
library(hexbin)
library(httr)
library(jsonlite)
source("helpers.R")
source("court_themes.R")
source("plot_court.R")
source("players_data.R")
source("fetch_shots.R")
source("hex_chart.R")
source("scatter_chart.R")
source("heatmap_chart.R")
shinyUI(
fixedPage(
theme = "flatly.css",
title = "BallR: Interactive NBA Shot Charts with R and Shiny",
tags$head(
tags$link(rel = "apple-touch-icon", href = "basketball.png"),
tags$link(rel = "icon", href = "basketball.png"),
tags$link(rel = "stylesheet", type = "text/css", href = "shared/selectize/css/selectize.bootstrap3.css"),
tags$link(rel = "stylesheet", type = "text/css", href = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css"),
tags$link(rel = "stylesheet", type = "text/css", href = "custom_styles.css"),
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"),
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"),
tags$script(src = "shared/selectize/js/selectize.min.js"),
tags$script(src = "ballr.js"),
uiOutput("shot_chart_css")
),
HTML('
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div>
<ul class="nav navbar-nav col-xs-12">
<li class="col-xs-8 col-md-9">
<a href="#">BallR<span class="hidden-xs">: Interactive NBA Shot Charts</span></a>
</li>
<li class="col-xs-4 col-md-3 github-link">
<a href="https://github.com/toddwschneider/ballr" target="_blank">
<span class="hidden-xs">Code on </span>GitHub
</a>
</li>
</ul>
</div>
</div>
</nav>
'),
fixedRow(class = "primary-content",
div(class = "col-sm-8 col-md-9",
div(class = "shot-chart-container",
div(class = "shot-chart-header",
h2(textOutput("chart_header_player")),
h4(textOutput("chart_header_info")),
h4(textOutput("chart_header_team"))
),
plotOutput("court", width = 800, height = "auto"),
uiOutput("shot_filters_applied"),
uiOutput("shot_chart_footer")
),
div(class = "download-link-container",
uiOutput("download_link")
),
h3(textOutput("summary_stats_header")),
uiOutput("summary_stats")
),
div(class = "col-sm-4 col-md-3",
div(class = "shot-chart-inputs",
uiOutput("player_photo"),
selectInput(inputId = "player_name",
label = "Player",
choices = c("Enter a player..." = "", available_players$name),
selected = default_player$name,
selectize = FALSE),
selectInput(inputId = "season",
label = "Season",
choices = rev(default_seasons),
selected = default_season,
selectize = FALSE),
radioButtons(inputId = "season_type",
label = "Season Type",
choices = c("Regular Season", "Playoffs"),
selected = default_season_type),
dateRangeInput(inputId = "date_range",
label = "Date range",
start = FALSE,
end = FALSE),
radioButtons(inputId = "court_theme",
label = "Theme",
choices = c("Light", "Dark"),
selected = "Light"),
radioButtons(inputId = "chart_type",
label = "Chart Type",
choices = c("Hexagonal", "Scatter", "Heat Map"),
selected = "Hexagonal"),
uiOutput("hex_metric_buttons"),
uiOutput("hexbinwidth_slider"),
uiOutput("hex_radius_slider"),
uiOutput("scatter_size_slider"),
uiOutput("scatter_alpha_slider"),
h4("Filters"),
selectInput(inputId = "shot_zone_basic_filter",
label = "Shot Zones",
choices = c("Above the Break 3",
"Left Corner 3",
"Right Corner 3",
"Mid-Range",
"In The Paint (Non-RA)",
"Restricted Area"),
multiple = TRUE,
selectize = FALSE),
selectInput(inputId = "shot_zone_angle_filter",
label = "Shot Angles",
choices = c("Left Side" = "Left Side(L)",
"Left Center" = "Left Side Center(LC)",
"Center" = "Center(C)",
"Right Center" = "Right Side Center(RC)",
"Right Side" = "Right Side(R)"),
multiple = TRUE,
selectize = FALSE),
selectInput(inputId = "shot_distance_filter",
label = "Shot Distances",
choices = c("0-8 ft" = "Less Than 8 ft.",
"8-16 ft" = "8-16 ft.",
"16-24 ft" = "16-24 ft.",
"24+ ft" = "24+ ft."),
multiple = TRUE,
selectize = FALSE),
selectInput(inputId = "shot_result_filter",
label = "FG Made/Missed",
choices = c("All" = "all", "Made" = "made", "Missed" = "missed"),
selected = "all",
selectize = FALSE)
)
)
)
)
)