Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -137,11 +137,10 @@ from shiny import App, reactive, ui, render
|
|
| 137 |
from shiny.ui import h2, tags
|
| 138 |
|
| 139 |
# Define the UI layout for the app
|
| 140 |
-
app_ui = ui.
|
| 141 |
-
|
| 142 |
-
|
| 143 |
ui.tags.div(
|
| 144 |
-
|
| 145 |
ui.tags.style(
|
| 146 |
"""
|
| 147 |
h4 {
|
|
@@ -151,61 +150,55 @@ app_ui = ui.page_fluid(
|
|
| 151 |
font-size:25px;
|
| 152 |
}
|
| 153 |
"""
|
| 154 |
-
),
|
| 155 |
-
|
| 156 |
-
ui.tags.h4("TJStats"),
|
| 157 |
-
ui.tags.i("Baseball Analytics and Visualizations"),
|
| 158 |
-
ui.markdown("""<a href='https://x.com/TJStats'>Follow me on Twitter</a><sup>1</sup>"""),
|
| 159 |
-
ui.markdown("""<a href='https://www.patreon.com/tj_stats'>Support me on Patreon for Access to 2024 Apps</a><sup>1</sup>"""),
|
| 160 |
-
|
| 161 |
-
ui.markdown("### MiLB Statcast Batting Summaries"),
|
| 162 |
-
ui.markdown("""This Shiny App allows you to generate Baseball Savant-style percentile bars for MiLB players in the 2024 Season.
|
| 163 |
-
Currently, MiLB Statcast is only available for AAA and A (Florida State League) level.
|
| 164 |
-
"""),
|
| 165 |
-
ui.markdown("""
|
| 166 |
-
For ease of sharing, you can right-click (desktop) or press+hold (mobile) to save/copy the image.
|
| 167 |
-
"""),
|
| 168 |
-
|
| 169 |
-
ui.layout_sidebar(
|
| 170 |
-
ui.panel_sidebar(
|
| 171 |
-
# Row for selecting season and level
|
| 172 |
-
ui.row(
|
| 173 |
-
ui.column(6, ui.input_select('year_input', 'Select Season', year_list, selected=2024)),
|
| 174 |
-
ui.column(6, ui.input_select('level_input', 'Select Level', level_dict)),
|
| 175 |
-
),
|
| 176 |
-
# Row for the action button to get player list
|
| 177 |
-
ui.row(ui.input_action_button("player_button", "Get Player List", class_="btn-primary")),
|
| 178 |
-
# Row for selecting the player
|
| 179 |
-
ui.row(ui.column(12, ui.output_ui('player_select_ui', 'Select Player'))),
|
| 180 |
-
|
| 181 |
-
ui.row(
|
| 182 |
-
ui.column(6, ui.input_switch("switch", "Custom Team?", False)),
|
| 183 |
-
ui.column(6, ui.input_select('logo_select', 'Select Custom Logo', image_dict_flip, multiple=False))
|
| 184 |
-
),
|
| 185 |
-
|
| 186 |
-
# Row for the action button to generate plot
|
| 187 |
-
ui.row(ui.input_action_button("generate_plot", "Generate Plot", class_="btn-primary")),
|
| 188 |
-
width=3,
|
| 189 |
),
|
| 190 |
-
|
| 191 |
-
ui.
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
)
|
| 206 |
)
|
| 207 |
-
)
|
| 208 |
-
|
| 209 |
def server(input, output, session):
|
| 210 |
@render.ui
|
| 211 |
@reactive.event(input.player_button,input.tabset, ignore_none=False)
|
|
|
|
| 137 |
from shiny.ui import h2, tags
|
| 138 |
|
| 139 |
# Define the UI layout for the app
|
| 140 |
+
app_ui = ui.page_sidebar(
|
| 141 |
+
# Header content
|
|
|
|
| 142 |
ui.tags.div(
|
| 143 |
+
{"style": "width:90%;margin: 0 auto;max-width: 1600px;"},
|
| 144 |
ui.tags.style(
|
| 145 |
"""
|
| 146 |
h4 {
|
|
|
|
| 150 |
font-size:25px;
|
| 151 |
}
|
| 152 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
),
|
| 154 |
+
ui.tags.h4("TJStats"),
|
| 155 |
+
ui.tags.i("Baseball Analytics and Visualizations"),
|
| 156 |
+
ui.markdown("""<a href='https://x.com/TJStats'>Follow me on Twitter</a><sup>1</sup>"""),
|
| 157 |
+
ui.markdown("""<a href='https://www.patreon.com/tj_stats'>Support me on Patreon for Access to 2024 Apps</a><sup>1</sup>"""),
|
| 158 |
+
ui.markdown("### MiLB Statcast Batting Summaries"),
|
| 159 |
+
ui.markdown("""This Shiny App allows you to generate Baseball Savant-style percentile bars for MiLB players in the 2024 Season.
|
| 160 |
+
Currently, MiLB Statcast is only available for AAA and A (Florida State League) level.
|
| 161 |
+
"""),
|
| 162 |
+
ui.markdown("""
|
| 163 |
+
For ease of sharing, you can right-click (desktop) or press+hold (mobile) to save/copy the image.
|
| 164 |
+
"""),
|
| 165 |
+
),
|
| 166 |
+
|
| 167 |
+
# Sidebar content
|
| 168 |
+
ui.sidebar(
|
| 169 |
+
# Row for selecting season and level
|
| 170 |
+
ui.row(
|
| 171 |
+
ui.column(6, ui.input_select('year_input', 'Select Season', year_list, selected=2024)),
|
| 172 |
+
ui.column(6, ui.input_select('level_input', 'Select Level', level_dict)),
|
| 173 |
+
),
|
| 174 |
+
# Row for the action button to get player list
|
| 175 |
+
ui.row(ui.input_action_button("player_button", "Get Player List", class_="btn-primary")),
|
| 176 |
+
# Row for selecting the player
|
| 177 |
+
ui.row(ui.column(12, ui.output_ui('player_select_ui', 'Select Player'))),
|
| 178 |
+
|
| 179 |
+
ui.row(
|
| 180 |
+
ui.column(6, ui.input_switch("switch", "Custom Team?", False)),
|
| 181 |
+
ui.column(6, ui.input_select('logo_select', 'Select Custom Logo', image_dict_flip, multiple=False))
|
| 182 |
+
),
|
| 183 |
+
|
| 184 |
+
# Row for the action button to generate plot
|
| 185 |
+
ui.row(ui.input_action_button("generate_plot", "Generate Plot", class_="btn-primary")),
|
| 186 |
+
width="400px"
|
| 187 |
+
),
|
| 188 |
+
|
| 189 |
+
# Main content area with tabs
|
| 190 |
+
ui.navset_tab(
|
| 191 |
+
ui.nav_panel("Batter Summary",
|
| 192 |
+
ui.output_text("status_batter"),
|
| 193 |
+
ui.output_plot('batter_plot', width='1200px', height='1200px')
|
| 194 |
+
),
|
| 195 |
+
ui.nav_panel("Pitcher Summary",
|
| 196 |
+
ui.output_text("status_pitcher"),
|
| 197 |
+
ui.output_plot('pitcher_plot', width='1200px', height='1200px')
|
| 198 |
+
),
|
| 199 |
+
id="tabset"
|
| 200 |
)
|
| 201 |
)
|
|
|
|
|
|
|
| 202 |
def server(input, output, session):
|
| 203 |
@render.ui
|
| 204 |
@reactive.event(input.player_button,input.tabset, ignore_none=False)
|