Render separate Figures.
This commit is contained in:
parent
6ac04e4452
commit
e261018aa4
|
|
@ -1,4 +1,5 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from plotly.graph_objs import Figure
|
||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
|
|
||||||
from corchestrate.chart_data import ChartData
|
from corchestrate.chart_data import ChartData
|
||||||
|
|
@ -13,8 +14,6 @@ def plot_over_time(input_data: list[ChartData]):
|
||||||
|
|
||||||
datetime_indices = []
|
datetime_indices = []
|
||||||
|
|
||||||
fig = make_subplots(5, 1)
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
min_datetime: datetime | None = None
|
min_datetime: datetime | None = None
|
||||||
# Find min_datetime
|
# Find min_datetime
|
||||||
|
|
@ -58,33 +57,37 @@ def plot_over_time(input_data: list[ChartData]):
|
||||||
# Advance to next index
|
# Advance to next index
|
||||||
indexed_input.next()
|
indexed_input.next()
|
||||||
|
|
||||||
|
heart_rate_figure = Figure()
|
||||||
|
speed_figure = Figure()
|
||||||
|
cadence_figure = Figure()
|
||||||
|
power_figure = Figure()
|
||||||
|
temperature_figure = Figure()
|
||||||
|
|
||||||
# Plot
|
# Plot
|
||||||
for indexed_input in indexed_inputs:
|
for indexed_input in indexed_inputs:
|
||||||
fig.add_scatter(x=datetime_indices,
|
heart_rate_figure.add_scatter(x=datetime_indices,
|
||||||
y=indexed_input.extracted_heart_rate,
|
y=indexed_input.extracted_heart_rate,
|
||||||
row=1,
|
name=indexed_input.name,
|
||||||
col=1,
|
hoverlabel=dict(namelength=-1))
|
||||||
name=f"Heart rate - {indexed_input.name}")
|
speed_figure.add_scatter(x=datetime_indices,
|
||||||
fig.add_scatter(x=datetime_indices,
|
y=indexed_input.extracted_speed,
|
||||||
y=indexed_input.extracted_speed,
|
name=indexed_input.name,
|
||||||
row=2,
|
hoverlabel=dict(namelength=-1))
|
||||||
col=1,
|
cadence_figure.add_scatter(x=datetime_indices,
|
||||||
name=f"Speed - {indexed_input.name}")
|
y=indexed_input.extracted_cadence,
|
||||||
fig.add_scatter(x=datetime_indices,
|
name=indexed_input.name,
|
||||||
y=indexed_input.extracted_cadence,
|
hoverlabel=dict(namelength=-1))
|
||||||
row=3,
|
power_figure.add_scatter(x=datetime_indices,
|
||||||
col=1,
|
y=indexed_input.extracted_power,
|
||||||
name=f"Cadence - {indexed_input.name}")
|
name=indexed_input.name,
|
||||||
fig.add_scatter(x=datetime_indices,
|
hoverlabel=dict(namelength=-1))
|
||||||
y=indexed_input.extracted_power,
|
temperature_figure.add_scatter(
|
||||||
row=4,
|
x=datetime_indices,
|
||||||
col=1,
|
y=indexed_input.extracted_temperature,
|
||||||
name=f"Power - {indexed_input.name}")
|
name=f"Temperature - {indexed_input.name}")
|
||||||
fig.add_scatter(x=datetime_indices,
|
|
||||||
y=indexed_input.extracted_temperature,
|
|
||||||
row=5,
|
|
||||||
col=1,
|
|
||||||
name=f"Temperature - {indexed_input.name}")
|
|
||||||
|
|
||||||
fig.update_layout(height=3000)
|
heart_rate_figure.write_html("hr.html", auto_open=True)
|
||||||
fig.show()
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue