File size: 22,320 Bytes
6b8ef05 260d0ed 6b8ef05 18dab29 64dfa95 1dd5e98 6b8ef05 260d0ed 6b8ef05 64dfa95 260d0ed 6b8ef05 260d0ed 6b8ef05 260d0ed 6b8ef05 1dd5e98 6b8ef05 b6fc911 6b8ef05 b6fc911 6b8ef05 4f84edb 97b25ec a2e42ca 97b25ec 260d0ed 64dfa95 260d0ed 6b8ef05 260d0ed 937857b 260d0ed 1dd5e98 cdee994 1dd5e98 260d0ed cdee994 1dd5e98 260d0ed cdee994 1dd5e98 260d0ed cdee994 3a5af50 fc50594 3a5af50 18dab29 3a5af50 18dab29 3a5af50 18dab29 3a5af50 fc50594 3a5af50 fc50594 3a5af50 18dab29 3a5af50 fc50594 3a5af50 fc50594 3a5af50 fc50594 3a5af50 18dab29 3a5af50 fc50594 3a5af50 39cf52e fc50594 39cf52e 9b6795d fc50594 9b6795d 18dab29 2f3eb8e f37b6a4 39cf52e 9b6795d fc50594 cdee994 01cfc0b 260d0ed 6b8ef05 260d0ed 6b8ef05 0e017e5 | 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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | from shared import app_dir
from utils import create_nav_button
from shiny import App, ui
import shinyswatch
from server import create_server, q1, q2, q3, q4 #QUESTION_TO_SHEET
import numpy as np
from shinywidgets import output_widget, render_widget
app_ui = ui.page_fluid(
ui.tags.style("""
.big-table {
font-size: 22px; /* Increase font size */
padding: 25px; /* Add padding for spacing */
width: 100%; /* Make the card take full width */
overflow-x: auto; /* Enable horizontal scrolling if needed */
}
.big-table table {
width: 100%; /* Make table take full width within card */
}
.title-logo-container {
display: flex;
align-items: center;
gap: 15px; /* Add some space between the logo and title */
}
.title-logo-container img {
max-height: 50px; /* Adjust logo size */
height: auto;
}
.title-logo-container h1 {
margin: 0;
font-size: 28px; /* Adjust title font size */
font-weight: bold; /* Make it bold */
}
"""),
ui.page_fillable(
ui.page_sidebar(
ui.sidebar(
ui.div(
ui.output_image("clientlogo"),
style="display: inline-block; overflow: hidden; max-height: 75px; width: 90%;"
),
ui.card(
create_nav_button(
button_icon="house",
button_label_text="Homepage",
button_link="https://rsginc-nvtbs.hf.space",
#button_cls="btn btn-secondary"
),
create_nav_button(
button_icon = "route",
button_label_text = "Origin-Destination",
button_link = "https://rsginc-nvtbsod.hf.space",
button_cls="btn btn-secondary"
),
# create_nav_button(
# button_icon = "car",
# button_label_text = "Auto Travel",
# button_link = "https://www.rsginc.com"
# ),
#create_nav_button(
# button_icon = "road",
# button_label_text = "VMT",
# button_link = "https://rsginc-nvtbsvmt.hf.space"
#),
create_nav_button(
button_icon = "house-laptop",
button_label_text = "Home-Work Location",
button_link = "https://rsginc-nvtbsdwell.hf.space",
#button_cls="btn btn-secondary"
),
#create_nav_button(
# button_icon = "truck",
# button_label_text = "Truck",
# button_link = "https://rsginc-nvtbstruck.hf.space"
#),
create_nav_button(
button_icon = "clipboard-question",
button_label_text = "Survey",
button_link = "https://rsginc-nvtbssurvey.hf.space"
)
),
ui.div(
ui.output_image("rsglogo"),
style="display: inline-block; overflow: hidden; max-height: 40px; width: 50%;"
),
open="desktop",
),
ui.include_css(app_dir / "styles.css"),
ui.div(
ui.tags.div(
ui.h1("NAPA Valley Travels", style="margin: 0; font-size: 28px; font-weight: bold;"),
class_="title-logo-container"
),
style="padding-bottom: 20px;"
),
# Tabs inside a card
ui.card(
ui.tags.h5("Travel Trends in NAPA Valley", style="text-align: center; font-weight: bold; margin-bottom: 15px;"), # Add card title
ui.navset_card_underline(
ui.nav_panel(
"OD Map",
ui.tags.div(
ui.HTML("""
<div class='tableauPlaceholder' id='viz1737474527739' style='position: relative'>
<noscript>
<a href='#'>
<img alt='OD ' src='https://public.tableau.com/static/images/QK/QKbdPUgUZcnPzx2zlYiGlcG_DpGX6bB/OD/1_rss.png' style='border: none' />
</a>
</noscript>
<object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='QKbdPUgUZcnPzx2zlYiGlcG_DpGX6bB/OD' />
<param name='tabs' value='no' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/QK/QKbdPUgUZcnPzx2zlYiGlcG_DpGX6bB/OD/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en-US' />
<param name='filter' value='publish=yes' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1737474527739');
var vizElement = divElement.getElementsByTagName('object')[0];
if (divElement.offsetWidth > 800) {
vizElement.style.width='1366px';vizElement.style.height='795px';
} else if (divElement.offsetWidth > 500) {
vizElement.style.width='1366px';vizElement.style.height='795px';
} else {
vizElement.style.width='100%';vizElement.style.height='727px';
}
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
"""
),
)
),
ui.nav_panel(
"Trip distribution",
ui.tags.div(
ui.HTML("""
<div class='tableauPlaceholder' id='viz1737489104795' style='position: relative'><noscript><a href='#'><img alt='ALL ' src='https://public.tableau.com/static/images/jL/jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_ALL/ALL/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_ALL/ALL' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='https://public.tableau.com/static/images/jL/jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_ALL/ALL/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='language' value='en-US' /><param name='filter' value='publish=yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1737489104795'); var vizElement = divElement.getElementsByTagName('object')[0]; if ( divElement.offsetWidth > 800 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else { vizElement.style.width='100%';vizElement.style.height='1577px';} var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>
"""
),
),
),
ui.nav_panel(
"School Trips",
ui.tags.div(
ui.HTML("""
<div class='tableauPlaceholder' id='viz1737489301212' style='position: relative'><noscript><a href='#'><img alt='School ' src='https://public.tableau.com/static/images/jL/jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_School/School/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_School/School' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='https://public.tableau.com/static/images/jL/jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_School/School/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='language' value='en-US' /><param name='filter' value='publish=yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1737489301212'); var vizElement = divElement.getElementsByTagName('object')[0]; if ( divElement.offsetWidth > 800 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else { vizElement.style.width='100%';vizElement.style.height='1627px';} var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>
"""
),
),
),
ui.nav_panel(
"Winery Trips",
ui.tags.div(
ui.HTML("""
<div class='tableauPlaceholder' id='viz1737489606286' style='position: relative'><noscript><a href='#'><img alt='Winery ' src='https://public.tableau.com/static/images/jL/jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_Winery/Winery/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_Winery/Winery' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='https://public.tableau.com/static/images/jL/jLOgmDzZqy_TqH2SEbAnEk_4pfd8Y7_Winery/Winery/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='language' value='en-US' /><param name='filter' value='publish=yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1737489606286'); var vizElement = divElement.getElementsByTagName('object')[0]; if ( divElement.offsetWidth > 800 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.width='1366px';vizElement.style.height='795px';} else { vizElement.style.width='100%';vizElement.style.height='1577px';} var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>
"""
),
),
),
ui.nav_panel(
"Travel Patterns",
ui.tags.h3("Select a Question to View Travel Patterns", style="text-align: center;"),
# Add radio button for date and data table selection
ui.input_radio_buttons(
"data_year_selector1",
label="Select Data Year:",
choices=["Fall 2014", "Fall 2018", "Fall 2024"],
selected="Fall 2024", # Preselect a default year
inline=True
),
ui.tags.br(),
# Add dropdown for question selection
ui.input_select(
"question_selector1",
label="Select a Question:",
choices=list(q1.keys()),
selected="What types of trips are occurring within Napa County?", # Preselect a valid question
),
ui.tags.br(),
#ui.input_radio_buttons(
# "data_year_selector",
# label="Select Data Year:",
# choices=["Fall 2014", "Fall 2018", "Fall 2024"],
# selected="Fall 2024" # Preselect a default year
#),
# Output table for the selected sheet
ui.output_table("table_title1"),
ui.output_table("trip_table1"),
),
ui.nav_panel(
"Travel Characteristics",
ui.tags.h3("Select a Question to View Travel Characteristics", style="text-align: center;"),
# Add radio button for date and data table selection
ui.input_radio_buttons(
"data_year_selector2",
label="Select Data Year:",
choices=["Fall 2014", "Fall 2018", "Fall 2024"],
selected="Fall 2024", # Preselect a default year
inline=True
),
ui.tags.br(),
# Add dropdown for question selection
ui.input_select(
"question_selector2",
label="Select a Question:",
choices=list(q2.keys()),
selected="What types of trips are occurring within Napa County?", # Preselect a valid question
),
ui.tags.br(),
#ui.input_radio_buttons(
# "data_year_selector",
# label="Select Data Year:",
# choices=["Fall 2014", "Fall 2018", "Fall 2024"],
# selected="Fall 2024" # Preselect a default year
#),
# Output table for the selected sheet
ui.output_table("table_title2"),
ui.output_table("trip_table2"),
),
ui.nav_panel(
"Roadway Segments",
ui.tags.h3("Select a Question to View Travel Characteristics for Roadway Segments", style="text-align: center;"),
# Add radio button for date and data table selection
ui.input_radio_buttons(
"data_year_selector3",
label="Select Data Year:",
choices=["Fall 2014", "Fall 2018", "Fall 2024"],
selected="Fall 2024", # Preselect a default year
inline=True
),
ui.tags.br(),
# Add dropdown for question selection
ui.input_select(
"question_selector3",
label="Select a Question:",
choices=list(q3.keys()),
selected="What types of trips are occurring within Napa County?", # Preselect a valid question
),
ui.tags.br(),
#ui.input_radio_buttons(
# "data_year_selector",
# label="Select Data Year:",
# choices=["Fall 2014", "Fall 2018", "Fall 2024"],
# selected="Fall 2024" # Preselect a default year
#),
# Output table for the selected sheet
ui.output_table("table_title3"),
ui.output_table("trip_table3"),
),
ui.nav_panel(
"Commercial Vehicle Travel Characteristics",
ui.tags.h3("Select a Question to View Travel Characteristics for Commercial Vehicle", style="text-align: center;"),
# Add radio button for date and data table selection
ui.input_radio_buttons(
"data_year_selector4",
label="Select Data Year:",
choices=["Fall 2014", "Fall 2018", "Fall 2024"],
selected="Fall 2024", # Preselect a default year
inline=True
),
ui.tags.br(),
# Add dropdown for question selection
ui.input_select(
"question_selector4",
label="Select a Question:",
choices=list(q4.keys()),
selected="What types of trips are occurring within Napa County?", # Preselect a valid question
),
ui.tags.br(),
#ui.input_radio_buttons(
# "data_year_selector",
# label="Select Data Year:",
# choices=["Fall 2014", "Fall 2018", "Fall 2024"],
# selected="Fall 2024" # Preselect a default year
#),
# Output table for the selected sheet
ui.output_table("table_title4"),
ui.output_table("trip_table4"),
),
#ui.nav_panel(
# "Mode",
# ui.tags.div(
# ui.HTML("""
# Mode
# """
# ),
# ),
#),
#ui.nav_panel(
# "VMT",
# ui.tags.div(
# ui.HTML("""
# VMT
# """
# ),
# ),
#),
),
style="padding: 10px; margin-top: 20px;",
class_="tabbed-card",
),
)
),
theme=shinyswatch.theme.spacelab,
)
app = App(app_ui, create_server(app_dir))
if __name__ == "__main__":
import asyncio
try:
app.run() # Use this for environments without a running event loop
except RuntimeError as e:
if "asyncio.run()" in str(e):
asyncio.run(app.start()) # Fallback for environments with an active event loop
|