Skip to content

fix(explore): zero-value stacked bar segment no longer overlaps its neighbor's label - #42882

Open
vjymisal0 wants to merge 4 commits into
apache:masterfrom
vjymisal0:fix/stacked-label-overlap-zero-value-clean
Open

fix(explore): zero-value stacked bar segment no longer overlaps its neighbor's label#42882
vjymisal0 wants to merge 4 commits into
apache:masterfrom
vjymisal0:fix/stacked-label-overlap-zero-value-clean

Conversation

@vjymisal0

Copy link
Copy Markdown

SUMMARY

On a stacked Timeseries Bar chart (echarts_timeseries_bar) with multiple metrics/series and "Show Value" enabled (not "Only Total"), a series whose value is exactly 0 for a given x-axis category still gets a visible value label, rendered at the same pixel position as the label of the segment directly below it — a zero-height stacked segment starts and ends at the same y-coordinate as the top of the previous segment, so the two labels overlap into unreadable, doubled text.

Root cause, in the per-series label.formatter in Timeseries/transformers.ts: the label is shown when numericValue >= thresholdValues[dataIndex]. thresholdValues[dataIndex] comes from ((percentageThreshold || 0) / 100) * values in extractDataTotalValues, so under the default percentage_threshold: 0 it's 0 for every row — and 0 >= 0 is true, so a segment with literally no height still gets a label.

Fix: require the value to be strictly positive before showing a per-series stacked label, independent of the configured threshold. A zero-height segment has no meaningful position to attach a label to regardless of threshold settings.

Related to, but distinct from, #42701 (which is about the "Only Total" sum being wrong rather than per-series label overlap) — I opened a separate PR (#42881) for that one since the two bugs are in different functions with independent fixes.

Closes #42702

TESTING INSTRUCTIONS

