G
YouTube TikTok Games
Skip to content

[Bug] #4528

Open
Open

Description

@xuefei1313

Version

2.0.19

Link to Minimal Reproduction

https://www.visactor.com/vchart/playground?specId=4144852520&timestamp=1774424993291&version=2.0.19&theme=light&demoType=react

Steps to Reproduce

滚动到 100 多位后,左轴标签位置错误

Current Behavior

Image

Expected Behavior

布局正常

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

Activity

  1. adaelixir commented on Mar 25, 2026

    @adaelixir
    Image

    @xuefei1313 [formatMethod]里用来生成序号的[index]变量是在组件外部定义的闭包变量,通过 [index++]自增。
    每次 VChart 需要重新渲染坐标轴标签(比如布局计算、滚动更新),就会调用 [formatMethod],而这些调用不会触发 React 重渲染,[index]不会被重置,一直往上累加。所以同一个 "杭州元通" 标签在不同时刻被调用时,拿到的 [index]值就会变。

    修复方法:用数据在原数组中的位置来确定序号,而不是依赖可变计数器。
    https://www.visactor.com/vchart/playground?specId=1485759273&timestamp=1774430971476&version=2.0.19&theme=light&demoType=react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions