Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -240,47 +240,47 @@ files_dates_selected = [i for i in files if any(
|
|
| 240 |
# Get Data
|
| 241 |
df_data, max_values = get_data(row, col, radius)
|
| 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 |
with col1:
|
| 273 |
st.title(f'Hail')
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
|
| 285 |
|
| 286 |
with col2:
|
|
|
|
| 240 |
# Get Data
|
| 241 |
df_data, max_values = get_data(row, col, radius)
|
| 242 |
|
| 243 |
+
df_data = df_data.query(f"'{start_date}'<=Date<='{end_date}'")
|
| 244 |
+
df_data['Max'] = df_data['Max'].round(3)
|
| 245 |
+
df_data['Actual'] = df_data['Actual'].round(3)
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
# Create the bar chart
|
| 249 |
+
fig = alt.Chart(df_data).mark_bar(size=3, color='red').encode(
|
| 250 |
+
x='Date:T', # Temporal data type
|
| 251 |
+
y='Actual:Q', # Quantitative data type
|
| 252 |
+
color='Actual:Q', # Color based on Actual values
|
| 253 |
+
tooltip=[ # Adding tooltips
|
| 254 |
+
alt.Tooltip('Date:T', title='Date'),
|
| 255 |
+
alt.Tooltip('Actual:Q', title='Actual Value'),
|
| 256 |
+
alt.Tooltip('Max:Q', title=f'Max Value with {circle_radius} Miles')
|
| 257 |
+
]
|
| 258 |
+
).configure(
|
| 259 |
+
view=alt.ViewConfig(
|
| 260 |
+
strokeOpacity=0 # No border around the chart
|
| 261 |
+
)
|
| 262 |
+
).configure_axis(
|
| 263 |
+
grid=False # Disable grid lines
|
| 264 |
+
).configure_legend(
|
| 265 |
+
fillColor='transparent', # Ensure no legend is shown
|
| 266 |
+
strokeColor='transparent'
|
| 267 |
+
)
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
with col1:
|
| 273 |
st.title(f'Hail')
|
| 274 |
+
try:
|
| 275 |
+
st.altair_chart(fig, use_container_width=True)
|
| 276 |
+
csv = convert_df(df_data)
|
| 277 |
+
st.download_button(
|
| 278 |
+
label="Download data as CSV",
|
| 279 |
+
data=csv,
|
| 280 |
+
file_name='data.csv',
|
| 281 |
+
mime='text/csv')
|
| 282 |
+
except:
|
| 283 |
+
pass
|
| 284 |
|
| 285 |
|
| 286 |
with col2:
|