{# Cost-trend line chart. Reused by: - templates/opportunities/detail.html - embedded for context - templates/failures/detail.html - embedded for context Caller sets: - chart_points_payload : list[dict] (from cohort_view.build_chart_points_payload or JobCohortView.chart_points_payload()). REQUIRED. - chart_title : str (defaults to "Cost trend") - chart_subtitle : str (default explains skipped-days) X axis (spec 162): one tick per EXECUTION (label "YYYY-MM-DD HH:MM"), so a query run 18× in a day shows as 18 dots. For tables above ``_PER_EXECUTION_CAP`` executions it falls back to one tick per UTC day (label "YYYY-MM-DD"); ``granularity`` in each point says which. Y axis: USD cost - per execution, or summed over the day in fallback mode. Markers: a contrasting scatter point overlays the FIRST occurrence of each query_hash (i.e., a version transition starts here). Click handler: navigates to /jobs/{first_job_id} (the exact execution for per-execution points; the day's first run in fallback). Mirrors the dashboard's _trend_chart.html ECharts/ChartUtils setup so the colours / axis styling stay consistent with the rest of the audit. ``chart_collapsible`` is optional; collapsed charts defer ECharts initialization until opened so hidden containers do not initialize at zero width. #} {% set _chart_title = chart_title | default("Cost trend") %} {% set _gran = (chart_points_payload[0].granularity if chart_points_payload else "execution") %} {% set _chart_subtitle = chart_subtitle | default( "One point per execution. Red points mark executions that tripped a detection rule." if _gran == "execution" else "One point per day (high-frequency table; executions rolled up daily). Days without executions are skipped. Red points mark days when an execution tripped a detection rule." ) %} {% set _chart_collapsible = chart_collapsible | default(false) %} {% if chart_open is defined %} {% set _chart_open = chart_open %} {% else %} {% set _chart_open = not _chart_collapsible %} {% endif %} {% if _chart_collapsible %}

{{ _chart_title }}

{{ _chart_subtitle }}

{% else %}

{{ _chart_title }}

{{ _chart_subtitle }}

{% endif %} {% if chart_points_payload %}
{% else %}

No executions in the current scan window.

{% endif %} {% if _chart_collapsible %}
{% else %} {% endif %} {% if chart_points_payload %} {% endif %}