Skip to content

fix(visualMap): prevent tooltip label overlap#21586

Open
Resbi-Anik wants to merge 2 commits intoapache:masterfrom
Resbi-Anik:fix/visualmap-tooltip-overlap
Open

fix(visualMap): prevent tooltip label overlap#21586
Resbi-Anik wants to merge 2 commits intoapache:masterfrom
Resbi-Anik:fix/visualmap-tooltip-overlap

Conversation

@Resbi-Anik
Copy link
Copy Markdown

@Resbi-Anik Resbi-Anik commented Apr 15, 2026

  • Introduced a new margin constant for handle label overlap detection.
  • Added logic to merge handle labels when they overlap, improving visual clarity.
  • Refactored handle label position updates to accommodate new merging behavior.
  • Implemented a method to calculate the bounding rectangle of handle labels for accurate overlap testing.

Resolves: #21585

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Prevents overlapping of visualMap handle tooltip labels when the slider handles are positioned close to each other.

Fixed issues

Details

Before: What was the problem?

When using visualMap with calculable: true, the tooltip labels for the min and max values overlap when the slider handles are positioned close to each other.

This makes the labels unreadable and affects usability.

Screenshot 2026-04-15 at 5 21 26 PM

After: How does it behave after the fixing?

The tooltip labels no longer overlap when the handles are close.

When the distance between handles is below a threshold, the labels are adjusted/merged to maintain readability and avoid visual collision.

When there is enough spece no "-" between the values

Screenshot 2026-04-15 at 8 40 33 PM

when the values are close enough

Screenshot 2026-04-15 at 5 50 28 PM

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).

Merging options

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

Other information

Tested with heatmap and visualMap slider in minimal configuration. The fix works without requiring additional user configuration.

- Introduced a new margin constant for handle label overlap detection.
- Added logic to merge handle labels when they overlap, improving visual clarity.
- Refactored handle label position updates to accommodate new merging behavior.
- Implemented a method to calculate the bounding rectangle of handle labels for accurate overlap testing.

Resolves: apache#21585
@echarts-bot
Copy link
Copy Markdown

echarts-bot bot commented Apr 15, 2026

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.

@Justin-ZS
Copy link
Copy Markdown
Contributor

Justin-ZS commented Apr 17, 2026

Thanks for the fix, the overlap handling logic looks solid and the handleIndex === 'all' hover-link update also makes sense.

Could you also add a small regression case in test/visualMap-continuous.html (or a new visualMap HTML case) to cover both states:

  1. labels overlap and are merged;
  2. labels separate again and return to two draggable labels.

That would help guard against future regressions in label visibility/draggability transitions.

- Implemented two new test cases: 'Color HueRange handles: merge on overlap' and 'Color HueRange handles: dual drag when apart'.
- Each test case generates a dataset and configures the chart options to validate visualMap behavior.

Resolves: apache#21585
@Resbi-Anik
Copy link
Copy Markdown
Author

Resbi-Anik commented Apr 17, 2026

Thanks for the fix, the overlap handling logic looks solid and the handleIndex === 'all' hover-link update also makes sense.

Could you also add a small regression case in test/visualMap-continuous.html (or a new visualMap HTML case) to cover both states:

  1. labels overlap and are merged;
  2. labels separate again and return to two draggable labels.

That would help guard against future regressions in label visibility/draggability transitions.

I have updated the PR with new regression case :

Screenshot 2026-04-17 at 3 31 27 PM

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.

[Bug] VisualMap slider tooltip labels overlap when handles are close

2 participants