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 datazoom change\n\n",
"type": "none",
"packageName": "@visactor/vchart"
}
],
"packageName": "@visactor/vchart",
"email": "dingling112@gmail.com"
}
8 changes: 4 additions & 4 deletions packages/vchart/src/component/crosshair/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
): void;

abstract setAxisValue(v: StringOrNumber, axis: IAxis): void;
abstract layoutByValue(v?: number): void;
abstract layoutByValue(enableRemain?: boolean): void;
protected abstract _getDatumAtPoint(axis: IAxis, point: IPoint): number | string;

/**
Expand Down Expand Up @@ -138,7 +138,7 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
const { axis, value } = d;
this.setAxisValue(value, axis);
});
this.layoutByValue();
this.layoutByValue(false);
}

protected _getLimitBounds() {
Expand Down Expand Up @@ -187,14 +187,14 @@ export abstract class BaseCrossHair<T extends ICartesianCrosshairSpec | IPolarCr
});

if (hasVisible) {
this.layoutByValue();
this.layoutByValue(false);
}
}

protected _showDefaultCrosshair() {
if (this.showDefault) {
this._showDefaultCrosshairBySpec();
this.layoutByValue();
this.layoutByValue(false);
} else {
this._updateVisibleCrosshair();
}
Expand Down
7 changes: 3 additions & 4 deletions packages/vchart/src/component/crosshair/cartesian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type { IAxis } from '../axis/interface';
import type { IOrientType, IPoint, StringOrNumber, TooltipActiveType, TooltipData } from '../../typings';
import { isXAxis, isYAxis } from '../axis/cartesian/util/common';
import { Factory } from '../../core/factory';
import { LayoutType } from './config';
import type { IModelSpecInfo } from '../../model/interface';
import { layoutByValue, layoutCrosshair } from './utils/cartesian';
import { getFirstSeries } from '../../util';
Expand Down Expand Up @@ -156,10 +155,10 @@ export class CartesianCrossHair<T extends ICartesianCrosshairSpec = ICartesianCr
xAxisMap && xAxisMap.size && this._setAllAxisValues(xAxisMap, { x, y }, 'xField');
yAxisMap && yAxisMap.size && this._setAllAxisValues(yAxisMap, { x, y }, 'yField');

this.layoutByValue(LayoutType.ALL);
this.layoutByValue();
}

layoutByValue(tag: number = LayoutType.ALL) {
layoutByValue(enableRemain?: boolean) {
if (!this.enable) {
return;
}
Expand All @@ -168,7 +167,7 @@ export class CartesianCrossHair<T extends ICartesianCrosshairSpec = ICartesianCr
return;
}

layoutByValue(this._stateByField, series, this.getLayoutStartPoint(), this.enableRemain);
layoutByValue(this._stateByField, series, this.getLayoutStartPoint(), enableRemain ?? this.enableRemain);

Object.keys(this._stateByField).forEach(field => {
this._layoutByField(field);
Expand Down
2 changes: 1 addition & 1 deletion packages/vchart/src/component/crosshair/interface/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { IComponent } from '../../interface';
export interface ICrossHair extends IComponent {
clearAxisValue: () => void;
setAxisValue: (v: StringOrNumber, axis: IAxis) => void;
layoutByValue: (v?: number) => void;
layoutByValue: (enableRemain?: boolean) => void;
hideCrosshair: () => any;
showCrosshair: (dimInfo: { axis: IAxis; value: string | number }[]) => any;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/vchart/src/component/crosshair/polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { polarToCartesian } from '@visactor/vutils';
import type { IGroup, INode } from '@visactor/vrender-core';
import { angleLabelOrientAttribute, radiusLabelOrientAttribute } from '../../util/math';
import { Factory } from '../../core/factory';
import { LayoutType } from './config';
import type { IModelSpecInfo } from '../../model/interface';
import { layoutByValue, layoutCrosshair } from './utils/polar';
import { getFirstSeries } from '../../util';
Expand Down Expand Up @@ -153,10 +152,10 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
angleAxisMap && this._setAllAxisValues(angleAxisMap, { x, y }, 'categoryField');
radiusAxisMap && this._setAllAxisValues(radiusAxisMap, { x, y }, 'valueField');

this.layoutByValue(LayoutType.ALL);
this.layoutByValue();
}

layoutByValue(tag: number = LayoutType.ALL) {
layoutByValue(enableRemain?: boolean) {
if (!this.enable) {
return;
}
Expand All @@ -165,7 +164,7 @@ export class PolarCrossHair<T extends IPolarCrosshairSpec = IPolarCrosshairSpec>
return;
}

layoutByValue(this._stateByField, series, this.enableRemain);
layoutByValue(this._stateByField, series, enableRemain ?? this.enableRemain);

Object.keys(this._stateByField).forEach(field => {
this._layoutByField(field);
Expand Down