Skip to content
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

[Feature Request] customisable dcc.Tooltip position/direction #3087

Open
celia-lm opened this issue Nov 21, 2024 · 1 comment
Open

[Feature Request] customisable dcc.Tooltip position/direction #3087

celia-lm opened this issue Nov 21, 2024 · 1 comment
Labels
feature something new

Comments

@celia-lm
Copy link

celia-lm commented Nov 21, 2024

  • Add the possibility to combine the existing directions: direction="bottom+right". dbc.Tooltip already includes this in their placement argument: https://dash-bootstrap-components.opensource.faculty.ai/docs/components/tooltip/
  • (maybe) add an offset argument that allows developers to specify the distance between the hover point and the hover box. Some developers want the box to be further from the data point so that it (the data point) and its context can be seen better. It could look something like dcc.Tooltip(..., offset={"x":"15px", "y":"0px"})

Related requests:

Relevant code:

Workaround with css

assets/styles.css

/* makes the hover box go to the bottom right corner */
.hover-content[class^="jsx-"] {
    transform: translate(0%,0%) !important;
}

Image

@celia-lm celia-lm added the feature something new label Nov 21, 2024
@yuvashrikarunakaran
Copy link
Contributor

Add Combined Directions Support
In Tooltip.react.js, update the direction handling logic

const DIRECTIONS = {
top: "translate(0, -100%)",
bottom: "translate(0, 0%)",
left: "translate(-100%, 0)",
right: "translate(100%, 0)"
};

function getTransform(direction) {
const directions = direction.split('+');
let transformX = 0, transformY = 0;

directions.forEach(dir => {
    const [x, y] = DIRECTIONS[dir].match(/-?\d+%/g) || [0, 0];
    transformX += parseFloat(x);
    transformY += parseFloat(y);
});

return `translate(${transformX}%, ${transformY}%)`;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

2 participants