fix: fixed the problem of unreasonable automatic indentation being triggered after modifying the axis range in datazoom

This commit is contained in:
lixuefei.1313 2023-11-16 10:59:22 +08:00 committed by Weixing Zhang
parent 440b8048aa
commit 4f34d7528c
2 changed files with 26 additions and 7 deletions

View File

@ -78,6 +78,12 @@ export abstract class CartesianAxis<T extends ICartesianAxisCommonSpec = ICartes
this._layoutOrient = v;
}
protected _autoIndentOnce: boolean = false;
protected _hasAutoIndent: boolean = false;
set autoIndentOnce(v: boolean) {
this._autoIndentOnce = v;
}
protected _scales: IBaseScale[] = [];
getScales() {
return this._scales;
@ -837,18 +843,27 @@ export abstract class CartesianAxis<T extends ICartesianAxisCommonSpec = ICartes
});
// outBounds
['x1', 'x2', 'y1', 'y2'].forEach(key => {
if (this._lastComputeOutBounds[key] < this._layoutCache._lastComputeOutBounds[key]) {
this._lastComputeOutBounds[key] = this._layoutCache._lastComputeOutBounds[key];
} else {
this._layoutCache._lastComputeOutBounds[key] = this._lastComputeOutBounds[key];
}
});
if (this._autoIndentOnce && this._hasAutoIndent) {
// use cache
['x1', 'x2', 'y1', 'y2'].forEach(key => {
this.getLastComputeOutBounds()[key] = this._layoutCache._lastComputeOutBounds[key];
});
} else {
this._hasAutoIndent = true;
['x1', 'x2', 'y1', 'y2'].forEach(key => {
if (this.getLastComputeOutBounds()[key] < this._layoutCache._lastComputeOutBounds[key]) {
this.getLastComputeOutBounds()[key] = this._layoutCache._lastComputeOutBounds[key];
} else {
this._layoutCache._lastComputeOutBounds[key] = this.getLastComputeOutBounds()[key];
}
});
}
return rect;
}
_clearLayoutCache() {
this._hasAutoIndent = false;
this._layoutCache.width = 0;
this._layoutCache.height = 0;
this._layoutCache._lastComputeOutBounds = { x1: 0, x2: 0, y1: 0, y2: 0 };

View File

@ -264,6 +264,10 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
this._relatedAxisComponent = bandAxis;
}
}
if (this._relatedAxisComponent && this._filterMode === IFilterMode.axis) {
(this._relatedAxisComponent as CartesianAxis<any>).autoIndentOnce = true;
}
}
protected _setRegionsFromSpec() {