Skip to content

fix(echarts): fix stacked horizontal bar chart clipping and duplicate x-axis labels#39012

Merged
michael-s-molina merged 2 commits intoapache:masterfrom
michael-s-molina:fix-stacked-bar
Apr 1, 2026
Merged

fix(echarts): fix stacked horizontal bar chart clipping and duplicate x-axis labels#39012
michael-s-molina merged 2 commits intoapache:masterfrom
michael-s-molina:fix-stacked-bar

Conversation

@michael-s-molina
Copy link
Copy Markdown
Member

@michael-s-molina michael-s-molina commented Apr 1, 2026

User description

SUMMARY

Fixes two related bugs in the ECharts horizontal stacked bar chart (echarts_timeseries_bar with horizontal orientation and truncateYAxis enabled):

  1. Bars appear not stacked — stacked bars beyond the individual series max were clipped, making the chart look like bars were rendering individually rather than stacked.
  2. Duplicate x-axis labels — with an artificially low xAxis.max, ECharts generated ticks at sub-integer intervals (e.g. 0.5 steps), and the integer formatter produced labels like 1 2 2 3 3 4 4.

Root cause

shouldCalculateDataBounds computes yAxisMax from individual per-series values (dataMax). For a stacked chart this is incorrect — the axis maximum must accommodate the stacked total per row, not any single series value.

Example: with series High=2, Low=2, Medium=4, dataMax=4 but the stacked total is 8. Setting xAxis.max=4 clips bars at half their height and produces a cramped axis range that triggers duplicate tick labels.

Fix

When stack is truthy, use the max of sortedTotalValues (per-row stacked totals already computed by extractSeries) as the effective axis max instead of dataMax.

Additionally, guard the stackDimension series assignment to skip undefined dimension values, preventing accidental overwrite of the stack property with undefined.

Fixes #38989
Fixes #38988

BEFORE / AFTER

Screenshot 2026-04-01 at 15 20 05 Screenshot 2026-04-01 at 15 20 17

TESTING INSTRUCTIONS

  1. Create a horizontal bar chart (echarts_timeseries_bar, orientation = Horizontal) with multiple metrics and Stack enabled.
  2. Enable Truncate Y Axis (or set y-axis bounds).
  3. Verify bars stack correctly to their full combined height.
  4. Verify x-axis labels show clean integer ticks without duplicates.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

CodeAnt-AI Description

Fix stacked horizontal bar charts so bars are fully visible and axis labels stay clean

What Changed

  • Stacked horizontal bar charts now use the full stacked total when setting the axis range, so bars are no longer cut off.
  • This also prevents cramped axis spacing that caused duplicate number labels.
  • Series grouping no longer gets overwritten when the selected grouping value is missing.

Impact

✅ Fewer clipped stacked bars
✅ Clearer axis labels on horizontal charts
✅ More reliable stacked bar grouping

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 1, 2026

Code Review Agent Run #ede868

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

@dosubot dosubot Bot added viz:charts:bar Related to the Bar chart viz:charts:echarts Related to Echarts labels Apr 1, 2026
@codeant-ai-for-open-source codeant-ai-for-open-source Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Apr 1, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 1, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 2ee1490
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69cd6226c90ff8000860e75c
😎 Deploy Preview https://deploy-preview-39012--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 1, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit dee926b
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69cd62c69099e100086fbec0
😎 Deploy Preview https://deploy-preview-39012--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.42%. Comparing base (8ed7578) to head (a781bcd).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
...gin-chart-echarts/src/Timeseries/transformProps.ts 76.92% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #39012   +/-   ##
=======================================
  Coverage   64.42%   64.42%           
=======================================
  Files        2536     2536           
  Lines      131103   131113   +10     
  Branches    30434    30441    +7     
=======================================
+ Hits        84467    84476    +9     
- Misses      45173    45174    +1     
  Partials     1463     1463           
Flag Coverage Δ
javascript 65.83% <76.92%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@michael-s-molina michael-s-molina merged commit 0223428 into apache:master Apr 1, 2026
72 checks passed
michael-s-molina added a commit that referenced this pull request Apr 1, 2026
michael-s-molina added a commit that referenced this pull request Apr 1, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

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

Labels

plugins size/L size:S This PR changes 10-29 lines, ignoring generated files viz:charts:bar Related to the Bar chart viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bar charts when unstacked don't correctly display for value 1 Bar chart results & displayed data mismatch

2 participants