Skip to content

fix(mixed-timeseries): stop duplicating first metric in multi-metric + group-by series names - #40146

Merged
rusackas merged 2 commits into
masterfrom
test/mixed-chart-duplicate-first-metric-37921
Jul 28, 2026
Merged

fix(mixed-timeseries): stop duplicating first metric in multi-metric + group-by series names#40146
rusackas merged 2 commits into
masterfrom
test/mixed-chart-duplicate-first-metric-37921

Conversation

@rusackas

@rusackas rusackas commented May 15, 2026

Copy link
Copy Markdown
Member

SUMMARY

Fixes #37921 ("Residual" follow-up to #37055): in a Mixed Chart, when Query A (or B) has multiple metrics plus at least one Group By dimension, the first metric's label got prepended to every other metric's series, producing legend/tooltip entries like score_one, score_two, A instead of score_two, A.

Root cause: in MixedTimeseries/transformProps.ts the "metric, dimension" display-name builder always used metrics[0] (MetricDisplayNameA / MetricDisplayNameB). The guard was entryName.includes(metricPart), which is false for every series belonging to metrics[1+], so those series got the first metric's label prepended on top of their own.

Fix: each series' metric is derived from its label_map tuple ([metric, ...dimensions]), which the backend already provides and which the per-series formatter lookup was already using. When the tuple doesn't carry a metric part (single-element tuples), behavior falls back to the first metric exactly as before, so single-metric charts and the showQueryIdentifiers naming are unchanged. The same fix is applied to both the Query A and Query B paths.

This PR originally landed as a deliberately-failing regression test; it has been reworked to include the actual fix, and the test passes. The test:

  • Builds a Mixed Chart with metrics: ['score_one', 'score_two'] + groupby: ['category'] on Query A
  • Provides 4-column query data (score_one, A, score_one, B, score_two, A, score_two, B) with a matching label_map
  • Asserts each (metric, dim_value) combo appears exactly once with the correct metric prefix
  • Asserts no series name contains both metric labels concatenated (/score_one,\s+score_two/)

Verified red→green locally: on master without the fix the series come back as ["score_one, score_two, B", "score_one, score_two, A", "score_one, B", "score_one, A"]; with the fix they are the expected four distinct metric, dimension names.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — string-level series naming in transformProps; see the issue for the user-visible legend symptom.

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts

All 37 MixedTimeseries tests (and the full 722-test plugin-chart-echarts suite) pass locally.

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

@rusackas
rusackas requested a review from sadpandajoe May 15, 2026 16:13
@rusackas
rusackas force-pushed the test/mixed-chart-duplicate-first-metric-37921 branch from b9ef239 to 3cc68d1 Compare July 22, 2026 04:43
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 22, 2026
@rusackas rusackas changed the title test(mixed-timeseries): regression coverage for #37921 (first metric duplicated with multi-metric + group-by) fix(mixed-timeseries): stop duplicating first metric in multi-metric + group-by series names Jul 22, 2026
@rusackas
rusackas marked this pull request as ready for review July 22, 2026 04:43
@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 32f252f
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a65649a289f74000832e5b6
😎 Deploy Preview https://deploy-preview-40146--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.24%. Comparing base (6c2ccc4) to head (897f916).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #40146   +/-   ##
=======================================
  Coverage   65.24%   65.24%           
=======================================
  Files        2795     2795           
  Lines      157643   157649    +6     
  Branches    36061    36067    +6     
=======================================
+ Hits       102853   102859    +6     
  Misses      52814    52814           
  Partials     1976     1976           
Flag Coverage Δ
javascript 71.27% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review

bito-code-review Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #484e66

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 3cc68d1..3cc68d1
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

