Skip to content

fix(toolbox): respect series.stack when switching magicType stack. close #15571 - #21799

Open
b84330808 wants to merge 1 commit into
apache:masterfrom
b84330808:fix-15571
Open

b84330808 wants to merge 1 commit into
apache:masterfrom
b84330808:fix-15571

Conversation

@b84330808

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Make the magicType stack button recognize series that are already stacked by series.stack, and restore those stack groups when switching back from tiled.

Fixed issues

Details

Before: What was the problem?

The stack button only treated a series as stacked when its stack was the inner keyword set by the button itself (__ec_magicType_stack__). For series stacked by users (e.g. stack: 'cars'):

  • The first click "stacked" them again, so nothing visibly changed, and it only took effect on the second click.
  • Separate user stack groups (e.g. groupA and groupB) were merged into one single stack, and the original groups were never restored.

After: How does it behave after the fixing?

  • Whether the chart is currently stacked is decided once per click over all target line/bar series: it is stacked if any series uses the magicType inner stack, or if any series.stack value is shared by more than one series. So user-stacked charts switch to tiled on the first click.
  • When switching to tiled, the user-defined stack values are remembered per series id on the global model (like the dataZoom history) and restored when switching back. Series without a user-defined stack still use the inner magicType stack as before.
  • Existing behaviors are kept: charts without stacks, a single series, and a stack name used by only one series (as in test/toolbox-stack.html) toggle the same way as before.

Added unit tests in test/ut/spec/component/toolbox/magicType.test.ts. They click the actual toolbox icon, and 3 of them fail without this change. The full unit test suite, tsc --noEmit and eslint pass.

I used Claude Code to write this change.

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/ut/spec/component/toolbox/magicType.test.ts

Merging options

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

Other information

Related reports: #16473, #20371, #20031, #13103.

…lose apache#15571

The stack button of magicType only regarded series as stacked when their
`stack` was the inner keyword set by the button itself. So series stacked
by users were stacked again on the first click (nothing changed, and
separate stack groups were merged into one), and the original stack
groups were lost after switching back from tiled.

Now whether the series are stacked is decided by all of the target
series, which also recognizes the stacks defined in `series.stack`, and
the original stacks are restored when switching back to stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echarts-bot

echarts-bot Bot commented Oct 20, 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.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

This branch has not been deployed

No deployments
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.

1 participant