Skip to content

fix(plugin-chart-echarts): hide value labels on zero-height stacked segments - #42854

Open
krishn1301 wants to merge 1 commit into
apache:masterfrom
krishn1301:fix-zero-value-stacked-label-overlap
Open

fix(plugin-chart-echarts): hide value labels on zero-height stacked segments#42854
krishn1301 wants to merge 1 commit into
apache:masterfrom
krishn1301:fix-zero-value-stacked-label-overlap

Conversation

@krishn1301

Copy link
Copy Markdown

SUMMARY

Fixes #42702.

On a stacked timeseries bar chart, a series whose value is 0 occupies no vertical space, but its value label was still rendered — landing on top of the label of the segment next to it.

The root cause is a falsy check, not the label logic itself. In transformSeries:

numericValue >= (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)

When percentage_threshold is 0 (the default), thresholdValues[dataIndex] is 0, which is falsy, so the || falls through to Number.MIN_SAFE_INTEGER and every value passes the guard, including 0.

This skips the label when the value is exactly 0, before the threshold comparison.

I used numericValue !== 0 rather than the numericValue > 0 suggested in the issue: > 0 would also hide labels on negative segments, which do occupy space and legitimately need a label. There's a regression test covering that case.

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test/Timeseries/transformers.test.ts

Four tests were added under transformSeries › stacked value labels:

  • hides the label for a zero value when the threshold is 0 (fails without this change)
  • still shows the label for a non-zero value at threshold 0
  • still shows the label for a negative value (guards against the > 0 regression)
  • still hides a value that is below an explicit non-zero threshold

Manually: create a Stacked Timeseries Bar chart with two metrics where one returns 0 for some x-values, turn on Show Value, and confirm the 0 labels no longer overlap the adjacent labels.

ADDITIONAL INFORMATION

…egments

thresholdValues[dataIndex] is 0 when percentage_threshold is 0, which is falsy, so the guard fell back to Number.MIN_SAFE_INTEGER and every value passed. A zero-value series occupies no space in a stacked chart, so its label rendered on top of the adjacent segment's label.

Skips the label when the value is exactly 0 while leaving negative values and non-zero thresholds untouched.

Fixes apache#42702

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dosubot dosubot Bot added change:frontend Requires changing the frontend 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 #2b2655

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts - 1
    • Test gap for threshold logic · Line 474-474
      Tests use threshold=0 for all cases, which triggers the MIN_SAFE_INTEGER fallback path. No test exercises the case where `thresholdValues[dataIndex]` is actually set and non-zero, leaving the primary logic path unvalidated.
Filtered by Review Rules

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

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

@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

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

Comment on lines 473 to 477
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 zero-value guard is reached for non-stacked series when legendState marks the series as unselected, because those series bypass the earlier !stack && isSelectedLegend branch. This changes the existing behavior and suppresses zero labels even though the overlap problem only applies to stacked segments. Restrict the zero suppression to stacked series or preserve the non-stacked label path. [incorrect condition logic]

Severity Level: Minor 🧹
- ⚠️ Isolated unstacked series can lose zero-value labels.
- ⚠️ Legend double-click filtering affects label rendering.
- ⚠️ Stacked-chart overlap fix changes unstacked chart 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:** 473:477
**Comment:**
	*Incorrect Condition Logic: The zero-value guard is reached for non-stacked series when `legendState` marks the series as unselected, because those series bypass the earlier `!stack && isSelectedLegend` branch. This changes the existing behavior and suppresses zero labels even though the overlap problem only applies to stacked segments. Restrict the zero suppression to stacked series or preserve the non-stacked label path.

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
👍 | 👎

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current implementation unconditionally suppresses zero-value labels for all series, which incorrectly affects non-stacked charts where zero values should remain visible. To resolve this, the zero-value check should be conditional on whether the chart is stacked.

Proposed Fix

Update the condition in superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts to only suppress zero values when stack is enabled:

          if (
            (stack && numericValue !== 0 || !stack) &&
            numericValue >=
              (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
          ) {
            return formatter(numericValue);
          }

This change ensures that zero-value suppression only applies to stacked series, preserving existing behavior for non-stacked charts. Please let me know if you would like me to check the remaining comments on this PR.

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

if (
            (stack && numericValue !== 0 || !stack) &&
            numericValue >=
              (thresholdValues[dataIndex] || Number.MIN_SAFE_INTEGER)
          ) {
            return formatter(numericValue);
          }

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

Labels

change:frontend Requires changing the frontend 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): zero-value series label overlaps the adjacent segment's label when percentage_threshold is 0

1 participant