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

关于Shape children更新的问题 #2626

Closed
baweiji opened this issue Jul 5, 2020 · 1 comment
Closed

关于Shape children更新的问题 #2626

baweiji opened this issue Jul 5, 2020 · 1 comment
Assignees
Labels

Comments

@baweiji
Copy link

baweiji commented Jul 5, 2020

  • G2 Version: 4.0.12
  • Platform: Windows/Mac
  • Mini Showcase(like screenshots):

参考帮助文档(https://g2.antv.vision/zh/examples/gallery/line#line8), 在写自己的一个多颜色段的line shape。发现如果数据更新时,往数据源里添加新的数据,效果就不对了,新添加的折线会空白显示。

以下是我的自己写shape

registerShape('line', 'split-line', {
  draw(cfg, container) {
    const path = [];
    const lines = buildLines()
    lines.map(line=>{
      container.addShape('path',{
         attrs:{
            path: line.path,
            stroke: line.color,
            lineWidth: 2
         }
      }
    })
    return container;
  }
});

看了下源代码,问题应该是在更新shape时,有关更新shape信息的相关代码syncShapeStyle没有和最新的shape同步。

for (let i = 0; i < children.length; i++) {
     this.syncShapeStyle(children[i], newChildren[i], state, animateCfg, index + i);
}

这里是根据原来shape的children在更新,如果newChildren里的数量大于原来children,那么最新的shape属性是更新不上去的。

@hustcc hustcc added the Mark label Jan 29, 2021
@hustcc hustcc self-assigned this Jan 29, 2021
@hustcc
Copy link
Member

hustcc commented Jan 29, 2021

4.1.x 的最新版本,已经处理了这个情况,可以升级使用。

@hustcc hustcc closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants