Skip to content

Avoid bar with text to jump when selected #6043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 26, 2021
Merged
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
1 change: 1 addition & 0 deletions draftlogs/6043_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Avoid bar with text to jump when selected [[#6043](https://github.com/plotly/plotly.js/pull/6043)]
9 changes: 6 additions & 3 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
@@ -927,7 +927,7 @@ var TEXTOFFSETSIGN = {
start: 1, end: -1, middle: 0, bottom: 1, top: -1
};

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

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

// fix the overall text group position
s.attr('text-anchor', h);
group.attr('transform', strTranslate(dx, dy));
if(!dontTouchParent) {
group.attr('transform', strTranslate(dx, dy));
}
}

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

Color.fill(tx, tc);
textPointPosition(tx, tp, fontSize, d.mrc2 || d.mrc);
var dontTouchParent = Registry.traceIs(trace, 'bar-like');
textPointPosition(tx, tp, fontSize, d.mrc2 || d.mrc, dontTouchParent);
});
};