Skip to content

Commit

Permalink
Merge pull request #3369 from VisActor/fix/scroll
Browse files Browse the repository at this point in the history
fix: scroll not dispatch view update when axis is not display. fix#3278
  • Loading branch information
xile611 authored Oct 30, 2024
2 parents a4a7486 + e7c3629 commit 8709e85
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
10 changes: 10 additions & 0 deletions common/changes/@visactor/vchart/develop_2024-10-30-09-16.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix: scroll not dispatch view update when axis is not display. fix#3278",
"type": "none"
}
],
"packageName": "@visactor/vchart"
}
22 changes: 21 additions & 1 deletion packages/vchart/src/component/axis/base-axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,27 @@ export abstract class AxisComponent<T extends ICommonAxisSpec & Record<string, a
}

protected computeData(updateType?: 'domain' | 'range' | 'force'): void {
if (this._tickData && this._tickData.length && (updateType === 'force' || !isEqual(this._scale.range(), [0, 1]))) {
// 对应问题#3287: 轴隐藏(tickData为[])时, dataZoom/scrollBar无法触发视图更新
// 解决方式: dataZoom/scrollBar更新时, 使用force, 此时即使没有tickData也要触发视图更新
// ps:
// 1. 其他逻辑没有使用force更新, 所以不会带来额外影响
// 2. force更新时, 如果有tickData仍然走老逻辑, 这里只考虑force && 无tickData的情况
if (updateType === 'force' && (!this._tickData || !this._tickData.length)) {
eachSeries(
this._regions,
s => {
s.getViewData()?.reRunAllTransform();
},
{
userId: this._seriesUserId,
specIndex: this._seriesIndex
}
);
} else if (
this._tickData &&
this._tickData.length &&
(updateType === 'force' || !isEqual(this._scale.range(), [0, 1]))
) {
this._tickData.forEach(tickData => {
tickData.getDataView().reRunAllTransform();
tickData.updateData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ export abstract class DataFilterBaseComponent<T extends IDataFilterComponentSpec
(this._component as DataZoom)?.setStartAndEnd?.(this._start, this._end);
}

axis.effect.scaleUpdate();
// 强制更新视图, 不管/component/axis/base-axis.ts computeData中的tickData判断
axis.effect.scaleUpdate({
value: 'force'
});
} else {
eachSeries(
this._regions,
Expand Down

0 comments on commit 8709e85

Please sign in to comment.