Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: crosshair should hide when mouseleave chart\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "dingling112@gmail.com"
}
13 changes: 8 additions & 5 deletions packages/vchart/src/component/crosshair/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
}

protected _showDefaultCrosshairBySpec() {
let hasDefaultCrosshair = false;
Object.keys(this._stateByField).forEach(field => {
const fieldSpec = (this._spec as any)[field];

Expand All @@ -166,11 +167,14 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
const axis = this._option.getComponentsByKey('axes').find(c => c.getSpecIndex() === axisIndex) as IAxis;

if (axis) {
hasDefaultCrosshair = true;
this._stateByField[field].currentValue.clear();
this._stateByField[field].currentValue.set(axisIndex, { axis, datum });
}
}
});

return hasDefaultCrosshair;
}

protected _updateVisibleCrosshair() {
Expand All @@ -193,8 +197,8 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr

protected _showDefaultCrosshair() {
if (this.showDefault) {
this._showDefaultCrosshairBySpec();
this.layoutByValue(false);
const hasDefault = this._showDefaultCrosshairBySpec();
hasDefault && this.layoutByValue(false);
} else {
this._updateVisibleCrosshair();
}
Expand Down Expand Up @@ -337,8 +341,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
return;
}
this.clearOutEvent();

this.hide();
this.hideCrosshair();
};

private _getTriggerEvent() {
Expand Down Expand Up @@ -405,7 +408,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
private _handleTooltipHideOrRelease = () => {
this.clearOutEvent();

this.hide();
this.hideCrosshair();
};

protected _getAxisInfoByField<T = IAxis>(field: 'x' | 'y' | 'category' | 'value') {
Expand Down
Loading