Skip to content

fix(echarts): stop labeling zero-value segments in stacked bar charts - #43178

Open
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/bar-zero-value-label-overlap
Open

fix(echarts): stop labeling zero-value segments in stacked bar charts#43178
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/bar-zero-value-label-overlap

Conversation

@bikash-barnwal

Copy link
Copy Markdown

SUMMARY

In a stacked Timeseries Bar chart with Values labels on, a series whose value is exactly 0 still rendered a label. A zero-value segment has no height, so its label is anchored to the same pixel as the neighboring segment's label and the two render on top of each other.

The mechanism is the threshold guard in transformSeries:

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

With percentage_threshold at its default of 0, extractDataTotalValues pushes a per-row threshold of 0 — which is falsy, so the guard degrades to numericValue >= Number.MIN_SAFE_INTEGER and admits everything, zeros included.

The fix returns an empty label for numericValue === 0 in that branch. It deliberately does not use > 0: negative stacked values render visible segments and are legitimately labeled today, so only the zero case — the one with nothing to anchor to — is suppressed. The guard sits after the !stack early return, so unstacked charts still label zeros as before. MixedTimeseries shares this code path and is fixed along with it.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: the zero series' 0 label sits on top of the adjacent segment's label.
After: no label is drawn for the zero-height segment; every other label is unchanged.

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test/Timeseries plugins/plugin-chart-echarts/test/MixedTimeseries

(295 tests across 17 suites pass, including the new case.)

Manually:

  1. Build a Timeseries Bar chart with a dimension that produces a zero value for one series in a given bucket.
  2. Set Stacked Style to Stack, enable Show Values, leave Percentage threshold at 0.
  3. Before this change the zero series' label overlaps its neighbor's; after it, only visible segments carry labels.

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

A stacked segment whose value is exactly 0 has no height, so its value
label is anchored to the same pixel as the label of the segment below it
and the two render on top of each other as unreadable doubled text. The
percentage-threshold guard does not catch this: with the field's default
of 0 the per-row threshold is 0, which falls back to
Number.MIN_SAFE_INTEGER, so every value including 0 clears it. There is
nothing visible to label for a zero-height segment, so suppress the
label regardless of the threshold setting instead of making users
configure a positive percentage threshold as a workaround.

Fixes apache#42702

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

bito-code-review Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #4e1103

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: a2fd145..a2fd145
    • 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

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.70%. Comparing base (c068a8c) to head (a2fd145).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43178   +/-   ##
=======================================
  Coverage   66.70%   66.70%           
=======================================
  Files        2872     2872           
  Lines      163447   163449    +2     
  Branches    37727    37728    +1     
=======================================
+ Hits       109024   109026    +2     
  Misses      52293    52293           
  Partials     2130     2130           
Flag Coverage Δ
javascript 73.76% <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.

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

2 participants