Skip to content

Commit

Permalink
fix(#2261): 修复 tooltip 数据查找补全的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ authored and hustcc committed Apr 3, 2020
1 parent 0e9e65f commit 4b29fea
Show file tree
Hide file tree
Showing 2 changed files with 416 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export function findDataByPoint(point: Point, data: MappingDatum[], geometry: Ge
// 其他 Geometry 类型按照 x 字段数据进行查找
const first = data[0];
let last = data[data.length - 1];

const xValue = getXValueByPoint(point, geometry);
const firstXValue = first[FIELD_ORIGIN][xField];
const firstYValue = first[FIELD_ORIGIN][yField];
Expand Down Expand Up @@ -248,7 +247,8 @@ export function findDataByPoint(point: Point, data: MappingDatum[], geometry: Ge
}
} else {
// x 轴对应的数据为线性以及时间类型,进行二分查找,性能更好
if (xValue > xScale.translate(lastXValue) || xValue < xScale.translate(firstXValue)) {
if ((xValue > xScale.translate(lastXValue) || xValue < xScale.translate(firstXValue))
&& (xValue > xScale.max || xValue < xScale.min)) {
// 不在数据范围内
return null;
}
Expand Down
Loading

0 comments on commit 4b29fea

Please sign in to comment.