Skip to content

Commit 5b5c460

Browse files
authored
Fixed bug where flipped activities were not plotted (#45)
* Fixed bug where flipped activities were not plotted * Cleanup
1 parent 8d0cf82 commit 5b5c460

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

src/strava_collections/activity.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,17 @@ def add_elevation_to_fig(self, fig, distance_traveled=0.0, color="black"):
8282
# rgba_color = pc.hex_to_rgb(line_color)
8383
# fillcolor = f"rgba({rgba_color[0]},{rgba_color[1]},{rgba_color[2]},0.3)"
8484

85-
fig.add_trace(
86-
go.Scatter(
87-
x=distance + distance_traveled,
88-
y=elev,
89-
mode="lines",
90-
name=self.activity.name or f"Activity {self.activity.id}",
91-
line=dict(color=color),
92-
fill="tozeroy",
93-
# fillcolor=fillcolor,
94-
hovertemplate="Distance: %{x:.1f} m<br>Elevation: %{y:.1f} m<extra></extra>",
95-
)
85+
fig.add_trace(
86+
go.Scatter(
87+
x=distance + distance_traveled,
88+
y=elev,
89+
mode="lines",
90+
name=self.activity.name or f"Activity {self.activity.id}",
91+
line=dict(color=color),
92+
fill="tozeroy",
93+
hovertemplate="Distance: %{x:.1f} m<br>Elevation: %{y:.1f} m<extra></extra>",
9694
)
95+
)
9796

9897
def plot_elevation(
9998
self,
@@ -211,7 +210,7 @@ def generate_markdown_summary(self):
211210

212211
out_str += f"""
213212
<div style="position: relative; width: 100%; padding-bottom: 250px; height: 0;">
214-
<iframe src="_static/{self.activity_id}.html" style="position:absolute; top:0; left:0; width:100%; height:100%; border:none;"></iframe>
213+
<iframe src="_static/activity-{self.activity_id}.html" style="position:absolute; top:0; left:0; width:100%; height:100%; border:none;"></iframe>
215214
</div>\n\n"""
216215

217216
# Photos

src/strava_collections/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def main():
100100

101101
for activity in collection.activities:
102102
activity.plot_elevation(
103-
filepath=os.path.join(path_static, f"{activity.activity_id}.html"),
103+
filepath=os.path.join(path_static, f"activity-{activity.activity_id}.html"),
104104
)
105105

106106
# Plot figures

src/strava_collections/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ def export_plotly_fig(fig, filepath, config, height=200, width_to_height=2.0):
1010
)
1111
elif ext in {"png", "jpg", "jpeg", "pdf", "svg", "webp"}:
1212
fig.write_image(
13-
filepath, width=width_to_height * height, height=height, scale=1
13+
filepath,
14+
width=width_to_height * height,
15+
height=height,
16+
scale=1,
1417
)
1518
else:
1619
raise ValueError(f"Unsupported file extension '.{ext}'")

0 commit comments

Comments
 (0)