Updated the update_all_plots(json_data) function since passing literal json to 'read_json' got deprecated

This commit is contained in:
2025-09-03 23:33:21 +02:00
parent a869b565e4
commit 9861aea0d9

16
app.py
View File

@@ -150,7 +150,7 @@ def create_info_banner(df):
# START OF THE PLOTS
# =============================================================================
def create_map_plot(df):
# fig = px.line_mapbox(
# fig = px.line_map(
# df,
# lat='lat',
# lon='lon',
@@ -169,7 +169,7 @@ def create_map_plot(df):
# zoom=13,
# height=800
# )
fig = px.line_mapbox(
fig = px.line_map(
df,
lat='lat',
lon='lon',
@@ -185,18 +185,20 @@ def create_map_plot(df):
),
customdata=df[['time', 'cum_dist_km', 'duration_hms']]
)
#
fig.update_layout(mapbox_style="open-street-map")
# Define map style and the line ontop
fig.update_layout(map_style="open-street-map")
# The built-in plotly.js styles are: carto-darkmatter, carto-positron, open-street-map, stamen-terrain, stamen-toner, stamen-watercolor, white-bg
# The built-in Mapbox styles are: basic, streets, outdoors, light, dark, satellite, satellite-streets
fig.update_traces(line=dict(color="#f54269", width=3))
# Start / Stop marker
start = df.iloc[0]
end = df.iloc[-1]
fig.add_trace(go.Scattermapbox(
fig.add_trace(go.Scattermap(
lat=[start['lat']], lon=[start['lon']], mode='markers+text',
marker=dict(size=12, color='#fca062'), text=['Start'], name='Start', textposition='bottom left'
))
fig.add_trace(go.Scattermapbox(
fig.add_trace(go.Scattermap(
lat=[end['lat']], lon=[end['lon']], mode='markers+text',
marker=dict(size=12, color='#b9fc62'), text=['Stop'], name='Stop', textposition='bottom left'
))
@@ -455,7 +457,7 @@ def load_gpx_data(path):
Input('stored-df', 'data')
)
def update_all_plots(json_data):
df = pd.read_json(json_data, orient='split')
df = pd.read_json(io.StringIO(json_data), orient='split')
info = create_info_banner(df)
fig_map = create_map_plot(df)