Skip to content

feat(statchart): use an instant query when the value allows it - #781

Open
s3onghyun wants to merge 1 commit into
perses:mainfrom
s3onghyun:statchart-instant-query-mode
Open

feat(statchart): use an instant query when the value allows it#781
s3onghyun wants to merge 1 commit into
perses:mainfrom
s3onghyun:statchart-instant-query-mode

Conversation

@s3onghyun

Copy link
Copy Markdown

What

StatChart always issued a range query, even when it only needed the latest point. Now that #752 added a per-query instant mode, this derives the panel query mode from the spec — the same thing TablePanel already does via getTablePanelQueryMode.

getStatChartQueryMode returns instant only when it's safe:

  • last → instant (it's exactly what an instant query returns)
  • last-number, mean/sum/min/max, first/first-number → range (they need the full series)
  • any spec with a sparkline → range (it draws the series)

So the default (sparkline on) stays range, and nothing that renders the series changes — the #738 sparkline regression is kept covered by tests.

Follow-up to #746, which was closed in favour of #752's per-query flag.

Test

stat-chart-model.test.ts covers each calculation + the sparkline cases. npm run test, tsc, and oxlint are clean.

StatChart always ran a range query, even when it only needed the latest
point. Now that a per-query instant mode exists (perses#752), derive the panel
query mode from the spec, mirroring what TablePanel already does with
getTablePanelQueryMode.

Only `last` is instant-safe: it is exactly what an instant query returns.
`last-number`, the aggregations, `first`/`first-number`, and any spec with
a sparkline still use a range query, so nothing that renders the series is
affected (see the perses#738 sparkline regression, kept covered by tests).

Follow-up to perses#746, which was closed in favour of the per-query flag in perses#752.

Signed-off-by: s3onghyun <s3onghyun@users.noreply.github.com>
@s3onghyun
s3onghyun requested a review from a team as a code owner August 26, 2026 05:12
@s3onghyun
s3onghyun requested review from Gladorme and removed request for a team August 26, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant