Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/component/visualMap/ContinuousView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,26 @@ class ContinuousView extends VisualMapView {
bidirectional: false,
}
);

// When the two labels overlap and display the same text (the same value, or values
// rendered identically after `precision`/`formatter`), showing two identical labels
// is redundant. Show only one label at the middle of the two handles instead.
const showSingleLabel = labelsOverlap && handleLabels[0].style.text === handleLabels[1].style.text;
handleLabels[1].attr({
invisible: showSingleLabel,
silent: showSingleLabel
});
if (showSingleLabel) {
handleLabels[0].setStyle({
x: (textPosPair[0].x + textPosPair[1].x) / 2,
y: (textPosPair[0].y + textPosPair[1].y) / 2
});
// The two handles are at (almost) the same position, so the bar is hard to hit.
// Let the single label drag both handles together.
elInner(handleLabels[0]).hdlIdx = 'all';
return;
}

if (labelsOverlap) {
textPosPair[0].scaleAndAdd(mtv, -0.5);
textPosPair[1].scaleAndAdd(mtv, 0.5);
Expand Down
102 changes: 102 additions & 0 deletions test/ut/spec/component/visualMap/continuousHandleLabel.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions test/visualMap-continuous.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.