Skip to content

Commit f6b8bb9

Browse files
authoredNov 26, 2021
Merge pull request #6043 from plotly/bar-jumps-when-selected
Avoid bar with text to jump when selected
2 parents 2b01f3c + b51fc71 commit f6b8bb9

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

Diff for: ‎draftlogs/6043_fix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Avoid bar with text to jump when selected [[#6043](https://github.com/plotly/plotly.js/pull/6043)]

Diff for: ‎src/components/drawing/index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ var TEXTOFFSETSIGN = {
927927
start: 1, end: -1, middle: 0, bottom: 1, top: -1
928928
};
929929

930-
function textPointPosition(s, textPosition, fontSize, markerRadius) {
930+
function textPointPosition(s, textPosition, fontSize, markerRadius, dontTouchParent) {
931931
var group = d3.select(s.node().parentNode);
932932

933933
var v = textPosition.indexOf('top') !== -1 ?
@@ -949,7 +949,9 @@ function textPointPosition(s, textPosition, fontSize, markerRadius) {
949949

950950
// fix the overall text group position
951951
s.attr('text-anchor', h);
952-
group.attr('transform', strTranslate(dx, dy));
952+
if(!dontTouchParent) {
953+
group.attr('transform', strTranslate(dx, dy));
954+
}
953955
}
954956

955957
function extracTextFontSize(d, trace) {
@@ -1019,7 +1021,8 @@ drawing.selectedTextStyle = function(s, trace) {
10191021
var fontSize = extracTextFontSize(d, trace);
10201022

10211023
Color.fill(tx, tc);
1022-
textPointPosition(tx, tp, fontSize, d.mrc2 || d.mrc);
1024+
var dontTouchParent = Registry.traceIs(trace, 'bar-like');
1025+
textPointPosition(tx, tp, fontSize, d.mrc2 || d.mrc, dontTouchParent);
10231026
});
10241027
};
10251028

0 commit comments

Comments
 (0)