Skip to content

fix(visualMap): show a single handle label when both handles have the same value - #21885

Open
Resbi-Anik wants to merge 1 commit into
apache:masterfrom
Resbi-Anik:fix/visualmap-single-label-same-value
Open

Resbi-Anik wants to merge 1 commit into
apache:masterfrom
Resbi-Anik:fix/visualmap-single-label-same-value

Conversation

@Resbi-Anik

@Resbi-Anik Resbi-Anik commented Nov 30, 2026 •

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Shows one handle label, not two identical ones, when the two handle labels of a calculable continuous visualMap overlap and show the same text.

This fixes a bug on the master branch (introduced by #21637, verified on the latest commit 34f4d92). It is not in the 6.1.0 release, so this PR targets master.

Fixed issues

Details

Before: What was the problem?

On the current master branch (verified on 34f4d92): since #21637, overlapping handle labels are pushed apart instead of merged. When both handles have the same value, or values that format to the same text via precision/formatter, the same number is shown twice (50 50, or 50 stacked above 50 in vertical layout).

issueB-before

After: How does it behave after the fixing?

One label is shown, centered on the handles:

issueB-after
  • The check runs only when the labels overlap, after the existing overlap test in _updateHandle. Labels that are far apart with the same text (e.g. a constant formatter) keep two labels.
  • The formatted text is compared, not the raw values, so values that format to the same text (e.g. via precision) are also covered.
  • Dragging the single label moves both handles (the same 'all' drag mode fixRegression: Fix the implementation of visualMap labels overlap. Fix #21586.  #21637 uses for close labels). The handle thumbs can still pull the handles apart.
  • The hidden label is set invisible + silent, so it can't catch pointer events. Both are reset on every _updateHandle, so no extra state is kept.
  • visualMap.formatter / formatValueText are unchanged.

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

  • Unit test: test/ut/spec/component/visualMap/continuousHandleLabel.test.ts (horizontal + vertical: same value, same formatted value, same text but far apart, and back to two labels).
  • Visual test: new case "Single handle label when both handles show the same text" in test/visualMap-continuous.html.

Merging options

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

Other information

Related: #21766 / #21807 (vertical labels overlapping when the handles are close). That push-apart behavior is unchanged here; the single-label path only applies when the overlapping labels have the same text.

@echarts-bot

echarts-bot Bot commented Nov 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.

@Resbi-Anik
Resbi-Anik force-pushed the fix/visualmap-single-label-same-value branch from 153786d to 6932d37 Compare November 30, 2026 13:03
… same value

When the two handle labels of a calculable continuous visualMap overlap and
display the same text (the same value, or values formatted identically by
`precision`/`formatter`), show only one label centered on the handles
instead of two duplicated labels. The single label drags both handles
together. Labels that are far apart keep two labels even if their text is
the same.

Add unit tests and a visual test case.

Close apache#21884
@Resbi-Anik
Resbi-Anik force-pushed the fix/visualmap-single-label-same-value branch from 6932d37 to 7479473 Compare November 30, 2026 13:06
@Resbi-Anik

Copy link
Copy Markdown
Author

Hi @Justin-ZS,
Could you please approve the workflow so the checks can run?
Thanks!

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.

2 participants