Skip to content

fix(toolbox): update brush icon status when brushed areas change; fix features never updated or disposed. close #21771 - #21773

Open
noodleslove wants to merge 1 commit into
apache:releasefrom
noodleslove:fix-21771
Open

noodleslove wants to merge 1 commit into
apache:releasefrom
noodleslove:fix-21771

Conversation

@noodleslove

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Update the status of the toolbox brush icons as soon as the brushed areas are changed, and fix that the toolbox features are never updated or disposed.

Fixed issues

Details

Before: What was the problem?

The highlight of the brush icon "Clear Selections" did not follow the brushed areas. With a brush component and the toolbox brush feature:

Step Brushed areas "Clear Selections"
Brush an area 1 Not highlighted
Any full update, e.g., click "Switch to Line Chart" 1 Highlighted
Click "Clear Selections" 0 Still highlighted

It only went back to normal after the next full update.

Two causes:

  1. The status of the brush icons is only calculated in render and updateView of the brush feature. The action brush is registered with update: 'updateVisual', which ToolboxView did not handle. So the icons were not updated when the areas were changed. When "Clear Selections" is clicked, axisAreaSelect is dispatched first, which triggers a full update while the areas still exist, and then brush with command: 'clear', which only updates visual. That is why the icon stayed highlighted.
  2. ToolboxView._features is a HashMap, but updateView and dispose iterated it with zrUtil.each, which only visits the internal data property. So both methods have done nothing since 6de824d. The features were never updated by updateView, and never disposed.

After: How does it behave after the fixing?

The icon "Clear Selections" is highlighted as soon as an area is brushed, and goes back to normal as soon as the areas are cleared. The other icons are not affected. The features are disposed when the chart is disposed.

Changes in src/component/toolbox/ToolboxView.ts:

  • Iterate _features with its own each in updateView and dispose.
  • Add updateVisual, which delegates to updateView, so that the features can update the icon status after the actions that only update visual.
  • Apply the icon status by api.enterEmphasis / api.leaveEmphasis instead of the functions in util/states, so that the states are applied in the next frame even if the status is changed out of a full update.

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/toolbox-brush-iconStatus.html
  • test/ut/spec/component/toolbox/brushIconStatus.test.ts. All of the four cases fail without the fix.

Merging options

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

Other information

…en the brushed areas are changed, e.g., the icon "clear" stays highlighted after clicked. (2) Fix that the features are not updated and disposed, since the HashMap of features is iterated incorrectly. close apache#21771
@echarts-bot

echarts-bot Bot commented Sep 30, 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.

@noodleslove
noodleslove marked this pull request as ready for review September 30, 2026 19:27

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