Skip to content

Commit

Permalink
fix: heart rate plots with no operation
Browse files Browse the repository at this point in the history
This fixes a bug that would crash the application when plotting
heart rate (i.e. `HKQuantityTypeIdentifierHeartRate`) data with no operation.
  • Loading branch information
alxdrcirilo committed Jun 29, 2024
1 parent cff4b71 commit f8a8019
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions apple_health_parser/interfaces/plot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ def _get_plot_settings(self) -> PlotSettings:
legend = None
title = None
title_yaxis = None

match self.flag:
case "HKQuantityTypeIdentifierHeartRate":
# Special case for the heart rate flag ot include the motion context
if self.flag == "HKQuantityTypeIdentifierHeartRate" and self.oper is None:
x = "start_date"
y = "value"
color = "motion_context"
legend = "Motion Context"
case _:
x = "date"
y = "value"
else:
x = "date"
y = "value"

match self.title:
case True:
Expand Down Expand Up @@ -157,7 +157,7 @@ def plot(
figure.write_html(output_dir / f"{filename}.html")
else:
figure.write_image(
file=output_dir / f"{filename}.{format}", format=format, scale=1
file=output_dir / f"{filename}.{format}", format=format, scale=2
)

return figure

0 comments on commit f8a8019

Please sign in to comment.