Add clinical threshold lines to AGP/Dagoverzicht charts, TIR stacked bar to Samenvatting

Closes gitea #14, #15.
This commit is contained in:
2026-08-01 22:26:26 +02:00
parent 699848b479
commit 00fb81b283
5 changed files with 135 additions and 3 deletions
+30 -1
View File
@@ -1,4 +1,12 @@
from ui_common import hex_to_rgba
import plotly.graph_objects as go
from ui_common import (
PALETTE,
THRESHOLD_LINES,
add_threshold_lines,
build_tir_stacked_bar_figure,
hex_to_rgba,
)
def test_hex_to_rgba_converts_correctly():
@@ -7,3 +15,24 @@ def test_hex_to_rgba_converts_correctly():
def test_hex_to_rgba_handles_hash_optional():
assert hex_to_rgba("2a78d6", 0.3) == "rgba(42,120,214,0.3)"
def test_add_threshold_lines_adds_one_line_per_clinical_threshold():
fig = go.Figure()
add_threshold_lines(fig, PALETTE["light"])
assert len(fig.layout.shapes) == len(THRESHOLD_LINES)
def test_add_threshold_lines_targets_subplot_row_when_given():
fig = go.Figure()
fig.add_trace(go.Scatter(x=[0], y=[0]))
add_threshold_lines(fig, PALETTE["light"], row=1)
assert len(fig.layout.shapes) == len(THRESHOLD_LINES)
def test_build_tir_stacked_bar_figure_has_one_bar_trace_per_band():
tir = {"very_low": 1.0, "low": 3.0, "in_range": 80.0, "high": 12.0, "very_high": 4.0}
fig = build_tir_stacked_bar_figure(tir, PALETTE["light"])
assert len(fig.data) == 5
assert [trace.y[0] for trace in fig.data] == [1.0, 3.0, 80.0, 12.0, 4.0]
assert fig.layout.barmode == "stack"