Skip to content

Aggregate y value for same x - #7631

Merged
yoshiokatsuneo merged 3 commits into
getredash:masterfrom
yoshiokatsuneo:feat/aggregate_y_value_for_same_x
Feb 20, 2026
Merged

yoshiokatsuneo merged 3 commits into
getredash:masterfrom
yoshiokatsuneo:feat/aggregate_y_value_for_same_x

Conversation

@yoshiokatsuneo

@yoshiokatsuneo yoshiokatsuneo commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Feature

Description

Before the PR, when the data have multiple items for the same x, Redash shows weird chart.
For Line or Area(non-stacked) chart, it have horizontal line for the multiple value.
For Bar or Area(stacked) chart, it shows aggregated(summed) value but the label is not correct.

This PR handle the situation where there are multiple items for the same x by aggregate(sum up) y value, like Pie chart does.

This makes easy to create chart from the data having multiple group columns which is suitable for Pivot Table.

How is this tested?

  • Manually
  1. Create and run the following query (for PostgreSQL data source, in this example.)
select '2025-01-01' as t, 'apple' as grp1, 'tokyo' as grp2, 10 as value
union all
select '2025-01-01' as t, 'orange' as grp1, 'tokyo' as grp2, 20 as value
union all
select '2025-01-01' as t, 'apple' as grp1, 'osaka' as grp2, 30 as value
union all
select '2025-01-01' as t, 'orange' as grp1, 'osaka' as grp2, 40 as value
union all
select '2025-01-02' as t, 'apple' as grp1, 'tokyo' as grp2, 210 as value
union all
select '2025-01-02' as t, 'orange' as grp1, 'tokyo' as grp2, 220 as value
union all
select '2025-01-02' as t, 'apple' as grp1, 'osaka' as grp2, 230 as value
union all
select '2025-01-02' as t, 'orange' as grp1, 'osaka' as grp2, 240 as value
union all
select '2025-01-03' as t, 'apple' as grp1, 'tokyo' as grp2, 110 as value
union all
select '2025-01-03' as t, 'orange' as grp1, 'tokyo' as grp2, 120 as value
union all
select '2025-01-03' as t, 'apple' as grp1, 'osaka' as grp2, 130 as value
union all
select '2025-01-03' as t, 'orange' as grp1, 'osaka' as grp2, 140 as value
  1. Create Bar / Line / Area chart
image image image
  1. See the chart

Before the PR, the chart is shown like below.
image
image
image

After the PR, the chart is shown like below.

image image image

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

@yoshiokatsuneo
yoshiokatsuneo marked this pull request as ready for review February 19, 2026 17:16

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts">

<violation number="1" location="viz-lib/src/visualizations/chart/plotly/prepareDefaultData.ts:130">
P2: Aggregating `y` with `item.y += y` can turn a valid value into `NaN` when a later row has missing `y`, because `cleanNumber` returns `undefined` for missing inputs. Guard against `null/undefined` so missing values don’t corrupt the aggregated total.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

eradman
eradman previously approved these changes Feb 19, 2026

@eradman eradman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested this with several charts that may have duplicate values on X. No regressions found so far

@yoshiokatsuneo

Copy link
Copy Markdown
Contributor Author

@eradman Sorry, but I changed the PR to add null check for the values.
Ca you re-review, if possible?

@eradman eradman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

@yoshiokatsuneo
yoshiokatsuneo merged commit 3b0ea56 into getredash:master Feb 20, 2026
10 checks passed
@yoshiokatsuneo

Copy link
Copy Markdown
Contributor Author

@eradman

Thank you for the quick review and testing !

woogakoki added a commit to wooga/redash that referenced this pull request Feb 25, 2026
* master: (69 commits)
  Update Python version to 3.13 (getredash#7636)
  Update plotly.js to 3.3.1, react-pivottable to 0.11.0 (getredash#7634)
  Add charset option to RDS MySQL datasource (getredash#7616)
  Aggregate y value for same x (getredash#7631)
  fix(mysql): Change default charset to utf8mb4 (getredash#7615)
  Update packages for compatibility with setuptools 82 (getredash#7622)
  Snapshot: 26.02.0-dev
  chore: support ipv6 for server in docker (getredash#7596)
  Add impersonation option in trino datasource (getredash#7605)
  Fix Elasticsearch connector configuration key mismatch (getredash#7607)
  duckdb: Show catalog (database) where applicable (e.g. Motherduck) (getredash#7599)
  Snapshot: 26.01.0-dev
  Feature/catch notsupported exception (getredash#7573)
  Multi-org: format base path, not including protocol (getredash#7260)
  fix(destinations): Handle unicode characters in webhook notifications (getredash#7586)
  Persist updated values and apply saved dashboard parameters (getredash#7570)
  Add ibm-db package to enable DB2 as datasource: (getredash#7581)
  Snapshot: 25.12.0-dev
  PostgreSQL: allow connection parameters to be specified (getredash#7579)
  Add lineShape option for Line and Area charts (getredash#7582)
  ...
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.

2 participants