…p duplicating first metric (#37921)

When Query A (or B) on a Mixed Chart has multiple metrics plus at least
one Group By dimension, the display-name builder in transformProps.ts
always prepended metrics[0]'s label: the entryName.includes(metricPart)
guard is false for every series belonging to metrics[1+], so those
series were renamed to e.g. 'score_one, score_two, A' instead of
'score_two, A' — the 'first metric duplicated in legend/tooltip'
symptom reported in #37921 (residual follow-up to #37055).

Derive each series' metric from its label_map tuple
([metric, ...dimensions]) instead, matching what the per-series
formatter lookup already does. Single-element tuples (no metric part)
fall back to the first metric, preserving existing behavior for
single-metric charts and showQueryIdentifiers naming. Applied to both
the Query A and Query B paths.

Includes the regression test originally landed red on this branch,
verified red on master without the fix and green with it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rusackas
rusackas force-pushed the test/mixed-chart-duplicate-first-metric-37921 branch from 3cc68d1 to 32f252f Compare July 26, 2026 01:36
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. Using toContain only verifies that each expected series name exists at least once, which allows for potential regressions where duplicate series are emitted. To ensure each metric/dimension combination appears exactly once, you should assert the length of the filtered series array and verify the count of each expected name.

To resolve this, you can update the test to count occurrences:

  // Instead of just toContain, verify the exact count
  expect(queryASeriesNames).toHaveLength(4);
  expect(queryASeriesNames.filter(n => n === 'score_one, A')).toHaveLength(1);
  expect(queryASeriesNames.filter(n => n === 'score_one, B')).toHaveLength(1);
  expect(queryASeriesNames.filter(n => n === 'score_two, A')).toHaveLength(1);
  expect(queryASeriesNames.filter(n => n === 'score_two, B')).toHaveLength(1);

There are no other comments on this PR to address. Would you like me to implement this change for you?

superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts

expect(queryASeriesNames).toHaveLength(4);
  expect(queryASeriesNames.filter(n => n === 'score_one, A')).toHaveLength(1);
  expect(queryASeriesNames.filter(n => n === 'score_one, B')).toHaveLength(1);
  expect(queryASeriesNames.filter(n => n === 'score_two, A')).toHaveLength(1);
  expect(queryASeriesNames.filter(n => n === 'score_two, B')).toHaveLength(1);

@bito-code-review

bito-code-review Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e8fde8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 32f252f..32f252f
    • superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

…te series

toContain only checked presence, so a regression emitting duplicate
series with the same (correct) name could still pass the regression
test. Compare the sorted array against the expected names instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2a37bd

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 32f252f..897f916
    • superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas requested a review from aminghadersohi July 28, 2026 04:10

@aminghadersohi aminghadersohi 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.

Approving.

Crux — series-label correctness across the full matrix. The fix derives each series' metric from its label_map tuple [metric, ...dims] (getMetricDisplayName(labelMapValues[0], verboseMap) when the tuple has >1 element) instead of always using metrics[0]. Walked the matrix:

  • multi-metric + groupby → each series gets its own correct prefix (score_two, A), no first-metric duplication;
  • single-metric + groupby → length-1/absent tuple falls back to metrics[0], behavior unchanged;
  • no-groupby → untouched else branch;
  • showQueryIdentifiers correctly threads the per-series metric into the (Query A/B) form;
  • groupby value colliding with a metric name is handled, since metricPart is now the real per-series metric so the includes guard matches the actual prefix;
  • Query B path is a faithful mirror;
  • the displayLabelMap / cross-filter map (#41622) stays consistent since the corrected displayName is also series.name.
    No legitimate series is dropped, renamed, or collapsed in any cell. It reuses the existing getMetricDisplayName helper keyed on the label-map string rather than positional indexing, so it's robust to A/B metric-array length differences.

Test (Rule-26). The regression test runs the real transformProps on real 4-column data + matching label_map and asserts sorted actual series names equal the four expected metric, dimension names plus not.toMatch(/score_one,\s+score_two/). Reverting only the production change makes metricPart = score_one for every series → score_one, score_two, A → fails both assertions. It specifically catches the duplication regression.

Threads / CI. codeant-ai's thread (swap toContain → sorted toEqual) is resolved and the change is present at HEAD; htcnokia approved; rusackas's comment resolves the codeant thread; bito reported 0 actionable suggestions. No unresolved review threads at HEAD 897f9164. Full gh pr checks all green (jest shards, playwright, cypress, lint, mypy, pre-commit, CodeQL); mergeable: MERGEABLE.

@rusackas
rusackas merged commit b5c8d4a into master Jul 28, 2026
66 checks passed
@rusackas
rusackas deleted the test/mixed-chart-duplicate-first-metric-37921 branch July 28, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: [Residual] Master Branch Mixed Chart - First metric duplicated with multiple metrics + Group By

5 participants