diff --git a/src/corchestrate/chart.py b/src/corchestrate/chart.py index b0fd356..f591412 100644 --- a/src/corchestrate/chart.py +++ b/src/corchestrate/chart.py @@ -1,4 +1,5 @@ from datetime import datetime +from plotly.graph_objs import Figure from plotly.subplots import make_subplots from corchestrate.chart_data import ChartData @@ -13,8 +14,6 @@ def plot_over_time(input_data: list[ChartData]): datetime_indices = [] - fig = make_subplots(5, 1) - while True: min_datetime: datetime | None = None # Find min_datetime @@ -58,33 +57,37 @@ def plot_over_time(input_data: list[ChartData]): # Advance to next index indexed_input.next() + heart_rate_figure = Figure() + speed_figure = Figure() + cadence_figure = Figure() + power_figure = Figure() + temperature_figure = Figure() + # Plot for indexed_input in indexed_inputs: - fig.add_scatter(x=datetime_indices, - y=indexed_input.extracted_heart_rate, - row=1, - col=1, - name=f"Heart rate - {indexed_input.name}") - fig.add_scatter(x=datetime_indices, - y=indexed_input.extracted_speed, - row=2, - col=1, - name=f"Speed - {indexed_input.name}") - fig.add_scatter(x=datetime_indices, - y=indexed_input.extracted_cadence, - row=3, - col=1, - name=f"Cadence - {indexed_input.name}") - fig.add_scatter(x=datetime_indices, - y=indexed_input.extracted_power, - row=4, - col=1, - name=f"Power - {indexed_input.name}") - fig.add_scatter(x=datetime_indices, - y=indexed_input.extracted_temperature, - row=5, - col=1, - name=f"Temperature - {indexed_input.name}") + heart_rate_figure.add_scatter(x=datetime_indices, + y=indexed_input.extracted_heart_rate, + name=indexed_input.name, + hoverlabel=dict(namelength=-1)) + speed_figure.add_scatter(x=datetime_indices, + y=indexed_input.extracted_speed, + name=indexed_input.name, + hoverlabel=dict(namelength=-1)) + cadence_figure.add_scatter(x=datetime_indices, + y=indexed_input.extracted_cadence, + name=indexed_input.name, + hoverlabel=dict(namelength=-1)) + power_figure.add_scatter(x=datetime_indices, + y=indexed_input.extracted_power, + name=indexed_input.name, + hoverlabel=dict(namelength=-1)) + temperature_figure.add_scatter( + x=datetime_indices, + y=indexed_input.extracted_temperature, + name=f"Temperature - {indexed_input.name}") - fig.update_layout(height=3000) - fig.show() + heart_rate_figure.write_html("hr.html", auto_open=True) + speed_figure.write_html("speed.html", auto_open=True) + cadence_figure.write_html("cad.html", auto_open=True) + power_figure.write_html("pwr.html", auto_open=True) + temperature_figure.write_html("temp.html", auto_open=True)