-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: tooltip pickup error when width is not equal #6738
base: v5
Are you sure you want to change the base?
Conversation
现在逻辑修改为三种情况:
let target;
const domainX = getDomainXByPoint(mouse, scaleX, coordinate);
const targets = elements.filter((d) => d.__data__.title === domainX);
// the domainX have multiple targets, we need to find the closest one. case: mockGroupInterval.
if (targets.length > 1) {
const search = bisector(xof).center;
const i = search(targets, abstractX);
target = targets[i];
}
// if the domainX have only one target, we can return it directly.
else if (targets.length === 1) {
target = targets[0];
}
// when can not get the target from the domainX, we need to find the closest one as the default target.
else {
const search = bisector(xof).center;
const i = search(elements, abstractX);
target = elements[i];
} |
Pull Request Test Coverage Report for Build 14239491881Details
💛 - Coveralls |
这个查找逻辑对于未经过 |
可能会,逻辑处理变化了一下,原来是根据就近原则找到最近的,再判断其 domainX 是否正确,现在是找到对应的 domainX,之后进行上面的三个判断,再判断 domainX 是否正确(因为有可能进入兜底情况,所以最后判断逻辑不能删除)。我单测过了一遍,都没有问题。 |
我觉得在使用 就是类似下面这种逻辑: const search = bisector(xof).center;
const i = search(elements, abstractX);
target = elements[i]; |
还有一个点是 |
可以看下能不能提一个公共的逻辑出来,这样后续好维护 |
我尝试用 x 值匹配试一试,感觉用 title 定位还是不准确的 |
Checklist
npm test
passesDescription of change