{# partials/_breakdown_card.html Stacked bar breakdown. No legend — colours match Overview stat cards exactly. Bootstrap semantic colours: Success → #198754 (bg-success) Failure → #6c757d (bg-secondary) Guardrail→ #ffc107 (bg-warning) Error → #dc3545 (bg-danger) Columns: Total | GTR% (if present) | ASR Rows sorted by ASR descending. row = (label, total, successes, asr_pct[, gtr_count]) #} {% if rows %} {% set sorted_rows = rows | sort(attribute=3, reverse=true) %} {% set max_total = rows | map(attribute=1) | max %} {% set has_gtr = rows[0]|length > 4 %}
Breakdown by {{ title }}
Total {% if has_gtr %} GTR {% endif %} ASR
{% for row in sorted_rows %} {% set label = row[0] %} {% set total = row[1] %} {% set succ = row[2] %} {% set asr = row[3] %} {% set gtr_n = row[4] if has_gtr else 0 %} {% set succ_pct = ((succ / total * 100) if total > 0 else 0) | round(1) %} {% set gtr_pct = ((gtr_n / total * 100) if (has_gtr and total > 0) else 0) | round(1) %} {% set full_pct = ((total / max_total * 100)) | round(1) %} {# ASR text uses same colour as success bar — green when high, grey when low #} {% set asr_col = "#198754" if asr >= 50 else ("#ffc107" if asr >= 20 else "#6c757d") %}
{{ label }}
{# Track — width proportional to this row's share of the largest total. Base fill = failure colour (#6c757d). Guardrail fill (amber) sits on top, width = succ + gtr stacked. Success fill (green) sits on top of that. #}
{# Failure (light grey) track — full_pct wide, solid #}
{# Guardrail (warning) layer — stacked on top of failure #} {% if has_gtr and gtr_pct > 0 %}
{% endif %} {# Success (green) layer — on top #} {% if succ_pct > 0 %}
{% endif %}
{{ total }}
{% if has_gtr %}
{{ "%.1f"|format(gtr_pct) }}%
{% endif %}
{{ "%.1f"|format(asr) }}%
{% endfor %}
{% endif %}