Skip to content

[ENHANCEMENT] timeserieschart: add per-query stack override#670

Open
SoWieMarkus wants to merge 4 commits into
perses:mainfrom
SoWieMarkus:feat/exclude-time-series-from-stacking
Open

[ENHANCEMENT] timeserieschart: add per-query stack override#670
SoWieMarkus wants to merge 4 commits into
perses:mainfrom
SoWieMarkus:feat/exclude-time-series-from-stacking

Conversation

@SoWieMarkus

@SoWieMarkus SoWieMarkus commented Jun 5, 2026

Copy link
Copy Markdown

Description

Adds a per-query stack override to the Time Series Chart plugin, allowing individual queries to opt in or out of stacking regardless of the global visual stack setting. This mirrors the behavior of Grafana/Plutono, where stacking can be controlled at the series level.

What changed:

  • Added a stack?: bool field to QuerySettingsOptions in the model, CUE schema, and Go SDK
  • Added a Stack Switch in the QuerySettingsEditor
  • Updated getTimeSeries() in data-transform.ts to prefer the per-query stack flag over the global visual.stack === 'all' when set
  • Moved getCommonTimeScale and getTimeSeriesValues imports from @perses-dev/components to @perses-dev/core (because not available in @perses-dev/components? Can revert that change ofc)

Open question:

The drawing order of stacked series depends on the order queries are defined. This could be relevant now since time series can overlap. But if they are not stacked it's the same. So just a thought. A dedicated zIndex field in QuerySettingsOptions could give explicit control over this - though it only matters at higher opacity values anyway.

Also in Grafana / Plutono the Stacking Option is a boolean. I didn't want to adjust that since that would be a breaking change, but might also be something to consider.

Screenshots

Query 1 excluded from stacking

Query 1 excluded from stacking.

Query 1 included again in stacking

Query 1 included again in stacking.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Signed-off-by: Markus Wieland <markus.wieland@sap.com>
@SoWieMarkus SoWieMarkus requested review from a team, AntoineThebaud and Nexucis as code owners June 5, 2026 14:30
@SoWieMarkus SoWieMarkus requested review from jgbernalp and removed request for a team June 5, 2026 14:30
@ibakshay ibakshay requested a review from Copilot June 12, 2026 05:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a per-query stack?: boolean override to the Time Series Chart plugin so individual queries can opt in/out of stacking regardless of the global visual stacking setting, and wires this through the model + UI + series transformation logic.

Changes:

  • Extends query settings (TS model, CUE schema, Go SDK) with stack?: boolean.
  • Adds a Stack override control to the Query Settings editor.
  • Updates series generation to prefer per-query stack override over global visual.stack.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
timeserieschart/src/VisualOptionsEditor.tsx Minor adjustment in visual stack option update line.
timeserieschart/src/utils/data-transform.ts Implements per-query stack override logic in getTimeSeries() and moves getCommonTimeScale import.
timeserieschart/src/TimeSeriesChartPanel.tsx Moves getTimeSeriesValues import to @perses-dev/core.
timeserieschart/src/TimeSeriesChartBase.tsx Moves getCommonTimeScale import to @perses-dev/core.
timeserieschart/src/time-series-chart-model.ts Adds stack?: boolean to QuerySettingsOptions.
timeserieschart/src/QuerySettingsEditor.tsx Adds Stack override UI (Switch) and plumbing for query settings updates.
timeserieschart/sdk/go/time-series.go Adds stack field to Go SDK query settings struct.
timeserieschart/schemas/time-series.cue Adds stack?: bool to the CUE schema.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread timeserieschart/src/utils/data-transform.ts
Comment thread timeserieschart/src/TimeSeriesChartBase.tsx
Comment thread timeserieschart/src/TimeSeriesChartPanel.tsx
Comment thread timeserieschart/src/utils/data-transform.ts
Comment on lines 75 to 96
@@ -90,7 +92,7 @@ export function getTimeSeries(
datasetIndex,
name: formattedName,
color: paletteColor,
stack: visual.stack === 'all' ? visual.stack : undefined,
stack: shouldStack ? 'all' : undefined,
yAxisIndex: yAxisIndex,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoWieMarkus, I can also confirm that the tooltip is not working anymore when it is stacked after your changes. I tested manually.

@ibakshay ibakshay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with the PR! I left some minor comments.

I also have a question.
How does your change will affect the existing "Stack Series - All | None" feature?

Image

Comment thread timeserieschart/src/utils/data-transform.ts Outdated
Comment thread timeserieschart/src/TimeSeriesChartBase.tsx Outdated
Comment thread timeserieschart/src/TimeSeriesChartPanel.tsx Outdated
SoWieMarkus and others added 3 commits June 12, 2026 11:00
Co-authored-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Markus Wieland <44964229+SoWieMarkus@users.noreply.github.com>
Co-authored-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Markus Wieland <44964229+SoWieMarkus@users.noreply.github.com>
Co-authored-by: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
Signed-off-by: Markus Wieland <44964229+SoWieMarkus@users.noreply.github.com>
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.

3 participants