Skip to content

Commit

Permalink
Merge pull request #3695 from VisActor/fix/crosshair-cache-value
Browse files Browse the repository at this point in the history
fix: fix cache of crosshair value when hide crosshair, fix #3686
  • Loading branch information
xile611 authored Jan 26, 2025
2 parents a02c8b2 + 1576f08 commit 4e64c33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: fix cache of crosshair value when hide crosshair, fix #3686\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "[email protected]"
}
6 changes: 3 additions & 3 deletions packages/vchart/src/component/crosshair/cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ export class CartesianCrossHair<T extends ICartesianCrosshairSpec = ICartesianCr
y = pos?.y;
}
}

// 删除之前的currValue
this.clearAxisValue();
// 找到所有的包含这个点的轴
const { xAxisMap, yAxisMap } = this._findAllAxisContains(x, y);
if ((xAxisMap && xAxisMap.size === 0) || (yAxisMap && yAxisMap.size === 0)) {
Expand All @@ -151,8 +152,7 @@ export class CartesianCrossHair<T extends ICartesianCrosshairSpec = ICartesianCr
this.hide();
return;
}
// 删除之前的currValue
this.clearAxisValue();

// 将数据保存到这个对象中,如果不存在,就直接不执行后续逻辑
xAxisMap && xAxisMap.size && this._setAllAxisValues(xAxisMap, { x, y }, 'xField');
yAxisMap && yAxisMap.size && this._setAllAxisValues(yAxisMap, { x, y }, 'yField');
Expand Down
5 changes: 3 additions & 2 deletions packages/vchart/src/component/crosshair/polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
y = pos.y;
}
}
// 删除之前的currValue
this.clearAxisValue();

// 找到所有的包含这个点的轴
const { angleAxisMap, radiusAxisMap } = this._findAllAxisContains(x, y);
Expand All @@ -146,8 +148,7 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
this.hide();
return;
}
// 删除之前的currValue
this.clearAxisValue();

// 将数据保存到这个对象中,如果不存在,就直接不执行后续逻辑
angleAxisMap && this._setAllAxisValues(angleAxisMap, { x, y }, 'categoryField');
radiusAxisMap && this._setAllAxisValues(radiusAxisMap, { x, y }, 'valueField');
Expand Down

0 comments on commit 4e64c33

Please sign in to comment.