Skip to content

[ENHANCEMENT]: Add negative y axis support#696

Open
ibakshay wants to merge 1 commit into
mainfrom
feat/timeserieschart-negative-y
Open

[ENHANCEMENT]: Add negative y axis support#696
ibakshay wants to merge 1 commit into
mainfrom
feat/timeserieschart-negative-y

Conversation

@ibakshay

Copy link
Copy Markdown
Contributor

Description

This pull request resolves perses/perses#3315

Screenshots

Screenshot 1

image

Screenshot 2

image

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: Akshay Iyyadurai Balasundaram <akshay.iyyadurai.balasundaram@sap.com>
@ibakshay ibakshay requested review from a team, AntoineThebaud and Nexucis as code owners June 22, 2026 13:30
@ibakshay ibakshay requested review from Copilot and shahrokni and removed request for a team June 22, 2026 13:30

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

This PR adds per-query Negative Y support to the TimeSeriesChart plugin so a query’s series can be negated for display (rendering below the X axis) while keeping the original values for legend calculations and CSV export, matching the Grafana “negative-Y” transform use case (issue #3315).

Changes:

  • Negate rendered datapoints when querySettings[].negativeY is enabled, without altering underlying query results / legend calculations.
  • Fix percent-threshold computation to use absolute magnitudes so percent thresholds still work when series are negated.
  • Extend plugin model/schema/SDK + migration and validation tests, and document the new option.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
timeserieschart/src/utils/data-transform.ts Uses absolute values when computing max for percent thresholds (supports negated series).
timeserieschart/src/utils/data-transform.test.ts Adds a unit test ensuring percent thresholds still resolve with negated (negative) inputs.
timeserieschart/src/TimeSeriesChartPanel.tsx Applies negativeY by negating rendered series values while keeping original values for legend/CSV.
timeserieschart/src/time-series-chart-model.ts Adds negativeY?: boolean to query settings model with docstring.
timeserieschart/src/QuerySettingsEditor.tsx Adds UI controls to add/remove the per-query Negative Y setting.
timeserieschart/sdk/go/time-series.go Adds NegativeY to the Go SDK query settings struct.
timeserieschart/schemas/time-series.cue Extends the CUE schema to allow negativeY?: bool.
timeserieschart/schemas/tests/valid/time-series-negative-y.json Adds a valid schema test fixture for negativeY.
timeserieschart/schemas/tests/valid/time-series-negative-y-stacked.json Adds a valid schema test fixture for negativeY with stacking.
timeserieschart/schemas/migrate/migrate.cue Migrates Grafana transform: "negative-Y" (panel default + overrides) into querySettings[].negativeY.
timeserieschart/schemas/migrate/tests/negative-y-panel-default/input.json Migration test input for panel-level negative-Y transform.
timeserieschart/schemas/migrate/tests/negative-y-panel-default/expected.json Expected migrated output with negativeY applied to queries.
timeserieschart/schemas/migrate/tests/negative-y-override/input.json Migration test input for per-series override negative-Y transform.
timeserieschart/schemas/migrate/tests/negative-y-override/expected.json Expected migrated output with negativeY applied to the overridden query only.
docs/timeserieschart/model.md Documents negativeY and notes compatibility/edge cases.

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

Comment on lines +281 to +284
// When negativeY is set on this query, negate the rendered values so the
// series renders below the X axis. The original (positive) values are
// preserved in `timeSeries.values` (used for legend calculations) and in
// `queryResults` (used for CSV export).
Comment on lines +49 to +53
/**
* If true, the query's series values are negated for display so they render
* below the X axis. The original (positive) values are preserved for legend
* calculations and CSV export, matching Grafana's `transform: "negative-Y"` behavior.
*/
Comment on lines +86 to +88
# negativeY renders the query's series below the X axis. Values are negated for display only;
# legend calculations and CSV export keep the original (positive) values.
negativeY: <boolean> # Optional
Comment on lines +97 to +98
- **CSV export**: exports the original positive values from the query results.
- **Legend calculations (min / max / mean / …)**: computed from the original positive values.
lineStyle?: #lineStyle
areaOpacity?: #areaOpacity
format?: common.#format
negativeY?: bool // render the query's series below the X axis
Comment on lines +508 to +510
<Typography variant="body2" color="text.secondary" sx={{ flexGrow: 1, py: 0.5 }}>
Series rendered below the X axis
</Typography>
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.

TimeSeriesChart: query settings: add option to have negative Y

2 participants