fix: anchor hedge contribution bars at zero

This commit is contained in:
Bu5hm4nn
2026-03-24 19:34:41 +01:00
parent 98ecfb735e
commit 021ce7dd99
2 changed files with 12 additions and 20 deletions

View File

@@ -33,19 +33,8 @@ def _cost_benefit_options(metrics: dict) -> dict:
def _waterfall_options(metrics: dict) -> dict:
steps = metrics["waterfall_steps"]
running = 0.0
base: list[float] = []
values: list[dict[str, object]] = []
for index, (label, amount) in enumerate(steps):
if index == 0:
base.append(0)
running = amount
elif index == len(steps) - 1:
base.append(0)
else:
base.append(running)
running += amount
for label, amount in steps:
color = "#0ea5e9" if label == "Net equity" else ("#22c55e" if amount >= 0 else "#ef4444")
values.append({"value": amount, "itemStyle": {"color": color}})
@@ -56,14 +45,6 @@ def _waterfall_options(metrics: dict) -> dict:
"series": [
{
"type": "bar",
"stack": "total",
"data": base,
"itemStyle": {"color": "rgba(0,0,0,0)"},
"tooltip": {"show": False},
},
{
"type": "bar",
"stack": "total",
"data": values,
},
],