Skip to content

[Bug] 在使用gantt组件的时候 如果没有配置scales参数 但是配置了zoomScale参数,存在报错 #5159

@yrc2333

Description

@yrc2333

Version

1.26.1

Link to Minimal Reproduction

https://visactor.io/vtable/demo/gantt/gantt-datazoom

Steps to Reproduce

在 [Gantt.ts 构造函数]中,执行顺序是:
先初始化 ZoomScaleManager(如果配置了 zoomScale)
ZoomScaleManager 内部会尝试从 levels 中找到合适的级别并设置 scales
然后调用 _sortScales()
问题出在 [_sortScales]方法中,第 693 行取 timelineHeader.scales 赋值给 timelineScales,第 695 行直接访问 timelineScales.length,但没有检查 timelineScales 是否为 undefined。当用户只配了 zoomScale 但没配 scales 时,如果 zoomScale.levels 为空或初始化失败,setInitialLevel 不会执行,timelineHeader.scales 就仍然是 undefined,导致报错。

Current Behavior

当前必须配置scales和zoomScale中的level,并且初始化会使用scales中的缩放比例,当用户拖动滚动条后会根据缩放比例切换到zoomScale中的level,体验比较割裂

20260610_112131.mp4

Expected Behavior

可以直接采用zoomScale中的level配置

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions