Skip to content

fix(plugin-chart-echarts): exclude extra metrics from stacked totals - #42855

Open
krishn1301 wants to merge 1 commit into
apache:masterfrom
krishn1301:fix-only-total-excludes-sort-metric
Open

fix(plugin-chart-echarts): exclude extra metrics from stacked totals#42855
krishn1301 wants to merge 1 commit into
apache:masterfrom
krishn1301:fix-only-total-excludes-sort-metric

Conversation

@krishn1301

Copy link
Copy Markdown

SUMMARY

Fixes #42701.

With Stacked Style: Stack and Only Total enabled, the total shown above each bar included the sort metric. In the reported case, metrics A = 32 and B = 0 with a timeseries_limit_metric of 2 displayed a total of 34 instead of 32.

extractDataTotalValues sums every numeric column in each row:

Object.keys(data).reduce((prev, curr) => { ... prev + data[curr] ... })

A sort metric is present in the query result but is never rendered as a series, so it silently inflated the total — and the thresholdValues derived from that total, which decides which labels are shown.

This threads the extra metric labels into extractDataTotalValues and skips those columns when accumulating. The labels were already being computed in transformProps.ts via extractExtraMetrics(...).map(getMetricLabel); that computation just happened after the extractDataTotalValues call, so it's moved above and passed in. The new option is optional, so other callers of extractDataTotalValues are unaffected.

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test/utils/series.test.ts

Four tests were added under extractDataTotalValues, using the exact numbers from the issue:

  • excludes extra metrics from the stacked total — A=32, B=0, Sort=2 gives [32] (fails without this change)
  • includes every metric when no extraMetricLabels are passed — the same row gives [34]
  • derives thresholdValues from the total excluding extra metrics (fails without this change)
  • respects legendState alongside the exclusion

Manually: build a Stacked Timeseries Bar chart with two metrics, set a Sort By metric that differs from both, enable Only Total, and confirm the total equals the sum of the visible segments.

ADDITIONAL INFORMATION

extractDataTotalValues summed every numeric column in each row, so a timeseries_limit_metric that is not rendered as a series still inflated the Only Total value. With metrics A=32, B=0 and a sort metric of 2, the total showed 34 instead of 32.

Threads extraMetricLabels into extractDataTotalValues and excludes those columns from both the total and the derived threshold.

Fixes apache#42701

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dosubot dosubot Bot added viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries labels Aug 6, 2026
@bito-code-review

bito-code-review Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #05c1eb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 2b65713..2b65713
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/series.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

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 2b65713
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a74d4efa4ce930008d23ee9
😎 Deploy Preview https://deploy-preview-42855--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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timeseries Bar: stacked 'Only Total' sum includes the series-limit/sort metric's value, not just the displayed metrics

1 participant