{# Sparkline region — UX-069 (cycle 28, v0.60.0). Contract: ~/.claude/skills/ux-architect/components/sparkline-region.md Compact time-series for KPI tiles: title + big-number + tiny line underneath. Single-dim only — always time-bucketed. Consumes `bucketed_metrics` from _aggregate_via_groupby. Card safety: region emits zero chrome + zero title. v0.62 CSS refactor: inline Tailwind → semantic .dz-sparkline-* classes (components/regions.css). SVG fill/stroke tokens stay inline (per-element shape colour) — Tailwind-arbitrary-value removal applies to layout/typography only. #} {% from 'macros/region_wrapper.html' import region_card %} {% call region_card(title) %}
{% if bucketed_metrics and bucketed_metrics | length > 0 %} {% set last = bucketed_metrics[-1] %} {% set max_val = bucketed_metrics | map(attribute='value') | max %} {% set max_val = max_val if max_val > 0 else 1 %} {% set count = bucketed_metrics | length %}
{{ last.value }} {{ last.label }}
{% if count > 1 %} {% set w = 180 %} {% set h = 32 %} {% set pt = 2 %} {% set pb = 2 %} {% set step = w / (count - 1) %} {% set plot_h = h - pt - pb %} {% set pts = [] %} {% for b in bucketed_metrics %} {% set x = (loop.index0 * step) %} {% set y = pt + plot_h - ((b.value / max_val) * plot_h) %} {% set _ = pts.append(x | round(2) ~ ',' ~ y | round(2)) %} {% endfor %} {% endif %} {% else %}
{{ empty_message | default("—") }}
{% endif %}
{% endcall %}