echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Fix/bug multiple brush and opacity

Open Adityakashyap1011 opened this issue 3 months ago • 1 comments

Brief Information

This pull request is in the type of:

  • [ ] bug fixing
  • [x] new feature
  • [ ] others

What does this PR do?

Changes the default brush selection mode from 'single' to 'multiple' and increases the opacity of selected areas from 0.1 to 1.0 for better visibility.

Fixed issues

  • Brush selection now defaults to multiple mode for improved user experience
  • Selected area opacity increased from 0.1 to 1.0 for clearer visual feedback

Details

Before: What was the problem?

Issue 1: Brush Selection Mode

  • The brush component defaulted to 'single' selection mode
  • Users had to manually click the "keep selection" button to enable multiple selections
  • Each new brush selection would replace the previous one by default
  • This required an extra step for a common use case (selecting multiple areas)

Issue 2: Selected Area Opacity

  • The opacity of selected areas was set to 0.1, making them barely visible
  • Visual feedback for brush selections was too faint and unclear
  • Users had difficulty seeing which areas were selected

After: How does it behave after the fixing?

Brush Selection Mode:

  • The brush component now defaults to 'multiple' selection mode
  • The "keep selection" button is highlighted/emphasized by default
  • Users can make multiple brush selections immediately without any extra clicks
  • Each new selection adds to existing selections instead of replacing them
  • The brush mode is always set to 'multiple' for consistent behavior

Selected Area Opacity:

  • Selected areas now have an opacity of 1.0 (fully opaque)
  • Provides clear and visible feedback for brushed regions
  • Significantly improves visual clarity when selecting multiple areas
  • Users can now clearly see all selected regions

Implementation details:

  1. Changed BrushModel.defaultOption.brushMode from 'single' to 'multiple'
  2. Updated Brush.ts (toolbox feature) to default to 'multiple' mode in the render method
  3. Modified onclick method to always use 'multiple' mode
  4. Increased opacity of selected brush areas from 0.1 to 1.0

Document Info

One of the following should be checked.

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

Note: Documentation should be updated to reflect that brush selection now defaults to multiple mode and the changed opacity behavior of selected areas.

Misc

Security Checking

  • [x] This PR uses security-sensitive Web APIs.

Note: No security-sensitive Web APIs are used in this PR.

ZRender Changes

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

Related test cases or examples to use the new APIs

Test file created: test/brush-multiple-test.html to demonstrate the new default behavior and improved opacity settings.

Merging options

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

Other information

Files modified:

  • src/component/brush/BrushModel.ts - Changed default brushMode to 'multiple' and increased opacity to 1.0
  • src/component/toolbox/feature/Brush.ts - Updated to always use 'multiple' mode
  • test/brush-multiple-test.html - Added test file for verification

Breaking change consideration: This changes default behavior but improves UX. The increased opacity provides much better visual feedback. Users who specifically want single-selection mode or different opacity can still configure it via options.

https://github.com/user-attachments/assets/4f719bf8-fcd1-465e-aa4a-e95d5ab6a0b4

Adityakashyap1011 avatar Nov 12 '25 10:11 Adityakashyap1011

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.

Document changes are required in this PR. Please also make a PR to apache/echarts-doc for document changes and update the issue id in the PR description. When the doc PR is merged, the maintainers will remove the PR: awaiting doc label.

echarts-bot[bot] avatar Nov 12 '25 10:11 echarts-bot[bot]