Skip to content

fix(bar): draw bars stacked over out-of-log-domain values from the axis start#21702

Open
rusackas wants to merge 1 commit into
apache:releasefrom
rusackas:fix/stacked-bar-log-axis
Open

fix(bar): draw bars stacked over out-of-log-domain values from the axis start#21702
rusackas wants to merge 1 commit into
apache:releasefrom
rusackas:fix/stacked-bar-log-axis

Conversation

@rusackas

@rusackas rusackas commented Jul 21, 2026

Copy link
Copy Markdown
Member

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Draws a bar that is stacked over an out-of-log-domain value (e.g. stacked over a null value) from the value axis start, instead of silently not rendering it.

Fixed issues

Details

Before: What was the problem?

When bars are stacked on a log axis and a lower series has a null ('-') value, the upper bar's stack base is 0. Since log(0) is -Infinity, that bar's base coordinate is non-finite and the rect is never drawn, even though the value still shows up in the tooltip. Minimal repro is in #19517 (live example).

Per the analysis in #19517 this seems to have regressed in 5.3.0 with the bar layout changes; earlier versions rendered this case fine.

The second series' bar (2500 in First, stacked over the null) is simply missing:

before: only two bars drawn, First is empty

After: How does it behave after the fixing?

In the progressive bar layout, a non-finite stacked base coordinate is clamped back to the value axis start, in both orientations. A bar stacked over a null value is drawn from the axis start, using the same baseline as the first bar in a stack. Bars in fully-populated stacks are unaffected.

Same option with this fix, all three bars drawn:

after: all three bars drawn

Added unit tests in test/ut/spec/series/barStackLog.test.ts (vertical, horizontal, and a guard asserting fully-populated stacked layouts are unchanged). The first two fail without the fix. Also added a manual case to test/bar-log.html.

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

test/bar-log.html, second chart.

Merging options

  • Please squash the commits into a single one when merging.

Other information

I'm aware of the conclusion in #19234 that stacked bars on a log axis can be misleading, and this PR doesn't take a position on that. The proportions concern is about how visible bars are read. This is a different problem: a value that exists in the data and the tooltip silently doesn't render at all, which reads as data loss rather than distortion. The drawn bar's top edge is still truthful against the axis.

#19518 attempted a fix for the same issue but hardcoded the stack base to 1, which would be wrong whenever the axis min isn't 1. This version clamps the computed pixel coordinate instead, so no data values are changed.

For what it's worth, we hit this downstream in Apache Superset (apache/superset#25829), where stacked bar charts on a log axis drop bars whenever a series has gaps in it.

…is start

When a bar is stacked over a value that is out of the log domain (e.g.,
stacked over a null value, making the stack base 0, and log(0) being
-Infinity), its base coordinate is non-finite and the bar is silently
not rendered. Draw such bars from the value axis start instead, as if
they were the first bar in their stack.

close apache#19517

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@echarts-bot

echarts-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

The pull request is marked to be PR: author is committer because you are a committer of this project.

@villebro villebro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for the fix! Tagging PMCs for final review/merge.

@rusackas

Copy link
Copy Markdown
Member Author

Hi @Ovilia and @100pah :) Long time since we've talked, I hope all is well. Let me know if there are any questions I/we can answer, and thanks in advance if it merges!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants