fix: filter mode error when roam in scrollbar and datazoom

This commit is contained in:
skie1997 2023-11-14 21:14:04 +08:00 committed by Weixing Zhang
parent e8a47007e2
commit 9790e7f53e
2 changed files with 19 additions and 3 deletions

View File

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix: default realtime not effect in scrollbar and datazoom. fix#1462",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}

View File

@ -17,6 +17,7 @@ import type { IDataZoomSpec } from './interface';
import { IFilterMode } from '../constant';
import { Factory } from '../../../core/factory';
import type { IZoomable } from '../../../interaction/zoom';
import type { CartesianAxis } from '../../axis/cartesian';
export class DataZoom<T extends IDataZoomSpec = IDataZoomSpec> extends DataFilterBaseComponent<T> {
static type = ComponentTypeEnum.dataZoom;
@ -156,14 +157,19 @@ export class DataZoom<T extends IDataZoomSpec = IDataZoomSpec> extends DataFilte
if (!this._stateScale || !this._valueScale) {
return;
}
let stateScaleRange;
const relatedAxisRange = (this._relatedAxisComponent as CartesianAxis<any>).getScale().range();
if (this._isHorizontal) {
this._stateScale.range([0, this._computeWidth() - handlerSize]);
stateScaleRange = this._visible ? [0, this._computeWidth() - handlerSize] : relatedAxisRange;
this._stateScale.range(stateScaleRange);
this._valueScale.range([this._computeHeight() - this._middleHandlerSize, 0]);
} else if (this.layoutOrient === 'left') {
this._stateScale.range([0, this._computeHeight() - handlerSize]);
stateScaleRange = this._visible ? [0, this._computeHeight() - handlerSize] : relatedAxisRange;
this._stateScale.range(stateScaleRange);
this._valueScale.range([this._computeWidth() - this._middleHandlerSize, 0]);
} else {
this._stateScale.range([0, this._computeHeight() - handlerSize]);
stateScaleRange = this._visible ? [0, this._computeHeight() - handlerSize] : relatedAxisRange;
this._stateScale.range(stateScaleRange);
this._valueScale.range([0, this._computeWidth() - this._middleHandlerSize]);
}