Implement ticket 057: fix rate() line charts for sparse/bursty occurrences
A rate() series over a metric whose occurrences are confined to a short burst within a much wider queried range (e.g. sum by (code) (rate(KeyPressed[5m])) against a ~10h log where all key presses happen in the first 10s) rendered as broken: the line simply stopped at the last real occurrence, and the chart's x-axis auto-scaled to the tiny span of actual data points rather than the queried range, silently narrowing a 10-hour view down to ~10 seconds with no indication anything was off. Backend (src/engine.rs): windowed_rate_series now appends a synthetic boundary point at start_ms/end_ms (computed via the existing rate::rate_at against the original occurrence points, so a boundary inside a still-warm window gets its true partial value rather than a hardcoded 0) whenever the real series doesn't already reach that edge. Wired into both the bare rate() and sum()/avg(rate()) evaluate_promql branches, which already had start_ms/end_ms in scope. Frontend (PanelChart.tsx/Dashboards.tsx): the line chart's XAxis now uses an explicit numeric domain pinned to the panel's queried range (passed down from Dashboards.tsx's PanelPreview) instead of recharts' default auto-scale-to-data-extent, so sparse data can no longer make the axis look narrower than what was actually queried. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
5493358db8
commit
79d252c1df
@@ -96,7 +96,7 @@ function PanelPreview({ panel, range }: { panel: Panel; range: TimeRange | null
|
||||
if (loading && series.length === 0) {
|
||||
return <div className="flex h-48 items-center justify-center text-xs text-text-faint">Loading…</div>
|
||||
}
|
||||
return <PanelChart series={series} chartType={panel.chart_type} />
|
||||
return <PanelChart series={series} chartType={panel.chart_type} range={range} />
|
||||
}
|
||||
|
||||
function AutosaveStatus({ status, error }: { status: SaveStatus; error: string | null }) {
|
||||
|
||||
Reference in New Issue
Block a user