echarts icon indicating copy to clipboard operation
echarts copied to clipboard

fix(datalabel): hideOverlap not work on emphasis state

Open Justin-ZS opened this issue 4 months ago • 8 comments

Brief Information

This pull request is in the type of:

  • [x] bug fixing

What does this PR do?

Fix hideOverlap not working on emphasis state for data labels.

Fixed issues

  • #20744 截屏2025-
08-28 12 05 37 截屏2025-08-28 12 05 30

  • #19192 截屏2025-08-28 16 27 51

录屏2025-08-28 13 44 03

Details

Before: What was the problem?

When data labels have hideOverlap enabled, all overlapping labels are forcibly displayed during emphasis state (hover or other emphasis triggers), completely ignoring the overlap detection settings. This causes dense label overlapping and affects readability.

After: How does it behave after the fixing?

  • Emphasis labels get the highest display priority
  • Other labels that overlap with emphasis labels are intelligently hidden
  • Non-overlapping labels display normally
  • Original overlap handling logic is restored when exiting emphasis state

Fix Method:

  1. Added EmphasisManager class to manage label overlap during emphasis state
  2. Used reordering mechanism to give emphasis labels highest priority
  3. Modified hideOverlap function to support pre-ordered mode, emphasis state labels also follow overlap rules
  4. Added state listeners for dynamic overlap handling

Document Info

  • [x] 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

ZRender Changes

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

Related test cases or examples to use the new APIs

N.A.

Others

Merging options

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

Other information

Justin-ZS avatar Aug 28 '25 04:08 Justin-ZS

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.

echarts-bot[bot] avatar Aug 28 '25 04:08 echarts-bot[bot]

To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: PR: doc ready, PR: awaiting doc, PR: doc unchanged

This message is shown because the PR description doesn't contain the document related template.

echarts-bot[bot] avatar Aug 28 '25 08:08 echarts-bot[bot]

The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-21233@88eb99f

github-actions[bot] avatar Sep 02 '25 02:09 github-actions[bot]

@100pah Could you help to review the PR? Thanks!

Justin-ZS avatar Sep 05 '25 06:09 Justin-ZS

@plainheart @pissang Could you help to review the PR? Thanks!

Justin-ZS avatar Sep 18 '25 02:09 Justin-ZS

@Justin-ZS Hi, I've voted you to be a committer of Apache ECharts due to your continuous contribution. Can you provide an Email address for me to send our invitation. Please add my We-chat oviliazhang with a note "Justin-ZS" so that I can add you to our committer group. Thanks!

Ovilia avatar Oct 17 '25 06:10 Ovilia

@Justin-ZS Hi, I've voted you to be a committer of Apache ECharts due to your continuous contribution. Can you provide an Email address for me to send our invitation. Please add my We-chat oviliazhang with a note "Justin-ZS" so that I can add you to our committer group. Thanks!

Thank you! I’m so happy to hear that! I've sent the We-chat friend request. My Email is [email protected]

Justin-ZS avatar Oct 20 '25 07:10 Justin-ZS

@plainheart @100pah Could you help to review? Thanks!

Justin-ZS avatar Nov 26 '25 10:11 Justin-ZS