Added does not render a per-series stacked label for a zero-value segment (#42702) to test/Timeseries/transformers.test.ts's transformSeries suite, exercising the label.formatter directly: asserts an empty string for a 0 value and the formatted string for a non-zero one, with thresholdValues: [0] to match the default percentage_threshold.

Ran locally:

npx jest plugins/plugin-chart-echarts/test/Timeseries
npx oxlint --config oxlint.json --quiet <changed files>

240 tests pass, oxlint clean.

Manual repro steps are in the linked issue (stacked bar chart, 2 metrics where one is 0 for a category, Show Value on, Only Total off).

ADDITIONAL INFORMATION

…eighbor's label

On a stacked Timeseries Bar chart with "Show Value" enabled (not
"Only Total"), a series whose value was exactly 0 for a category
still got a visible label, rendered at the same position as the
label of the segment directly below it, since a zero-height stacked
segment starts and ends where the previous segment's top is.

The per-series label formatter only compared the value against
thresholdValues[dataIndex], which is 0 for every row under the
default percentage_threshold of 0 — so `numericValue >= 0` always
passed for a literal 0. Now requires the value to be strictly
positive first, independent of the configured threshold.

Closes apache#42702
Copilot AI lite review requested due to automatic review settings August 7, 2026 06:46

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dosubot dosubot Bot added viz:charts:echarts Related to Echarts viz:charts:timeseries Related to Timeseries labels Aug 7, 2026
@bito-code-review

bito-code-review Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ff2283

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts - 1
Review Details
  • Files reviewed - 2 · Commit Range: 57a199f..57a199f
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.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

Comment on lines 477 to +480
if (
numericValue > 0 &&
numericValue >=
(thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
(thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)

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.

Suggestion: The strictly-positive guard suppresses every negative stacked-segment label, even when the configured percentage threshold allows it. Negative values have a nonzero segment position and the previous comparison could legitimately render them, particularly when the stacked total and threshold are negative. Restrict the new guard to excluding exactly zero while preserving the existing threshold behavior for negative values. [logic error]

Severity Level: Major ⚠️
- ⚠️ Negative stacked segment labels disappear under negative totals.
- ⚠️ Configured percentage thresholds no longer preserve prior behavior.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
**Line:** 477:480
**Comment:**
	*Logic Error: The strictly-positive guard suppresses every negative stacked-segment label, even when the configured percentage threshold allows it. Negative values have a nonzero segment position and the previous comparison could legitimately render them, particularly when the stacked total and threshold are negative. Restrict the new guard to excluding exactly zero while preserving the existing threshold behavior for negative values.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 26a1ab9 — changed the guard from numericValue > 0 to numericValue !== 0 so negative values are no longer suppressed, and added a regression test.

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current implementation uses numericValue > 0, which incorrectly suppresses negative values that should be rendered if they meet the threshold criteria. To resolve this, the guard should be updated to exclude only zero (numericValue !== 0) while allowing negative values to be evaluated against the threshold.

Here is the corrected implementation for the logic in superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts:

          if (
            numericValue !== 0 &&
            numericValue >=
              (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
          ) {

I have validated this against the provided diff. Would you like me to check the other comments on this PR and implement fixes for them as well?

superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts

if (
            numericValue !== 0 &&
            numericValue >=
              (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
          ) {

…ones

numericValue > 0 also suppressed a genuine negative value whenever it
cleared the (possibly also negative) threshold for a category whose
stacked total is itself negative — the zero-height overlap bug this
guard fixes has nothing to do with sign, only with a value of exactly
0. Changed to numericValue !== 0 and added a regression test for the
negative case.

Thanks to the Bito AI review on this PR for catching this.
@vjymisal0

Copy link
Copy Markdown
Author

Good catch — pushed a fix. Changed numericValue > 0 to numericValue !== 0: the strictly-positive check also suppressed a genuine negative value whenever it cleared a (possibly also negative) threshold, for a category whose stacked total is itself negative. The zero-height overlap bug is specifically about a value of exactly 0, not about sign. Added a regression test for the negative case.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.37%. Comparing base (38ba4a6) to head (65e0ed5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42882      +/-   ##
==========================================
+ Coverage   57.10%   66.37%   +9.26%     
==========================================
  Files        2857     2857              
  Lines      161125   161047      -78     
  Branches    37060    37048      -12     
==========================================
+ Hits        92014   106888   +14874     
+ Misses      68259    52143   -16116     
- Partials      852     2016    +1164     
Flag Coverage Δ
javascript 73.19% <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 Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #b3a042

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 57a199f..26a1ab9
    • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.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

@sadpandajoe

Copy link
Copy Markdown
Member

@vjymisal0 can you add before and after screenshots of your fix into the PR description?

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts:171

  • The test comment explains the pre-fix behavior as numericValue >= 0, but the implementation uses (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER), so with a default threshold of 0 the check effectively doesn’t filter values at all. Updating the comment to match the actual logic will avoid confusion for future readers.
      // percentage_threshold defaults to 0, so thresholdValues[dataIndex] is
      // 0 too — a value of exactly 0 would satisfy `numericValue >= 0`
      // without the explicit `numericValue !== 0` guard.

transformSeries expects opts.formatter: ValueFormatter (NumberFormatter |
CurrencyFormatter), but the two zero/negative-value regression tests
passed a plain arrow function, which fails tsc under lint-frontend CI.
Wrap the same format logic in a NumberFormatter instance instead.
@vjymisal0

Copy link
Copy Markdown
Author

Pushed 5ffaf3a — the two regression tests were passing a plain arrow function for opts.formatter, but that option is typed as ValueFormatter (a NumberFormatter/CurrencyFormatter instance), which broke tsc under lint-frontend CI. Wrapped the same format logic in new NumberFormatter({...}) — no behavior change.

@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

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

@bito-code-review

bito-code-review Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2538c4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 26a1ab9..5ffaf3a
    • superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformers.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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timeseries Bar (stacked): zero-value series label overlaps the adjacent segment's label when percentage_threshold is 0

3 participants