Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scrollbar): 修复了由于getYScales方法中去重方法错误导致的 scrollbar会在特定情况下失效(#3569) #3570

Merged
merged 1 commit into from Sep 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/chart/view.ts
Expand Up @@ -936,14 +936,16 @@ export class View extends Base {
public getYScales(): Scale[] {
// 拿到所有的 Geometry 的 Y scale,然后去重
const tmpMap = {};
return this.geometries.map((g: Geometry) => {
const yScales = [];
this.geometries.forEach((g: Geometry) => {
const yScale = g.getYScale();
const field = yScale.field;
if (!tmpMap[field]) {
tmpMap[field] = true;
return yScale;
yScales.push(yScale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个问题的原因是之前 yScales 数组中中可能有 undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,因为之前使用的是map方法去重,但实际上如果map回调函数没有手动return的话,默认会返回undefined
[1,1,2].map(item=>{
if(item!==1){
return item
}
})
// [undefined, undefined, 2]

}
});
return yScales;
}

/**
Expand Down