Update app.py
Browse files
app.py
CHANGED
|
@@ -1,162 +1,120 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
from
|
| 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 |
-
yvar = input.tip_perc_y()
|
| 122 |
-
uvals = dat[yvar].unique()
|
| 123 |
-
|
| 124 |
-
samples = [[dat.percent[dat[yvar] == val]] for val in uvals]
|
| 125 |
-
|
| 126 |
-
plt = ridgeplot(
|
| 127 |
-
samples=samples,
|
| 128 |
-
labels=uvals,
|
| 129 |
-
bandwidth=0.01,
|
| 130 |
-
colorscale="viridis",
|
| 131 |
-
colormode="row-index",
|
| 132 |
-
)
|
| 133 |
-
|
| 134 |
-
plt.update_layout(
|
| 135 |
-
legend=dict(
|
| 136 |
-
orientation="h", yanchor="bottom", y=1.02, xanchor="center", x=0.5
|
| 137 |
-
)
|
| 138 |
-
)
|
| 139 |
-
|
| 140 |
-
return plt
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
ui.include_css(app_dir / "styles.css")
|
| 144 |
-
|
| 145 |
-
# --------------------------------------------------------
|
| 146 |
-
# Reactive calculations and effects
|
| 147 |
-
# --------------------------------------------------------
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
@reactive.calc
|
| 151 |
-
def tips_data():
|
| 152 |
-
bill = input.total_bill()
|
| 153 |
-
idx1 = tips.total_bill.between(bill[0], bill[1])
|
| 154 |
-
idx2 = tips.time.isin(input.time())
|
| 155 |
-
return tips[idx1 & idx2]
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
@reactive.effect
|
| 159 |
-
@reactive.event(input.reset)
|
| 160 |
-
def _():
|
| 161 |
-
ui.update_slider("total_bill", value=bill_rng)
|
| 162 |
-
ui.update_checkbox_group("time", selected=["Lunch", "Dinner"])
|
|
|
|
| 1 |
+
from shared import app_dir
|
| 2 |
+
from utils import create_nav_button
|
| 3 |
+
from shiny import App, reactive, render, ui
|
| 4 |
+
import shinyswatch
|
| 5 |
+
from server import create_server
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
app_ui = ui.page_fluid(
|
| 9 |
+
ui.tags.style("""
|
| 10 |
+
.big-table {
|
| 11 |
+
font-size: 22px; /* Increase font size */
|
| 12 |
+
padding: 25px; /* Add padding for spacing */
|
| 13 |
+
width: 100%; /* Make the card take full width */
|
| 14 |
+
overflow-x: auto; /* Enable horizontal scrolling if needed */
|
| 15 |
+
}
|
| 16 |
+
.big-table table {
|
| 17 |
+
width: 100%; /* Make table take full width within card */
|
| 18 |
+
}
|
| 19 |
+
.title-logo-container {
|
| 20 |
+
display: flex;
|
| 21 |
+
align-items: center;
|
| 22 |
+
gap: 15px; /* Add some space between the logo and title */
|
| 23 |
+
}
|
| 24 |
+
.title-logo-container img {
|
| 25 |
+
max-height: 50px; /* Adjust logo size */
|
| 26 |
+
height: auto;
|
| 27 |
+
}
|
| 28 |
+
.title-logo-container h1 {
|
| 29 |
+
margin: 0;
|
| 30 |
+
font-size: 28px; /* Adjust title font size */
|
| 31 |
+
}
|
| 32 |
+
"""),
|
| 33 |
+
|
| 34 |
+
ui.page_fillable(
|
| 35 |
+
ui.page_sidebar(
|
| 36 |
+
ui.sidebar(
|
| 37 |
+
ui.div(
|
| 38 |
+
ui.output_image("logo"),
|
| 39 |
+
style="display: inline-block; overflow: hidden; max-height: 70px; width: 80%;"
|
| 40 |
+
),
|
| 41 |
+
|
| 42 |
+
ui.card(
|
| 43 |
+
create_nav_button(
|
| 44 |
+
button_icon = "house",
|
| 45 |
+
button_label_text = "Homepage",
|
| 46 |
+
button_link = "https://www.rsginc.com",
|
| 47 |
+
button_cls = "btn btn-secondary"
|
| 48 |
+
),
|
| 49 |
+
|
| 50 |
+
create_nav_button(
|
| 51 |
+
button_icon = "route",
|
| 52 |
+
button_label_text = "Origin-Destination",
|
| 53 |
+
button_link = "https://www.rsginc.com"
|
| 54 |
+
),
|
| 55 |
+
|
| 56 |
+
create_nav_button(
|
| 57 |
+
button_icon = "car",
|
| 58 |
+
button_label_text = "Auto Travel",
|
| 59 |
+
button_link = "https://www.rsginc.com"
|
| 60 |
+
),
|
| 61 |
+
|
| 62 |
+
create_nav_button(
|
| 63 |
+
button_icon = "road",
|
| 64 |
+
button_label_text = "VMT",
|
| 65 |
+
button_link = "https://www.rsginc.com"
|
| 66 |
+
),
|
| 67 |
+
|
| 68 |
+
create_nav_button(
|
| 69 |
+
button_icon = "truck",
|
| 70 |
+
button_label_text = "Truck",
|
| 71 |
+
button_link = "https://www.rsginc.com"
|
| 72 |
+
),
|
| 73 |
+
|
| 74 |
+
create_nav_button(
|
| 75 |
+
button_icon = "plane",
|
| 76 |
+
button_label_text = "Air Travels",
|
| 77 |
+
button_link = "https://www.rsginc.com"
|
| 78 |
+
),
|
| 79 |
+
),
|
| 80 |
+
|
| 81 |
+
open="desktop",
|
| 82 |
+
),
|
| 83 |
+
|
| 84 |
+
ui.include_css(app_dir / "styles.css"),
|
| 85 |
+
#title="NAPA Valley Travels",
|
| 86 |
+
ui.div(
|
| 87 |
+
ui.tags.div(
|
| 88 |
+
# ui.img(
|
| 89 |
+
# src="images/logo.jpg",
|
| 90 |
+
# style="max-height: 50px; height: auto;"
|
| 91 |
+
# ),
|
| 92 |
+
ui.h1("NAPA Valley Travels", style="margin: 0; font-size: 28px; font-weight: bold;"),
|
| 93 |
+
class_="title-logo-container"
|
| 94 |
+
),
|
| 95 |
+
style="padding-bottom: 20px;"
|
| 96 |
+
),
|
| 97 |
+
ui.div(
|
| 98 |
+
ui.h2("Bar Chart", style="text-align: center;"),
|
| 99 |
+
ui.output_plot("bar_chart"), # Placeholder for bar chart
|
| 100 |
+
class_="chart-container",
|
| 101 |
+
),
|
| 102 |
+
ui.div(
|
| 103 |
+
ui.h2("Trip Purposes", style="text-align: center;"),
|
| 104 |
+
ui.output_plot("pie_chart"), # Placeholder for pie chart
|
| 105 |
+
class_="chart-container",
|
| 106 |
+
),
|
| 107 |
+
fillable=True,
|
| 108 |
+
)
|
| 109 |
+
), theme=shinyswatch.theme.spacelab,
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# def server(input, output, session):
|
| 113 |
+
# @render.image
|
| 114 |
+
# def logo():
|
| 115 |
+
# img = {"src": app_dir / "images" / "logo.png", "style": "width: 80%; height: auto; max-height: 150px; margin-bottom: 0px;"}
|
| 116 |
+
# return img
|
| 117 |
+
|
| 118 |
+
app = App(app_ui, create_server(app_dir))
|
| 119 |
+
#app = App(app_ui, server)
|
| 120 |
+
app.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|